Subversion Repositories Tewi

Rev

Rev 255 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 255 Rev 289
Line 1... Line 1...
1
/* $Id: gui.c 255 2024-10-04 04:08:58Z nishi $ */
1
/* $Id: gui.c 289 2024-10-09 03:08:14Z nishi $ */
2
 
2
 
3
#include "../config.h"
3
#include "../config.h"
4
 
4
 
5
#include "gui.h"
5
#include "gui.h"
6
#include "tw_server.h"
6
#include "tw_server.h"
Line 18... Line 18...
18
HWND button_start;
18
HWND button_start;
19
HWND button_stop;
19
HWND button_stop;
20
HWND button_about;
20
HWND button_about;
21
HWND button_reset;
21
HWND button_reset;
22
HWND button_exit;
22
HWND button_exit;
23
HWND status;
23
HWND statuswnd;
24
HFONT monospace;
24
HFONT monospace;
25
BOOL tewi_alive;
25
BOOL tewi_alive;
26
BOOL was_starting;
26
BOOL was_starting;
27
BOOL exiting;
27
BOOL exiting;
28
BOOL idle;
28
BOOL idle;
Line 135... Line 135...
135
			if(ev == BN_CLICKED) {
135
			if(ev == BN_CLICKED) {
136
				DialogBox(hInst, "VERSIONDLG", hWnd, (DLGPROC)VersionDialog);
136
				DialogBox(hInst, "VERSIONDLG", hWnd, (DLGPROC)VersionDialog);
137
			}
137
			}
138
		} else if(trig == GUI_BUTTON_START) {
138
		} else if(trig == GUI_BUTTON_START) {
139
			if(ev == BN_CLICKED) {
139
			if(ev == BN_CLICKED) {
140
				SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Starting Tewi HTTPd");
140
				SendMessage(statuswnd, SB_SETTEXT, 0, (LPARAM) "Starting Tewi HTTPd");
141
				StartTewi();
141
				StartTewi();
142
			}
142
			}
143
		} else if(trig == GUI_BUTTON_STOP) {
143
		} else if(trig == GUI_BUTTON_STOP) {
144
			if(ev == BN_CLICKED) {
144
			if(ev == BN_CLICKED) {
145
				SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Stopping Tewi HTTPd");
145
				SendMessage(statuswnd, SB_SETTEXT, 0, (LPARAM) "Stopping Tewi HTTPd");
146
				StopTewi();
146
				StopTewi();
147
			}
147
			}
148
		} else if(trig == GUI_BUTTON_RESET) {
148
		} else if(trig == GUI_BUTTON_RESET) {
149
			if(ev == BN_CLICKED) {
149
			if(ev == BN_CLICKED) {
150
				SendMessage(logarea, LB_RESETCONTENT, 0, 0);
150
				SendMessage(logarea, LB_RESETCONTENT, 0, 0);
Line 152... Line 152...
152
				SendMessage(logarea, LB_SETHORIZONTALEXTENT, max, 0);
152
				SendMessage(logarea, LB_SETHORIZONTALEXTENT, max, 0);
153
			}
153
			}
154
		} else if(trig == GUI_BUTTON_EXIT) {
154
		} else if(trig == GUI_BUTTON_EXIT) {
155
			if(ev == BN_CLICKED) {
155
			if(ev == BN_CLICKED) {
156
				if(tewi_alive) {
156
				if(tewi_alive) {
157
					SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Stopping Tewi HTTPd");
157
					SendMessage(statuswnd, SB_SETTEXT, 0, (LPARAM) "Stopping Tewi HTTPd");
158
					StopTewi();
158
					StopTewi();
159
					exiting = TRUE;
159
					exiting = TRUE;
160
				} else {
160
				} else {
161
					SendMessage(hWnd, WM_CLOSE, 0, 0);
161
					SendMessage(hWnd, WM_CLOSE, 0, 0);
162
				}
162
				}
Line 174... Line 174...
174
 
174
 
175
		InitCommonControls();
175
		InitCommonControls();
176
 
176
 
177
		monospace = (HFONT)GetStockObject(SYSTEM_FIXED_FONT);
177
		monospace = (HFONT)GetStockObject(SYSTEM_FIXED_FONT);
178
 
178
 
179
		status = CreateStatusWindow(WS_CHILD | WS_VISIBLE | CCS_BOTTOM, NULL, hWnd, GUI_STATUS);
179
		statuswnd = CreateStatusWindow(WS_CHILD | WS_VISIBLE | CCS_BOTTOM, NULL, hWnd, GUI_STATUS);
180
		SendMessage(status, SB_SIMPLE, 0, 0);
180
		SendMessage(statuswnd, SB_SIMPLE, 0, 0);
181
		SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Welcome to Tewi HTTPd");
181
		SendMessage(statuswnd, SB_SETTEXT, 0, (LPARAM) "Welcome to Tewi HTTPd");
182
		SendMessage(status, SB_GETRECT, 0, (LPARAM)&src);
182
		SendMessage(statuswnd, SB_GETRECT, 0, (LPARAM)&src);
183
 
183
 
184
		pbtewi_brush = CreateSolidBrush(RGB(0xf7, 0xc9, 0xf3));
184
		pbtewi_brush = CreateSolidBrush(RGB(0xf7, 0xc9, 0xf3));
185
		button_start = CreateWindow("BUTTON", "&Start", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, WINWIDTH(rc) - 100, 20 * 0, 100, 20, hWnd, (HMENU)GUI_BUTTON_START, hInst, NULL);
185
		button_start = CreateWindow("BUTTON", "&Start", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, WINWIDTH(rc) - 100, 20 * 0, 100, 20, hWnd, (HMENU)GUI_BUTTON_START, hInst, NULL);
186
		button_stop = CreateWindow("BUTTON", "S&top", WS_CHILD | WS_VISIBLE | WS_DISABLED | BS_PUSHBUTTON, WINWIDTH(rc) - 100, 20 * 1, 100, 20, hWnd, (HMENU)GUI_BUTTON_STOP, hInst, NULL);
186
		button_stop = CreateWindow("BUTTON", "S&top", WS_CHILD | WS_VISIBLE | WS_DISABLED | BS_PUSHBUTTON, WINWIDTH(rc) - 100, 20 * 1, 100, 20, hWnd, (HMENU)GUI_BUTTON_STOP, hInst, NULL);
187
		button_about = CreateWindow("BUTTON", "&About", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, WINWIDTH(rc) - 100, 20 * 2, 100, 20, hWnd, (HMENU)GUI_BUTTON_ABOUT, hInst, NULL);
187
		button_about = CreateWindow("BUTTON", "&About", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, WINWIDTH(rc) - 100, 20 * 2, 100, 20, hWnd, (HMENU)GUI_BUTTON_ABOUT, hInst, NULL);
Line 196... Line 196...
196
		if(wp == TIMER_WATCH_TEWI) {
196
		if(wp == TIMER_WATCH_TEWI) {
197
			if(idle) {
197
			if(idle) {
198
			} else if(tewi_alive) {
198
			} else if(tewi_alive) {
199
				if(was_starting) {
199
				if(was_starting) {
200
					was_starting = FALSE;
200
					was_starting = FALSE;
201
					SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Started Tewi HTTPd");
201
					SendMessage(statuswnd, SB_SETTEXT, 0, (LPARAM) "Started Tewi HTTPd");
202
				}
202
				}
203
				EnableWindow(button_start, FALSE);
203
				EnableWindow(button_start, FALSE);
204
				EnableWindow(button_stop, TRUE);
204
				EnableWindow(button_stop, TRUE);
205
				idle = TRUE;
205
				idle = TRUE;
206
			} else {
206
			} else {
207
				if(was_starting) {
207
				if(was_starting) {
208
					was_starting = FALSE;
208
					was_starting = FALSE;
209
					SendMessage(status, SB_SETTEXT, 0, (LPARAM) "Stopped Tewi HTTPd");
209
					SendMessage(statuswnd, SB_SETTEXT, 0, (LPARAM) "Stopped Tewi HTTPd");
210
				}
210
				}
211
				EnableWindow(button_start, TRUE);
211
				EnableWindow(button_start, TRUE);
212
				EnableWindow(button_stop, FALSE);
212
				EnableWindow(button_stop, FALSE);
213
				if(exiting) {
213
				if(exiting) {
214
					KillTimer(hWnd, TIMER_WATCH_TEWI);
214
					KillTimer(hWnd, TIMER_WATCH_TEWI);