X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/9ef3c1cab755348f63c462bbd350af3c3c6ecfbe..4692a14af3bec03d75acad7795a8ca469cab0b1b:/mac/macdlg.c diff --git a/mac/macdlg.c b/mac/macdlg.c index 3da50831..ad7a1ffa 100644 --- a/mac/macdlg.c +++ b/mac/macdlg.c @@ -1,4 +1,4 @@ -/* $Id: macdlg.c,v 1.10 2003/02/02 15:59:00 ben Exp $ */ +/* $Id: macdlg.c,v 1.12 2003/02/15 16:22:15 ben Exp $ */ /* * Copyright (c) 2002 Ben Harris * All rights reserved. @@ -46,9 +46,15 @@ #include "macresid.h" #include "storage.h" +static void mac_clickdlg(WindowPtr, EventRecord *); +static void mac_activatedlg(WindowPtr, EventRecord *); +static void mac_updatedlg(WindowPtr); +static void mac_adjustdlgmenus(WindowPtr); + void mac_newsession(void) { Session *s; + WinInfo *wi; /* This should obviously be initialised by other means */ s = smalloc(sizeof(*s)); @@ -59,13 +65,21 @@ void mac_newsession(void) s->settings_window = GetDialogWindow(GetNewDialog(wSettings, NULL, (WindowPtr)-1)); - SetWRefCon(s->settings_window, (long)s); + wi = smalloc(sizeof(*wi)); + memset(wi, 0, sizeof(*wi)); + wi->s = s; + wi->wtype = wSettings; + wi->update = &mac_updatedlg; + wi->click = &mac_clickdlg; + wi->activate = &mac_activatedlg; + wi->adjustmenus = &mac_adjustdlgmenus; + SetWRefCon(s->settings_window, (long)wi); ShowWindow(s->settings_window); } void mac_dupsession(void) { - Session *s1 = (Session *)GetWRefCon(FrontWindow()); + Session *s1 = mac_windowsession(FrontWindow()); Session *s2; s2 = smalloc(sizeof(*s2)); @@ -180,7 +194,7 @@ void mac_opensession(void) void mac_savesession(void) { - Session *s = (Session *)GetWRefCon(FrontWindow()); + Session *s = mac_windowsession(FrontWindow()); void *sesshandle; assert(s->hasfile); @@ -193,7 +207,7 @@ void mac_savesession(void) void mac_savesessionas(void) { #if !TARGET_API_MAC_CARBON /* XXX Navigation Services */ - Session *s = (Session *)GetWRefCon(FrontWindow()); + Session *s = mac_windowsession(FrontWindow()); StandardFileReply sfr; void *sesshandle; @@ -266,7 +280,7 @@ pascal OSErr mac_aevt_pdoc(const AppleEvent *req, AppleEvent *reply, return errAEEventNotHandled; } -void mac_activatedlg(WindowPtr window, EventRecord *event) +static void mac_activatedlg(WindowPtr window, EventRecord *event) { DialogItemType itemtype; Handle itemhandle; @@ -281,10 +295,10 @@ void mac_activatedlg(WindowPtr window, EventRecord *event) DialogSelect(event, &dialog, &item); } -void mac_clickdlg(WindowPtr window, EventRecord *event) +static void mac_clickdlg(WindowPtr window, EventRecord *event) { short item; - Session *s = (Session *)GetWRefCon(window); + Session *s = mac_windowsession(window); DialogRef dialog = GetDialogFromWindow(window); if (DialogSelect(event, &dialog, &item)) @@ -296,6 +310,41 @@ void mac_clickdlg(WindowPtr window, EventRecord *event) } } +static void mac_updatedlg(WindowPtr window) +{ +#if TARGET_API_MAC_CARBON + RgnHandle rgn; +#endif + + BeginUpdate(window); +#if TARGET_API_MAC_CARBON + rgn = NewRgn(); + GetPortVisibleRegion(GetWindowPort(window), rgn); + UpdateDialog(GetDialogFromWindow(window), rgn); + DisposeRgn(rgn); +#else + UpdateDialog(window, window->visRgn); +#endif + EndUpdate(window); +} + +#if TARGET_API_MAC_CARBON +#define EnableItem EnableMenuItem +#define DisableItem DisableMenuItem +#endif +static void mac_adjustdlgmenus(WindowPtr window) +{ + MenuHandle menu; + + menu = GetMenuHandle(mFile); + DisableItem(menu, iSave); /* XXX enable if modified */ + EnableItem(menu, iSaveAs); + EnableItem(menu, iDuplicate); + + menu = GetMenuHandle(mEdit); + DisableItem(menu, 0); +} + /* * Local Variables: * c-file-style: "simon"