aboutsummaryrefslogtreecommitdiff
path: root/windows.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2004-04-29 19:23:08 +0000
committerSimon Tatham <anakin@pobox.com>2004-04-29 19:23:08 +0000
commita8c8237bd0362e4fe44a451eb81544b451ae4444 (patch)
treec50e8ec0ef03edcdba50cd651076290f657ffa7e /windows.c
parentfa7ef572c782c9394f60202d950d3380dfdce5c3 (diff)
downloadpuzzles-a8c8237bd0362e4fe44a451eb81544b451ae4444.zip
puzzles-a8c8237bd0362e4fe44a451eb81544b451ae4444.tar.gz
puzzles-a8c8237bd0362e4fe44a451eb81544b451ae4444.tar.bz2
puzzles-a8c8237bd0362e4fe44a451eb81544b451ae4444.tar.xz
Added a status bar.
[originally from svn r4174]
Diffstat (limited to 'windows.c')
-rw-r--r--windows.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/windows.c b/windows.c
index ea5d7a2..507203e 100644
--- a/windows.c
+++ b/windows.c
@@ -3,6 +3,7 @@
*/
#include <windows.h>
+#include <commctrl.h>
#include <stdio.h>
#include <assert.h>
@@ -72,7 +73,7 @@ struct font {
struct frontend {
midend_data *me;
- HWND hwnd;
+ HWND hwnd, statusbar;
HBITMAP bitmap, prevbm;
HDC hdc_bm;
COLORREF *colours;
@@ -100,6 +101,11 @@ void fatal(char *fmt, ...)
exit(1);
}
+void status_bar(frontend *fe, char *text)
+{
+ SetWindowText(fe->statusbar, text);
+}
+
void frontend_default_colour(frontend *fe, float *output)
{
DWORD c = GetSysColor(COLOR_MENU); /* ick */
@@ -291,7 +297,7 @@ static frontend *new_window(HINSTANCE inst)
{
frontend *fe;
int x, y;
- RECT r;
+ RECT r, sr;
HDC hdc;
fe = snew(frontend);
@@ -374,6 +380,21 @@ static frontend *new_window(HINSTANCE inst)
SetMenu(fe->hwnd, bar);
}
+ if (midend_wants_statusbar(fe->me)) {
+ fe->statusbar = CreateWindowEx(0, STATUSCLASSNAME, "ooh",
+ WS_CHILD | WS_VISIBLE,
+ 0, 0, 0, 0, /* status bar does these */
+ fe->hwnd, NULL, inst, NULL);
+ GetWindowRect(fe->statusbar, &sr);
+ SetWindowPos(fe->hwnd, NULL, 0, 0,
+ r.right - r.left, r.bottom - r.top + sr.bottom - sr.top,
+ SWP_NOMOVE | SWP_NOZORDER);
+ SetWindowPos(fe->statusbar, NULL, 0, y, x, sr.bottom - sr.top,
+ SWP_NOZORDER);
+ } else {
+ fe->statusbar = NULL;
+ }
+
hdc = GetDC(fe->hwnd);
fe->bitmap = CreateCompatibleBitmap(hdc, x, y);
ReleaseDC(fe->hwnd, hdc);
@@ -424,7 +445,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
int p = ((wParam &~ 0xF) - IDM_PRESETS) / 0x10;
if (p >= 0 && p < fe->npresets) {
- RECT r;
+ RECT r, sr;
HDC hdc;
int x, y;
@@ -440,9 +461,18 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
WS_OVERLAPPED),
TRUE, 0);
+ if (fe->statusbar != NULL) {
+ GetWindowRect(fe->statusbar, &sr);
+ } else {
+ sr.left = sr.right = sr.top = sr.bottom = 0;
+ }
SetWindowPos(fe->hwnd, NULL, 0, 0,
- r.right - r.left, r.bottom - r.top,
+ r.right - r.left,
+ r.bottom - r.top + sr.bottom - sr.top,
SWP_NOMOVE | SWP_NOZORDER);
+ if (fe->statusbar != NULL)
+ SetWindowPos(fe->statusbar, NULL, 0, y, x,
+ sr.bottom - sr.top, SWP_NOZORDER);
DeleteObject(fe->bitmap);
@@ -572,6 +602,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
srand(time(NULL));
+ InitCommonControls();
+
if (!prev) {
WNDCLASS wndclass;