Add a minimalist settings dialogue, which contains a single button
authorben <ben@cda61777-01e9-0310-a592-d414129be87e>
Tue, 31 Dec 2002 01:40:14 +0000 (01:40 +0000)
committerben <ben@cda61777-01e9-0310-a592-d414129be87e>
Tue, 31 Dec 2002 01:40:14 +0000 (01:40 +0000)
marked "open".  Still, it seems to work.

git-svn-id: svn://svn.tartarus.org/sgt/putty@2392 cda61777-01e9-0310-a592-d414129be87e

Recipe
mac/mac.c
mac/mac.h
mac/mac_res.r
mac/macdlg.c [new file with mode: 0644]
mac/macresid.h
mac/macterm.c

diff --git a/Recipe b/Recipe
index 5a830f3..aa3e0f9 100644 (file)
--- 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
index deb083a..89cbc1d 100644 (file)
--- 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;
 }
 
 /*
index 16ec50d..612e947 100644 (file)
--- 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);
index 1884427..d0a4f78 100644 (file)
@@ -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 (file)
index 0000000..a7c3c3f
--- /dev/null
@@ -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 <MacTypes.h>
+#include <Dialogs.h>
+#include <Windows.h>
+
+#include <string.h>
+
+#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:
+ */
index 8013901..e56a53e 100644 (file)
@@ -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
index 2e0f25d..6d0904b 100644 (file)
@@ -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;