AmendHub

Download:

jcs

/

wifi_da

/

amendments

/

17

*: Don't add our own about menu on System 7+, simplify dialog

The DA Handler on System 7+ creates its own "About (DA name)" menu
which draws its own dialog and the only customization we get is to
define a "dast" string which it will draw in the dialog. To avoid
confusion having two about screens, on System 7+ just defer to this
mechanism.
 
On System 6, continue adding our own "Wi-Fi" menu as expected from a
DA, and then draw our custom about dialog.
 
Technically there is a way to do this on System 7 by clearing the
menu bar and adding our own Apple/File/Edit menus, but then there's
another problem of a DA can only get events from one menu. To work
around /that/, one must diddle the "MBarEnable" global and then reset
it each time the DA's window becomes deactivated. This becomes kind
of brittle, so don't bother with all of it just for a custom about
screen. MacTech 07.07 explains how to do this.
 
So for now, only cool System 6 users get to see Carl's sweet face.

jcs made amendment 17 6 months ago
--- about.c Fri Oct 20 23:39:59 2023 +++ about.c Tue Oct 24 11:32:15 2023 @@ -16,48 +16,27 @@ #include "wi-fi.h" -#define CARL_PICT_ID 0 - void wifi_about(void) { - BitMap cur_bits, off_bits; DialogPtr dp; - PicHandle pic; - Rect bounds, pic_rect; - short width, height, hit; + StringHandle dast; + Rect bounds; + short hit; Handle h; dp = GetNewDialog(OwnedResourceID(ABOUT_DIALOG_ID), 0L, (WindowPtr)-1L); - ParamText("\pBlueSCSI Wi-Fi DA", "\p© 2023, joshua stein\r", - "\pWeb: http://jcs.org/\r", - "\pI miss you, Carl"); - + dast = (StringHandle)GetResource('dast', OwnedResourceID(0)); + ParamText("\pWi-Fi", *dast, "\p", "\p"); + DisposHandle(dast); + center_in_screen(((DialogPeek)dp)->window.port.portRect.right, ((DialogPeek)dp)->window.port.portRect.bottom, false, &bounds); MoveWindow(dp, bounds.left, bounds.top, false); SetPort(dp); - - pic = GetPicture(OwnedResourceID(CARL_PICT_ID)); - ShowWindow(dp); - - if (pic != NULL) { - HLock(pic); - - pic_rect.left = 0; - pic_rect.top = 0; - pic_rect.right = (**(pic)).picFrame.right - (**(pic)).picFrame.left; - pic_rect.bottom = (**(pic)).picFrame.bottom - (**(pic)).picFrame.top; - - pic_rect.left -= 10; - pic_rect.right -= 10; - DrawPicture(pic, &pic_rect); - - ReleaseResource(pic); - } for (;;) { ModalDialog(0, &hit); --- main.c Tue Oct 24 09:52:14 2023 +++ main.c Tue Oct 24 10:20:44 2023 @@ -22,13 +22,16 @@ /* device control entry */ DCtlPtr dce = NULL; +SysEnvRec world; +#define ON_SYSTEM_7 (world.systemVersion >= 0x0700) + short da_state = STATE_CLOSED; short wifi_scsi_id = WIFI_SCSI_ID_FINDING; unsigned long wifi_scan_started = 0; struct wifi_network_entry wifi_cur_info = { 0 }; struct wifi_network_entry wifi_scan_networks[10] = { 0 }; MenuHandle menu, apple_menu; -short menuID; +short menuID = 0; WindowPtr win = 0L; Cursor watch; short logger_y = 12; @@ -57,9 +60,11 @@ main(cntrlParam *p, DCtlPtr d, short n) return 0; } - if (dce == NULL) + if (dce == NULL) { util_init(d); - + SysEnvirons(1, &world); + } + dce = d; dce->dCtlFlags &= ~dCtlEnable; @@ -126,13 +131,15 @@ da_open(void) BlockMove(*(h = GetCursor(watchCursor)), &watch, sizeof(Cursor)); if (dispose) ReleaseResource((Handle)h); - - dce->dCtlMenu = menuID = OwnedResourceID(MAIN_MENU_ID); - menu = GetMenu(menuID); - (**menu).menuID = menuID; - InsertMenu(menu = GetMenu(menuID), 0); - DrawMenuBar(); - + + if (!ON_SYSTEM_7) { + dce->dCtlMenu = menuID = OwnedResourceID(MAIN_MENU_ID); + menu = GetMenu(menuID); + (**menu).menuID = menuID; + InsertMenu(menu = GetMenu(menuID), 0); + DrawMenuBar(); + } + dce->dCtlWindow = create_window(dce->dCtlRefNum); HiliteMenu(0); @@ -159,10 +166,13 @@ da_control(short code, short *param) void da_close(void) { - DeleteMenu(dce->dCtlMenu); - DrawMenuBar(); + if (!ON_SYSTEM_7) { + DeleteMenu(dce->dCtlMenu); + DrawMenuBar(); + DisposeMenu(menu); + } + dce->dCtlMenu = 0; - DisposeMenu(menu); destroy_window(); if (logger) { DisposeWindow(logger); --- wi-fi.h Tue Oct 24 09:55:49 2023 +++ wi-fi.h Tue Oct 24 10:15:43 2023 @@ -21,7 +21,7 @@ #include "util.h" /* disable in production */ -#define DEBUG_LOGGING 1 +//#define DEBUG_LOGGING 1 #define MAIN_MENU_ID 1 #define MAIN_MENU_ABOUT_ID 1 --- Wi-Fi DA.π.r Tue Oct 24 09:53:10 2023 +++ Wi-Fi DA.π.r Tue Oct 24 11:41:20 2023 @@ -21,9 +21,10 @@ data 'DITL' (-15999, "CONNECT") { }; data 'DITL' (-15998, "ABOUT", purgeable, preload) { - $"0001 0000 0000 00D2 0154 00E6 0190 0402" /* .......“.T...ê.. */ - $"4F4B 0000 0000 000A 00FA 0087 019F 880B" /* OK.........á.üà. */ - $"5E30 0D5E 310D 5E32 0D5E 3300" /* ^0¬^1¬^2¬^3. */ + $"0002 0000 0000 00B4 0140 00C8 017C 0402" /* .......¥.@.».|.. */ + $"4F4B 0000 0000 000A 00DC 0090 01A2 880B" /* OK.........ê.¢à. */ + $"5E30 205E 310D 5E32 0D5E 3300 0000 0000" /* ^0 ^1¬^2¬^3..... */ + $"0000 FFD8 0106 011E C002 C180" /* ...ÿ....¿.¡Ä */ }; data 'MENU' (-15999) { @@ -526,5 +527,14 @@ data 'PICT' (-16000) { $"7FF7 FFF7 EBFF 0FFA FF09 BFFE EFFF FFED" /* .........∆ø..... */ $"FFDD FFDF EAFF 3400 FD01 3C01 0701 4638" /* ......4...<...F8 */ $"A000 83FF" /* †.É. */ +}; + +data 'dast' (-16000) { + $"5F76 312E 3062 320D 4465 736B 2041 6363" /* _v1.0b2¬Desk Acc */ + $"6573 736F 7279 2066 6F72 2042 6C75 6553" /* essory for BlueS */ + $"4353 490D A920 3230 3233 2C20 6A6F 7368" /* CSI¬© 2023, josh */ + $"7561 2073 7465 696E 0D0D 5765 623A 2068" /* ua stein¬¬Web: h */ + $"7474 703A 2F2F 6A63 732E 6F72 672F 0D0D" /* ttp://jcs.org/¬¬ */ + $"4920 6D69 7373 2079 6F75 2C20 4361 726C" /* I miss you, Carl */ };