1 /* $Id: macpgkey.c,v 1.2 2003/02/16 14:27:37 ben Exp $ */
3 * Copyright (c) 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
28 /* Stuff to handle the key window in PuTTYgen */
32 #include <MacWindows.h>
38 static void mac_clickkey(WindowPtr window
, EventRecord
*event
)
43 dialog
= GetDialogFromWindow(window
);
44 if (DialogSelect(event
, &dialog
, &item
))
52 static void mac_activatekey(WindowPtr window
, EventRecord
*event
)
55 DialogItemType itemtype
;
61 dialog
= GetDialogFromWindow(window
);
62 active
= (event
->modifiers
& activeFlag
) != 0;
63 GetDialogItem(dialog
, wiKeyGenerate
, &itemtype
, &itemhandle
, &itemrect
);
64 HiliteControl((ControlHandle
)itemhandle
, active ?
0 : 255);
65 DialogSelect(event
, &dialog
, &item
);
68 static void mac_updatekey(WindowPtr window
)
70 #if TARGET_API_MAC_CARBON
75 #if TARGET_API_MAC_CARBON
77 GetPortVisibleRegion(GetWindowPort(window
), rgn
);
78 UpdateDialog(GetDialogFromWindow(window
), rgn
);
81 UpdateDialog(window
, window
->visRgn
);
91 ks
= smalloc(sizeof(*ks
));
92 ks
->box
= GetNewDialog(wKey
, NULL
, (WindowPtr
)-1);
93 wi
= smalloc(sizeof(*wi
));
94 memset(wi
, 0, sizeof(*wi
));
97 wi
->update
= &mac_updatekey
;
98 wi
->click
= &mac_clickkey
;
99 wi
->activate
= &mac_activatekey
;
100 SetWRefCon(GetDialogWindow(ks
->box
), (long)wi
);
101 ShowWindow(GetDialogWindow(ks
->box
));
106 * c-file-style: "simon"