Moved DejaVue fonts to contrib. They are only needed by applications
[AROS-Contrib.git] / dopus / Library / menus.c
blob5005fee9a99a5a5b6aff2e17db5b41d36756d74e
1 /*
3 Directory Opus 4
4 Original GPL release version 4.12
5 Copyright 1993-2000 Jonathan Potter
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 All users of Directory Opus 4 (including versions distributed
22 under the GPL) are entitled to upgrade to the latest version of
23 Directory Opus version 5 at a reduced price. Please see
24 http://www.gpsoft.com.au for more information.
26 The release of Directory Opus 4 under the GPL in NO WAY affects
27 the existing commercial status of Directory Opus 5.
31 #include "dopuslib.h"
33 __saveds DoFSSetMenuStrip(register struct Window *window __asm("a0"),
34 register struct Menu *firstmenu __asm("a1"))
36 struct Menu *menu;
37 struct MenuItem *item;
38 struct DrawInfo *drinfo;
39 int fpen,bpen;
40 int y,offset,xpos=0,iwidth,comwidth,checkwidth;
41 struct IntuiText testtext;
42 struct TextAttr testattr;
44 comwidth=COMMWIDTH;
45 checkwidth=CHECKWIDTH;
47 AskFont(&window->WScreen->RastPort,&testattr);
48 testtext.FrontPen=1;
49 testtext.DrawMode=JAM1;
50 testtext.NextText=NULL;
52 if (//IntuitionBase->LibNode.lib_Version>36 &&
53 (drinfo=GetScreenDrawInfo(window->WScreen))) {
54 // if (IntuitionBase->LibNode.lib_Version>=39) {
55 fpen=drinfo->dri_Pens[BARDETAILPEN];
56 bpen=drinfo->dri_Pens[BARBLOCKPEN];
57 if (drinfo->dri_AmigaKey) comwidth=drinfo->dri_AmigaKey->Width;
58 if (drinfo->dri_CheckMark) checkwidth=drinfo->dri_CheckMark->Width;
61 else {
62 fpen=drinfo->dri_Pens[DETAILPEN];
63 bpen=drinfo->dri_Pens[BLOCKPEN];
66 FreeScreenDrawInfo(window->WScreen,drinfo);
68 else {
69 fpen=0;
70 bpen=1;
73 offset=window->WScreen->Font->ta_YSize+3;
74 menu=firstmenu;
75 while (menu) {
76 if (xpos==0) xpos=menu->LeftEdge;
77 else menu->LeftEdge=xpos;
78 menu->Width=
79 TextLength(&window->WScreen->RastPort,menu->MenuName,strlen(menu->MenuName))+
80 window->WScreen->RastPort.Font->tf_XSize;
81 xpos+=menu->Width+16;
83 y=0;
84 iwidth=0;
85 item=menu->FirstItem;
87 while (item) {
88 item->TopEdge=y;
90 if (item->Flags&ITEMTEXT) {
91 struct IntuiText *text;
92 int wid,mwidth=0,first=0;
94 item->Height=offset-1;
96 text=(struct IntuiText *)item->ItemFill;
97 while (text) {
98 text->FrontPen=fpen;
99 text->BackPen=bpen;
101 if (first==0) {
102 if (LStrnCmp(text->IText," ",3)==0) text->IText=&text->IText[3];
103 if (item->Flags&CHECKIT) text->LeftEdge=checkwidth;
104 else text->LeftEdge=0;
107 if (text->ITextFont) testtext.ITextFont=text->ITextFont;
108 else testtext.ITextFont=&testattr;
109 testtext.IText=text->IText;
111 wid=text->LeftEdge+IntuiTextLength(&testtext)+window->WScreen->RastPort.Font->tf_XSize;
112 if (wid>mwidth) mwidth=wid;
114 if (text=text->NextText) {
115 y+=offset;
116 text->TopEdge=offset+3;
118 ++first;
120 if (item->Flags&COMMSEQ)
121 mwidth+=comwidth+TextLength(&window->WScreen->RastPort,&item->Command,1);
122 if (mwidth>iwidth) iwidth=mwidth;
124 y+=offset;
126 else {
127 struct Image *image;
128 int wid;
130 ++item->TopEdge;
132 image=(struct Image *)item->ItemFill;
133 while (image) {
134 if (image->ImageData==NULL) {
135 image->Height=2;
136 image->PlaneOnOff=fpen;
138 else {
139 wid=image->LeftEdge+image->Width;
140 if (wid>iwidth) iwidth=wid;
143 y+=image->TopEdge+image->Height;
145 image=image->NextImage;
147 y+=3;
149 item=item->NextItem;
152 item=menu->FirstItem;
153 while (item) {
154 item->Width=iwidth;
155 if (!(item->Flags&ITEMTEXT)) {
156 struct Image *image;
158 image=(struct Image *)item->ItemFill;
159 while (image) {
160 if (image->ImageData==NULL) image->Width=iwidth;
161 image=image->NextImage;
164 item=item->NextItem;
167 menu=menu->NextMenu;
170 return((int)SetMenuStrip(window,firstmenu));