aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/PalmOS/Src/launcher/forms/forminfo.cpp
blob: 74622d8f14b99bb63b853208dd1f048d26761c46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include <PalmOS.h>

#include "start.h"
#include "formTabs.h"
#include "forms.h"

#include "base/version.h"
#include "globals.h"
#include "init_palmos.h"

/***********************************************************************
 *
 * FUNCTION:    MiscOptionsFormSave
 * FUNCTION:    MiscOptionsFormInit
 * FUNCTION:    MiscOptionsFormHandleEvent
 *
 * DESCRIPTION: Misc. Options form functions
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/
static TabType *myTabP;
static UInt16 lastTab = 0;

static UInt32 GetStackSize() {
	MemPtr startPP, endPP;
	SysGetStackInfo(&startPP, &endPP);

	return ((Char *)endPP - (Char *)startPP) / 1024L;
}

static void VersionTabDraw() {
	WinDrawChars(gScummVMVersion, StrLen(gScummVMVersion), 47, 12 + 30);
	WinDrawChars(gScummVMBuildDate, StrLen(gScummVMBuildDate), 47, 24 + 30);
}

static void SystemTabDraw() {
	Coord x;
	UInt32 dm, sm, df, sf, stack;
	Char num[10];

	PalmGetMemory(&sm, &dm, &sf, 0);
	stack = GetStackSize();
	df = gVars->startupMemory;
	
	WinSetTextColor(UIColorGetTableEntryIndex(UIObjectForeground));
	FntSetFont(stdFont);
	
	StrIToA(num, dm);
	x = 147 - FntCharsWidth(num, StrLen(num)) + 5;
	WinDrawChars(num, StrLen(num), x, 12 + 30);

	StrIToA(num, sm);
	x = 147 - FntCharsWidth(num, StrLen(num)) + 5;
	WinDrawChars(num, StrLen(num), x, 24 + 30);

	StrIToA(num, stack);
	x = 147 - FntCharsWidth(num, StrLen(num)) + 5;
	WinDrawChars(num, StrLen(num), x, 36 + 30);

	StrIToA(num, df);
	x = 107 - FntCharsWidth(num, StrLen(num)) + 5;
	WinDrawChars(num, StrLen(num), x, 12 + 30);

	StrIToA(num, sf);
	x = 107 - FntCharsWidth(num, StrLen(num)) + 5;
	WinDrawChars(num, StrLen(num), x, 24 + 30);

	StrCopy(num,"-");
	x = 107 - FntCharsWidth(num, StrLen(num)) + 5;
	WinDrawChars(num, StrLen(num), x, 36 + 30);
}

static void InfoFormSave() {
	TabDeleteTabs(myTabP);
	FrmReturnToMain();
}

static void AboutTabDraw() {
	MemHandle hTemp;
	BitmapPtr bmpTemp;

	hTemp = DmGetResource (bitmapRsc, 1200);
	if (hTemp) {
		bmpTemp = (BitmapType *)MemHandleLock(hTemp);
		WinDrawBitmap(bmpTemp,3,44);
		MemPtrUnlock(bmpTemp);
		DmReleaseResource(hTemp);
	}
}

static void InfoFormInit() {
	TabType *tabP;
	FormType *frmP = FrmGetActiveForm();

	tabP = TabNewTabs(3);
	TabAddContent(&frmP, tabP, "About", TabInfoAboutForm, AboutTabDraw);
	TabAddContent(&frmP, tabP, "Version", TabInfoVersionForm, VersionTabDraw);
	TabAddContent(&frmP, tabP, "Memory", TabInfoSystemForm, SystemTabDraw);

	lastTab = 0;
	FrmDrawForm(frmP);
	TabSetActive(frmP, tabP, lastTab);

	myTabP = tabP;
}

Boolean InfoFormHandleEvent(EventPtr eventP) {
	FormPtr frmP = FrmGetActiveForm();
	Boolean handled = false;

	switch (eventP->eType) {
		case frmOpenEvent:
			InfoFormInit();
			handled = true;
			break;
			
		case frmCloseEvent:
			InfoFormSave();
			handled = true;
			break;

		case ctlSelectEvent:
			switch (eventP->data.ctlSelect.controlID)
			{
				case (InfoForm + 1) :
				case (InfoForm + 2) :
				case (InfoForm + 3) :
					lastTab = (eventP->data.ctlSelect.controlID - InfoForm - 1);
					TabSetActive(frmP, myTabP, lastTab);
					break;

				case InfoOKButton:
					InfoFormSave();
					break;
			}
			handled = true;
			break;

		default:
			break;
	}
	
	return handled;
}