From 8a7e67ec6766225bff72cf384a82d7647fa65fa0 Mon Sep 17 00:00:00 2001 From: ben Date: Mon, 17 Mar 2003 21:40:37 +0000 Subject: [PATCH] Partial implementation of the platform-independent dialogue-box interface for the Mac OS. This isn't anywhere near complete, and is wrong in a few important regards, but I think it's heading in the right direction. git-svn-id: svn://svn.tartarus.org/sgt/putty@2953 cda61777-01e9-0310-a592-d414129be87e --- Recipe | 4 +- mac/mac.h | 24 +- mac/mac_res.r | 24 +- mac/macctrls.c | 718 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mac/macdlg.c | 95 ++------ mac/macstuff.h | 4 + mac/macucs.c | 21 +- 7 files changed, 793 insertions(+), 97 deletions(-) create mode 100644 mac/macctrls.c diff --git a/Recipe b/Recipe index d5612af7..ddc18a1e 100644 --- a/Recipe +++ b/Recipe @@ -155,10 +155,10 @@ plink : [U] uxplink uxcons NONSSH UXSSH be_all logging UXMISC signal ux_x11 PuTTY : [M] terminal wcwidth ldiscucs logging be_all mac macdlg macevlog + macterm macucs mac_res.rsrc testback NONSSH MACSSH MACMISC CHARSET - + stricmp vsnprint + + stricmp vsnprint dialog config macctrls PuTTYtel : [M] terminal wcwidth ldiscucs logging be_nossh mac macdlg macevlog + macterm macucs mac_res.rsrc testback NONSSH MACMISC CHARSET - + stricmp vsnprint + + stricmp vsnprint dialog config macctrls PuTTYgen : [M] macpgen sshrsag sshdssg sshprime sshdes sshbn sshmd5 version + sshrand macnoise sshsha macstore misc sshrsa sshdss macmisc sshpubk + sshaes sshsh512 import macpgen.rsrc macpgkey macabout diff --git a/mac/mac.h b/mac/mac.h index 07c8513b..30796a93 100644 --- a/mac/mac.h +++ b/mac/mac.h @@ -15,6 +15,7 @@ #include #include "charset.h" +#include "tree234.h" #define PUTTY_CREATOR FOUR_CHAR_CODE('pTTY') #define INTERNAL_CREATOR FOUR_CHAR_CODE('pTTI') @@ -47,6 +48,7 @@ extern UInt32 sleeptime; typedef struct { struct Session *s; /* Only used in PuTTY */ struct KeyState *ks; /* Only used in PuTTYgen */ + struct macctrls *mcs; void (*activate) (WindowPtr, EventRecord *); void (*adjustcursor)(WindowPtr, Point, RgnHandle); @@ -63,6 +65,12 @@ typedef struct { #define mac_wininfo(w) ((WinInfo *)GetWRefCon(w)) #define mac_windowsession(w) (((WinInfo *)GetWRefCon(w))->s) +#define mac_winctrls(w) (((WinInfo *)GetWRefCon(w))->mcs) + +struct macctrls { + tree234 *byctrl; + void *data; /* private data for config box */ +}; typedef struct Session { struct Session *next; @@ -96,7 +104,6 @@ typedef struct Session { Point font_bignumer; Point font_bigdenom; WindowPtr window; - WindowPtr settings_window; WindowPtr eventlog_window; ListHandle eventlog; PaletteHandle palette; @@ -107,6 +114,11 @@ typedef struct Session { charset_t font_charset; /* font_charset is used at a time. */ int hasfile; FSSpec savefile; + + /* Config dialogue bits */ + WindowPtr settings_window; + struct controlbox *ctrlbox; + struct macctrls settings_ctrls; } Session; extern Session *sesslist; @@ -179,6 +191,16 @@ extern Socket ot_newlistener(char *, int, Plug, int); extern char *ot_addr_error(SockAddr); /* from macabout.c */ extern void mac_openabout(void); +/* from macctrls.c */ +extern void macctrl_layoutbox(struct controlbox *, WindowPtr, + struct macctrls *); +extern void macctrl_activate(WindowPtr, EventRecord *); +extern void macctrl_click(WindowPtr, EventRecord *); +extern void macctrl_update(WindowPtr); +extern void macctrl_adjustmenus(WindowPtr); +extern void macctrl_close(WindowPtr); + + /* from macpgkey.c */ extern void mac_newkey(void); /* Apple Event Handlers (in various files) */ diff --git a/mac/mac_res.r b/mac/mac_res.r index 0aef8b2c..17e1bce7 100644 --- a/mac/mac_res.r +++ b/mac/mac_res.r @@ -1,4 +1,4 @@ -/* $Id: mac_res.r,v 1.31 2003/03/11 22:35:07 ben Exp $ */ +/* $Id: mac_res.r,v 1.32 2003/03/17 21:40:37 ben Exp $ */ /* * Copyright (c) 1999, 2002, 2003 Ben Harris * All rights reserved. @@ -1023,30 +1023,16 @@ resource 'CNTL' (cVScroll, "vscroll", purgeable) { /* Settings dialogue */ -resource 'DLOG' (wSettings, "settings", purgeable) { - { 0, 0, 46, 240 }, +resource 'WIND' (wSettings, "settings", purgeable) { + { 0, 0, 350, 500 }, noGrowDocProc, invisible, goAway, - wSettings, - wSettings, - "Settings", + 0x0, + "untitled", staggerParentWindowScreen }; -resource 'dlgx' (wSettings, "settings", purgeable) { - versionZero { - kDialogFlagsUseThemeBackground | kDialogFlagsUseThemeControls - } -}; - -resource 'DITL' (wSettings, "settings", purgeable) { - { - { 13, 13, 33, 227 }, - Button { enabled, "Open" }, - } -}; - /* Event log */ resource 'WIND' (wEventLog, "event log", purgeable) { { 0, 0, 200, 200 }, diff --git a/mac/macctrls.c b/mac/macctrls.c new file mode 100644 index 00000000..354f9dec --- /dev/null +++ b/mac/macctrls.c @@ -0,0 +1,718 @@ +/* $Id: macctrls.c,v 1.1 2003/03/17 21:40:37 ben Exp $ */ +/* + * Copyright (c) 2003 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. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "putty.h" +#include "mac.h" +#include "macresid.h" +#include "dialog.h" +#include "tree234.h" + +union macctrl { + struct macctrl_generic { + enum { + MACCTRL_TEXT, + MACCTRL_RADIO, + MACCTRL_CHECKBOX, + MACCTRL_BUTTON + } type; + /* Template from which this was generated */ + union control *ctrl; + } generic; + struct { + struct macctrl_generic generic; + ControlRef tbctrl; + } text; + struct { + struct macctrl_generic generic; + ControlRef *tbctrls; + } radio; + struct { + struct macctrl_generic generic; + ControlRef tbctrl; + } checkbox; + struct { + struct macctrl_generic generic; + ControlRef tbctrl; + } button; +}; + +struct mac_layoutstate { + Point pos; + unsigned int width; +}; + +#define ctrlevent(mcs, mc, event) do { \ + if ((mc)->generic.ctrl->generic.handler != NULL) \ + (*(mc)->generic.ctrl->generic.handler)((mc)->generic.ctrl, (mc),\ + (mcs)->data, (event)); \ +} while (0) + +static void macctrl_layoutset(struct mac_layoutstate *, struct controlset *, + WindowPtr, struct macctrls *); +static void macctrl_text(struct macctrls *, WindowPtr, + struct mac_layoutstate *, union control *); +static void macctrl_radio(struct macctrls *, WindowPtr, + struct mac_layoutstate *, union control *); +static void macctrl_checkbox(struct macctrls *, WindowPtr, + struct mac_layoutstate *, union control *); +static void macctrl_button(struct macctrls *, WindowPtr, + struct mac_layoutstate *, union control *); + +static int macctrl_cmp_byctrl(void *av, void *bv) +{ + union macctrl *a = (union macctrl *)av; + union macctrl *b = (union macctrl *)bv; + + if (a->generic.ctrl < b->generic.ctrl) + return -1; + else if (a->generic.ctrl > b->generic.ctrl) + return +1; + else + return 0; +} + +void macctrl_layoutbox(struct controlbox *cb, WindowPtr window, + struct macctrls *mcs) +{ + int i; + struct mac_layoutstate curstate; + ControlRef root; + Rect rect; + +#if TARGET_API_MAC_CARBON + GetPortBounds(GetWindowPort(window), &rect); +#else + rect = window->portRect; +#endif + curstate.pos.h = rect.left + 13; + curstate.pos.v = rect.top + 13; + curstate.width = rect.right - rect.left - (13 * 2); + if (mac_gestalts.apprvers >= 0x100) + CreateRootControl(window, &root); + mcs->byctrl = newtree234(macctrl_cmp_byctrl); + for (i = 0; i < cb->nctrlsets; i++) + macctrl_layoutset(&curstate, cb->ctrlsets[i], window, mcs); +} + +static void macctrl_layoutset(struct mac_layoutstate *curstate, + struct controlset *s, + WindowPtr window, struct macctrls *mcs) +{ + unsigned int i; + + fprintf(stderr, "--- begin set ---\n"); + if (s->boxname && *s->boxname) + fprintf(stderr, "boxname = %s\n", s->boxname); + if (s->boxtitle) + fprintf(stderr, "boxtitle = %s\n", s->boxtitle); + + + for (i = 0; i < s->ncontrols; i++) { + union control *ctrl = s->ctrls[i]; + char const *s; + + switch (ctrl->generic.type) { + case CTRL_TEXT: s = "text"; break; + case CTRL_EDITBOX: s = "editbox"; break; + case CTRL_RADIO: s = "radio"; break; + case CTRL_CHECKBOX: s = "checkbox"; break; + case CTRL_BUTTON: s = "button"; break; + case CTRL_LISTBOX: s = "listbox"; break; + case CTRL_COLUMNS: s = "columns"; break; + case CTRL_FILESELECT: s = "fileselect"; break; + case CTRL_FONTSELECT: s = "fontselect"; break; + case CTRL_TABDELAY: s = "tabdelay"; break; + default: s = "unknown"; break; + } + fprintf(stderr, " control: %s\n", s); + switch (ctrl->generic.type) { + case CTRL_TEXT: + macctrl_text(mcs, window, curstate, ctrl); + break; + case CTRL_RADIO: + macctrl_radio(mcs, window, curstate, ctrl); + break; + case CTRL_CHECKBOX: + macctrl_checkbox(mcs, window, curstate, ctrl); + break; + case CTRL_BUTTON: + macctrl_button(mcs, window, curstate, ctrl); + break; + + } + } +} + +static void macctrl_text(struct macctrls *mcs, WindowPtr window, + struct mac_layoutstate *curstate, + union control *ctrl) +{ + union macctrl *mc = smalloc(sizeof *mc); + Rect bounds; + + fprintf(stderr, " label = %s\n", ctrl->text.label); + mc->generic.type = MACCTRL_TEXT; + mc->generic.ctrl = ctrl; + bounds.left = curstate->pos.h; + bounds.right = bounds.left + curstate->width; + bounds.top = curstate->pos.v; + bounds.bottom = bounds.top + 16; + if (mac_gestalts.apprvers >= 0x100) { + SInt16 height; + Size olen; + + mc->text.tbctrl = NewControl(window, &bounds, NULL, TRUE, 0, 0, 0, + kControlStaticTextProc, (long)mc); + SetControlData(mc->text.tbctrl, kControlEntireControl, + kControlStaticTextTextTag, + strlen(ctrl->text.label), ctrl->text.label); + GetControlData(mc->text.tbctrl, kControlEntireControl, + kControlStaticTextTextHeightTag, + sizeof(height), &height, &olen); + fprintf(stderr, " height = %d\n", height); + SizeControl(mc->text.tbctrl, curstate->width, height); + curstate->pos.v += height + 6; + } else { + /* Do something useful */ + } + add234(mcs->byctrl, mc); +} + +static void macctrl_radio(struct macctrls *mcs, WindowPtr window, + struct mac_layoutstate *curstate, + union control *ctrl) +{ + union macctrl *mc = smalloc(sizeof *mc); + Rect bounds; + Str255 title; + unsigned int i, colwidth; + + fprintf(stderr, " label = %s\n", ctrl->radio.label); + mc->generic.type = MACCTRL_RADIO; + mc->generic.ctrl = ctrl; + mc->radio.tbctrls = + smalloc(sizeof(*mc->radio.tbctrls) * ctrl->radio.nbuttons); + colwidth = (curstate->width + 13) / ctrl->radio.ncolumns; + for (i = 0; i < ctrl->radio.nbuttons; i++) { + fprintf(stderr, " button = %s\n", ctrl->radio.buttons[i]); + bounds.top = curstate->pos.v; + bounds.bottom = bounds.top + 16; + bounds.left = curstate->pos.h + colwidth * (i % ctrl->radio.ncolumns); + if (i == ctrl->radio.nbuttons - 1 || + i % ctrl->radio.ncolumns == ctrl->radio.ncolumns - 1) { + bounds.right = curstate->pos.h + curstate->width; + curstate->pos.v += 22; + } else + bounds.right = bounds.left + colwidth - 13; + c2pstrcpy(title, ctrl->radio.buttons[i]); + mc->radio.tbctrls[i] = NewControl(window, &bounds, title, TRUE, + 0, 0, 1, radioButProc, (long)mc); + } + add234(mcs->byctrl, mc); + ctrlevent(mcs, mc, EVENT_REFRESH); +} + +static void macctrl_checkbox(struct macctrls *mcs, WindowPtr window, + struct mac_layoutstate *curstate, + union control *ctrl) +{ + union macctrl *mc = smalloc(sizeof *mc); + Rect bounds; + Str255 title; + + fprintf(stderr, " label = %s\n", ctrl->checkbox.label); + mc->generic.type = MACCTRL_CHECKBOX; + mc->generic.ctrl = ctrl; + bounds.left = curstate->pos.h; + bounds.right = bounds.left + curstate->width; + bounds.top = curstate->pos.v; + bounds.bottom = bounds.top + 16; + c2pstrcpy(title, ctrl->checkbox.label); + mc->checkbox.tbctrl = NewControl(window, &bounds, title, TRUE, 0, 0, 1, + checkBoxProc, (long)mc); + add234(mcs->byctrl, mc); + curstate->pos.v += 22; + ctrlevent(mcs, mc, EVENT_REFRESH); +} + +static void macctrl_button(struct macctrls *mcs, WindowPtr window, + struct mac_layoutstate *curstate, + union control *ctrl) +{ + union macctrl *mc = smalloc(sizeof *mc); + Rect bounds; + Str255 title; + + fprintf(stderr, " label = %s\n", ctrl->button.label); + if (ctrl->button.isdefault) + fprintf(stderr, " is default\n"); + mc->generic.type = MACCTRL_BUTTON; + mc->generic.ctrl = ctrl; + bounds.left = curstate->pos.h; + bounds.right = bounds.left + 100; /* XXX measure string */ + bounds.top = curstate->pos.v; + bounds.bottom = bounds.top + 20; + c2pstrcpy(title, ctrl->button.label); + mc->button.tbctrl = NewControl(window, &bounds, title, TRUE, 0, 0, 1, + pushButProc, (long)mc); + if (mac_gestalts.apprvers >= 0x100) { + Boolean isdefault = ctrl->button.isdefault; + + SetControlData(mc->button.tbctrl, kControlEntireControl, + kControlPushButtonDefaultTag, + sizeof(isdefault), &isdefault); + } + add234(mcs->byctrl, mc); + curstate->pos.v += 26; +} + + +void macctrl_activate(WindowPtr window, EventRecord *event) +{ + Boolean active = (event->modifiers & activeFlag) != 0; + GrafPtr saveport; + ControlRef root; + + GetPort(&saveport); + SetPort((GrafPtr)GetWindowPort(window)); + if (mac_gestalts.apprvers >= 0x100) { + SetThemeWindowBackground(window, active ? + kThemeBrushModelessDialogBackgroundActive : + kThemeBrushModelessDialogBackgroundInactive, + TRUE); + GetRootControl(window, &root); + if (active) + ActivateControl(root); + else + DeactivateControl(root); + } else { + /* (De)activate controls one at a time */ + } + SetPort(saveport); +} + +void macctrl_click(WindowPtr window, EventRecord *event) +{ + Point mouse; + ControlHandle control; + int part; + GrafPtr saveport; + union macctrl *mc; + struct macctrls *mcs = mac_winctrls(window); + int i; + + GetPort(&saveport); + SetPort((GrafPtr)GetWindowPort(window)); + mouse = event->where; + GlobalToLocal(&mouse); + part = FindControl(mouse, window, &control); + if (control != NULL) + if (TrackControl(control, mouse, NULL) != 0) { + mc = (union macctrl *)GetControlReference(control); + switch (mc->generic.type) { + case MACCTRL_RADIO: + for (i = 0; i < mc->generic.ctrl->radio.nbuttons; i++) { + if (mc->radio.tbctrls[i] == control) + SetControlValue(mc->radio.tbctrls[i], + kControlRadioButtonCheckedValue); + else + SetControlValue(mc->radio.tbctrls[i], + kControlRadioButtonUncheckedValue); + } + ctrlevent(mcs, mc, EVENT_VALCHANGE); + break; + case MACCTRL_CHECKBOX: + SetControlValue(control, !GetControlValue(control)); + ctrlevent(mcs, mc, EVENT_VALCHANGE); + break; + case MACCTRL_BUTTON: + ctrlevent(mcs, mc, EVENT_ACTION); + break; + } + } + SetPort(saveport); +} + +void macctrl_update(WindowPtr window) +{ +#if TARGET_API_MAC_CARBON + RgnHandle visrgn; +#endif + Rect rect; + GrafPtr saveport; + + BeginUpdate(window); + GetPort(&saveport); + SetPort((GrafPtr)GetWindowPort(window)); + if (mac_gestalts.apprvers >= 0x101) { +#if TARGET_API_MAC_CARBON + GetPortBounds(GetWindowPort(window), &rect); +#else + rect = window->portRect; +#endif + InsetRect(&rect, -1, -1); + DrawThemeModelessDialogFrame(&rect, mac_frontwindow() == window ? + kThemeStateActive : kThemeStateInactive); + } +#if TARGET_API_MAC_CARBON + visrgn = NewRgn(); + GetPortVisibleRegion(GetWindowPort(window), visrgn); + UpdateControls(window, visrgn); + DisposeRgn(visrgn); +#else + UpdateControls(window, window->visRgn); +#endif + SetPort(saveport); + EndUpdate(window); +} + +#if TARGET_API_MAC_CARBON +#define EnableItem EnableMenuItem +#define DisableItem DisableMenuItem +#endif +void macctrl_adjustmenus(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); +} + +void macctrl_close(WindowPtr window) +{ + struct macctrls *mcs = mac_winctrls(window); + union macctrl *mc; + + while ((mc = index234(mcs->byctrl, 0)) != NULL) { + del234(mcs->byctrl, mc); + sfree(mc); + } + + freetree234(mcs->byctrl); + mcs->byctrl = NULL; + +/* XXX + DisposeWindow(window); + if (s->window == NULL) + sfree(s); +*/ +} + +void dlg_update_start(union control *ctrl, void *dlg) +{ + + /* No-op for now */ +} + +void dlg_update_done(union control *ctrl, void *dlg) +{ + + /* No-op for now */ +} + +void dlg_set_focus(union control *ctrl, void *dlg) +{ + + if (mac_gestalts.apprvers >= 0x100) { + /* Use SetKeyboardFocus() */ + } else { + /* Do our own mucking around */ + } +} + +union control *dlg_last_focused(void *dlg) +{ + + return NULL; +} + +void dlg_beep(void *dlg) +{ + + SysBeep(30); +} + +void dlg_error_msg(void *dlg, char *msg) +{ + Str255 pmsg; + + c2pstrcpy(pmsg, msg); + ParamText(pmsg, NULL, NULL, NULL); + StopAlert(128, NULL); +} + +void dlg_end(void *dlg, int value) +{ + +}; + +void dlg_refresh(union control *ctrl, void *dlg) +{ + +}; + +void *dlg_get_privdata(union control *ctrl, void *dlg) +{ + + return NULL; +} + +void dlg_set_privdata(union control *ctrl, void *dlg, void *ptr) +{ + + fatalbox("dlg_set_privdata"); +} + +void *dlg_alloc_privdata(union control *ctrl, void *dlg, size_t size) +{ + + fatalbox("dlg_alloc_privdata"); +} + + +/* + * Radio Button control + */ + +void dlg_radiobutton_set(union control *ctrl, void *dlg, int whichbutton) +{ + union macctrl *mc = dlg; + int i; + + for (i = 0; i < ctrl->radio.nbuttons; i++) { + if (i == whichbutton) + SetControlValue(mc->radio.tbctrls[i], + kControlRadioButtonCheckedValue); + else + SetControlValue(mc->radio.tbctrls[i], + kControlRadioButtonUncheckedValue); + } + +}; + +int dlg_radiobutton_get(union control *ctrl, void *dlg) +{ + union macctrl *mc = dlg; + int i; + + for (i = 0; i < ctrl->radio.nbuttons; i++) { + if (GetControlValue(mc->radio.tbctrls[i]) == + kControlRadioButtonCheckedValue) + return i; + } + return -1; +}; + + +/* + * Check Box control + */ + +void dlg_checkbox_set(union control *ctrl, void *dlg, int checked) +{ + union macctrl *mc = dlg; + + SetControlValue(mc->checkbox.tbctrl, + checked ? kControlCheckBoxCheckedValue : + kControlCheckBoxUncheckedValue); +} + +int dlg_checkbox_get(union control *ctrl, void *dlg) +{ + union macctrl *mc = dlg; + + return GetControlValue(mc->checkbox.tbctrl); +} + + +/* + * Edit Box control + */ + +void dlg_editbox_set(union control *ctrl, void *dlg, char const *text) +{ + +}; + +void dlg_editbox_get(union control *ctrl, void *dlg, char *buffer, int length) +{ + +}; + + +/* + * List Box control + */ + +void dlg_listbox_clear(union control *ctrl, void *dlg) +{ + +}; + +void dlg_listbox_del(union control *ctrl, void *dlg, int index) +{ + +}; + +void dlg_listbox_add(union control *ctrl, void *dlg, char const *text) +{ + +}; + +void dlg_listbox_addwithindex(union control *ctrl, void *dlg, + char const *text, int id) +{ + +}; + +int dlg_listbox_getid(union control *ctrl, void *dlg, int index) +{ + + return 0; +}; + +int dlg_listbox_index(union control *ctrl, void *dlg) +{ + + return 0; +}; + +int dlg_listbox_issel(union control *ctrl, void *dlg, int index) +{ + + return 0; +}; + +void dlg_listbox_select(union control *ctrl, void *dlg, int index) +{ + +}; + + +/* + * Text control + */ + +void dlg_text_set(union control *ctrl, void *dlg, char const *text) +{ + union macctrl *mc = dlg; + + if (mac_gestalts.apprvers >= 0x100) + SetControlData(mc->text.tbctrl, kControlEntireControl, + kControlStaticTextTextTag, + strlen(ctrl->text.label), ctrl->text.label); +} + + +/* + * File Selector control + */ + +void dlg_filesel_set(union control *ctrl, void *dlg, Filename fn) +{ + +} + +void dlg_filesel_get(union control *ctrl, void *dlg, Filename *fn) +{ + +} + + +/* + * Font Selector control + */ + +void dlg_fontsel_set(union control *ctrl, void *dlg, FontSpec fn) +{ + +} + +void dlg_fontsel_get(union control *ctrl, void *dlg, FontSpec *fn) +{ + +} + + +/* + * Printer enumeration + */ + +printer_enum *printer_start_enum(int *nprinters) +{ + + *nprinters = 0; + return NULL; +} + +char *printer_get_name(printer_enum *pe, int thing) +{ + + return ""; +} + +void printer_finish_enum(printer_enum *pe) +{ + +} + + +/* + * Colour selection stuff + */ + +void dlg_coloursel_start(union control *ctrl, void *dlg, + int r, int g, int b) +{ + +} + +int dlg_coloursel_results(union control *ctrl, void *dlg, + int *r, int *g, int *b) +{ + + return 0; +} + +/* + * Local Variables: + * c-file-style: "simon" + * End: + */ diff --git a/mac/macdlg.c b/mac/macdlg.c index ad7a1ffa..d293811e 100644 --- a/mac/macdlg.c +++ b/mac/macdlg.c @@ -1,4 +1,4 @@ -/* $Id: macdlg.c,v 1.12 2003/02/15 16:22:15 ben Exp $ */ +/* $Id: macdlg.c,v 1.13 2003/03/17 21:40:37 ben Exp $ */ /* * Copyright (c) 2002 Ben Harris * All rights reserved. @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -42,6 +41,7 @@ #include #include "putty.h" +#include "dialog.h" #include "mac.h" #include "macresid.h" #include "storage.h" @@ -50,29 +50,41 @@ static void mac_clickdlg(WindowPtr, EventRecord *); static void mac_activatedlg(WindowPtr, EventRecord *); static void mac_updatedlg(WindowPtr); static void mac_adjustdlgmenus(WindowPtr); +static void mac_closedlg(WindowPtr); void mac_newsession(void) { Session *s; WinInfo *wi; + static struct sesslist sesslist; - /* This should obviously be initialised by other means */ s = smalloc(sizeof(*s)); memset(s, 0, sizeof(*s)); do_defaults(NULL, &s->cfg); s->hasfile = FALSE; - s->settings_window = - GetDialogWindow(GetNewDialog(wSettings, NULL, (WindowPtr)-1)); + if (HAVE_COLOR_QD()) + s->settings_window = GetNewCWindow(wSettings, NULL, (WindowPtr)-1); + else + s->settings_window = GetNewWindow(wSettings, NULL, (WindowPtr)-1); + + get_sesslist(&sesslist, TRUE); + s->ctrlbox = ctrl_new_box(); + setup_config_box(s->ctrlbox, &sesslist, FALSE, 0); + + s->settings_ctrls.data = &s->cfg; + macctrl_layoutbox(s->ctrlbox, s->settings_window, &s->settings_ctrls); wi = smalloc(sizeof(*wi)); memset(wi, 0, sizeof(*wi)); wi->s = s; + wi->mcs = s->settings_ctrls; wi->wtype = wSettings; - wi->update = &mac_updatedlg; - wi->click = &mac_clickdlg; - wi->activate = &mac_activatedlg; - wi->adjustmenus = &mac_adjustdlgmenus; + wi->update = &macctrl_update; + wi->click = &macctrl_click; + wi->activate = &macctrl_activate; + wi->adjustmenus = &macctrl_adjustmenus; + wi->close = &macctrl_close; SetWRefCon(s->settings_window, (long)wi); ShowWindow(s->settings_window); } @@ -280,71 +292,6 @@ pascal OSErr mac_aevt_pdoc(const AppleEvent *req, AppleEvent *reply, return errAEEventNotHandled; } -static void mac_activatedlg(WindowPtr window, EventRecord *event) -{ - DialogItemType itemtype; - Handle itemhandle; - short item; - Rect itemrect; - int active; - DialogRef dialog = GetDialogFromWindow(window); - - active = (event->modifiers & activeFlag) != 0; - GetDialogItem(dialog, wiSettingsOpen, &itemtype, &itemhandle, &itemrect); - HiliteControl((ControlHandle)itemhandle, active ? 0 : 255); - DialogSelect(event, &dialog, &item); -} - -static void mac_clickdlg(WindowPtr window, EventRecord *event) -{ - short item; - Session *s = mac_windowsession(window); - DialogRef dialog = GetDialogFromWindow(window); - - if (DialogSelect(event, &dialog, &item)) - switch (item) { - case wiSettingsOpen: - HideWindow(window); - mac_startsession(s); - break; - } -} - -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" diff --git a/mac/macstuff.h b/mac/macstuff.h index c0728859..b0633c60 100644 --- a/mac/macstuff.h +++ b/mac/macstuff.h @@ -59,3 +59,7 @@ extern int vsnprintf(char *, size_t, char const *, va_list); extern int stricmp(char const *, char const *); extern int strnicmp(char const *, char const *, size_t); + +#define HELPCTX(foo) I(0) + +#define FILTER_KEY_FILES "pAgt.PPK" diff --git a/mac/macucs.c b/mac/macucs.c index 659f33b9..0601b9c8 100644 --- a/mac/macucs.c +++ b/mac/macucs.c @@ -1,4 +1,4 @@ -/* $Id: macucs.c,v 1.5 2003/01/14 19:57:36 ben Exp $ */ +/* $Id: macucs.c,v 1.6 2003/03/17 21:40:37 ben Exp $ */ #include #include @@ -109,3 +109,22 @@ void init_ucs(Session *s) s->ucsdata.unitab_xterm['_'] = ' '; } + +int decode_codepage(char *cp_name) +{ + + return 0; +} + +char *cp_enumerate (int index) +{ + + if (index == 0) return "ISO/IEC 8859-1"; + return NULL; +} + +char *cp_name(int codepage) +{ + + return "ISO/IEC 8859-1"; +} -- 2.11.0