add menu bar and about info box

This commit is contained in:
cy384 2020-08-05 20:59:49 -04:00
parent aef30ac837
commit e4123f41e3
4 changed files with 288 additions and 1 deletions

View File

@ -46,5 +46,14 @@
#define ALRT_CPU_BAD 132
#define DITL_CPU_BAD 132
/* about info window */
#define DLOG_ABOUT 133
#define DITL_ABOUT 133
#define PICT_ABOUT 133
/* menus */
#define SSHEVEN_MBAR 128
#define MENU_APPLE 128
#define MENU_FILE 129
#endif

View File

@ -181,6 +181,53 @@ void check_network_events(void)
return;
}
void display_about_box(void)
{
DialogRef about = GetNewDialog(DLOG_ABOUT, 0, (WindowPtr)-1);
UpdateDialog(about, about->visRgn);
while (!Button()) YieldToAnyThread();
while (Button()) YieldToAnyThread();
FlushEvents(everyEvent, 0);
DisposeWindow(about);
}
/* returns 1 if quit selected, else 0 */
int process_menu_select(int32_t result)
{
int exit = 0;
int16_t menu = (result & 0xFFFF0000) >> 16;
int16_t item = (result & 0x0000FFFF);
Str255 name;
switch (menu)
{
case MENU_APPLE:
if (item == 1)
{
display_about_box();
}
else
{
GetMenuItemText(GetMenuHandle(menu), item, name);
OpenDeskAcc(name);
}
break;
case MENU_FILE:
if (item == 1) exit = 1;
break;
default:
break;
}
HiliteMenu(0);
return exit;
}
void event_loop(void)
{
int exit_event_loop = 0;
@ -256,6 +303,7 @@ void event_loop(void)
break;
case inMenuBar:
exit_event_loop = process_menu_select(MenuSelect(event.where));
break;
case inSysWindow:
@ -366,7 +414,7 @@ int intro_dialog(char* hostname, char* username, char* password)
// modal dialog setup
TEInit();
InitDialogs(NULL);
DialogPtr dlg = GetNewDialog(128,0,(WindowPtr)-1);
DialogPtr dlg = GetNewDialog(DLOG_CONNECT, 0, (WindowPtr)-1);
InitCursor();
// select all text in dialog item 4 (the hostname+port one)
@ -578,6 +626,11 @@ int main(int argc, char** argv)
InitWindows();
InitMenus();
void* menu = GetNewMBar(SSHEVEN_MBAR);
SetMenuBar(menu);
AppendResMenu(GetMenuHandle(MENU_APPLE), 'DRVR');
DrawMenuBar();
console_setup();
char* logo = " _____ _____ _ _\n"

View File

@ -19,6 +19,7 @@
#include <Windows.h>
#include <Sound.h>
#include <Gestalt.h>
#include <Devices.h>
// libssh2
#include <libssh2.h>

224
ssheven.r
View File

@ -2,6 +2,33 @@
#include "Dialogs.r"
resource 'DLOG' (DLOG_ABOUT, purgeable) {
{0, 0, 148, 420},
dBoxProc,
visible,
goAway,
0,
DITL_ABOUT,
"",
centerMainScreen
};
resource 'DITL' (DITL_ABOUT, purgeable) {
{
{ 10, 10, 138, 138 },
Picture { enabled, PICT_ABOUT };
{ 34, 160, 54, 410},
StaticText { disabled, "ssheven" };
{ 64, 160, 84, 410},
StaticText { disabled, SSHEVEN_LONG_VERSION };
{ 94, 160, 114, 410},
StaticText { disabled, "https://github.com/cy384/ssheven" };
}
};
resource 'DLOG' (DLOG_CONNECT) {
{ 50, 100, 240, 420 },
dBoxProc,
@ -204,6 +231,32 @@ resource 'BNDL' (128, purgeable) {
}
};
#include "Menus.r"
resource 'MBAR' (SSHEVEN_MBAR, preload)
{
{ MENU_APPLE, MENU_FILE };
};
resource 'MENU' (MENU_APPLE) {
MENU_APPLE, textMenuProc;
allEnabled, enabled;
apple;
{
"About ssheven...", noIcon, noKey, noMark, plain;
"-", noIcon, noKey, noMark, plain;
}
};
resource 'MENU' (MENU_FILE) {
MENU_FILE, textMenuProc;
allEnabled, enabled;
"File";
{
"Quit", noIcon, "Q", noMark, plain;
}
};
#include "Icons.r"
/* use this regex to get rid of data comments: " \/\*[^\*]*\*\/" */
@ -366,3 +419,174 @@ data 'ics8' (128) {
$"0000 0000 FFFF 0000 0000 0000 0000 0000"
};
data 'PICT' (PICT_ABOUT) {
$"0A64 0000 0000 0020 0020 0011 02FF 0C00"
$"FFFF FFFF 0000 0000 0000 0000 0020 0000"
$"0020 0000 0000 0000 000C 001E 0007 0001"
$"000A 0007 001E 0027 003E 0090 0004 0000"
$"0000 0020 0020 0000 0000 0020 0020 0007"
$"001E 0027 003E 0003 1FFF FFF8 0FFF FFF0"
$"07FF FFF0 03FF FFE0 0000 03E0 0000 07C0"
$"0000 07C0 0000 0F80 0000 0F80 0000 1F00"
$"0000 1F00 0000 3E00 0180 3E00 03C0 7C00"
$"07E0 7C00 0FFF FFE0 0E7F FFF0 0E7F FFF0"
$"0FFF FFE0 07E3 E3E0 03C3 E140 0187 C000"
$"0007 C000 000F 8000 000F 8000 001F 0000"
$"001F 0000 003E 0000 003E 0000 007C 0000"
$"007C 0000 00F8 0000 0098 8020 0000 0000"
$"0020 0020 0000 0000 0000 0000 0048 0000"
$"0048 0000 0000 0008 0001 0008 0000 0000"
$"0001 7810 A020 0000 0000 0008 8000 00FF"
$"0000 FFFF FFFF FFFF 0000 FFFF FFFF CCCC"
$"0004 FFFF FFFF 9999 0004 FFFF FFFF 6666"
$"0004 FFFF FFFF 3333 0000 FFFF FFFF 0000"
$"0004 FFFF CCCC FFFF 0004 FFFF CCCC CCCC"
$"0000 FFFF CCCC 9999 0004 FFFF CCCC 6666"
$"0004 FFFF CCCC 3333 0004 FFFF CCCC 0000"
$"0004 FFFF 9999 FFFF 0004 FFFF 9999 CCCC"
$"0004 FFFF 9999 9999 0004 FFFF 9999 6666"
$"0004 FFFF 9999 3333 0004 FFFF 9999 0000"
$"0004 FFFF 6666 FFFF 0000 FFFF 6666 CCCC"
$"0004 FFFF 6666 9999 0004 FFFF 6666 6666"
$"0000 FFFF 6666 3333 0004 FFFF 6666 0000"
$"0004 FFFF 3333 FFFF 0004 FFFF 3333 CCCC"
$"0004 FFFF 3333 9999 0004 FFFF 3333 6666"
$"0004 FFFF 3333 3333 0004 FFFF 3333 0000"
$"0004 FFFF 0000 FFFF 0004 FFFF 0000 CCCC"
$"0004 FFFF 0000 9999 0004 FFFF 0000 6666"
$"0004 FFFF 0000 3333 0004 FFFF 0000 0000"
$"0004 CCCC FFFF FFFF 0004 CCCC FFFF CCCC"
$"0004 CCCC FFFF 9999 0004 CCCC FFFF 6666"
$"0004 CCCC FFFF 3333 0004 CCCC FFFF 0000"
$"0000 CCCC CCCC FFFF 0000 CCCC CCCC CCCC"
$"0004 CCCC CCCC 9999 0004 CCCC CCCC 6666"
$"0004 CCCC CCCC 3333 0004 CCCC CCCC 0000"
$"0004 CCCC 9999 FFFF 0004 CCCC 9999 CCCC"
$"0004 CCCC 9999 9999 0000 CCCC 9999 6666"
$"0004 CCCC 9999 3333 0004 CCCC 9999 0000"
$"0004 CCCC 6666 FFFF 0004 CCCC 6666 CCCC"
$"0004 CCCC 6666 9999 0004 CCCC 6666 6666"
$"0004 CCCC 6666 3333 0004 CCCC 6666 0000"
$"0004 CCCC 3333 FFFF 0004 CCCC 3333 CCCC"
$"0004 CCCC 3333 9999 0004 CCCC 3333 6666"
$"0004 CCCC 3333 3333 0004 CCCC 3333 0000"
$"0004 CCCC 0000 FFFF 0004 CCCC 0000 CCCC"
$"0004 CCCC 0000 9999 0004 CCCC 0000 6666"
$"0004 CCCC 0000 3333 0004 CCCC 0000 0000"
$"0000 9999 FFFF FFFF 0004 9999 FFFF CCCC"
$"0004 9999 FFFF 9999 0004 9999 FFFF 6666"
$"0004 9999 FFFF 3333 0004 9999 FFFF 0000"
$"0004 9999 CCCC FFFF 0004 9999 CCCC CCCC"
$"0004 9999 CCCC 9999 0004 9999 CCCC 6666"
$"0004 9999 CCCC 3333 0004 9999 CCCC 0000"
$"0000 9999 9999 FFFF 0004 9999 9999 CCCC"
$"0004 9999 9999 9999 0004 9999 9999 6666"
$"0004 9999 9999 3333 0004 9999 9999 0000"
$"0004 9999 6666 FFFF 0004 9999 6666 CCCC"
$"0000 9999 6666 9999 0004 9999 6666 6666"
$"0004 9999 6666 3333 0004 9999 6666 0000"
$"0004 9999 3333 FFFF 0004 9999 3333 CCCC"
$"0004 9999 3333 9999 0004 9999 3333 6666"
$"0004 9999 3333 3333 0004 9999 3333 0000"
$"0004 9999 0000 FFFF 0004 9999 0000 CCCC"
$"0004 9999 0000 9999 0000 9999 0000 6666"
$"0004 9999 0000 3333 0004 9999 0000 0000"
$"0004 6666 FFFF FFFF 0004 6666 FFFF CCCC"
$"0004 6666 FFFF 9999 0004 6666 FFFF 6666"
$"0004 6666 FFFF 3333 0004 6666 FFFF 0000"
$"0004 6666 CCCC FFFF 0004 6666 CCCC CCCC"
$"0004 6666 CCCC 9999 0004 6666 CCCC 6666"
$"0004 6666 CCCC 3333 0004 6666 CCCC 0000"
$"0004 6666 9999 FFFF 0004 6666 9999 CCCC"
$"0004 6666 9999 9999 0004 6666 9999 6666"
$"0004 6666 9999 3333 0004 6666 9999 0000"
$"0004 6666 6666 FFFF 0000 6666 6666 CCCC"
$"0004 6666 6666 9999 0004 6666 6666 6666"
$"0004 6666 6666 3333 0004 6666 6666 0000"
$"0004 6666 3333 FFFF 0004 6666 3333 CCCC"
$"0004 6666 3333 9999 0004 6666 3333 6666"
$"0004 6666 3333 3333 0004 6666 3333 0000"
$"0004 6666 0000 FFFF 0004 6666 0000 CCCC"
$"0004 6666 0000 9999 0004 6666 0000 6666"
$"0004 6666 0000 3333 0004 6666 0000 0000"
$"0004 3333 FFFF FFFF 0004 3333 FFFF CCCC"
$"0000 3333 FFFF 9999 0004 3333 FFFF 6666"
$"0004 3333 FFFF 3333 0004 3333 FFFF 0000"
$"0004 3333 CCCC FFFF 0004 3333 CCCC CCCC"
$"0004 3333 CCCC 9999 0004 3333 CCCC 6666"
$"0004 3333 CCCC 3333 0004 3333 CCCC 0000"
$"0004 3333 9999 FFFF 0004 3333 9999 CCCC"
$"0004 3333 9999 9999 0000 3333 9999 6666"
$"0004 3333 9999 3333 0004 3333 9999 0000"
$"0004 3333 6666 FFFF 0004 3333 6666 CCCC"
$"0004 3333 6666 9999 0000 3333 6666 6666"
$"0004 3333 6666 3333 0004 3333 6666 0000"
$"0004 3333 3333 FFFF 0004 3333 3333 CCCC"
$"0004 3333 3333 9999 0000 3333 3333 6666"
$"0004 3333 3333 3333 0004 3333 3333 0000"
$"0004 3333 0000 FFFF 0004 3333 0000 CCCC"
$"0000 3333 0000 9999 0004 3333 0000 6666"
$"0004 3333 0000 3333 0004 3333 0000 0000"
$"0004 0000 FFFF FFFF 0004 0000 FFFF CCCC"
$"0004 0000 FFFF 9999 0004 0000 FFFF 6666"
$"0004 0000 FFFF 3333 0004 0000 FFFF 0000"
$"0004 0000 CCCC FFFF 0004 0000 CCCC CCCC"
$"0004 0000 CCCC 9999 0004 0000 CCCC 6666"
$"0004 0000 CCCC 3333 0004 0000 CCCC 0000"
$"0000 0000 9999 FFFF 0004 0000 9999 CCCC"
$"0004 0000 9999 9999 0004 0000 9999 6666"
$"0004 0000 9999 3333 0004 0000 9999 0000"
$"0004 0000 6666 FFFF 0004 0000 6666 CCCC"
$"0004 0000 6666 9999 0004 0000 6666 6666"
$"0004 0000 6666 3333 0004 0000 6666 0000"
$"0004 0000 3333 FFFF 0004 0000 3333 CCCC"
$"0004 0000 3333 9999 0004 0000 3333 6666"
$"0004 0000 3333 3333 0004 0000 3333 0000"
$"0004 0000 0000 FFFF 0004 0000 0000 CCCC"
$"0004 0000 0000 9999 0004 0000 0000 6666"
$"0004 0000 0000 3333 0004 EEEE 0000 0000"
$"0000 DDDD 0000 0000 0004 BBBB 0000 0000"
$"0004 AAAA 0000 0000 0004 8888 0000 0000"
$"0004 7777 0000 0000 0004 5555 0000 0000"
$"0004 4444 0000 0000 0004 2222 0000 0000"
$"0004 1111 0000 0000 0004 0000 EEEE 0000"
$"0004 0000 DDDD 0000 0000 0000 BBBB 0000"
$"0004 0000 AAAA 0000 0004 0000 8888 0000"
$"0004 0000 7777 0000 0004 0000 5555 0000"
$"0004 0000 4444 0000 0004 0000 2222 0000"
$"0004 0000 1111 0000 0004 0000 0000 EEEE"
$"0000 0000 0000 DDDD 0004 0000 0000 BBBB"
$"0004 0000 0000 AAAA 0004 0000 0000 8888"
$"0004 0000 0000 7777 0004 0000 0000 5555"
$"0004 0000 0000 4444 0004 0000 0000 2222"
$"0004 0000 0000 1111 0000 EEEE EEEE EEEE"
$"0000 DDDD DDDD DDDD 0000 BBBB BBBB BBBB"
$"0000 AAAA AAAA AAAA 0000 8888 8888 8888"
$"0000 7777 7777 7777 0000 5555 5555 5555"
$"0000 4444 4444 4444 0000 2222 2222 2222"
$"0000 1111 1111 1111 0000 0000 0000 0000"
$"0000 0000 0020 0020 0007 001E 0027 003E"
$"0001 06FE 00E7 FFFE 0006 FD00 E9FF FD00"
$"06FC 00EA FFFD 0006 FB00 ECFF FC00 06EB"
$"00FC FFFC 0006 EC00 FCFF FB00 06EC 00FC"
$"FFFB 0006 ED00 FCFF FA00 06ED 00FC FFFA"
$"0006 EE00 FCFF F900 06EE 00FC FFF9 0006"
$"EF00 FCFF F800 0BFA 0001 FFFF F800 FCFF"
$"F800 0DFB 0003 FF05 05FF FA00 FCFF F700"
$"0EFC 0000 FFFD 0500 FFFB 00FC FFF7 000E"
$"FD00 06FF 0505 FFFF 0505 F1FF FC00 0FFD"
$"0005 FF05 FF00 00FF F005 00FF FD00 10FD"
$"0006 FF05 FF00 00FF 05F1 1600 FFFD 0013"
$"FD00 06FF 1605 FFFF 0516 F5FF 0305 FF05"
$"FFFC 0017 FC00 05FF 1605 0516 FFFE 00FC"
$"FFFE 0004 FF16 FF16 FFFC 0013 FB00 03FF"
$"1616 FFFD 00FC FFFD 0002 FF00 FFFB 000B"
$"FA00 01FF FFFD 00FC FFF3 0006 F400 FCFF"
$"F300 06F5 00FC FFF2 0006 F500 FCFF F200"
$"06F6 00FC FFF1 0006 F600 FCFF F100 06F7"
$"00FC FFF0 0006 F700 FCFF F000 06F8 00FC"
$"FFEF 0006 F800 FCFF EF00 06F9 00FC FFEE"
$"0000 00FF"
};