3 * Copyright (c) 1999, 2002, 2003 Ben Harris
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 #include <MacWindows.h>
31 #include <Resources.h>
33 #include <ToolUtils.h>
42 static struct mac_windows
{
47 static void mac_openlicence(void);
49 static void mac_clickabout(WindowPtr window
, EventRecord
*event
)
54 dialog
= GetDialogFromWindow(window
);
55 if (DialogSelect(event
, &dialog
, &item
))
63 static void mac_activateabout(WindowPtr window
, EventRecord
*event
)
66 DialogItemType itemtype
;
72 dialog
= GetDialogFromWindow(window
);
73 active
= (event
->modifiers
& activeFlag
) != 0;
74 GetDialogItem(dialog
, wiAboutLicence
, &itemtype
, &itemhandle
, &itemrect
);
75 HiliteControl((ControlHandle
)itemhandle
, active ?
0 : 255);
76 DialogSelect(event
, &dialog
, &item
);
79 static void mac_updateabout(WindowPtr window
)
81 #if TARGET_API_MAC_CARBON
86 #if TARGET_API_MAC_CARBON
88 GetPortVisibleRegion(GetWindowPort(window
), rgn
);
89 UpdateDialog(GetDialogFromWindow(window
), rgn
);
92 UpdateDialog(window
, window
->visRgn
);
97 static void mac_closeabout(WindowPtr window
)
100 windows
.about
= NULL
;
101 DisposeDialog(GetDialogFromWindow(window
));
104 static void mac_updatelicence(WindowPtr window
)
111 SetPort((GrafPtr
)GetWindowPort(window
));
113 fondsize
= GetScriptVariable(smRoman
, smScriptSmallFondSize
);
114 TextFont(HiWord(fondsize
));
115 TextSize(LoWord(fondsize
));
116 h
= Get1Resource('TEXT', wLicence
);
117 len
= GetResourceSizeOnDisk(h
);
118 #if TARGET_API_MAC_CARBON
119 GetPortBounds(GetWindowPort(window
), &textrect
);
121 textrect
= window
->portRect
;
125 TETextBox(*h
, len
, &textrect
, teFlushDefault
);
131 static void mac_closelicence(WindowPtr window
)
134 windows
.licence
= NULL
;
135 DisposeWindow(window
);
138 void mac_openabout(void)
140 DialogItemType itemtype
;
148 SelectWindow(windows
.about
);
151 GetDialogWindow(GetNewDialog(wAbout
, NULL
, (WindowPtr
)-1));
153 memset(wi
, 0, sizeof(*wi
));
155 wi
->update
= &mac_updateabout
;
156 wi
->click
= &mac_clickabout
;
157 wi
->activate
= &mac_activateabout
;
158 wi
->close
= &mac_closeabout
;
159 SetWRefCon(windows
.about
, (long)wi
);
160 vers
= (VersRecHndl
)Get1Resource('vers', 1);
161 if (vers
!= NULL
&& *vers
!= NULL
) {
162 longvers
= (*vers
)->shortVersion
+ (*vers
)->shortVersion
[0] + 1;
163 GetDialogItem(GetDialogFromWindow(windows
.about
), wiAboutVersion
,
164 &itemtype
, &item
, &box
);
165 assert(itemtype
& kStaticTextDialogItem
);
166 SetDialogItemText(item
, longvers
);
168 ShowWindow(windows
.about
);
172 static void mac_openlicence(void)
177 SelectWindow(windows
.licence
);
179 windows
.licence
= GetNewWindow(wLicence
, NULL
, (WindowPtr
)-1);
181 memset(wi
, 0, sizeof(*wi
));
182 wi
->wtype
= wLicence
;
183 wi
->update
= &mac_updatelicence
;
184 wi
->close
= &mac_closelicence
;
185 SetWRefCon(windows
.licence
, (long)wi
);
186 ShowWindow(windows
.licence
);