From 44d02d36e12d944066c5079037f80d3e5e355e1f Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Thu, 11 Apr 2019 14:40:12 -0500 Subject: [PATCH] More event processing and tweaks to controls. --- diskbrowser.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ diskbrowser.rez | 18 ++++++++--------- 2 files changed, 62 insertions(+), 9 deletions(-) diff --git a/diskbrowser.c b/diskbrowser.c index 1a071ef..df804a5 100644 --- a/diskbrowser.c +++ b/diskbrowser.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,18 @@ GrafPortPtr window; Boolean resourceFileOpened, windowOpened; +/* User preference */ +boolean gsDisksOnly = true; + +#define DISK_LIST_LENGTH 10 + +struct diskListEntry { + char *memPtr; + Byte memFlag; +}; + +struct diskListEntry diskList[DISK_LIST_LENGTH]; + /* Record about our system window, to support processing by Desk Manager. */ /* See Prog. Ref. for System 6.0, page 20. */ static NDASysWindRecord sysWindRecord; @@ -93,6 +106,9 @@ void CloseBrowserWindow(void) { CloseWindow(window); windowOpened = false; window = NULL; + + /* reset state */ + gsDisksOnly = true; } if (resourceFileOpened && !windowOpened) { @@ -134,9 +150,46 @@ boolean DoLEEdit (int editAction) { return ((id == searchLine) || (id == pageNumberLine)); } +/* Do a search */ +void DoSearch(void) { + for (int i = 0; i < DISK_LIST_LENGTH; i++) { + diskList[i].memPtr = "This is the title of some disk you could mount"; + diskList[i].memFlag = 0; + } + + NewList2(NULL, 1, (Ref) diskList, refIsPointer, + DISK_LIST_LENGTH, (Handle) GetCtlHandleFromID(window, disksList)); +} + /* Handle an event after TaskMasterDA processing */ void HandleEvent(int eventCode, WmTaskRec *taskRec) { switch (eventCode) { + case wInControl: + switch (taskRec->wmTaskData4) { + case searchButton: + DoSearch(); + break; + + case forIIGSRadio: + gsDisksOnly = true; + break; + case forAnyAppleIIRadio: + gsDisksOnly = false; + break; + + case previousPageButton: + //TODO + break; + case nextPageButton: + //TODO + break; + + case mountDiskButton: + // TODO + break; + } + break; + case keyDownEvt: case autoKeyEvt: /* Handle keyboard shortcuts for cut/copy/paste */ diff --git a/diskbrowser.rez b/diskbrowser.rez index 0154ac1..b54bab3 100644 --- a/diskbrowser.rez +++ b/diskbrowser.rez @@ -35,18 +35,18 @@ resource rWindParam1 (winDiskBrowser) { }; resource rControlList (winDiskBrowser) {{ - searchLine, - searchButton, - findDisksForText, - forIIGSRadio, - forAnyAppleIIRadio, - disksList, + mountDiskButton, previousPageButton, pageText, pageNumberLine, ofPagesText, nextPageButton, - mountDiskButton + disksList, + findDisksForText, + forIIGSRadio, + forAnyAppleIIRadio, + searchLine, + searchButton }}; resource rControlTemplate (searchLine) { @@ -126,7 +126,7 @@ resource rControlTemplate (disksList) { {45, 10, 147, 410}, /* control rect */ ListControl {{ $0007, /* flags */ - $1400, /* more flags */ + $7400, /* more flags */ 0, /* refcon */ 0, /* list size */ 10, /* List View */ @@ -195,7 +195,7 @@ resource rControlTemplate (ofPagesText) { }; resource rTextForLETextBox2 (ofPagesText) { - "" + " " }; resource rControlTemplate (nextPageButton) {