Rev 268 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
259 | daniel-mar | 1 | /* |
268 | daniel-mar | 2 | This file is part of a common library |
536 | daniel-mar | 3 | Copyright (C) 1990-2006 Toby Thain, toby@telegraphics.net |
259 | daniel-mar | 4 | |
5 | This program is free software; you can redistribute it and/or modify |
||
268 | daniel-mar | 6 | it under the terms of the GNU General Public License as published by |
259 | daniel-mar | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. |
||
9 | |||
10 | This program is distributed in the hope that it will be useful, |
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
13 | GNU General Public License for more details. |
||
14 | |||
268 | daniel-mar | 15 | You should have received a copy of the GNU General Public License |
259 | daniel-mar | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
18 | */ |
||
19 | |||
20 | #include <dialogs.h> |
||
21 | #include <menus.h> |
||
22 | #include <osutils.h> |
||
23 | #include <textutils.h> |
||
24 | #include <windows.h> |
||
25 | |||
26 | #include "dlg.h" |
||
27 | #include "menu.h" |
||
28 | #include "carbonstuff.h" |
||
29 | |||
30 | void set_item_state(MenuHandle m,short i,Boolean f){ |
||
31 | #if TARGET_API_MAC_CARBON |
||
32 | f ? EnableMenuItem(m,i) : DisableMenuItem(m,i); |
||
33 | #else |
||
34 | f ? EnableItem(m,i) : DisableItem(m,i); |
||
35 | #endif |
||
36 | } |
||
37 | |||
38 | void draw_popup(DialogPtr d,short i,unsigned char*s){ |
||
39 | static short arrow_data[] = {0xffe0,0x7fc0,0x3f80,0x1f00,0x0e00,0x0400}; |
||
40 | static BitMap arrow = {(void*)arrow_data,2,{0,0,6,11}}; // ppcc wants cast |
||
41 | Rect r,r2; |
||
42 | |||
43 | get_item_rect(d,i,&r); |
||
44 | EraseRect(&r); |
||
45 | r.right--; |
||
46 | r.bottom--; |
||
47 | FrameRect(&r); |
||
48 | MoveTo(r.left+3,r.bottom); |
||
49 | LineTo(r.right,r.bottom); |
||
50 | LineTo(r.right,r.top+3); |
||
51 | r2 = arrow.bounds; |
||
52 | OffsetRect(&r2,r.right-17,r.top+6); |
||
53 | CopyBits(&arrow,GetPortBitMapForCopyBits((CGrafPtr)d),&arrow.bounds,&r2,srcOr,0); |
||
54 | MoveTo(r.left+15,r.top+13); |
||
55 | DrawString(s); |
||
56 | } |
||
57 | |||
58 | void adjust_popup(DialogPtr d,short i,MenuHandle m,short mItem,short max,unsigned char *s){ |
||
59 | KIND_ITEM_BOX |
||
60 | short j; |
||
61 | unsigned char *t; |
||
62 | GrafPtr gp; |
||
63 | Rect r; |
||
268 | daniel-mar | 64 | |
259 | daniel-mar | 65 | GetPort(&gp); |
66 | SetPort((GrafPtr)GetWindowPort(GetDialogWindow(d))); |
||
67 | max -= 12/*info.ascent*/ + 11 + 16; |
||
68 | |||
69 | GetMenuItemText(m,mItem,s); |
||
268 | daniel-mar | 70 | |
71 | #if ! TARGET_API_MAC_CARBON |
||
259 | daniel-mar | 72 | { |
73 | SysEnvRec w; |
||
74 | |||
75 | SysEnvirons(curSysEnvVers,&w); |
||
76 | if(w.systemVersion < 0x700) |
||
77 | for(t = s + (j = *s); j && StringWidth(s) > max; *s = j--, t--) |
||
78 | *t = 'É'; |
||
79 | else |
||
80 | TruncString(max,s,smTruncEnd); |
||
81 | } |
||
268 | daniel-mar | 82 | #else |
259 | daniel-mar | 83 | TruncString(max,s,smTruncEnd); |
268 | daniel-mar | 84 | #endif |
259 | daniel-mar | 85 | |
86 | GetDialogItem(d,i,&kind,&item,&box); |
||
87 | InvalWindowRect(GetDialogWindow(d),&box); |
||
88 | r = box; |
||
89 | r.left = box.right = box.left + 12 /*info.ascent*/ + StringWidth(s) + 11 + 16; |
||
90 | EraseRect(&r); |
||
91 | InvalWindowRect(GetDialogWindow(d),&box); |
||
92 | SetDialogItem(d,i,kind,item,&box); |
||
93 | SetPort(gp); |
||
94 | } |