1 /* $Id: macabout.c,v 1.1 2003/02/15 16:22:15 ben Exp $ */
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_updatelicence(WindowPtr window
)
104 SetPort((GrafPtr
)GetWindowPort(window
));
106 fondsize
= GetScriptVariable(smRoman
, smScriptSmallFondSize
);
107 TextFont(HiWord(fondsize
));
108 TextSize(LoWord(fondsize
));
109 h
= Get1Resource('TEXT', wLicence
);
110 len
= GetResourceSizeOnDisk(h
);
111 #if TARGET_API_MAC_CARBON
112 GetPortBounds(GetWindowPort(window
), &textrect
);
114 textrect
= window
->portRect
;
118 TETextBox(*h
, len
, &textrect
, teFlushDefault
);
124 void mac_openabout(void)
126 DialogItemType itemtype
;
134 SelectWindow(windows
.about
);
137 GetDialogWindow(GetNewDialog(wAbout
, NULL
, (WindowPtr
)-1));
138 wi
= smalloc(sizeof(*wi
));
139 memset(wi
, 0, sizeof(*wi
));
141 wi
->update
= &mac_updateabout
;
142 wi
->click
= &mac_clickabout
;
143 wi
->activate
= &mac_activateabout
;
144 SetWRefCon(windows
.about
, (long)wi
);
145 vers
= (VersRecHndl
)Get1Resource('vers', 1);
146 if (vers
!= NULL
&& *vers
!= NULL
) {
147 longvers
= (*vers
)->shortVersion
+ (*vers
)->shortVersion
[0] + 1;
148 GetDialogItem(GetDialogFromWindow(windows
.about
), wiAboutVersion
,
149 &itemtype
, &item
, &box
);
150 assert(itemtype
& kStaticTextDialogItem
);
151 SetDialogItemText(item
, longvers
);
153 ShowWindow(windows
.about
);
157 static void mac_openlicence(void)
162 SelectWindow(windows
.licence
);
164 windows
.licence
= GetNewWindow(wLicence
, NULL
, (WindowPtr
)-1);
165 wi
= smalloc(sizeof(*wi
));
166 memset(wi
, 0, sizeof(*wi
));
167 wi
->wtype
= wLicence
;
168 wi
->update
= &mac_updatelicence
;
169 SetWRefCon(windows
.licence
, (long)wi
);
170 ShowWindow(windows
.licence
);