From 6cb61a05b6157236bbea7b351cfc741eb6853605 Mon Sep 17 00:00:00 2001 From: ben Date: Tue, 31 Dec 2002 01:40:14 +0000 Subject: [PATCH] Add a minimalist settings dialogue, which contains a single button marked "open". Still, it seems to work. git-svn-id: svn://svn.tartarus.org/sgt/putty@2392 cda61777-01e9-0310-a592-d414129be87e --- Recipe | 4 +-- mac/mac.c | 16 +++++++++-- mac/mac.h | 6 +++- mac/mac_res.r | 30 ++++++++++++++++++-- mac/macdlg.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mac/macresid.h | 4 ++- mac/macterm.c | 14 +-------- 7 files changed, 143 insertions(+), 21 deletions(-) create mode 100644 mac/macdlg.c diff --git a/Recipe b/Recipe index 5a830f3a..aa3e0f91 100644 --- a/Recipe +++ b/Recipe @@ -142,5 +142,5 @@ pterm : [X] pterm terminal wcwidth uxucs uxmisc tree234 misc ldisc ldiscucs plink : [U] uxplink uxcons NONSSH UXSSH be_all logging UXMISC PuTTY : [M] terminal wcwidth tree234 misc ldisc ldiscucs - + logging settings be_none mac macstore macterm macucs mac_res.rsrc - + testback + + logging settings be_none mac macdlg macstore macterm macucs + + mac_res.rsrc testback diff --git a/mac/mac.c b/mac/mac.c index deb083af..89cbc1d7 100644 --- a/mac/mac.c +++ b/mac/mac.c @@ -1,4 +1,4 @@ -/* $Id: mac.c,v 1.11 2002/12/30 19:01:44 ben Exp $ */ +/* $Id: mac.c,v 1.12 2002/12/31 01:40:14 ben Exp $ */ /* * Copyright (c) 1999 Ben Harris * All rights reserved. @@ -280,6 +280,9 @@ static void mac_contentclick(WindowPtr window, EventRecord *event) { break; } break; + case wSettings: + mac_clickdlg(window, event); + break; } } @@ -300,6 +303,9 @@ static void mac_activatewindow(WindowPtr window, EventRecord *event) { case wTerminal: mac_activateterm(window, active); break; + case wSettings: + mac_activatedlg(window, event); + break; case wAbout: mac_activateabout(window, event); break; @@ -326,6 +332,7 @@ static void mac_updatewindow(WindowPtr window) { mac_updateterm(window); break; case wAbout: + case wSettings: BeginUpdate(window); UpdateDialog(window, window->visRgn); EndUpdate(window); @@ -363,6 +370,7 @@ static void mac_updatelicence(WindowPtr window) */ static int mac_windowtype(WindowPtr window) { int kind; + long refcon; if (window == NULL) return wNone; @@ -371,7 +379,11 @@ static int mac_windowtype(WindowPtr window) { return wDA; if (GetWVariant(window) == zoomDocProc) return wTerminal; - return GetWRefCon(window); + refcon = GetWRefCon(window); + if (refcon < 1024) + return refcon; + else + return wSettings; } /* diff --git a/mac/mac.h b/mac/mac.h index 16ec50d8..612e947e 100644 --- a/mac/mac.h +++ b/mac/mac.h @@ -48,6 +48,7 @@ typedef struct { int font_leading; int font_boldadjust; WindowPtr window; + WindowPtr settings_window; PaletteHandle palette; ControlHandle scrollbar; WCTabHandle wctab; @@ -55,8 +56,11 @@ typedef struct { UnicodeToTextInfo uni_to_font; } Session; -/* from macterm.c */ +/* from macdlg.c */ extern void mac_newsession(void); +extern void mac_clickdlg(WindowPtr, EventRecord *); +extern void mac_activatedlg(WindowPtr, EventRecord *); +/* from macterm.c */ extern void mac_opensession(void); extern void mac_startsession(Session *); extern void mac_activateterm(WindowPtr, Boolean); diff --git a/mac/mac_res.r b/mac/mac_res.r index 1884427f..d0a4f786 100644 --- a/mac/mac_res.r +++ b/mac/mac_res.r @@ -1,6 +1,6 @@ -/* $Id: mac_res.r,v 1.7 2002/12/30 23:14:11 ben Exp $ */ +/* $Id: mac_res.r,v 1.8 2002/12/31 01:40:14 ben Exp $ */ /* - * Copyright (c) 1999 Ben Harris + * Copyright (c) 1999, 2002 Ben Harris * All rights reserved. * * Permission is hereby granted, free of charge, to any person @@ -494,6 +494,32 @@ resource 'CNTL' (cVScroll, "vscroll", purgeable) { scrollBarProc, 0, "" }; +/* Settings dialogue */ + +resource 'DLOG' (wSettings, "settings", purgeable) { + { 0, 0, 46, 240 }, + noGrowDocProc, + invisible, + goAway, + wSettings, + wSettings, + "Settings", + staggerParentWindowScreen +}; + +resource 'dlgx' (wSettings, "settings", purgeable) { + versionZero { + kDialogFlagsUseThemeBackground | kDialogFlagsUseThemeControls + } +}; + +resource 'DITL' (wSettings, "settings", purgeable) { + { + { 13, 13, 33, 227 }, + Button { enabled, "Open" }, + } +}; + /* "About" box */ resource 'DLOG' (wAbout, "about", purgeable) { diff --git a/mac/macdlg.c b/mac/macdlg.c new file mode 100644 index 00000000..a7c3c3f5 --- /dev/null +++ b/mac/macdlg.c @@ -0,0 +1,90 @@ +/* $Id: macdlg.c,v 1.1 2002/12/31 01:40:14 ben Exp $ */ +/* + * Copyright (c) 2002 Ben Harris + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * macdlg.c - settings dialogue box for Mac OS. + */ + +#include +#include +#include + +#include + +#include "putty.h" +#include "mac.h" +#include "macresid.h" + +void mac_newsession(void) +{ + Session *s; + + /* This should obviously be initialised by other means */ + s = smalloc(sizeof(*s)); + memset(s, 0, sizeof(*s)); + do_defaults(NULL, &s->cfg); + s->back = &loop_backend; + + s->settings_window = GetNewDialog(wSettings, NULL, (WindowPtr)-1); + + SetWRefCon(s->settings_window, (long)s); + ShowWindow(s->settings_window); +} + +void mac_activatedlg(WindowPtr window, EventRecord *event) +{ + DialogItemType itemtype; + Handle itemhandle; + short item; + Rect itemrect; + int active; + + active = (event->modifiers & activeFlag) != 0; + GetDialogItem(window, wiSettingsOpen, &itemtype, &itemhandle, &itemrect); + HiliteControl((ControlHandle)itemhandle, active ? 0 : 255); + DialogSelect(event, &window, &item); +} + +void mac_clickdlg(WindowPtr window, EventRecord *event) +{ + short item; + Session *s = (Session *)GetWRefCon(window); + + if (DialogSelect(event, &(DialogPtr)window, &item)) + switch (item) { + case wiSettingsOpen: + CloseWindow(window); + mac_startsession(s); + break; + } +} + +/* + * Local Variables: + * c-file-style: "simon" + * End: + */ diff --git a/mac/macresid.h b/mac/macresid.h index 8013901f..e56a53ec 100644 --- a/mac/macresid.h +++ b/mac/macresid.h @@ -1,4 +1,4 @@ -/* $Id: macresid.h,v 1.2 2002/12/30 18:21:17 ben Exp $ */ +/* $Id: macresid.h,v 1.3 2002/12/31 01:40:14 ben Exp $ */ /* * macresid.h -- Mac resource IDs @@ -40,6 +40,8 @@ #define wiAboutVersion 3 #define wTerminal 130 #define wLicence 131 +#define wSettings 132 +#define wiSettingsOpen 1 /* Controls */ #define cVScroll 128 diff --git a/mac/macterm.c b/mac/macterm.c index 2e0f25d9..6d0904bd 100644 --- a/mac/macterm.c +++ b/mac/macterm.c @@ -1,4 +1,4 @@ -/* $Id: macterm.c,v 1.26 2002/12/30 18:21:17 ben Exp $ */ +/* $Id: macterm.c,v 1.27 2002/12/31 01:40:14 ben Exp $ */ /* * Copyright (c) 1999 Simon Tatham * Copyright (c) 1999, 2002 Ben Harris @@ -137,18 +137,6 @@ static void display_resource(Session *s, unsigned long type, short id) { DisposeHandle(h); } - -void mac_newsession(void) { - Session *s; - - /* This should obviously be initialised by other means */ - s = smalloc(sizeof(*s)); - memset(s, 0, sizeof(*s)); - do_defaults(NULL, &s->cfg); - s->back = &loop_backend; - mac_startsession(s); -} - void mac_opensession(void) { Session *s; StandardFileReply sfr; -- 2.11.0