annotate win/dw.c @ 54:c4e1139d9872

Added new tree functions, and fixed a memory leak as well as use of invalid memory when a button destroys itself.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 17 Nov 2001 17:40:16 +0000
parents 0804483f6320
children b6948eac375a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2 * Dynamic Windows:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3 * A GTK like implementation of the Win32 GUI
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5 * (C) 2000,2001 Brian Smith <dbsoft@technologist.com>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8 #define _WIN32_IE 0x0500
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9 #define WINVER 0x400
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10 #include <windows.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11 #include <windowsx.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12 #include <commctrl.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
13 #include <stdlib.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
14 #include <string.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
15 #include <stdio.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
16 #include <process.h>
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
17 #include <time.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
18 #include "dw.h"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
19
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
20 /* this is the callback handle for the window procedure */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
21 /* make sure you always match the calling convention! */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
22 int (*filterfunc)(HWND, UINT, WPARAM, LPARAM) = 0L;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
23
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
24 HWND hwndBubble = (HWND)NULL, hwndBubbleLast, DW_HWND_OBJECT = (HWND)NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
25
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
26 HINSTANCE DWInstance = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
27
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
28 DWORD dwVersion = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
29
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
30 /* I should probably check the actual file version, but this will do for now */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
31 #define IS_WIN98PLUS (LOBYTE(LOWORD(dwVersion)) > 4 || \
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
32 (LOBYTE(LOWORD(dwVersion)) == 4 && HIBYTE(LOWORD(dwVersion)) > 0))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
33
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
34 char monthlist[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
35 "Sep", "Oct", "Nov", "Dec" };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
36
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
37 int main(int argc, char *argv[]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
38
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
39 #define ICON_INDEX_LIMIT 200
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
40 HICON lookup[200];
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
41 HIMAGELIST hSmall = 0, hLarge = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
42
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
43 #define THREAD_LIMIT 128
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
44 COLORREF _foreground[THREAD_LIMIT];
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
45 COLORREF _background[THREAD_LIMIT];
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
46 HPEN _hPen[THREAD_LIMIT];
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
47 HBRUSH _hBrush[THREAD_LIMIT];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
48
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
49 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
50 FILE *f;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
51
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
52 void reopen(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
53 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
54 fclose(f);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
55 f = fopen("dw.log", "at");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
56 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
57 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
58
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
59 BYTE _red[] = { 0x00, 0xbb, 0x00, 0xaa, 0x00, 0xbb, 0x00, 0xaa, 0x77,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
60 0xff, 0x00, 0xee, 0x00, 0xff, 0x00, 0xff, 0xaa, 0x00 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
61 BYTE _green[] = { 0x00, 0x00, 0xbb, 0xaa, 0x00, 0x00, 0xbb, 0xaa, 0x77,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
62 0x00, 0xff, 0xee, 0x00, 0x00, 0xee, 0xff, 0xaa, 0x00 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
63 BYTE _blue[] = { 0x00, 0x00, 0x00, 0x00, 0xcc, 0xbb, 0xbb, 0xaa, 0x77,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
64 0x00, 0x00, 0x00, 0xff, 0xff, 0xee, 0xff, 0xaa, 0x00};
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
65
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
66 HBRUSH _colors[18];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
67
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
68 static LONG lColor[SPLITBAR_WIDTH] =
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
69 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
70 DW_CLR_BLACK,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
71 DW_CLR_PALEGRAY,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
72 DW_CLR_WHITE
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
73 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
74
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
75 void _resize_notebook_page(HWND handle, int pageid);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
76 int _lookup_icon(HWND handle, HICON hicon, int type);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
77
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
78 #ifdef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
79 #define USE_FILTER
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
80 #else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
81 typedef struct _sighandler
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
82 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
83 struct _sighandler *next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
84 ULONG message;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
85 HWND window;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
86 void *signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
87 void *data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
88
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
89 } SignalHandler;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
90
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
91 SignalHandler *Root = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
92 int _index;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
93
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
94 typedef struct
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
95 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
96 ULONG message;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
97 char name[30];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
98
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
99 } SignalList;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
100
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
101 /* List of signals and their equivilent Win32 message */
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
102 #define SIGNALMAX 13
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
103
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
104 SignalList SignalTranslate[SIGNALMAX] = {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
105 { WM_SIZE, "configure_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
106 { WM_CHAR, "key_press_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
107 { WM_LBUTTONDOWN, "button_press_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
108 { WM_LBUTTONUP, "button_release_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
109 { WM_MOUSEMOVE, "motion_notify_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
110 { WM_CLOSE, "delete_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
111 { WM_PAINT, "expose_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
112 { WM_COMMAND, "clicked" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
113 { NM_DBLCLK, "container-select" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
114 { NM_RCLICK, "container-context" },
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
115 { LBN_SELCHANGE, "item-select" },
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
116 { TVN_SELCHANGED, "tree-select" },
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
117 { WM_SETFOCUS, "set-focus" }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
118 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
119
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
120 #ifdef BUILD_DLL
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
121 void Win32_Set_Instance(HINSTANCE hInstance)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
122 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
123 DWInstance = hInstance;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
124 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
125 #else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
126 char **_convertargs(int *count, char *start)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
127 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
128 char *tmp, *argstart, **argv;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
129 int loc = 0, inquotes = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
130
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
131 (*count) = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
132
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
133 tmp = start;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
134
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
135 /* Count the number of entries */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
136 if(*start)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
137 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
138 (*count)++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
139
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
140 while(*tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
141 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
142 if(*tmp == '"' && inquotes)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
143 inquotes = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
144 else if(*tmp == '"' && !inquotes)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
145 inquotes = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
146 else if(*tmp == ' ' && !inquotes)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
147 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
148 /* Push past any white space */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
149 while(*(tmp+1) == ' ')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
150 tmp++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
151 /* If we aren't at the end of the command
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
152 * line increment the count.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
153 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
154 if(*(tmp+1))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
155 (*count)++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
156 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
157 tmp++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
158 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
159 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
160
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
161 argv = (char **)malloc(sizeof(char *) * ((*count)+1));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
162 argv[0] = malloc(260);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
163 GetModuleFileName(DWInstance, argv[0], 260);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
164
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
165 argstart = tmp = start;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
166
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
167 if(*start)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
168 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
169 loc = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
170
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
171 while(*tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
172 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
173 if(*tmp == '"' && inquotes)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
174 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
175 *tmp = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
176 inquotes = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
177 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
178 else if(*tmp == '"' && !inquotes)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
179 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
180 argstart = tmp+1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
181 inquotes = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
182 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
183 else if(*tmp == ' ' && !inquotes)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
184 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
185 *tmp = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
186 argv[loc] = strdup(argstart);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
187
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
188 /* Push past any white space */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
189 while(*(tmp+1) == ' ')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
190 tmp++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
191
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
192 /* Move the start pointer */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
193 argstart = tmp+1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
194
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
195 /* If we aren't at the end of the command
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
196 * line increment the count.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
197 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
198 if(*(tmp+1))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
199 loc++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
200 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
201 tmp++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
202 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
203 if(*argstart)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
204 argv[loc] = strdup(argstart);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
205 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
206 argv[loc+1] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
207 return argv;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
208 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
209
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
210 /* Ok this is a really big hack but what the hell ;) */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
211 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
212 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
213 char **argv;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
214 int argc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
215
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
216 DWInstance = hInstance;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
217
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
218 argv = _convertargs(&argc, lpCmdLine);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
219
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
220 return main(argc, argv);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
221 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
222 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
223
45
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
224 /* This should return true for WinNT/2K/XP and false on Win9x */
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
225 int IsWinNT(void)
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
226 {
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
227 static int isnt = -1;
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
228
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
229 if(isnt == -1)
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
230 {
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
231 if (GetVersion() < 0x80000000)
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
232 isnt = 1;
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
233 else
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
234 isnt = 0;
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
235 }
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
236 return isnt;
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
237 }
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
238
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
239 /* This function adds a signal handler callback into the linked list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
240 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
241 void _new_signal(ULONG message, HWND window, void *signalfunction, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
242 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
243 SignalHandler *new = malloc(sizeof(SignalHandler));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
244
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
245 new->message = message;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
246 new->window = window;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
247 new->signalfunction = signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
248 new->data = data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
249 new->next = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
250
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
251 if (!Root)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
252 Root = new;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
253 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
254 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
255 SignalHandler *prev = NULL, *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
256 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
257 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
258 prev = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
259 tmp = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
260 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
261 if(prev)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
262 prev->next = new;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
263 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
264 Root = new;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
265 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
266 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
267
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
268 /* Finds the message number for a given signal name */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
269 ULONG _findsigmessage(char *signame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
270 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
271 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
272
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
273 for(z=0;z<SIGNALMAX;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
274 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
275 if(stricmp(signame, SignalTranslate[z].name) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
276 return SignalTranslate[z].message;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
277 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
278 return 0L;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
279 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
280 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
281
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
282 /* This function removes and handlers on windows and frees
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
283 * the user memory allocated to it.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
284 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
285 BOOL CALLBACK _free_window_memory(HWND handle, LPARAM lParam)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
286 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
287 void *ptr = (void *)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
288
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
289 #ifndef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
290 dw_signal_disconnect_by_window(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
291 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
292
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
293 if(ptr)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
294 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
295 SetWindowLong(handle, GWL_USERDATA, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
296 free(ptr);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
297 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
298 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
299 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
300
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
301 /* This function returns 1 if the window (widget) handle
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
302 * passed to it is a valid window that can gain input focus.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
303 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
304 int _validate_focus(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
305 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
306 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
307
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
308 if(!handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
309 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
310
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
311 if(!IsWindowEnabled(handle))
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
312 return 0;
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
313
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
314 GetClassName(handle, tmpbuf, 99);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
315
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
316 /* These are the window classes which can
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
317 * obtain input focus.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
318 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
319 if(strnicmp(tmpbuf, EDITCLASSNAME, strlen(EDITCLASSNAME))==0 || /* Entryfield */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
320 strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME))==0 || /* Button */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
321 strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0 || /* Combobox */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
322 strnicmp(tmpbuf, LISTBOXCLASSNAME, strlen(LISTBOXCLASSNAME))==0 || /* List box */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
323 strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0 || /* Spinbutton */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
324 strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW))== 0) /* Container */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
325 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
326 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
327 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
328
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
329 HWND _normalize_handle(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
330 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
331 char tmpbuf[100] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
332
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
333 GetClassName(handle, tmpbuf, 99);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
334 if(strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0) /* Spinner */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
335 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
336 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
337
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
338 if(cinfo && cinfo->buddy)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
339 return cinfo->buddy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
340 }
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
341 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) /* Combobox */
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
342 {
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
343 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
344
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
345 if(cinfo && cinfo->buddy)
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
346 return cinfo->buddy;
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
347 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
348 return handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
349 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
350
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
351 int _focus_check_box(Box *box, HWND handle, int start, HWND defaultitem)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
352 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
353 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
354 static HWND lasthwnd, firsthwnd;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
355 static int finish_searching;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
356
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
357 /* Start is 2 when we have cycled completely and
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
358 * need to set the focus to the last widget we found
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
359 * that was valid.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
360 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
361 if(start == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
362 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
363 if(lasthwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
364 SetFocus(lasthwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
365 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
366 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
367
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
368 /* Start is 1 when we are entering the function
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
369 * for the first time, it is zero when entering
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
370 * the function recursively.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
371 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
372 if(start == 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
373 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
374 lasthwnd = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
375 finish_searching = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
376 firsthwnd = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
377 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
378
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
379 for(z=box->count-1;z>-1;z--)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
380 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
381 if(box->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
382 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
383 Box *thisbox = (Box *)GetWindowLong(box->items[z].hwnd, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
384
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
385 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0, defaultitem))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
386 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
387 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
388 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
389 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
390 if(box->items[z].hwnd == handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
391 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
392 if(lasthwnd == handle && firsthwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
393 SetFocus(firsthwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
394 else if(lasthwnd == handle && !firsthwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
395 finish_searching = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
396 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
397 SetFocus(lasthwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
398
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
399 /* If we aren't looking for the last handle,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
400 * return immediately.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
401 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
402 if(!finish_searching)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
403 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
404 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
405 if(_validate_focus(box->items[z].hwnd))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
406 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
407 /* Start is 3 when we are looking for the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
408 * first valid item in the layout.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
409 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
410 if(start == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
411 {
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
412 if(!defaultitem || (defaultitem && box->items[z].hwnd == defaultitem))
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
413 {
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
414 SetFocus(_normalize_handle(box->items[z].hwnd));
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
415 return 1;
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
416 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
417 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
418
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
419 if(!firsthwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
420 firsthwnd = _normalize_handle(box->items[z].hwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
421
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
422 lasthwnd = _normalize_handle(box->items[z].hwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
423 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
424 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
425 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
426 char tmpbuf[100] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
427
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
428 GetClassName(box->items[z].hwnd, tmpbuf, 99);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
429
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
430 if(strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0) /* Notebook */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
431 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
432 NotebookPage **array = (NotebookPage **)GetWindowLong(box->items[z].hwnd, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
433 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
434
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
435 if(pageid > -1 && array && array[pageid])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
436 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
437 Box *notebox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
438
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
439 if(array[pageid]->hwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
440 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
441 notebox = (Box *)GetWindowLong(array[pageid]->hwnd, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
442
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
443 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, defaultitem))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
444 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
445 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
446 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
447 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
448 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
449 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
450 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
451 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
452 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
453
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
454 /* This function finds the first widget in the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
455 * layout and moves the current focus to it.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
456 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
457 void _initial_focus(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
458 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
459 Box *thisbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
460
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
461 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
462 thisbox = (Box *)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
463
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
464 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
465 {
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
466 _focus_check_box(thisbox, handle, 3, thisbox->defaultitem);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
467 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
468 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
469
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
470 /* This function finds the current widget in the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
471 * layout and moves the current focus to the next item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
472 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
473 void _shift_focus(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
474 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
475 Box *thisbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
476
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
477 HWND box, lastbox = GetParent(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
478
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
479 /* Find the toplevel window */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
480 while((box = GetParent(lastbox)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
481 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
482 lastbox = box;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
483 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
484
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
485 thisbox = (Box *)GetWindowLong(lastbox, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
486 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
487 {
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
488 if(_focus_check_box(thisbox, handle, 1, 0) == 0)
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
489 _focus_check_box(thisbox, handle, 2, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
490 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
491 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
492
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
493 /* ResetWindow:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
494 * Resizes window to the exact same size to trigger
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
495 * recalculation of frame.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
496 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
497 void _ResetWindow(HWND hwndFrame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
498 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
499 RECT rcl;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
500
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
501 GetWindowRect(hwndFrame, &rcl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
502 SetWindowPos(hwndFrame, HWND_TOP, 0, 0, rcl.right - rcl.left,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
503 rcl.bottom - rcl.top - 1, SWP_NOMOVE | SWP_NOZORDER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
504 SetWindowPos(hwndFrame, HWND_TOP, 0, 0, rcl.right - rcl.left,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
505 rcl.bottom - rcl.top, SWP_NOMOVE | SWP_NOZORDER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
506 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
507
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
508 /* Function: TrackRectangle
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
509 * Abstract: Tracks given rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
510 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
511 * If rclBounds is NULL, then track rectangle on entire desktop.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
512 * rclTrack is in window coorditates and will be mapped to
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
513 * desktop.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
514 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
515
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
516 BOOL _TrackRectangle(HWND hwndBase, RECTL* rclTrack, RECTL* rclBounds)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
517 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
518 ULONG rc = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
519 #if 0
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
520 TRACKINFO track;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
521
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
522 track.cxBorder = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
523 track.cyBorder = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
524 track.cxGrid = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
525 track.cyGrid = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
526 track.cxKeyboard = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
527 track.cyKeyboard = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
528
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
529 if(!rclTrack)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
530 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
531
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
532 if(rclBounds)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
533 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
534 track.rclBoundary = *rclBounds;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
535 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
536 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
537 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
538 track.rclBoundary.yTop =
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
539 track.rclBoundary.xRight = 3000;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
540 track.rclBoundary.yBottom =
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
541 track.rclBoundary.xLeft = -3000;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
542 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
543
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
544 track.rclTrack = *rclTrack;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
545
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
546 MapWindowPoints(hwndBase,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
547 HWND_DESKTOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
548 (PPOINT)&track.rclTrack,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
549 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
550
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
551 track.ptlMinTrackSize.x = track.rclTrack.xRight
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
552 - track.rclTrack.xLeft;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
553 track.ptlMinTrackSize.y = track.rclTrack.yTop
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
554 - track.rclTrack.yBottom;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
555 track.ptlMaxTrackSize.x = track.rclTrack.xRight
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
556 - track.rclTrack.xLeft;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
557 track.ptlMaxTrackSize.y = track.rclTrack.yTop
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
558 - track.rclTrack.yBottom;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
559
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
560 track.fs = TF_MOVE | TF_ALLINBOUNDARY;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
561
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
562 rc = WinTrackRect(HWND_DESKTOP, 0, &track);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
563
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
564 if(rc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
565 *rclTrack = track.rclTrack;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
566
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
567 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
568 return rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
569 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
570
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
571 /* This function calculates how much space the widgets and boxes require
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
572 * and does expansion as necessary.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
573 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
574 int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
575 int pass, int *usedpadx, int *usedpady)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
576 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
577 int z, currentx = 0, currenty = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
578 int uymax = 0, uxmax = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
579 int upymax = 0, upxmax = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
580 /* Used for the SIZEEXPAND */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
581 int nux = *usedx, nuy = *usedy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
582 int nupx = *usedpadx, nupy = *usedpady;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
583
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
584 (*usedx) += (thisbox->pad * 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
585 (*usedy) += (thisbox->pad * 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
586
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
587 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
588 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
589 if(thisbox->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
590 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
591 int initialx, initialy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
592 Box *tmp = (Box *)GetWindowLong(thisbox->items[z].hwnd, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
593
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
594 initialx = x - (*usedx);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
595 initialy = y - (*usedy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
596
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
597 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
598 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
599 int newx, newy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
600 int nux = *usedx, nuy = *usedy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
601 int upx = *usedpadx + (tmp->pad*2), upy = *usedpady + (tmp->pad*2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
602
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
603 /* On the second pass we know how big the box needs to be and how
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
604 * much space we have, so we can calculate a ratio for the new box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
605 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
606 if(pass == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
607 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
608 int deep = *depth + 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
609
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
610 _resize_box(tmp, &deep, x, y, &nux, &nuy, 1, &upx, &upy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
611
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
612 tmp->upx = upx - *usedpadx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
613 tmp->upy = upy - *usedpady;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
614
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
615 newx = x - nux;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
616 newy = y - nuy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
617
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
618 tmp->width = thisbox->items[z].width = initialx - newx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
619 tmp->height = thisbox->items[z].height = initialy - newy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
620
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
621 tmp->parentxratio = thisbox->xratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
622 tmp->parentyratio = thisbox->yratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
623
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
624 tmp->parentpad = tmp->pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
625
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
626 /* Just in case */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
627 tmp->xratio = thisbox->xratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
628 tmp->yratio = thisbox->yratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
629
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
630 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
631 if(pass > 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
632 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
633 fprintf(f, "FARK! depth %d\r\nwidth = %d, height = %d, nux = %d, nuy = %d, upx = %d, upy = %d xratio = %f, yratio = %f\r\n\r\n",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
634 *depth, thisbox->items[z].width, thisbox->items[z].height, nux, nuy, tmp->upx, tmp->upy, tmp->xratio, tmp->yratio);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
635 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
636 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
637 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
638 if(thisbox->type == BOXVERT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
639 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
640 if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
641 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2))));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
642 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
643 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
644 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
645 if((thisbox->items[z].width-tmp->upx)!=0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
646 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
647 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
648 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
649 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
650 if((thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
651 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2))));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
652 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
653 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
654 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
655 if((thisbox->items[z].height-tmp->upy)!=0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
656 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
657 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
658
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
659 nux = *usedx; nuy = *usedy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
660 upx = *usedpadx + (tmp->pad*2); upy = *usedpady + (tmp->pad*2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
661 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
662
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
663 (*depth)++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
664
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
665 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
666 if(pass > 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
667 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
668 fprintf(f, "Before Resize Box depth %d\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d xratio = %f, yratio = %f\r\n\r\n",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
669 *depth, x, y, *usedx, *usedy, *usedpadx, *usedpady, tmp->xratio, tmp->yratio);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
670 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
671 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
672 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
673
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
674 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
675
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
676 (*depth)--;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
677
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
678 newx = x - nux;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
679 newy = y - nuy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
680
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
681 tmp->minwidth = thisbox->items[z].width = initialx - newx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
682 tmp->minheight = thisbox->items[z].height = initialy - newy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
683
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
684 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
685 if(pass > 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
686 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
687 fprintf(f, "After Resize Box depth %d\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d width = %d, height = %d\r\n\r\n",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
688 *depth, x, y, *usedx, *usedy, *usedpadx, *usedpady, thisbox->items[z].width, thisbox->items[z].height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
689 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
690 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
691 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
692 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
693 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
694
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
695 if(pass > 1 && *depth > 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
696 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
697 if(thisbox->type == BOXVERT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
698 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
699 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
700 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
701
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
702 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
703 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
704 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
705 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy));
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
706
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
707 if(thisbox->items[z].type == TYPEBOX)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
708 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
709 Box *tmp = (Box *)GetWindowLong(thisbox->items[z].hwnd, GWL_USERDATA);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
710
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
711 if(tmp)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
712 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
713 tmp->parentxratio = thisbox->items[z].xratio;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
714 tmp->parentyratio = thisbox->items[z].yratio;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
715 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
716 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
717
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
718 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
719 fprintf(f, "RATIO- xratio = %f, yratio = %f, width = %d, height = %d, pad = %d, box xratio = %f, box yratio = %f, parent xratio = %f, parent yratio = %f, minwidth = %d, minheight = %d, width = %d, height = %d, upx = %d, upy = %d\r\n\r\n",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
720 thisbox->items[z].xratio, thisbox->items[z].yratio, thisbox->items[z].width, thisbox->items[z].height, thisbox->items[z].pad, thisbox->xratio, thisbox->yratio, thisbox->parentxratio, thisbox->parentyratio, thisbox->minwidth, thisbox->minheight, thisbox->width, thisbox->height, thisbox->upx, thisbox->upy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
721 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
722 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
723 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
724 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
725 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
726 thisbox->items[z].xratio = thisbox->xratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
727 thisbox->items[z].yratio = thisbox->yratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
728 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
729
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
730 if(thisbox->type == BOXVERT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
731 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
732 if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
733 uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
734 if(thisbox->items[z].hsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
735 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
736 if(((thisbox->items[z].pad*2) + thisbox->items[z].width) > upxmax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
737 upxmax = (thisbox->items[z].pad*2) + thisbox->items[z].width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
738 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
739 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
740 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
741 if(thisbox->items[z].pad*2 > upxmax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
742 upxmax = thisbox->items[z].pad*2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
743 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
744 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
745 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
746 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
747 if(thisbox->items[z].width == -1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
748 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
749 /* figure out how much space this item requires */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
750 /* thisbox->items[z].width = */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
751 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
752 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
753 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
754 (*usedx) += thisbox->items[z].width + (thisbox->items[z].pad*2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
755 if(thisbox->items[z].hsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
756 (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
757 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
758 (*usedpadx) += thisbox->items[z].pad*2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
759 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
760 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
761 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
762 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
763 if((thisbox->items[z].height + (thisbox->items[z].pad*2)) > uymax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
764 uymax = (thisbox->items[z].height + (thisbox->items[z].pad*2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
765 if(thisbox->items[z].vsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
766 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
767 if(((thisbox->items[z].pad*2) + thisbox->items[z].height) > upymax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
768 upymax = (thisbox->items[z].pad*2) + thisbox->items[z].height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
769 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
770 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
771 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
772 if(thisbox->items[z].pad*2 > upymax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
773 upymax = thisbox->items[z].pad*2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
774 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
775 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
776 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
777 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
778 if(thisbox->items[z].height == -1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
779 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
780 /* figure out how much space this item requires */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
781 /* thisbox->items[z].height = */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
782 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
783 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
784 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
785 (*usedy) += thisbox->items[z].height + (thisbox->items[z].pad*2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
786 if(thisbox->items[z].vsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
787 (*usedpady) += (thisbox->items[z].pad*2) + thisbox->items[z].height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
788 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
789 (*usedpady) += thisbox->items[z].pad*2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
790 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
791 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
792 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
793
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
794 (*usedx) += uxmax;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
795 (*usedy) += uymax;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
796 (*usedpadx) += upxmax;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
797 (*usedpady) += upymax;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
798
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
799 currentx += thisbox->pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
800 currenty += thisbox->pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
801
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
802 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
803 fprintf(f, "Done Calc depth %d\r\nusedx = %d, usedy = %d, usedpadx = %d, usedpady = %d, currentx = %d, currenty = %d, uxmax = %d, uymax = %d\r\n\r\n",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
804 *depth, *usedx, *usedy, *usedpadx, *usedpady, currentx, currenty, uxmax, uymax);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
805 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
806 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
807
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
808 /* The second pass is for expansion and actual placement. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
809 if(pass > 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
810 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
811 /* Any SIZEEXPAND items should be set to uxmax/uymax */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
812 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
813 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
814 if(thisbox->items[z].hsize == SIZEEXPAND && thisbox->type == BOXVERT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
815 thisbox->items[z].width = uxmax-(thisbox->items[z].pad*2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
816 if(thisbox->items[z].vsize == SIZEEXPAND && thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
817 thisbox->items[z].height = uymax-(thisbox->items[z].pad*2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
818 /* Run this code segment again to finalize the sized after setting uxmax/uymax values. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
819 if(thisbox->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
820 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
821 Box *tmp = (Box *)GetWindowLong(thisbox->items[z].hwnd, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
822
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
823 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
824 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
825 if(*depth > 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
826 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
827 if(thisbox->type == BOXVERT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
828 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
829 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/((float)(tmp->minwidth-((thisbox->items[z].pad*2)+(thisbox->pad*2))));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
830 tmp->width = thisbox->items[z].width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
831 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
832 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
833 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
834 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/((float)(tmp->minheight-((thisbox->items[z].pad*2)+(thisbox->pad*2))));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
835 tmp->height = thisbox->items[z].height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
836 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
837 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
838
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
839 (*depth)++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
840
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
841 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
842 fprintf(f, "2- Resize Box depth %d\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d xratio = %f, yratio = %f,\r\nupx = %d, upy = %d, width = %d, height = %d, minwidth = %d, minheight = %d, box xratio = %f, box yratio = %f\r\n\r\n",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
843 *depth, x, y, *usedx, *usedy, *usedpadx, *usedpady, tmp->xratio, tmp->yratio, tmp->upx, tmp->upy, thisbox->items[z].width, thisbox->items[z].height, tmp->minwidth, tmp->minheight, thisbox->xratio, thisbox->yratio);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
844 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
845 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
846
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
847 _resize_box(tmp, depth, x, y, &nux, &nuy, 3, &nupx, &nupy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
848
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
849 (*depth)--;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
850
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
851 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
852 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
853 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
854
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
855 for(z=0;z<(thisbox->count);z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
856 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
857 int height = thisbox->items[z].height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
858 int width = thisbox->items[z].width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
859 int pad = thisbox->items[z].pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
860 HWND handle = thisbox->items[z].hwnd;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
861 int vectorx, vectory;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
862
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
863 /* When upxmax != pad*2 then ratios are incorrect. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
864 vectorx = (int)((width*thisbox->items[z].xratio)-width);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
865 vectory = (int)((height*thisbox->items[z].yratio)-height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
866
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
867 if(width > 0 && height > 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
868 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
869 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
870 /* This is a hack to fix rounding of the sizing */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
871 if(*depth == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
872 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
873 vectorx++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
874 vectory++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
875 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
876
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
877 /* If this item isn't going to expand... reset the vectors to 0 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
878 if(thisbox->items[z].vsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
879 vectory = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
880 if(thisbox->items[z].hsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
881 vectorx = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
882
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
883 GetClassName(handle, tmpbuf, 99);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
884
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
885 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
886 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
887 /* Handle special case Combobox */
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
888 MoveWindow(handle, currentx + pad, currenty + pad,
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
889 width + vectorx, (height + vectory) + 400, TRUE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
890 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
891 else if(strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
892 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
893 /* Handle special case Spinbutton */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
894 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
895
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
896 MoveWindow(handle, currentx + pad + ((width + vectorx) - 20), currenty + pad,
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
897 20, height + vectory, TRUE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
898
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
899 if(cinfo)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
900 {
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
901 MoveWindow(cinfo->buddy, currentx + pad, currenty + pad,
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
902 (width + vectorx) - 20, height + vectory, TRUE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
903 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
904 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
905 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
906 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
907 /* Everything else */
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
908 MoveWindow(handle, currentx + pad, currenty + pad,
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
909 width + vectorx, height + vectory, TRUE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
910 if(thisbox->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
911 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
912 Box *boxinfo = (Box *)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
913
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
914 if(boxinfo && boxinfo->grouphwnd)
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
915 MoveWindow(boxinfo->grouphwnd, 0, 0,
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
916 width + vectorx, height + vectory, TRUE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
917
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
918 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
919 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
920
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
921 /* Notebook dialog requires additional processing */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
922 if(strncmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
923 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
924 RECT rect;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
925 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
926 int pageid = TabCtrl_GetCurSel(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
927
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
928 if(pageid > -1 && array && array[pageid])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
929 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
930 GetClientRect(handle,&rect);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
931 TabCtrl_AdjustRect(handle,FALSE,&rect);
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
932 MoveWindow(array[pageid]->hwnd, rect.left, rect.top,
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
933 rect.right - rect.left, rect.bottom-rect.top, TRUE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
934 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
935 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
936
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
937 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
938 fprintf(f, "Window Pos depth %d\r\ncurrentx = %d, currenty = %d, pad = %d, width = %d, height = %d, vectorx = %d, vectory = %d, Box type = %s\r\n\r\n",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
939 *depth, currentx, currenty, pad, width, height, vectorx, vectory,thisbox->type == BOXHORZ ? "Horizontal" : "Vertical");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
940 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
941 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
942
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
943 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
944 currentx += width + vectorx + (pad * 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
945 if(thisbox->type == BOXVERT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
946 currenty += height + vectory + (pad * 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
947 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
948 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
949 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
950 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
951 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
952
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
953 void _do_resize(Box *thisbox, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
954 {
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
955 if(x != 0 && y != 0)
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
956 {
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
957 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
958 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
959 int usedx = 0, usedy = 0, depth = 0, usedpadx = 0, usedpady = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
960
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
961 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
962
47
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
963 if(usedx-usedpadx == 0 || usedy-usedpady == 0)
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
964 return;
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
965
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
966 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
967 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
968
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
969 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
970 fprintf(f, "WM_SIZE Resize Box Pass 1\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d xratio = %f, yratio = %f\r\n\r\n",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
971 x, y, usedx, usedy, usedpadx, usedpady, thisbox->xratio, thisbox->yratio);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
972 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
973 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
974
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
975 usedpadx = usedpady = usedx = usedy = depth = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
976
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
977 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady);
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
978
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
979 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
980 fprintf(f, "WM_SIZE Resize Box Pass 2\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d\r\n",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
981 x, y, usedx, usedy, usedpadx, usedpady);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
982 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
983 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
984 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
985 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
986 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
987
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
988 /* The main window procedure for Dynamic Windows, all the resizing code is done here. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
989 BOOL CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
990 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
991 int result = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
992 static int command_active = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
993 #ifndef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
994 SignalHandler *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
995 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
996 void (* windowfunc)(PVOID);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
997 ULONG origmsg = msg;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
998
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
999 if(msg == WM_RBUTTONDOWN || msg == WM_MBUTTONDOWN)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1000 msg = WM_LBUTTONDOWN;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1001 if(msg == WM_RBUTTONUP || msg == WM_MBUTTONUP)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1002 msg = WM_LBUTTONUP;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1003
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1004 if(filterfunc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1005 result = filterfunc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1006
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1007 #ifndef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1008 if(result == -1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1009 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1010 /* Avoid infinite recursion */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1011 command_active = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1012
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1013 /* Find any callbacks for this function */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1014 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1015 {
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1016 if(tmp->message == msg || msg == WM_COMMAND || msg == WM_NOTIFY)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1017 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1018 switch(msg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1019 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1020 case WM_SETFOCUS:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1021 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1022 int (*setfocusfunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1023
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1024 if(hWnd == tmp->window)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1025 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1026 result = setfocusfunc(tmp->window, tmp->data);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1027 tmp = NULL;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1028 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1029 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1030 break;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1031 case WM_SIZE:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1032 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1033 int (*sizefunc)(HWND, int, int, void *) = tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1034
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1035 if(hWnd == tmp->window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1036 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1037 result = sizefunc(tmp->window, LOWORD(mp2), HIWORD(mp2), tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1038 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1039 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1040 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1041 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1042 case WM_LBUTTONDOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1043 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1044 POINTS pts = MAKEPOINTS(mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1045 int (*buttonfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1046
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1047 if(hWnd == tmp->window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1048 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1049 int button;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1050
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1051 switch(origmsg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1052 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1053 case WM_LBUTTONDOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1054 button = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1055 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1056 case WM_RBUTTONDOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1057 button = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1058 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1059 case WM_MBUTTONDOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1060 button = 3;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1061 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1062 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1063 result = buttonfunc(tmp->window, pts.x, pts.y, button, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1064 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1065 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1066 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1067 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1068 case WM_LBUTTONUP:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1069 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1070 POINTS pts = MAKEPOINTS(mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1071 int (*buttonfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1072
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1073 if(hWnd == tmp->window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1074 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1075 int button;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1076
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1077 switch(origmsg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1078 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1079 case WM_LBUTTONUP:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1080 button = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1081 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1082 case WM_RBUTTONUP:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1083 button = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1084 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1085 case WM_MBUTTONUP:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1086 button = 3;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1087 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1088 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1089 result = buttonfunc(tmp->window, pts.x, pts.y, button, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1090 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1091 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1092 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1093 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1094 case WM_MOUSEMOVE:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1095 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1096 POINTS pts = MAKEPOINTS(mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1097 int (*motionfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1098
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1099 if(hWnd == tmp->window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1100 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1101 int keys = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1102
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1103 if (mp1 & MK_LBUTTON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1104 keys = DW_BUTTON1_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1105 if (mp1 & MK_RBUTTON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1106 keys |= DW_BUTTON2_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1107 if (mp1 & MK_MBUTTON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1108 keys |= DW_BUTTON3_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1109
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1110 result = motionfunc(tmp->window, pts.x, pts.y, keys, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1111 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1112 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1113 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1114 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1115 case WM_CHAR:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1116 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1117 int (*keypressfunc)(HWND, int, void *) = tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1118
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1119 if(hWnd == tmp->window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1120 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1121 result = keypressfunc(tmp->window, LOWORD(mp2), tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1122 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1123 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1124 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1125 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1126 case WM_CLOSE:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1127 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1128 int (*closefunc)(HWND, void *) = tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1129
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1130 if(hWnd == tmp->window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1131 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1132 result = closefunc(tmp->window, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1133 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1134 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1135 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1136 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1137 case WM_PAINT:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1138 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1139 PAINTSTRUCT ps;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1140 DWExpose exp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1141 int (*exposefunc)(HWND, DWExpose *, void *) = tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1142
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1143 if(hWnd == tmp->window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1144 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1145 BeginPaint(hWnd, &ps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1146 exp.x = ps.rcPaint.left;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1147 exp.y = ps.rcPaint.top;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1148 exp.width = ps.rcPaint.right - ps.rcPaint.left;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1149 exp.height = ps.rcPaint.bottom - ps.rcPaint.top;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1150 result = exposefunc(hWnd, &exp, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1151 EndPaint(hWnd, &ps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1152 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1153 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1154 break;
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1155 case WM_NOTIFY:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1156 {
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1157 if(tmp->message == TVN_SELCHANGED || tmp->message == NM_RCLICK)
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1158 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1159 NMTREEVIEW FAR *tem=(NMTREEVIEW FAR *)mp2;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1160 char tmpbuf[100];
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1161
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1162 GetClassName(tem->hdr.hwndFrom, tmpbuf, 99);
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1163
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1164 if(strnicmp(tmpbuf, WC_TREEVIEW, strlen(WC_TREEVIEW))==0)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1165 {
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1166 if(tem->hdr.code == TVN_SELCHANGED && tmp->message == TVN_SELCHANGED)
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1167 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1168 if(tmp->window == tem->hdr.hwndFrom)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1169 {
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1170 int (*treeselectfunc)(HWND, HWND, char *, void *, void *) = tmp->signalfunction;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1171 TVITEM tvi;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1172 void **ptrs;
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1173
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1174 tvi.mask = TVIF_HANDLE;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1175 tvi.hItem = tem->itemNew.hItem;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1176
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1177 TreeView_GetItem(tmp->window, &tvi);
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1178
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1179 ptrs = (void **)tvi.lParam;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1180 if(ptrs)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1181 result = treeselectfunc(tmp->window, (HWND)tem->itemNew.hItem, (char *)ptrs[0], (void *)ptrs[1], tmp->data);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1182
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1183 tmp = NULL;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1184 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1185 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1186 else if(tem->hdr.code == NM_RCLICK && tmp->message == NM_RCLICK)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1187 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1188 if(tmp->window == tem->hdr.hwndFrom)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1189 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1190 int (*containercontextfunc)(HWND, char *, int, int, void *, void *) = tmp->signalfunction;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1191 HTREEITEM hti;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1192 TVITEM tvi;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1193 TVHITTESTINFO thi;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1194 void **ptrs = NULL;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1195 LONG x, y;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1196
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1197 dw_pointer_query_pos(&x, &y);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1198
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1199 thi.pt.x = x;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1200 thi.pt.y = y;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1201
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1202 MapWindowPoints(HWND_DESKTOP, tmp->window, &thi.pt, 1);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1203
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1204 hti = TreeView_HitTest(tmp->window, &thi);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1205
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1206 if(hti)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1207 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1208 tvi.mask = TVIF_HANDLE;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1209 tvi.hItem = hti;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1210
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1211 TreeView_GetItem(tmp->window, &tvi);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1212 dw_tree_item_select(tmp->window, (HWND)hti);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1213
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1214 ptrs = (void **)tvi.lParam;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1215
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1216 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1217 containercontextfunc(tmp->window, ptrs ? (char *)ptrs[0] : NULL, x, y, tmp->data, ptrs ? ptrs[1] : NULL);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1218 tmp = NULL;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1219 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1220 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1221 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1222 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1223 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1224 break;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1225 case WM_COMMAND:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1226 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1227 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1228 HWND command;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1229 ULONG passthru = (ULONG)LOWORD(mp1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1230 ULONG message = HIWORD(mp1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1231
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1232 command = (HWND)passthru;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1233
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1234 if(message == LBN_SELCHANGE || message == CBN_SELCHANGE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1235 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1236 int (*listboxselectfunc)(HWND, int, void *) = tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1237
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1238 if(tmp->message == LBN_SELCHANGE && tmp->window == (HWND)mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1239 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1240 result = listboxselectfunc(tmp->window, dw_listbox_selected(tmp->window), tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1241 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1242 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1243 } /* Make sure it's the right window, and the right ID */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1244 else if(tmp->window < (HWND)65536 && command == tmp->window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1245 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1246 result = clickfunc(tmp->window, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1247 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1248 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1249 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1250 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1251 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1252 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1253 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1254 tmp = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1255 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1256 command_active = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1257 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1258 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1259
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1260 /* Now that any handlers are done... do normal processing */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1261 switch( msg )
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1262 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1263 case WM_PAINT:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1264 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1265 PAINTSTRUCT ps;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1266
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1267 BeginPaint(hWnd, &ps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1268 EndPaint(hWnd, &ps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1269 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1270 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1271 case WM_SIZE:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1272 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1273 static int lastx = -1, lasty = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1274 static HWND lasthwnd = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1275
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1276 if(lastx != LOWORD(mp2) || lasty != HIWORD(mp2) || lasthwnd != hWnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1277 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1278 Box *mybox = (Box *)GetWindowLong(hWnd, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1279
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1280 if(mybox && mybox->count)
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1281 {
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1282 lastx = LOWORD(mp2);
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1283 lasty = HIWORD(mp2);
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1284 lasthwnd = hWnd;
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1285
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1286 ShowWindow(mybox->items[0].hwnd, SW_HIDE);
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1287 _do_resize(mybox,LOWORD(mp2),HIWORD(mp2));
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1288 ShowWindow(mybox->items[0].hwnd, SW_SHOW);
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1289 return 0;
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1290 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1291 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1292 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1293 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1294 case WM_CHAR:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1295 if(LOWORD(mp1) == '\t')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1296 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1297 _shift_focus(hWnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1298 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1299 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1300 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1301 case WM_USER:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1302 windowfunc = (void *)mp1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1303
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1304 if(windowfunc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1305 windowfunc((void *)mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1306 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1307 case WM_NOTIFY:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1308 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1309 NMHDR FAR *tem=(NMHDR FAR *)mp2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1310
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1311 if(tem->code == TCN_SELCHANGING)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1312 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1313 int num=TabCtrl_GetCurSel(tem->hwndFrom);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1314 NotebookPage **array = (NotebookPage **)GetWindowLong(tem->hwndFrom, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1315
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1316 if(num > -1 && array && array[num])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1317 SetParent(array[num]->hwnd, DW_HWND_OBJECT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1318
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1319 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1320 else if(tem->code == TCN_SELCHANGE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1321 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1322 int num=TabCtrl_GetCurSel(tem->hwndFrom);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1323 NotebookPage **array = (NotebookPage **)GetWindowLong(tem->hwndFrom, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1324
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1325 if(num > -1 && array && array[num])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1326 SetParent(array[num]->hwnd, tem->hwndFrom);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1327
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1328 _resize_notebook_page(tem->hwndFrom, num);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1329 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1330 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1331 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1332 case WM_GETMINMAXINFO:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1333 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1334 MINMAXINFO *info = (MINMAXINFO *)mp2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1335 info->ptMinTrackSize.x = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1336 info->ptMinTrackSize.y = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1337 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1338 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1339 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1340 case WM_DESTROY:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1341 /* Free memory before destroying */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1342 _free_window_memory(hWnd, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1343 EnumChildWindows(hWnd, _free_window_memory, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1344 break;
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1345 case WM_CTLCOLORSTATIC:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1346 case WM_CTLCOLORLISTBOX:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1347 case WM_CTLCOLORBTN:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1348 case WM_CTLCOLOREDIT:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1349 case WM_CTLCOLORMSGBOX:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1350 case WM_CTLCOLORSCROLLBAR:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1351 case WM_CTLCOLORDLG:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1352 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1353 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong((HWND)mp2, GWL_USERDATA);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1354 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
1355 {
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1356 if(thiscinfo->fore > -1 && thiscinfo->back > -1 &&
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1357 thiscinfo->fore < 18 && thiscinfo->back < 18)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
1358 {
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1359 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore],
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1360 _green[thiscinfo->fore],
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
1361 _blue[thiscinfo->fore]));
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1362 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back],
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1363 _green[thiscinfo->back],
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1364 _blue[thiscinfo->back]));
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1365 DeleteObject(thiscinfo->hbrush);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1366 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back],
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1367 _green[thiscinfo->back],
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1368 _blue[thiscinfo->back]));
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1369 SelectObject((HDC)mp1, thiscinfo->hbrush);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1370 return (LONG)thiscinfo->hbrush;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1371 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1372 if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR && (thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1373 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1374 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore),
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1375 DW_GREEN_VALUE(thiscinfo->fore),
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1376 DW_BLUE_VALUE(thiscinfo->fore)));
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1377 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back),
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
1378 DW_GREEN_VALUE(thiscinfo->back),
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
1379 DW_BLUE_VALUE(thiscinfo->back)));
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1380 DeleteObject(thiscinfo->hbrush);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1381 thiscinfo->hbrush = CreateSolidBrush(RGB(DW_RED_VALUE(thiscinfo->back),
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1382 DW_GREEN_VALUE(thiscinfo->back),
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1383 DW_BLUE_VALUE(thiscinfo->back)));
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1384 SelectObject((HDC)mp1, thiscinfo->hbrush);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1385 return (LONG)thiscinfo->hbrush;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
1386 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
1387 }
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1388
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1389 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1390 break;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1391 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
1392 if(result != -1)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1393 return result;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1394 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1395 return DefWindowProc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1396 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1397
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1398 BOOL CALLBACK _framewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1399 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1400 switch( msg )
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1401 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1402 case WM_LBUTTONDOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1403 case WM_MBUTTONDOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1404 case WM_RBUTTONDOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1405 SetActiveWindow(hWnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1406 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1407 case WM_COMMAND:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1408 case WM_NOTIFY:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1409 _wndproc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1410 break;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1411 #if 0
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1412 case WM_ERASEBKGND:
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1413 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1414 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong(hWnd, GWL_USERDATA);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1415
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1416 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1417 return FALSE;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1418 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1419 break;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1420 #endif
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1421 case WM_PAINT:
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1422 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1423 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong(hWnd, GWL_USERDATA);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1424
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1425 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1426 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1427 PAINTSTRUCT ps;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1428 HDC hdcPaint = BeginPaint(hWnd, &ps);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1429 int success = FALSE;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1430
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1431 if(thiscinfo->fore > -1 && thiscinfo->back > -1 &&
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1432 thiscinfo->fore < 18 && thiscinfo->back < 18)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1433 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1434 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore],
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1435 _green[thiscinfo->fore],
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1436 _blue[thiscinfo->fore]));
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1437 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back],
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1438 _green[thiscinfo->back],
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1439 _blue[thiscinfo->back]));
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1440 DeleteObject(thiscinfo->hbrush);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1441 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back],
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1442 _green[thiscinfo->back],
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1443 _blue[thiscinfo->back]));
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1444 SelectObject(hdcPaint, thiscinfo->hbrush);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1445 Rectangle(hdcPaint, ps.rcPaint.left - 1, ps.rcPaint.top - 1, ps.rcPaint.right + 1, ps.rcPaint.bottom + 1);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1446 success = TRUE;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1447 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1448 if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR && (thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1449 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1450 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore),
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1451 DW_GREEN_VALUE(thiscinfo->fore),
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1452 DW_BLUE_VALUE(thiscinfo->fore)));
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1453 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back),
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1454 DW_GREEN_VALUE(thiscinfo->back),
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1455 DW_BLUE_VALUE(thiscinfo->back)));
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1456 DeleteObject(thiscinfo->hbrush);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1457 thiscinfo->hbrush = CreateSolidBrush(RGB(DW_RED_VALUE(thiscinfo->back),
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1458 DW_GREEN_VALUE(thiscinfo->back),
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1459 DW_BLUE_VALUE(thiscinfo->back)));
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1460 SelectObject(hdcPaint, thiscinfo->hbrush);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1461 Rectangle(hdcPaint, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1462 success = TRUE;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1463 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1464
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1465 EndPaint(hWnd, &ps);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1466 if(success)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1467 return FALSE;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1468 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1469
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1470 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1471 break;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1472 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1473 return DefWindowProc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1474 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1475
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1476 BOOL CALLBACK _rendwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1477 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1478 switch( msg )
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1479 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1480 case WM_LBUTTONDOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1481 case WM_MBUTTONDOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1482 case WM_RBUTTONDOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1483 SetActiveWindow(hWnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1484 _wndproc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1485 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1486 case WM_LBUTTONUP:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1487 case WM_MBUTTONUP:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1488 case WM_RBUTTONUP:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1489 case WM_MOUSEMOVE:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1490 case WM_PAINT:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1491 case WM_SIZE:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1492 case WM_COMMAND:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1493 _wndproc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1494 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1495 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1496 return DefWindowProc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1497 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1498
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1499 BOOL CALLBACK _spinnerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1500 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1501 ColorInfo *cinfo;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1502
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1503 cinfo = (ColorInfo *)GetWindowLong(hWnd, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1504
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1505 if(cinfo)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1506 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1507 switch( msg )
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1508 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1509 case WM_LBUTTONDOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1510 case WM_MBUTTONDOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1511 case WM_RBUTTONDOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1512 case WM_CHAR:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1513 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1514 BOOL ret;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1515
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1516 if(!cinfo || !cinfo->pOldProc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1517 ret = DefWindowProc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1518 ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1519
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1520 /* Tell the edit control that a buttonpress has
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1521 * occured and to update it's window title.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1522 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1523 if(cinfo->buddy)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1524 SendMessage(cinfo->buddy, WM_USER+10, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1525
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1526 return ret;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1527 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1528 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1529 case WM_USER+10:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1530 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1531 if(cinfo->buddy)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1532 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1533 char tempbuf[100] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1534 long position;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1535
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1536 GetWindowText(cinfo->buddy, tempbuf, 99);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1537
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1538 position = atol(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1539
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1540 if(IS_WIN98PLUS)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1541 SendMessage(hWnd, UDM_SETPOS32, 0, (LPARAM)position);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1542 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1543 SendMessage(hWnd, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)position, 0));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1544 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1545 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1546 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1547 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1548 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1549
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1550 if(!cinfo || !cinfo->pOldProc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1551 return DefWindowProc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1552 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1553 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1554
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1555 void _click_default(HWND handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1556 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1557 char tmpbuf[100];
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1558
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1559 GetClassName(handle, tmpbuf, 99);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1560
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1561 /* These are the window classes which can
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1562 * obtain input focus.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1563 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1564 if(strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME))==0)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1565 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1566 /* Generate click on default item */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1567 SignalHandler *tmp = Root;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1568
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1569 /* Find any callbacks for this function */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1570 while(tmp)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1571 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1572 if(tmp->message == WM_COMMAND)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1573 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1574 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1575
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1576 /* Make sure it's the right window, and the right ID */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1577 if(tmp->window == handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1578 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1579 clickfunc(tmp->window, tmp->data);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1580 tmp = NULL;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1581 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1582 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1583 if(tmp)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1584 tmp= tmp->next;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1585 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1586 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1587 else
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1588 SetFocus(handle);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1589 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1590
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1591 BOOL CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1592 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1593 ColorInfo *cinfo;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1594 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1595
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1596 cinfo = (ColorInfo *)GetWindowLong(hWnd, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1597
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1598 GetClassName(hWnd, tmpbuf, 99);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1599 if(strcmp(tmpbuf, FRAMECLASSNAME) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1600 cinfo = &(((Box *)cinfo)->cinfo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1601
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1602 if(cinfo)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1603 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1604 switch( msg )
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1605 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1606 case WM_SETFOCUS:
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1607 if(cinfo->combo)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1608 _wndproc(cinfo->combo, msg, mp1, mp2);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1609 else
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1610 _wndproc(hWnd, msg, mp1, mp2);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1611 break;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1612 case WM_CHAR:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1613 if(LOWORD(mp1) == '\t')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1614 {
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
1615 if(cinfo->combo)
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
1616 _shift_focus(cinfo->combo);
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
1617 else if(cinfo->buddy)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1618 _shift_focus(cinfo->buddy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1619 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1620 _shift_focus(hWnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1621 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1622 }
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1623 else if(LOWORD(mp1) == '\r')
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1624 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1625 if(cinfo->clickdefault)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1626 _click_default(cinfo->clickdefault);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1627
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1628 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1629
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1630 /* Tell the spinner control that a keypress has
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1631 * occured and to update it's internal value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1632 */
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
1633 if(cinfo->buddy && !cinfo->combo)
45
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1634 {
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1635 if(IsWinNT())
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1636 PostMessage(cinfo->buddy, WM_USER+10, 0, 0);
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1637 else
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1638 SendMessage(cinfo->buddy, WM_USER+10, 0, 0);
90aa71b3298a Fixed makefile for Windows, and updated to latest source.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1639 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1640 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1641 case WM_USER+10:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1642 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1643 if(cinfo->buddy)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1644 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1645 long val, position;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1646 char tmpbuf[100] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1647
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1648 GetWindowText(cinfo->buddy, tmpbuf, 99);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1649
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1650 position = atol(tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1651
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1652 if(IS_WIN98PLUS)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1653 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS32, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1654 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1655 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1656
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1657 if(val != position)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1658 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1659 sprintf(tmpbuf, "%d", val);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1660 SetWindowText(hWnd, tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1661 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1662 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1663 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1664 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1665 case WM_KEYUP:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1666 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1667 if(mp1 == VK_UP || mp1 == VK_DOWN)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1668 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1669 if(cinfo->buddy)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1670 PostMessage(hWnd, WM_USER+10, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1671 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1672 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1673 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1674 case WM_CTLCOLORSTATIC:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1675 case WM_CTLCOLORLISTBOX:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1676 case WM_CTLCOLORBTN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1677 case WM_CTLCOLOREDIT:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1678 case WM_CTLCOLORMSGBOX:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1679 case WM_CTLCOLORSCROLLBAR:
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
1680 case WM_CTLCOLORDLG:
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1681 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1682 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong((HWND)mp2, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1683 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1684 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1685 if(thiscinfo->fore > -1 && thiscinfo->back > -1 &&
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1686 thiscinfo->fore < 18 && thiscinfo->back < 18)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1687 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1688 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore],
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1689 _green[thiscinfo->fore],
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1690 _blue[thiscinfo->fore]));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1691 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back],
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1692 _green[thiscinfo->back],
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1693 _blue[thiscinfo->back]));
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
1694 DeleteObject(thiscinfo->hbrush);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
1695 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back],
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
1696 _green[thiscinfo->back],
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
1697 _blue[thiscinfo->back]));
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
1698 SelectObject((HDC)mp1, thiscinfo->hbrush);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
1699 return (LONG)thiscinfo->hbrush;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1700 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1701 if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR && (thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1702 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1703 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1704 DW_GREEN_VALUE(thiscinfo->fore),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1705 DW_BLUE_VALUE(thiscinfo->fore)));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1706 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1707 DW_GREEN_VALUE(thiscinfo->back),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1708 DW_BLUE_VALUE(thiscinfo->back)));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1709 DeleteObject(thiscinfo->hbrush);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1710 thiscinfo->hbrush = CreateSolidBrush(RGB(DW_RED_VALUE(thiscinfo->back),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1711 DW_GREEN_VALUE(thiscinfo->back),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1712 DW_BLUE_VALUE(thiscinfo->back)));
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1713 SelectObject((HDC)mp1, thiscinfo->hbrush);
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1714 return (LONG)thiscinfo->hbrush;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1715 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1716 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1717
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1718 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1719 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1720 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1721 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1722
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1723 if(!cinfo || !cinfo->pOldProc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1724 return DefWindowProc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1725 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1726 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1727
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1728 BOOL CALLBACK _containerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1729 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1730 ContainerInfo *cinfo;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1731
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1732 cinfo = (ContainerInfo *)GetWindowLong(hWnd, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1733
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1734 switch( msg )
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1735 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1736 case WM_COMMAND:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1737 case WM_NOTIFY:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1738 _wndproc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1739 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1740 #ifndef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1741 case WM_LBUTTONDBLCLK:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1742 case WM_CHAR:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1743 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1744 LV_ITEM lvi;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1745 int iItem;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1746
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1747 if(LOWORD(mp1) == '\t')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1748 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1749 _shift_focus(hWnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1750 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1751 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1752
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1753 if(msg == WM_CHAR && (char)mp1 != '\r')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1754 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1755
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1756 iItem = ListView_GetNextItem(hWnd, -1, LVNI_FOCUSED);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1757
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1758 if(iItem > -1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1759 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1760 lvi.iItem = iItem;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1761 lvi.mask = LVIF_PARAM;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1762
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1763 ListView_GetItem(hWnd, &lvi);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1764 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1765 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1766 lvi.lParam = (LPARAM)NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1767
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1768 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1769 SignalHandler *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1770
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1771 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1772 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1773 if(tmp->message == NM_DBLCLK && tmp->window == hWnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1774 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1775 int (*containerselectfunc)(HWND, char *, void *) = tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1776
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1777 /* Seems to be having lParam as 1 which really sucks */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1778 if(lvi.lParam < 100)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1779 lvi.lParam = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1780
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1781 containerselectfunc(tmp->window, (char *)lvi.lParam, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1782 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1783 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1784 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1785 tmp = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1786 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1787 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1788 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1789 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1790 case WM_CONTEXTMENU:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1791 {
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1792 SignalHandler *tmp = Root;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1793
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1794 while(tmp)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1795 {
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1796 if(tmp->message == NM_RCLICK && tmp->window == hWnd)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1797 {
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1798 int (*containercontextfunc)(HWND, char *, int, int, void *) = tmp->signalfunction;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1799 LONG x,y;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1800 LV_ITEM lvi;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1801 int iItem;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1802 LVHITTESTINFO lhi;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1803
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1804 dw_pointer_query_pos(&x, &y);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1805
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1806 lhi.pt.x = x;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1807 lhi.pt.y = y;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1808
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1809 MapWindowPoints(HWND_DESKTOP, tmp->window, &lhi.pt, 1);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1810
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1811 iItem = ListView_HitTest(tmp->window, &lhi);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1812
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1813 if(iItem > -1)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1814 {
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1815 lvi.iItem = iItem;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1816 lvi.mask = LVIF_PARAM;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1817
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1818 ListView_GetItem(tmp->window, &lvi);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1819 ListView_SetSelectionMark(tmp->window, iItem);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1820 }
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1821 else
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1822 lvi.lParam = (LPARAM)NULL;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1823
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1824 /* Seems to be having lParam as 1 which really sucks */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1825 if(lvi.lParam < 100)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1826 lvi.lParam = 0;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1827
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1828 containercontextfunc(tmp->window, (char *)lvi.lParam, x, y, tmp->data);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1829 tmp = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1830 }
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1831 if(tmp)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1832 tmp = tmp->next;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1833 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1834 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1835 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1836 #else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1837 case WM_CHAR:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1838 if(LOWORD(mp1) == '\t')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1839 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1840 _shift_focus(hWnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1841 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1842 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1843 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1844 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1845 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1846
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1847 if(!cinfo || !cinfo->pOldProc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1848 return DefWindowProc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1849 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1850 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1851
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1852 void _changebox(Box *thisbox, int percent, int type)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1853 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1854 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1855
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1856 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1857 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1858 if(thisbox->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1859 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1860 Box *tmp = (Box*)GetWindowLong(thisbox->items[z].hwnd, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1861 _changebox(tmp, percent, type);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1862 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1863 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1864 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1865 if(type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1866 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1867 if(thisbox->items[z].hsize == SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1868 thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0)));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1869 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1870 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1871 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1872 if(thisbox->items[z].vsize == SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1873 thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0)));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1874 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1875 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1876 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1877 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1878
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1879 /* This handles any activity on the splitbars (sizers) */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1880 BOOL CALLBACK _splitwndproc(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1881 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1882 HWND hwndFrame = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1883 Box *thisbox = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1884
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1885 hwndFrame = GetParent(hwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1886 if(hwndFrame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1887 thisbox = (Box *)GetWindowLong(hwndFrame, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1888
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1889 switch (msg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1890 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1891 case WM_ACTIVATE:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1892 case WM_SETFOCUS:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1893 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1894
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1895 case WM_PAINT:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1896 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1897 HDC hdcPaint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1898 PAINTSTRUCT ps;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1899 POINT ptlStart[SPLITBAR_WIDTH];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1900 POINT ptlEnd[SPLITBAR_WIDTH];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1901 RECT rcPaint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1902 USHORT i;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1903
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1904 hdcPaint = BeginPaint(hwnd, &ps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1905 GetWindowRect(hwnd, &rcPaint);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1906
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1907 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1908 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1909 for(i = 0; i < SPLITBAR_WIDTH; i++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1910 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1911 ptlStart[i].x = i;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1912 ptlStart[i].y = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1913
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1914 ptlEnd[i].x = i;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1915 ptlEnd[i].y = rcPaint.bottom - rcPaint.top;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1916 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1917 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1918 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1919 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1920 for(i = 0; i < SPLITBAR_WIDTH; i++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1921 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1922 ptlStart[i].x = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1923 ptlStart[i].y = i;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1924
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1925 ptlEnd[i].x = rcPaint.right - rcPaint.left;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1926 ptlEnd[i].y = i;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1927 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1928 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1929
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1930 for(i = 0; i < SPLITBAR_WIDTH; i++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1931 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1932 HPEN hPen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1933 HPEN hOldPen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1934
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1935 hPen = CreatePen(PS_SOLID, 1, RGB (_red[lColor[i]], _green[lColor[i]], _blue[lColor[i]]));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1936 hOldPen = (HPEN)SelectObject(hdcPaint, hPen);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1937 MoveToEx(hdcPaint, ptlStart[i].x, ptlStart[i].y, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1938 LineTo(hdcPaint, ptlEnd[i].x, ptlEnd[i].y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1939 SelectObject(hdcPaint, hOldPen);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1940 DeleteObject(hPen);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1941 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1942 EndPaint(hwnd, &ps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1943 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1944 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1945 case WM_MOUSEMOVE:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1946 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1947 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1948 SetCursor(LoadCursor(NULL, IDC_SIZEWE));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1949 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1950 SetCursor(LoadCursor(NULL, IDC_SIZENS));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1951 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1952 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1953 #if 0
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1954 case WM_BUTTON1DOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1955 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1956 ULONG rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1957 RECTL rclFrame;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1958 RECTL rclBounds;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1959 RECTL rclStart;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1960 USHORT startSize, orig, actual;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1961
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1962 GetWindowRect(hwnd, &rclFrame);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1963 GetWindowRect(hwnd, &rclStart);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1964
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1965 GetWindowRect(hwndFrame, &rclBounds);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1966
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1967 WinMapWindowPoints(hwndFrame, HWND_DESKTOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1968 (PPOINTL)&rclBounds, 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1969 WinMapWindowPoints(hwnd, HWND_DESKTOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1970 (PPOINTL)&rclStart, 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1971
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1972 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1973 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1974 orig = thisbox->items[0].origwidth;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1975 actual = thisbox->items[0].width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1976
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1977 startSize = (rclStart.xLeft - rclBounds.xLeft)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1978 * (((float)orig)/((float)actual));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1979 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1980 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1981 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1982 orig = thisbox->items[0].origheight;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1983 actual = thisbox->items[0].height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1984
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1985 startSize = (rclStart.yBottom - rclBounds.yBottom)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1986 * (((float)actual)/((float)orig));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1987 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1988
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1989 rc = _TrackRectangle(hwnd, &rclFrame, &rclBounds);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1990
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1991 if(rc == TRUE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1992 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1993 USHORT usNewRB;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1994 USHORT usSize;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1995 USHORT percent;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1996 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1997
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1998 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1999 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2000 usNewRB = rclFrame.xLeft
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2001 - rclBounds.xLeft;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2002 usSize = rclBounds.xRight
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2003 - rclBounds.xLeft;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2004 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2005 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2006 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2007 usNewRB = rclFrame.yBottom
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2008 - rclBounds.yBottom;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2009 usSize = rclBounds.yTop
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2010 - rclBounds.yBottom;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2011 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2012
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2013 percent = (usNewRB*100)/startSize;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2014
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2015 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2016 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2017 if(thisbox->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2018 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2019 Box *tmp = (Box *)GetWindowLong(thisbox->items[z].hwnd, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2020 _changebox(tmp, percent, thisbox->type);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2021 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2022 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2023 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2024 if(thisbox->items[z].hwnd == hwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2025 percent = (startSize*100)/usNewRB;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2026
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2027 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2028 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2029 if(thisbox->items[z].hsize == SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2030 thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0)));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2031 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2032 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2033 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2034 if(thisbox->items[z].vsize == SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2035 thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0)));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2036 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2037 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2038 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2039
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2040 _ResetWindow(GetWindow(hwnd, GW_OWNER));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2041 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2042 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2043 return MRFROMSHORT(FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2044 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2045 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2046 return DefWindowProc(hwnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2047 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2048
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2049 /* This handles drawing the status text areas */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2050 BOOL CALLBACK _statuswndproc(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2051 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2052 switch (msg)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2053 {
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2054 case WM_SETTEXT:
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2055 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2056 /* Make sure the control redraws when there is a text change */
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2057 int ret = (int)DefWindowProc(hwnd, msg, mp1, mp2);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2058
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2059 InvalidateRgn(hwnd, NULL, TRUE);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2060 return ret;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2061 }
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2062 case WM_PAINT:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2063 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2064 HDC hdcPaint;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2065 PAINTSTRUCT ps;
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2066 RECT rc;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2067 HFONT hFont;
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2068 HBRUSH oldBrush;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2069 HPEN oldPen;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2070 unsigned long cx, cy;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2071 int threadid = dw_thread_id();
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2072 char tempbuf[1024] = "";
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2073
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2074 if(threadid < 0 || threadid >= THREAD_LIMIT)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2075 threadid = 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2076
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2077 hdcPaint = BeginPaint(hwnd, &ps);
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2078 EndPaint(hwnd, &ps);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2079
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2080 hdcPaint = GetDC(hwnd);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2081
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2082 oldBrush = _hBrush[threadid];
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2083 oldPen = _hPen[threadid];
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2084
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2085 dw_window_get_pos_size(hwnd, NULL, NULL, &cx, &cy);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2086
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2087
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2088 _hBrush[threadid] = CreateSolidBrush(GetSysColor(COLOR_3DFACE));
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2089
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2090 dw_draw_rect(hwnd, 0, TRUE, 0, 0, cx, cy);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2091
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2092 _hPen[threadid] = CreatePen(PS_SOLID, 1, RGB(_red[DW_CLR_DARKGRAY],
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2093 _green[DW_CLR_DARKGRAY],
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2094 _blue[DW_CLR_DARKGRAY]));
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2095
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2096 dw_draw_line(hwnd, 0, 0, 0, cx, 0);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2097 dw_draw_line(hwnd, 0, 0, 0, 0, cy);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2098
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2099 DeleteObject(_hPen[threadid]);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2100
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2101 _hPen[threadid] = GetStockObject(WHITE_PEN);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2102
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2103 dw_draw_line(hwnd, 0, cx - 1, cy - 1, cx - 1, 0);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2104 dw_draw_line(hwnd, 0, cx - 1, cy - 1, 0, cy - 1);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2105
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2106 rc.left = 3;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2107 rc.top = 1;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2108 rc.bottom = cy - 1;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2109 rc.right = cx - 1;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2110
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2111 GetWindowText(hwnd, tempbuf, 1024);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2112
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2113 hFont = (HFONT)SelectObject(hdcPaint, GetStockObject(DEFAULT_GUI_FONT));
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2114
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2115 SetTextColor(hdcPaint, RGB(0,0,0));
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2116 SetBkMode(hdcPaint, TRANSPARENT);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2117
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2118 ExtTextOut(hdcPaint, 3, 1, ETO_CLIPPED, &rc, tempbuf, strlen(tempbuf), NULL);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2119
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2120 SelectObject(hdcPaint, hFont);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2121
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2122 DeleteObject(_hBrush[threadid]);
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2123 _hBrush[threadid] = oldBrush;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2124 _hPen[threadid] = oldPen;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2125 ReleaseDC(hwnd, hdcPaint);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2126 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2127 return FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2128 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2129 return DefWindowProc(hwnd, msg, mp1, mp2);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2130 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2131
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2132 /* Function: _BtProc
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2133 * Abstract: Subclass procedure for buttons
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2134 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2135
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2136 BOOL CALLBACK _BtProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2137 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2138 BubbleButton *bubble;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2139 static int bMouseOver = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2140 POINT point;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2141 RECT rect;
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2142 WNDPROC pOldProc;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2143
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2144 bubble = (BubbleButton *)GetWindowLong(hwnd, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2145
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2146 if(!bubble)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2147 return DefWindowProc(hwnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2148
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2149 /* We must save a pointer to the old
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2150 * window procedure because if a signal
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2151 * handler attached here destroys this
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2152 * window it will then be invalid.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2153 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2154 pOldProc = bubble->pOldProc;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2155
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2156 switch(msg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2157 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2158 #ifndef NO_SIGNALS
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2159 case WM_SETFOCUS:
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2160 _wndproc(hwnd, msg, mp1, mp2);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2161 break;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2162 case WM_LBUTTONUP:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2163 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2164 SignalHandler *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2165
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2166 /* Find any callbacks for this function */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2167 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2168 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2169 if(tmp->message == WM_COMMAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2170 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2171 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2172
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2173 /* Make sure it's the right window, and the right ID */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2174 if(tmp->window == hwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2175 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2176 clickfunc(tmp->window, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2177 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2178 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2179 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2180 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2181 tmp= tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2182 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2183 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2184 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2185 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2186 case WM_CHAR:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2187 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2188 #ifndef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2189 /* A button press should also occur for an ENTER or SPACE press
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2190 * while the button has the active input focus.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2191 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2192 if(LOWORD(mp1) == '\r' || LOWORD(mp1) == ' ')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2193 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2194 SignalHandler *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2195
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2196 /* Find any callbacks for this function */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2197 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2198 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2199 if(tmp->message == WM_COMMAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2200 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2201 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2202
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2203 /* Make sure it's the right window, and the right ID */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2204 if(tmp->window == hwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2205 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2206 clickfunc(tmp->window, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2207 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2208 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2209 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2210 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2211 tmp= tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2212 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2213 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2214 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2215 if(LOWORD(mp1) == '\t')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2216 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2217 _shift_focus(hwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2218 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2219 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2220 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2221 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2222 case WM_TIMER:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2223 if (hwndBubble)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2224 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2225 DestroyWindow(hwndBubble);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2226 hwndBubble = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2227 KillTimer(hwnd, 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2228 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2229 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2230
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2231 case WM_MOUSEMOVE:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2232 GetCursorPos(&point);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2233 GetWindowRect(hwnd, &rect);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2234
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2235 if(PtInRect(&rect, point))
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2236 {
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2237 if(hwnd != GetCapture())
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2238 {
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2239 SetCapture(hwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2240 }
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2241 if(!bMouseOver)
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2242 {
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2243 bMouseOver = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2244 if(!*bubble->bubbletext)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2245 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2246
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2247 if(hwndBubble)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2248 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2249 DestroyWindow(hwndBubble);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2250 hwndBubble = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2251 KillTimer(hwndBubbleLast, 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2252 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2253
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2254 if(!hwndBubble)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2255 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2256 POINTL ptlWork = {0,0};
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2257 ULONG ulColor = DW_CLR_YELLOW;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2258 SIZE size;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2259 HDC hdc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2260 RECT rect;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2261 void *oldproc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2262
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2263 /* Use the WS_EX_TOOLWINDOW extended style
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2264 * so the window doesn't get listed in the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2265 * taskbar.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2266 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2267 hwndBubble = CreateWindowEx(WS_EX_TOOLWINDOW,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2268 STATICCLASSNAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2269 bubble->bubbletext,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2270 BS_TEXT | WS_POPUP |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2271 WS_BORDER |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2272 SS_CENTER,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2273 0,0,50,20,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2274 HWND_DESKTOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2275 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2276 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2277 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2278
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2279 dw_window_set_font(hwndBubble, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2280 dw_window_set_color(hwndBubble, DW_CLR_BLACK, DW_CLR_YELLOW);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2281
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2282 hwndBubbleLast = hwnd;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2283
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2284 SetTimer(hwnd, 1, 3000, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2285
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2286 hdc = GetDC(hwndBubble);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2287
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2288 GetTextExtentPoint(hdc, bubble->bubbletext, strlen(bubble->bubbletext), &size);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2289
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2290 MapWindowPoints(hwnd, HWND_DESKTOP, (LPPOINT)&ptlWork, 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2291
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2292 GetWindowRect(hwnd, &rect);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2293
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2294 SetWindowPos(hwndBubble,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2295 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2296 ptlWork.x,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2297 ptlWork.y + (rect.bottom-rect.top) + 1,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2298 size.cx + 2,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2299 size.cy + 2,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2300 SWP_NOACTIVATE | SWP_SHOWWINDOW);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2301
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2302 ReleaseDC(hwndBubble, hdc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2303 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2304 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2305 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2306 else{
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2307 /* Calling ReleaseCapture in Win95 also causes WM_CAPTURECHANGED
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2308 * to be sent. Be sure to account for that.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2309 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2310 ReleaseCapture();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2311
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2312 if(bMouseOver)
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2313 {
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2314 bMouseOver = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2315 DestroyWindow(hwndBubble);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2316 hwndBubble = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2317 KillTimer(hwndBubbleLast, 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2318 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2319 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2320 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2321 case WM_CAPTURECHANGED:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2322 /* This message means we are losing the capture for some reason
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2323 * Either because we intentionally lost it or another window
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2324 * stole it
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2325 */
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2326 if(bMouseOver)
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2327 {
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2328 bMouseOver = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2329 DestroyWindow(hwndBubble);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2330 hwndBubble = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2331 KillTimer(hwndBubbleLast, 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2332 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2333 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2334 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2335
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2336 if(!pOldProc)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2337 return DefWindowProc(hwnd, msg, mp1, mp2);
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2338 return CallWindowProc(pOldProc, hwnd, msg, mp1, mp2);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2339 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2340
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2341 /* This function recalculates a notebook page for example
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2342 * during switching of notebook pages.
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2343 */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2344 void _resize_notebook_page(HWND handle, int pageid)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2345 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2346 RECT rect;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2347 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2348
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2349 if(array && array[pageid])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2350 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2351 Box *box = (Box *)GetWindowLong(array[pageid]->hwnd, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2352
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2353 GetClientRect(handle,&rect);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2354 TabCtrl_AdjustRect(handle,FALSE,&rect);
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2355 MoveWindow(array[pageid]->hwnd, rect.left, rect.top,
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2356 rect.right - rect.left, rect.bottom-rect.top, TRUE);
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2357 if(box && box->count)
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2358 {
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2359 ShowWindow(box->items[0].hwnd, SW_HIDE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2360 _do_resize(box, rect.right - rect.left, rect.bottom - rect.top);
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2361 ShowWindow(box->items[0].hwnd, SW_SHOW);
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2362 }
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2363
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2364 ShowWindow(array[pageid]->hwnd, SW_SHOWNORMAL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2365 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2366 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2367
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2368 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2369 * Initializes the Dynamic Windows engine.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2370 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2371 * newthread: True if this is the only thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2372 * False if there is already a message loop running.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2373 */
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2374 int dw_init(int newthread, int argc, char *argv[])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2375 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2376 WNDCLASS wc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2377 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2378 INITCOMMONCONTROLSEX icc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2379
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2380 icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2381 icc.dwICC = ICC_WIN95_CLASSES;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2382
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2383 InitCommonControlsEx(&icc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2384
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2385 memset(lookup, 0, sizeof(HICON) * ICON_INDEX_LIMIT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2386
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2387 /* Register the generic Dynamic Windows class */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2388 memset(&wc, 0, sizeof(WNDCLASS));
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2389 wc.style = CS_DBLCLKS;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2390 wc.lpfnWndProc = (WNDPROC)_wndproc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2391 wc.cbClsExtra = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2392 wc.cbWndExtra = 32;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2393 wc.hbrBackground = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2394 wc.lpszMenuName = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2395 wc.lpszClassName = ClassName;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2396
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2397 RegisterClass(&wc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2398
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2399 /* Register the splitbar control */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2400 memset(&wc, 0, sizeof(WNDCLASS));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2401 wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2402 wc.lpfnWndProc = (WNDPROC)_splitwndproc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2403 wc.cbClsExtra = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2404 wc.cbWndExtra = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2405 wc.hbrBackground = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2406 wc.lpszMenuName = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2407 wc.lpszClassName = SplitbarClassName;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2408
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2409 RegisterClass(&wc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2410
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2411 /* Register a frame control like on OS/2 */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2412 memset(&wc, 0, sizeof(WNDCLASS));
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2413 wc.style = CS_DBLCLKS;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2414 wc.lpfnWndProc = (WNDPROC)_framewndproc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2415 wc.cbClsExtra = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2416 wc.cbWndExtra = 32;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2417 wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2418 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2419 wc.lpszMenuName = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2420 wc.lpszClassName = FRAMECLASSNAME;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2421
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2422 RegisterClass(&wc);
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2423
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2424 /* Create a set of brushes using the default OS/2 and DOS colors */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2425 for(z=0;z<18;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2426 _colors[z] = CreateSolidBrush(RGB(_red[z],_green[z],_blue[z]));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2427
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2428 /* Register an Object Windows class like OS/2 and Win2k+
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2429 * so similar functionality can be used on earlier releases
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2430 * of Windows.
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2431 */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2432 memset(&wc, 0, sizeof(WNDCLASS));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2433 wc.style = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2434 wc.lpfnWndProc = (WNDPROC)_wndproc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2435 wc.cbClsExtra = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2436 wc.cbWndExtra = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2437 wc.hbrBackground = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2438 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2439 wc.lpszMenuName = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2440 wc.lpszClassName = ObjectClassName;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2441
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2442 RegisterClass(&wc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2443
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2444 /* Since Windows 95/98/NT don't have a HWND_OBJECT class
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2445 * also known as a input only window, I will create a
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2446 * temporary window that isn't visible and really does nothing
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2447 * except temporarily hold the child windows before they are
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2448 * packed into their correct parent.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2449 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2450
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2451 DW_HWND_OBJECT = CreateWindow(ObjectClassName, "", 0, 0, 0,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2452 0, 0, HWND_DESKTOP, NULL, NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2453
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2454 if(!DW_HWND_OBJECT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2455 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2456 dw_messagebox("Dynamic Windows", "Could not initialize the object window. error code %d", GetLastError());
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2457 exit(1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2458 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2459
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2460 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2461 f = fopen("dw.log", "wt");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2462 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2463 /* We need the version to check capability like up-down controls */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2464 dwVersion = GetVersion();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2465
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2466 for(z=0;z<THREAD_LIMIT;z++)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2467 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2468 _foreground[z] = RGB(128,128,128);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2469 _background[z] = 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2470 _hPen[z] = CreatePen(PS_SOLID, 1, _foreground[z]);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2471 _hBrush[z] = CreateSolidBrush(_foreground[z]);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2472 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2473
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2474 #if 0
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2475 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2476 DWORD dwResult = GetSysColor(COLOR_3DFACE);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2477
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2478 dw_messagebox("DW",
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2479 "Window color: {%x, %x, %x}",
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2480 GetRValue(dwResult),
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2481 GetGValue(dwResult),
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2482 GetBValue(dwResult));
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2483 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2484 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2485 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2486 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2487
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2488 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2489 * Runs a message loop for Dynamic Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2490 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2491 * currenthab: The handle to the current anchor block
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2492 * or NULL if this DW is handling the message loop.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2493 * func: Function pointer to the message filter function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2494 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2495 void dw_main(HAB currenthab, void *func)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2496 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2497 MSG msg;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2498
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2499 /* Setup the filter function */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2500 filterfunc = func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2501
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2502 while (GetMessage(&msg, NULL, 0, 0))
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2503 {
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2504 TranslateMessage(&msg);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2505 DispatchMessage(&msg);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2506 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2507
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2508 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2509 fclose(f);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2510 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2511 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2512
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2513 /*
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2514 * Runs a message loop for Dynamic Windows, for a period of seconds.
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2515 * Parameters:
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2516 * seconds: Number of seconds to run the loop for.
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2517 */
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2518 void dw_main_sleep(int seconds)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2519 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2520 MSG msg;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2521 time_t start = time(NULL);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2522
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2523 while(time(NULL) - start <= seconds)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2524 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2525 if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2526 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2527 GetMessage(&msg, NULL, 0, 0);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2528 TranslateMessage(&msg);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2529 DispatchMessage(&msg);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2530 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2531 else
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2532 Sleep(1);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2533 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2534 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2535
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2536 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2537 * Free's memory allocated by dynamic windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2538 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2539 * ptr: Pointer to dynamic windows allocated
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2540 * memory to be free()'d.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2541 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2542 void dw_free(void *ptr)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2543 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2544 free(ptr);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2545 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2546
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2547 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2548 * Allocates and initializes a dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2549 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2550 * data: User defined data to be passed to functions.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2551 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2552 DWDialog *dw_dialog_new(void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2553 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2554 DWDialog *tmp = malloc(sizeof(DWDialog));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2555
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2556 tmp->eve = dw_event_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2557 dw_event_reset(tmp->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2558 tmp->data = data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2559 tmp->done = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2560 tmp->result = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2561
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2562 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2563 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2564
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2565 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2566 * Accepts a dialog struct and returns the given data to the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2567 * initial called of dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2568 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2569 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2570 * result: Data to be returned by dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2571 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2572 int dw_dialog_dismiss(DWDialog *dialog, void *result)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2573 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2574 dialog->result = result;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2575 dw_event_post(dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2576 dialog->done = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2577 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2578 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2579
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2580 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2581 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2582 * called by a signal handler with the given dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2583 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2584 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2585 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2586 void *dw_dialog_wait(DWDialog *dialog)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2587 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2588 MSG msg;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2589 void *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2590
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2591 while (GetMessage(&msg,NULL,0,0))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2592 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2593 TranslateMessage(&msg);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2594 DispatchMessage(&msg);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2595 if(dialog->done)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2596 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2597 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2598 dw_event_close(&dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2599 tmp = dialog->result;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2600 free(dialog);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2601 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2602 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2603
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2604 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2605 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2606 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2607 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2608 * format: printf style format string.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2609 * ...: Additional variables for use in the format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2610 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2611 int dw_messagebox(char *title, char *format, ...)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2612 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2613 va_list args;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2614 char outbuf[256];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2615
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2616 va_start(args, format);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2617 vsprintf(outbuf, format, args);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2618 va_end(args);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2619
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2620 MessageBox(HWND_DESKTOP, outbuf, title, MB_OK);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2621
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2622 return strlen(outbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2623 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2624
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2625 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2626 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2627 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2628 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2629 * text: The text to display in the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2630 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2631 * True if YES False of NO.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2632 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2633 int dw_yesno(char *title, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2634 {
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2635 if(MessageBox(HWND_DESKTOP, text, title, MB_YESNO) == IDYES)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2636 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2637 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2638 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2639
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2640 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2641 * Minimizes or Iconifies a top-level window.
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2642 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2643 * handle: The window handle to minimize.
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2644 */
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2645 int dw_window_minimize(HWND handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2646 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2647 return ShowWindow(handle, SW_MINIMIZE);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2648 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2649
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2650 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2651 * Makes the window topmost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2652 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2653 * handle: The window handle to make topmost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2654 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2655 int dw_window_raise(HWND handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2656 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2657 return SetWindowPos(handle, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2658 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2659
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2660 /*
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2661 * Makes the window bottommost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2662 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2663 * handle: The window handle to make bottommost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2664 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2665 int dw_window_lower(HWND handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2666 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2667 return SetWindowPos(handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2668 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2669
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2670 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2671 * Makes the window visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2672 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2673 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2674 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2675 int dw_window_show(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2676 {
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
2677 int rc = ShowWindow(handle, SW_SHOW);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2678 SetFocus(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2679 _initial_focus(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2680 return rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2681 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2682
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2683 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2684 * Makes the window invisible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2685 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2686 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2687 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2688 int dw_window_hide(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2689 {
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2690 return ShowWindow(handle, SW_HIDE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2691 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2692
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2693 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2694 * Destroys a window and all of it's children.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2695 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2696 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2697 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2698 int dw_window_destroy(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2699 {
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2700 HWND parent = GetParent(handle);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2701 Box *thisbox = (Box *)GetWindowLong(parent, GWL_USERDATA);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2702
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2703 if(parent != HWND_DESKTOP && thisbox && thisbox->count)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2704 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2705 int z, index = -1;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2706 Item *tmpitem, *thisitem = thisbox->items;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2707
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2708 for(z=0;z<thisbox->count;z++)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2709 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2710 if(thisitem[z].hwnd == handle)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2711 index = z;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2712 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2713
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2714 if(index == -1)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2715 return 0;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2716
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2717 tmpitem = malloc(sizeof(Item)*(thisbox->count-1));
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2718
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2719 /* Copy all but the current entry to the new list */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2720 for(z=0;z<index;z++)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2721 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2722 tmpitem[z] = thisitem[z];
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2723 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2724 for(z=index+1;z<thisbox->count;z++)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2725 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2726 tmpitem[z-1] = thisitem[z];
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2727 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2728
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2729 thisbox->items = tmpitem;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2730 free(thisitem);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2731 thisbox->count--;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2732 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2733 return DestroyWindow(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2734 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2735
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2736 /* Causes entire window to be invalidated and redrawn.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2737 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2738 * handle: Toplevel window handle to be redrawn.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2739 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2740 void dw_window_redraw(HWND handle)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2741 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2742 Box *mybox = (Box *)GetWindowLong(handle, GWL_USERDATA);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2743
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2744 if(mybox)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2745 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2746 RECT rect;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2747
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2748 GetClientRect(handle, &rect);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2749
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2750 ShowWindow(mybox->items[0].hwnd, SW_HIDE);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2751 _do_resize(mybox, rect.right - rect.left, rect.bottom - rect.top);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2752 ShowWindow(mybox->items[0].hwnd, SW_SHOW);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2753 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2754 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2755
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2756 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2757 * Changes a window's parent to newparent.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2758 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2759 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2760 * newparent: The window's new parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2761 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2762 void dw_window_reparent(HWND handle, HWND newparent)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2763 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2764 SetParent(handle, newparent);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2765 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2766
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2767 HFONT _aquire_font(char *fontname)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2768 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2769 HFONT hfont;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2770 int z, size = 9;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2771 LOGFONT lf;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2772
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2773 if(fontname == DefaultFont)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2774 hfont = GetStockObject(DEFAULT_GUI_FONT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2775 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2776 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2777 for(z=0;z<strlen(fontname);z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2778 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2779 if(fontname[z]=='.')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2780 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2781 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2782 size = atoi(fontname) + 5;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2783
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2784 lf.lfHeight = size;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2785 lf.lfWidth = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2786 lf.lfEscapement = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2787 lf.lfOrientation = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2788 lf.lfItalic = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2789 lf.lfUnderline = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2790 lf.lfStrikeOut = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2791 lf.lfWeight = FW_NORMAL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2792 lf.lfCharSet = DEFAULT_CHARSET;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2793 lf.lfOutPrecision = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2794 lf.lfClipPrecision = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2795 lf.lfQuality = DEFAULT_QUALITY;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2796 lf.lfPitchAndFamily = DEFAULT_PITCH | FW_DONTCARE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2797 strcpy(lf.lfFaceName, &fontname[z+1]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2798
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2799 hfont = CreateFontIndirect(&lf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2800 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2801 return hfont;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2802 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2803
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2804 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2805 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2806 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2807 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2808 * fontname: Name and size of the font in the form "size.fontname"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2809 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2810 int dw_window_set_font(HWND handle, char *fontname)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2811 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2812 HFONT hfont = _aquire_font(fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2813 ColorInfo *cinfo;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2814
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2815 cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2816
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2817 if(fontname)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2818 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2819 if(cinfo)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2820 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2821 strcpy(cinfo->fontname, fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2822 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2823 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2824 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2825 cinfo = calloc(1, sizeof(ColorInfo));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2826 cinfo->fore = cinfo->back = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2827 cinfo->buddy = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2828
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2829 strcpy(cinfo->fontname, fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2830
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2831 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2832 SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2833 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2834 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2835 SendMessage(handle, WM_SETFONT, (WPARAM)hfont, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2836 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2837 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2838
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2839 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2840 * Sets the colors used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2841 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2842 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2843 * fore: Foreground color in RGB format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2844 * back: Background color in RGB format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2845 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2846 int dw_window_set_color(HWND handle, ULONG fore, ULONG back)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2847 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2848 ColorInfo *cinfo;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2849 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2850
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2851 cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2852
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2853 GetClassName(handle, tmpbuf, 99);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2854
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2855 if(strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW))==0)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2856 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2857 ListView_SetTextColor(handle, RGB(DW_RED_VALUE(fore),
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2858 DW_GREEN_VALUE(fore),
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2859 DW_BLUE_VALUE(fore)));
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2860 ListView_SetTextBkColor(handle, RGB(DW_RED_VALUE(back),
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2861 DW_GREEN_VALUE(back),
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2862 DW_BLUE_VALUE(back)));
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2863 ListView_SetBkColor(handle, RGB(DW_RED_VALUE(back),
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2864 DW_GREEN_VALUE(back),
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2865 DW_BLUE_VALUE(back)));
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2866 InvalidateRgn(handle, NULL, TRUE);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2867 return TRUE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2868 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2869
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2870 if(cinfo)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2871 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2872 cinfo->fore = fore;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2873 cinfo->back = back;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2874 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2875 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2876 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2877 cinfo = calloc(1, sizeof(ColorInfo));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2878
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2879 cinfo->fore = fore;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2880 cinfo->back = back;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2881 cinfo->buddy = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2882
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2883 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2884 SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2885 }
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2886 InvalidateRgn(handle, NULL, TRUE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2887 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2888 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2889
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2890 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2891 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2892 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2893 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2894 * border: Size of the window border in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2895 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2896 int dw_window_set_border(HWND handle, int border)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2897 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2898 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2899 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2900
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2901 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2902 * Captures the mouse input to this window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2903 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2904 * handle: Handle to receive mouse input.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2905 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2906 void dw_window_capture(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2907 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2908 SetCapture(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2909 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2910
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2911 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2912 * Releases previous mouse capture.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2913 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2914 void dw_window_release(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2915 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2916 ReleaseCapture();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2917 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2918
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2919 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2920 * Changes the appearance of the mouse pointer.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2921 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2922 * handle: Handle to widget for which to change.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2923 * cursortype: ID of the pointer you want.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2924 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2925 void dw_window_pointer(HWND handle, int pointertype)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2926 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2927 SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(pointertype)));
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2928 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2929
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
2930 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2931 * Create a new Window Frame.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2932 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2933 * owner: The Owner's window handle or HWND_DESKTOP.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2934 * title: The Window title.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2935 * flStyle: Style flags, see the DW reference.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2936 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2937 HWND dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2938 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2939 HWND hwndframe;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2940 Box *newbox = malloc(sizeof(Box));
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2941 ULONG flStyleEx = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2942
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2943 newbox->pad = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2944 newbox->type = BOXVERT;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2945 newbox->count = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2946
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2947 if(hwndOwner)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2948 flStyleEx |= WS_EX_MDICHILD;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2949
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2950 if(!(flStyle & WS_CAPTION))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2951 flStyle |= WS_POPUPWINDOW;
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2952
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2953 if(flStyle & DW_FCF_TASKLIST)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2954 {
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2955 ULONG newflags = (flStyle | WS_CLIPCHILDREN) & ~DW_FCF_TASKLIST;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2956
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2957 hwndframe = CreateWindowEx(flStyleEx, ClassName, title, newflags, CW_USEDEFAULT, CW_USEDEFAULT,
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2958 CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, NULL, NULL, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2959 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2960 else
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2961 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2962 flStyleEx |= WS_EX_TOOLWINDOW;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2963
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2964 hwndframe = CreateWindowEx(flStyleEx, ClassName, title, flStyle | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT,
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2965 CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, NULL, NULL, NULL);
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2966 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2967 SetWindowLong(hwndframe, GWL_USERDATA, (ULONG)newbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2968
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2969 #if 0
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2970 if(hwndOwner)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2971 SetParent(hwndframe, hwndOwner);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2972 #endif
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2973
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2974 return hwndframe;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2975 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2976
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2977 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2978 * Create a new Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2979 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2980 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2981 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2982 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2983 HWND dw_box_new(int type, int pad)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2984 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2985 Box *newbox = malloc(sizeof(Box));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2986 HWND hwndframe;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2987
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2988 newbox->pad = pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2989 newbox->type = type;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2990 newbox->count = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2991 newbox->grouphwnd = (HWND)NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2992
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2993 hwndframe = CreateWindow(FRAMECLASSNAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2994 "",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2995 WS_CHILD | WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2996 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2997 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2998 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2999 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3000 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3001
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3002 newbox->cinfo.pOldProc = SubclassWindow(hwndframe, _colorwndproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3003 newbox->cinfo.fore = newbox->cinfo.back = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3004
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3005 SetWindowLong(hwndframe, GWL_USERDATA, (ULONG)newbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3006 return hwndframe;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3007 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3008
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3009 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3010 * Create a new Group Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3011 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3012 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3013 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3014 * title: Text to be displayined in the group outline.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3015 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3016 HWND dw_groupbox_new(int type, int pad, char *title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3017 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3018 Box *newbox = malloc(sizeof(Box));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3019 HWND hwndframe;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3020
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3021 newbox->pad = pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3022 newbox->type = type;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3023 newbox->count = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3024
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3025 hwndframe = CreateWindow(FRAMECLASSNAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3026 "",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3027 WS_CHILD,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3028 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3029 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3030 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3031 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3032 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3033
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3034 newbox->grouphwnd = CreateWindow(BUTTONCLASSNAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3035 title,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3036 WS_CHILD | BS_GROUPBOX |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3037 WS_VISIBLE | WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3038 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3039 hwndframe,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3040 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3041 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3042 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3043
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3044 SetWindowLong(hwndframe, GWL_USERDATA, (ULONG)newbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3045 dw_window_set_font(newbox->grouphwnd, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3046 return hwndframe;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3047 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3048
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3049 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3050 * Create a new MDI Frame to be packed.
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3051 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3052 * id: An ID to be used with dw_window_from_id or 0L.
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3053 */
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3054 HWND dw_mdi_new(unsigned long id)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3055 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3056 CLIENTCREATESTRUCT ccs;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3057 HWND hwndframe;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3058
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3059 ccs.hWindowMenu = NULL;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3060 ccs.idFirstChild = 0;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3061
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3062 hwndframe = CreateWindow("MDICLIENT",
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3063 "",
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3064 WS_CHILD | WS_CLIPSIBLINGS,
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3065 0,0,2000,1000,
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3066 DW_HWND_OBJECT,
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3067 NULL,
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3068 DWInstance,
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3069 &ccs);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3070 return hwndframe;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3071 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3072
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3073 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3074 * Create a bitmap object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3075 * Parameters:
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3076 * id: An ID to be used with dw_window_from_id or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3077 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3078 HWND dw_bitmap_new(ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3079 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3080 return CreateWindow(STATICCLASSNAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3081 "",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3082 SS_BITMAP | WS_CHILD | WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3083 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3084 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3085 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3086 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3087 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3088 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3089
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3090 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3091 * Create a notebook object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3092 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3093 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3094 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3095 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3096 HWND dw_notebook_new(ULONG id, int top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3097 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3098 ULONG flags = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3099 HWND tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3100 NotebookPage **array = calloc(256, sizeof(NotebookPage *));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3101
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3102 if(!top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3103 flags = TCS_BOTTOM;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3104
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3105 tmp = CreateWindow(WC_TABCONTROL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3106 "",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3107 WS_CHILD | WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3108 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3109 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3110 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3111 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3112 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3113 SetWindowLong(tmp, GWL_USERDATA, (ULONG)array);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3114 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3115 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3116 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3117
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3118 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3119 * Create a menu object to be popped up.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3120 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3121 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3122 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3123 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3124 HMENUI dw_menu_new(ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3125 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3126 HMENUI tmp = malloc(sizeof(struct _hmenui));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3127
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3128 if(!tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3129 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3130
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3131 tmp->menu = CreatePopupMenu();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3132 tmp->hwnd = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3133 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3134 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3135
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3136 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3137 * Create a menubar on a window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3138 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3139 * location: Handle of a window frame to be attached to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3140 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3141 HMENUI dw_menubar_new(HWND location)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3142 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3143 HMENUI tmp = malloc(sizeof(struct _hmenui));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3144
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3145 if(!tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3146 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3147
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3148 tmp->menu = CreateMenu();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3149 tmp->hwnd = location;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3150
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3151 SetMenu(location, tmp->menu);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3152 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3153 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3154
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3155 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3156 * Destroys a menu created with dw_menubar_new or dw_menu_new.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3157 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3158 * menu: Handle of a menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3159 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3160 void dw_menu_destroy(HMENUI *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3161 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3162 if(menu && *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3163 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3164 DestroyMenu((*menu)->menu);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3165 free(*menu);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3166 *menu = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3167 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3168 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3169
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3170 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3171 * Adds a menuitem or submenu to an existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3172 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3173 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3174 * title: The title text on the menu item to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3175 * id: An ID to be used for message passing.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3176 * end: If TRUE memu is positioned at the end of the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3177 * check: If TRUE menu is "check"able.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3178 * flags: Extended attributes to set on the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3179 * submenu: Handle to an existing menu to be a submenu or NULL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3180 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3181 HWND dw_menu_append_item(HMENUI menux, char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3182 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3183 MENUITEMINFO mii;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3184 HMENU menu;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3185
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3186 if(!menux)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3187 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3188
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3189 menu = menux->menu;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3190
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3191 mii.cbSize = sizeof(MENUITEMINFO);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3192 mii.fMask = MIIM_ID | MIIM_SUBMENU | MIIM_TYPE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3193
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3194 /* Convert from OS/2 style accellerators to Win32 style */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3195 if(title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3196 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3197 char *tmp = title;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3198
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3199 while(*tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3200 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3201 if(*tmp == '~')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3202 *tmp = '&';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3203 tmp++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3204 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3205 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3206
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3207 if(title && *title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3208 mii.fType = MFT_STRING;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3209 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3210 mii.fType = MFT_SEPARATOR;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3211
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3212 mii.wID = id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3213 mii.hSubMenu = submenu ? submenu->menu : 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3214 mii.dwTypeData = title;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3215 mii.cch = strlen(title);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3216
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3217 InsertMenuItem(menu, 65535, TRUE, &mii);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3218 if(menux->hwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3219 DrawMenuBar(menux->hwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3220 return (HWND)id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3221 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3222
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3223 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3224 * Sets the state of a menu item check.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3225 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3226 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3227 * id: Menuitem id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3228 * check: TRUE for checked FALSE for not checked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3229 */
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3230 void dw_menu_item_set_check(HMENUI menux, unsigned long id, int check)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3231 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3232 MENUITEMINFO mii;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3233 HMENU menu;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3234
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3235 if(!menux)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3236 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3237
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3238 menu = menux->menu;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3239
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3240 mii.cbSize = sizeof(MENUITEMINFO);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3241 mii.fMask = MIIM_STATE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3242 if(check)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3243 mii.fState = MFS_CHECKED;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3244 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3245 mii.fState = MFS_UNCHECKED;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3246 SetMenuItemInfo(menu, id, FALSE, &mii);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3247 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3248
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3249 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3250 * Pops up a context menu at given x and y coordinates.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3251 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3252 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3253 * parent: Handle to the window initiating the popup.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3254 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3255 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3256 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3257 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3258 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3259 if(menu && *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3260 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3261 TrackPopupMenu((*menu)->menu, 0, x, y, 0, parent, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3262 free(*menu);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3263 *menu = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3264 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3265 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3266
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3267
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3268 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3269 * Create a container object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3270 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3271 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3272 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3273 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3274 HWND dw_container_new(ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3275 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3276 HWND tmp = CreateWindow(WC_LISTVIEW,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3277 "",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3278 WS_CHILD | LVS_REPORT |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3279 LVS_SHAREIMAGELISTS | WS_BORDER |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3280 WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3281 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3282 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3283 (HMENU)id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3284 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3285 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3286 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3287
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3288 if(!cinfo)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3289 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3290 DestroyWindow(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3291 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3292 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3293
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3294 cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _containerwndproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3295
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3296 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3297 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3298 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3299 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3300
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3301 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3302 * Create a tree object to be packed.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3303 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3304 * id: An ID to be used for getting the resource from the
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3305 * resource file.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3306 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3307 HWND dw_tree_new(ULONG id)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3308 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3309 HWND tmp = CreateWindow(WC_TREEVIEW,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3310 "",
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3311 WS_CHILD | TVS_HASLINES |
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3312 TVS_HASBUTTONS | TVS_LINESATROOT |
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3313 WS_BORDER | WS_CLIPCHILDREN,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3314 0,0,2000,1000,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3315 DW_HWND_OBJECT,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3316 (HMENU)id,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3317 NULL,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3318 NULL);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3319 TreeView_SetItemHeight(tmp, 16);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3320 dw_window_set_font(tmp, DefaultFont);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3321 return tmp;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3322 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3323
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3324 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3325 * Returns the current X and Y coordinates of the mouse pointer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3326 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3327 * x: Pointer to variable to store X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3328 * y: Pointer to variable to store Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3329 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3330 void dw_pointer_query_pos(long *x, long *y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3331 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3332 POINT ptl;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3333
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3334 GetCursorPos(&ptl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3335 if(x && y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3336 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3337 *x = ptl.x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3338 *y = ptl.y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3339 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3340 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3341
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3342 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3343 * Sets the X and Y coordinates of the mouse pointer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3344 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3345 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3346 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3347 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3348 void dw_pointer_set_pos(long x, long y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3349 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3350 SetCursorPos(x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3351 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3352
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3353 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3354 * Create a new static text window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3355 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3356 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3357 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3358 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3359 HWND dw_text_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3360 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3361 HWND tmp = CreateWindow(STATICCLASSNAME,
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3362 text,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3363 BS_TEXT | WS_CHILD | WS_CLIPCHILDREN,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3364 0,0,2000,1000,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3365 DW_HWND_OBJECT,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3366 (HMENU)id,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3367 NULL,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3368 NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3369 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3370 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3371 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3372
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3373 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3374 * Create a new status text window (widget) to be packed.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3375 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3376 * text: The text to be display by the static text widget.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3377 * id: An ID to be used with WinWindowFromID() or 0L.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3378 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3379 HWND dw_status_text_new(char *text, ULONG id)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3380 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3381 HWND tmp = CreateWindow(STATICCLASSNAME,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3382 text,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3383 BS_TEXT | WS_CHILD | WS_CLIPCHILDREN,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3384 0,0,2000,1000,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3385 DW_HWND_OBJECT,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3386 (HMENU)id,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3387 NULL,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3388 NULL);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3389 dw_window_set_font(tmp, DefaultFont);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3390 SubclassWindow(tmp, _statuswndproc);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3391 return tmp;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3392 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3393
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3394 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3395 * Create a new Multiline Editbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3396 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3397 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3398 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3399 HWND dw_mle_new(ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3400 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3401
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3402 HWND tmp = CreateWindow(EDITCLASSNAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3403 "",
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3404 WS_BORDER |
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3405 WS_VSCROLL | ES_MULTILINE |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3406 ES_WANTRETURN | WS_CHILD |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3407 WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3408 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3409 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3410 (HMENU)id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3411 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3412 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3413 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3414 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3415 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3416
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3417 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3418 * Create a new Entryfield window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3419 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3420 * text: The default text to be in the entryfield widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3421 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3422 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3423 HWND dw_entryfield_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3424 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3425 HWND tmp = CreateWindow(EDITCLASSNAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3426 text,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3427 ES_WANTRETURN | WS_CHILD |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3428 WS_BORDER | ES_AUTOHSCROLL |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3429 WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3430 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3431 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3432 (HMENU)id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3433 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3434 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3435 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3436
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3437 cinfo->back = cinfo->fore = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3438 cinfo->buddy = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3439
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3440 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3441 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3442 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3443 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3444 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3445
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3446 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3447 * Create a new Entryfield passwird window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3448 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3449 * text: The default text to be in the entryfield widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3450 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3451 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3452 HWND dw_entryfield_password_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3453 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3454 HWND tmp = CreateWindow(EDITCLASSNAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3455 text,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3456 ES_WANTRETURN | WS_CHILD |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3457 ES_PASSWORD | WS_BORDER |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3458 ES_AUTOHSCROLL | WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3459 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3460 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3461 (HMENU)id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3462 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3463 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3464 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3465
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3466 cinfo->back = cinfo->fore = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3467 cinfo->buddy = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3468
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3469 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3470 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3471 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3472 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3473 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3474
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
3475 BOOL CALLBACK _subclass_child(HWND handle, LPARAM lp)
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
3476 {
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
3477 ColorInfo *cinfo = (ColorInfo *)lp;
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
3478
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
3479 if(cinfo)
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
3480 {
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
3481 cinfo->buddy = handle;
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
3482 cinfo->pOldProc = (WNDPROC)SubclassWindow(handle, _colorwndproc);
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
3483 SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo);
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
3484 }
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
3485 return FALSE;
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
3486 }
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
3487
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3488 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3489 * Create a new Combobox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3490 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3491 * text: The default text to be in the combpbox widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3492 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3493 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3494 HWND dw_combobox_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3495 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3496 HWND tmp = CreateWindow(COMBOBOXCLASSNAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3497 "",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3498 WS_CHILD | CBS_DROPDOWN | WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3499 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3500 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3501 (HMENU)id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3502 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3503 NULL);
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
3504 ColorInfo *cinfo = (ColorInfo *)calloc(1, sizeof(ColorInfo));
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3505 ColorInfo *cinfo2 = (ColorInfo *)calloc(1, sizeof(ColorInfo));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3506
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3507 if(!cinfo)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3508 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3509 DestroyWindow(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3510 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3511 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3512
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3513 cinfo2->fore = cinfo->fore = -1;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3514 cinfo2->back = cinfo->back = -1;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3515 cinfo2->combo = cinfo->combo = tmp;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3516 EnumChildWindows(tmp, _subclass_child, (LPARAM)cinfo2);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3517
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3518 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3519 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3520 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3521 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3522
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3523 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3524 * Create a new button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3525 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3526 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3527 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3528 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3529 HWND dw_button_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3530 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3531 BubbleButton *bubble = malloc(sizeof(BubbleButton));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3532
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3533 HWND tmp = CreateWindow(BUTTONCLASSNAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3534 text,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3535 WS_CHILD | BS_PUSHBUTTON | WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3536 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3537 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3538 (HMENU)id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3539 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3540 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3541
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3542 bubble->id = id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3543 bubble->bubbletext[0] = '\0';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3544 bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3545
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3546 SetWindowLong(tmp, GWL_USERDATA, (ULONG)bubble);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3547 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3548 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3549 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3550
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3551 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3552 * Create a new bitmap button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3553 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3554 * text: Bubble help text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3555 * id: An ID of a bitmap in the resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3556 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3557 HWND dw_bitmapbutton_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3558 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3559 HWND tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3560 BubbleButton *bubble = malloc(sizeof(BubbleButton));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3561 HBITMAP hbitmap = LoadBitmap(DWInstance, MAKEINTRESOURCE(id));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3562
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3563 tmp = CreateWindow(BUTTONCLASSNAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3564 "",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3565 WS_CHILD | BS_PUSHBUTTON |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3566 BS_BITMAP | WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3567 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3568 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3569 (HMENU)id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3570 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3571 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3572
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3573 bubble->id = id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3574 strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3575 bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3576 bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3577
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3578 SetWindowLong(tmp, GWL_USERDATA, (ULONG)bubble);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3579
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3580 SendMessage(tmp, BM_SETIMAGE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3581 (WPARAM) IMAGE_BITMAP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3582 (LPARAM) hbitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3583 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3584 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3585
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3586 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3587 * Create a new spinbutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3588 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3589 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3590 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3591 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3592 HWND dw_spinbutton_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3593 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3594 ULONG *data = malloc(sizeof(ULONG));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3595 HWND buddy = CreateWindow(EDITCLASSNAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3596 text,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3597 WS_CHILD | WS_BORDER |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3598 ES_NUMBER | WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3599 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3600 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3601 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3602 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3603 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3604 HWND tmp = CreateUpDownControl(
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3605 WS_CHILD | UDS_ALIGNRIGHT |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3606 UDS_ARROWKEYS | UDS_SETBUDDYINT |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3607 UDS_WRAP | UDS_NOTHOUSANDS,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3608 0,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3609 0,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3610 2000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3611 1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3612 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3613 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3614 DWInstance,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3615 buddy,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3616 0,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3617 100,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3618 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3619 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3620
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3621 cinfo->back = cinfo->fore = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3622 cinfo->buddy = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3623
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3624 cinfo->pOldProc = SubclassWindow(buddy, _colorwndproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3625 SetWindowLong(buddy, GWL_USERDATA, (ULONG)cinfo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3626
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3627 cinfo = calloc(1, sizeof(ColorInfo));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3628 cinfo->buddy = buddy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3629 cinfo->pOldProc = SubclassWindow(tmp, _spinnerwndproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3630
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3631 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3632 dw_window_set_font(buddy, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3633 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3634 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3635
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3636 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3637 * Create a new radiobutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3638 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3639 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3640 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3641 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3642 HWND dw_radiobutton_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3643 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3644 HWND tmp = CreateWindow(BUTTONCLASSNAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3645 text,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3646 WS_CHILD | BS_AUTORADIOBUTTON |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3647 WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3648 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3649 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3650 (HMENU)id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3651 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3652 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3653
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3654 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3655
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3656 cinfo->back = cinfo->fore = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3657 cinfo->buddy = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3658 cinfo->user = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3659
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3660 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3661 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3662 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3663 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3664 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3665
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3666
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3667 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
3668 * Create a new percent bar window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3669 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3670 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3671 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
3672 HWND dw_percent_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3673 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3674 return CreateWindow(PROGRESS_CLASS,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3675 "",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3676 WS_CHILD | WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3677 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3678 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3679 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3680 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3681 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3682 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3683
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3684 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3685 * Create a new checkbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3686 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3687 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3688 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3689 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3690 HWND dw_checkbox_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3691 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3692 HWND tmp = CreateWindow(BUTTONCLASSNAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3693 text,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3694 WS_CHILD | BS_AUTOCHECKBOX |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3695 BS_TEXT | WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3696 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3697 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3698 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3699 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3700 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3701 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3702
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3703 cinfo->back = cinfo->fore = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3704 cinfo->buddy = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3705 cinfo->user = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3706
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3707 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3708 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3709 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3710 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3711 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3712
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3713 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3714 * Create a new listbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3715 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3716 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3717 * multi: Multiple select TRUE or FALSE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3718 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3719 HWND dw_listbox_new(ULONG id, int multi)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3720 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3721 HWND tmp = CreateWindow(LISTBOXCLASSNAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3722 "",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3723 LBS_NOINTEGRALHEIGHT | WS_CHILD | LBS_HASSTRINGS |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3724 LBS_NOTIFY | WS_BORDER | WS_CLIPCHILDREN |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3725 WS_VSCROLL | (multi ? LBS_EXTENDEDSEL : 0) ,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3726 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3727 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3728 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3729 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3730 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3731 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3732
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3733 if(!cinfo)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3734 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3735 DestroyWindow(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3736 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3737 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3738
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3739 cinfo->cinfo.fore = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3740 cinfo->cinfo.back = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3741 cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _containerwndproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3742
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3743 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3744 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3745 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3746 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3747
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3748 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3749 * Sets the icon used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3750 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3751 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3752 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3753 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3754 void dw_window_set_icon(HWND handle, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3755 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3756 HICON hicon = LoadIcon(DWInstance, MAKEINTRESOURCE(id));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3757
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3758 SendMessage(handle, WM_SETICON,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3759 (WPARAM) IMAGE_ICON,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3760 (LPARAM) hicon);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3761 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3762
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3763 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3764 * Sets the bitmap used for a given static window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3765 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3766 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3767 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3768 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3769 void dw_window_set_bitmap(HWND handle, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3770 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3771 HBITMAP hbitmap = LoadBitmap(DWInstance, MAKEINTRESOURCE(id));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3772
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3773 SendMessage(handle, STM_SETIMAGE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3774 (WPARAM) IMAGE_BITMAP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3775 (LPARAM) hbitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3776 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3777
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3778 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3779 * Sets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3780 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3781 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3782 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3783 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3784 void dw_window_set_text(HWND handle, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3785 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3786 SetWindowText(handle, text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3787 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3788
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3789 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3790 * Gets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3791 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3792 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3793 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3794 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3795 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3796 char *dw_window_get_text(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3797 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3798 char tempbuf[4096] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3799
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3800 GetWindowText(handle, tempbuf, 4095);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3801 tempbuf[4095] = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3802
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3803 return strdup(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3804 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3805
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3806 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3807 * Disables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3808 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3809 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3810 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3811 void dw_window_disable(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3812 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3813 EnableWindow(handle, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3814 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3815
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3816 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3817 * Enables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3818 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3819 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3820 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3821 void dw_window_enable(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3822 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3823 EnableWindow(handle, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3824 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3825
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3826 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3827 * Gets the child window handle with specified ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3828 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3829 * handle: Handle to the parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3830 * id: Integer ID of the child.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3831 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3832 HWND dw_window_from_id(HWND handle, int id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3833 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3834 return 0L;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3835 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3836 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3837 * Pack windows (widgets) into a box from the start (or top).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3838 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3839 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3840 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3841 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3842 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3843 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3844 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3845 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3846 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3847 void dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3848 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3849 Box *thisbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3850
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3851 thisbox = (Box *)GetWindowLong(box, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3852 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3853 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3854 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3855 Item *tmpitem, *thisitem = thisbox->items;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3856 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3857
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3858 tmpitem = malloc(sizeof(Item)*(thisbox->count+1));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3859
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3860 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3861 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3862 tmpitem[z] = thisitem[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3863 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3864
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3865 GetClassName(item, tmpbuf, 99);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3866
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3867 if(strnicmp(tmpbuf, FRAMECLASSNAME, 2)==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3868 tmpitem[thisbox->count].type = TYPEBOX;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3869 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3870 tmpitem[thisbox->count].type = TYPEITEM;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3871
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3872 tmpitem[thisbox->count].hwnd = item;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3873 tmpitem[thisbox->count].origwidth = tmpitem[thisbox->count].width = width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3874 tmpitem[thisbox->count].origheight = tmpitem[thisbox->count].height = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3875 tmpitem[thisbox->count].pad = pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3876 if(hsize)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3877 tmpitem[thisbox->count].hsize = SIZEEXPAND;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3878 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3879 tmpitem[thisbox->count].hsize = SIZESTATIC;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3880
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3881 if(vsize)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3882 tmpitem[thisbox->count].vsize = SIZEEXPAND;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3883 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3884 tmpitem[thisbox->count].vsize = SIZESTATIC;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3885
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3886 thisbox->items = tmpitem;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3887
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3888 if(thisbox->count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3889 free(thisitem);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3890
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3891 thisbox->count++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3892
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3893 SetParent(item, box);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3894 ShowWindow(item, SW_SHOW);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3895 if(strncmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3896 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3897 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(item, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3898
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3899 if(cinfo)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3900 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3901 SetParent(cinfo->buddy, box);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3902 ShowWindow(cinfo->buddy, SW_SHOW);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3903 SendMessage(item, UDM_SETBUDDY, (WPARAM)cinfo->buddy, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3904 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3905 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3906 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3907 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3908
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3909 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3910 * Sets the size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3911 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3912 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3913 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3914 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3915 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3916 void dw_window_set_usize(HWND handle, ULONG width, ULONG height)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3917 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3918 SetWindowPos(handle, (HWND)NULL, 0, 0, width, height, SWP_SHOWWINDOW | SWP_NOZORDER | SWP_NOMOVE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3919 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3920
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3921 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3922 * Returns the width of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3923 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3924 int dw_screen_width(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3925 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3926 return GetSystemMetrics(SM_CXSCREEN);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3927 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3928
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3929 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3930 * Returns the height of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3931 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3932 int dw_screen_height(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3933 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3934 return GetSystemMetrics(SM_CYSCREEN);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3935 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3936
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3937 /* This should return the current color depth */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3938 unsigned long dw_color_depth(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3939 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3940 int bpp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3941 HDC hdc = GetDC(HWND_DESKTOP);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3942
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3943 bpp = GetDeviceCaps(hdc, BITSPIXEL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3944
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3945 ReleaseDC(HWND_DESKTOP, hdc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3946
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3947 return bpp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3948 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3949
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3950
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3951 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3952 * Sets the position of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3953 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3954 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3955 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3956 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3957 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3958 void dw_window_set_pos(HWND handle, ULONG x, ULONG y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3959 {
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3960 SetWindowPos(handle, (HWND)NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3961 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3962
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3963 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3964 * Sets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3965 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3966 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3967 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3968 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3969 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3970 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3971 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3972 void dw_window_set_pos_size(HWND handle, ULONG x, ULONG y, ULONG width, ULONG height)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3973 {
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3974 SetWindowPos(handle, (HWND)NULL, x, y, width, height, SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3975 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3976
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3977 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3978 * Gets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3979 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3980 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3981 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3982 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3983 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3984 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3985 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3986 void dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3987 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3988 WINDOWPLACEMENT wp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3989
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3990 wp.length = sizeof(WINDOWPLACEMENT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3991
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3992 GetWindowPlacement(handle, &wp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3993 if(x)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3994 *x = wp.rcNormalPosition.left;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3995 if(y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3996 *y = wp.rcNormalPosition.top;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3997 if(width)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3998 *width = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3999 if(height)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4000 *height = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4001
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4002 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4003
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4004 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4005 * Sets the style of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4006 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4007 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4008 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4009 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4010 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4011 void dw_window_set_style(HWND handle, ULONG style, ULONG mask)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4012 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4013 ULONG tmp, currentstyle = GetWindowLong(handle, GWL_STYLE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4014
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4015 tmp = currentstyle | mask;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4016 tmp ^= mask;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4017 tmp |= style;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4018
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4019 SetWindowLong(handle, GWL_STYLE, tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4020 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4021
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4022 /* Finds the physical ID from the reference ID */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4023 int _findnotebookid(NotebookPage **array, int pageid)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4024 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4025 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4026
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4027 for(z=0;z<256;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4028 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4029 if(array[z] && array[z]->realid == pageid)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4030 return z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4031 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4032 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4033 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4034
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4035 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4036 * Adds a new page to specified notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4037 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4038 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4039 * flags: Any additional page creation flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4040 * front: If TRUE page is added at the beginning.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4041 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4042 ULONG dw_notebook_page_new(HWND handle, ULONG flags, int front)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4043 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4044 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4045
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4046 if(array)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4047 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4048 int z, refid = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4049
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4050 for(z=0;z<256;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4051 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4052 if(_findnotebookid(array, z) == -1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4053 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4054 refid = z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4055 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4056 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4057 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4058
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4059 if(refid == -1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4060 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4061
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4062 for(z=0;z<256;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4063 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4064 if(!array[z])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4065 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4066 int oldpage = TabCtrl_GetCurSel(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4067
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4068 array[z] = calloc(1, sizeof(NotebookPage));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4069 array[z]->realid = refid;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4070 array[z]->item.mask = TCIF_TEXT;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4071 array[z]->item.iImage = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4072 array[z]->item.pszText = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4073 TabCtrl_InsertItem(handle, z, &(array[z]->item));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4074
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4075 if(oldpage > -1 && array[oldpage])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4076 SetParent(array[oldpage]->hwnd, DW_HWND_OBJECT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4077
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4078 TabCtrl_SetCurSel(handle, z);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4079 return refid;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4080 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4081 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4082 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4083 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4084 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4085
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4086 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4087 * Sets the text on the specified notebook tab.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4088 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4089 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4090 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4091 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4092 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4093 void dw_notebook_page_set_text(HWND handle, ULONG pageidx, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4094 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4095
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4096 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4097 int pageid;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4098
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4099 if(!array)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4100 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4101
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4102 pageid = _findnotebookid(array, pageidx);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4103
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4104 if(pageid > -1 && array[pageid])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4105 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4106 array[pageid]->item.mask = TCIF_TEXT;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4107 array[pageid]->item.pszText = text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4108 TabCtrl_SetItem(handle, pageid, &(array[pageid]->item));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4109 _resize_notebook_page(handle, pageid);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4110 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4111 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4112
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4113 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4114 * Sets the text on the specified notebook tab status area.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4115 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4116 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4117 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4118 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4119 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4120 void dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4121 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4122 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4123
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4124 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4125 * Packs the specified box into the notebook page.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4126 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4127 * handle: Handle to the notebook to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4128 * pageid: Page ID in the notebook which is being packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4129 * page: Box handle to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4130 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4131 void dw_notebook_pack(HWND handle, ULONG pageidx, HWND page)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4132 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4133 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4134 int pageid;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4135
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4136 if(!array)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4137 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4138
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4139 pageid = _findnotebookid(array, pageidx);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4140
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4141 if(pageid > -1 && array[pageid])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4142 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4143 HWND tmpbox = dw_box_new(BOXVERT, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4144
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4145 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4146 SubclassWindow(tmpbox, _wndproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4147 if(array[pageid]->hwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4148 dw_window_destroy(array[pageid]->hwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4149 array[pageid]->hwnd = tmpbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4150 if(pageidx == dw_notebook_page_query(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4151 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4152 SetParent(tmpbox, handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4153 _resize_notebook_page(handle, pageid);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4154 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4155 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4156 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4157
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4158 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4159 * Remove a page from a notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4160 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4161 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4162 * pageid: ID of the page to be destroyed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4163 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4164 void dw_notebook_page_destroy(HWND handle, unsigned int pageidx)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4165 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4166 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4167 int newid = -1, z, pageid;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4168
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4169 if(!array)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4170 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4171
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4172 pageid = _findnotebookid(array, pageidx);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4173
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4174 if(pageid < 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4175 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4176
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4177 if(array[pageid])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4178 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4179 SetParent(array[pageid]->hwnd, DW_HWND_OBJECT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4180 free(array[pageid]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4181 array[pageid] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4182 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4183
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4184 TabCtrl_DeleteItem(handle, pageid);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4185
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4186 /* Shift the pages over 1 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4187 for(z=pageid;z<255;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4188 array[z] = array[z+1];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4189 array[255] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4190
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4191 for(z=0;z<256;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4192 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4193 if(array[z])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4194 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4195 newid = z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4196 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4197 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4198 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4199 if(newid > -1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4200 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4201 SetParent(array[newid]->hwnd, handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4202 _resize_notebook_page(handle, newid);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4203 dw_notebook_page_set(handle, array[newid]->realid);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4204 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4205 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4206
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4207 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4208 * Queries the currently visible page ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4209 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4210 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4211 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4212 unsigned int dw_notebook_page_query(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4213 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4214 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4215 int physid = TabCtrl_GetCurSel(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4216
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4217 if(physid > -1 && physid < 256 && array && array[physid])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4218 return array[physid]->realid;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4219 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4220 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4221
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4222 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4223 * Sets the currently visible page ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4224 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4225 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4226 * pageid: ID of the page to be made visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4227 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4228 void dw_notebook_page_set(HWND handle, unsigned int pageidx)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4229 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4230 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4231 int pageid;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4232
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4233 if(!array)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4234 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4235
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
4236 pageid = _findnotebookid(array, pageidx);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4237
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4238 if(pageid > -1 && pageid < 256)
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
4239 {
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
4240 int oldpage = TabCtrl_GetCurSel(handle);
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
4241
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
4242 if(oldpage > -1 && array && array[oldpage])
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
4243 SetParent(array[oldpage]->hwnd, DW_HWND_OBJECT);
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
4244
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4245 TabCtrl_SetCurSel(handle, pageid);
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
4246
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
4247 SetParent(array[pageid]->hwnd, handle);
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
4248 _resize_notebook_page(handle, pageid);
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
4249 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4250 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4251
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4252 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4253 * Appends the specified text to the listbox's (or combobox) entry list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4254 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4255 * handle: Handle to the listbox to be appended to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4256 * text: Text to append into listbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4257 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4258 void dw_listbox_append(HWND handle, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4259 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4260 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4261
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4262 GetClassName(handle, tmpbuf, 99);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4263
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4264 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4265 SendMessage(handle,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4266 CB_ADDSTRING,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4267 0, (LPARAM)text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4268 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4269 SendMessage(handle,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4270 LB_ADDSTRING,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4271 0, (LPARAM)text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4272 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4273
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4274 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4275 * Clears the listbox's (or combobox) list of all entries.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4276 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4277 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4278 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4279 void dw_listbox_clear(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4280 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4281 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4282
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4283 GetClassName(handle, tmpbuf, 99);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4284
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4285 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4286 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4287 char *buf = dw_window_get_text(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4288
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4289 SendMessage(handle,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4290 CB_RESETCONTENT, 0L, 0L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4291
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4292 if(buf)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4293 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4294 dw_window_set_text(handle, buf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4295 free(buf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4296 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4297 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4298 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4299 SendMessage(handle,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4300 LB_RESETCONTENT, 0L, 0L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4301 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4302
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4303 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4304 * Sets the text of a given listbox entry.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4305 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4306 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4307 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4308 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4309 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4310 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4311 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4312 unsigned int sel = (unsigned int)SendMessage(handle, LB_GETCURSEL, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4313 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4314 SendMessage(handle, LB_INSERTSTRING, (WPARAM)index, (LPARAM)buffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4315 SendMessage(handle, LB_SETCURSEL, (WPARAM)sel, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4316 SendMessage(handle, LB_SETSEL, (WPARAM)TRUE, (LPARAM)sel);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4317 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4318
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4319 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4320 * Copies the given index item's text into buffer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4321 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4322 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4323 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4324 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4325 * length: Length of the buffer (including NULL).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4326 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4327 void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4328 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4329 SendMessage(handle,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4330 LB_GETTEXT, (WPARAM)index, (LPARAM)buffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4331 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4332
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4333 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4334 * Returns the index to the item in the list currently selected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4335 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4336 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4337 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4338 unsigned int dw_listbox_selected(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4339 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4340 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4341
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4342 GetClassName(handle, tmpbuf, 99);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4343
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4344 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4345 return (unsigned int)SendMessage(handle,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4346 CB_GETCURSEL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4347 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4348
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4349 return (unsigned int)SendMessage(handle,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4350 LB_GETCURSEL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4351 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4352 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4353
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4354 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4355 * Returns the index to the current selected item or -1 when done.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4356 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4357 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4358 * where: Either the previous return or -1 to restart.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4359 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4360 int dw_listbox_selected_multi(HWND handle, int where)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4361 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4362 int *array, count, z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4363
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4364 count = (int)SendMessage(handle, LB_GETSELCOUNT, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4365 if(count > 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4366 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4367 array = malloc(sizeof(int)*count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4368 SendMessage(handle, LB_GETSELITEMS, (WPARAM)count, (LPARAM)array);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4369
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4370 if(where == -1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4371 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4372 int ret = array[0];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4373 free(array);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4374 return ret;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4375 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4376 for(z=0;z<count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4377 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4378 if(array[z] == where && (z+1) < count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4379 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4380 int ret = array[z+1];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4381 free(array);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4382 return ret;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4383 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4384 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4385 free(array);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4386 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4387 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4388 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4389
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4390 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4391 * Sets the selection state of a given index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4392 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4393 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4394 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4395 * state: TRUE if selected FALSE if unselected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4396 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4397 void dw_listbox_select(HWND handle, int index, int state)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4398 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4399 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4400
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4401 GetClassName(handle, tmpbuf, 99);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4402
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4403 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4404 SendMessage(handle, CB_SETCURSEL, (WPARAM)index, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4405 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4406 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4407 SendMessage(handle, LB_SETCURSEL, (WPARAM)index, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4408 SendMessage(handle, LB_SETSEL, (WPARAM)state, (LPARAM)index);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4409 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4410 _wndproc(handle, WM_COMMAND, (WPARAM)(LBN_SELCHANGE << 16), (LPARAM)handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4411 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4412
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4413 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4414 * Deletes the item with given index from the list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4415 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4416 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4417 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4418 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4419 void dw_listbox_delete(HWND handle, int index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4420 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4421 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4422 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4423
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4424 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4425 * Returns the listbox's item count.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4426 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4427 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4428 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4429 int dw_listbox_count(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4430 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4431 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4432
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4433 GetClassName(handle, tmpbuf, 99);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4434
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4435 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4436 return (int)SendMessage(handle,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4437 CB_GETCOUNT,0L, 0L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4438
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4439 return (int)SendMessage(handle,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4440 LB_GETCOUNT,0L, 0L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4441 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4442
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4443 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4444 * Sets the topmost item in the viewport.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4445 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4446 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4447 * top: Index to the top item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4448 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4449 void dw_listbox_set_top(HWND handle, int top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4450 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4451 SendMessage(handle, LB_SETTOPINDEX, (WPARAM)top, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4452 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4453
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4454 #define MLE_MAX 200000
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4455 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4456 * Adds text to an MLE box and returns the current point.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4457 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4458 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4459 * buffer: Text buffer to be imported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4460 * startpoint: Point to start entering text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4461 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4462 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4463 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4464 char *tmpbuf = calloc(1, MLE_MAX+1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4465 int len;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4466
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4467 if(strlen(buffer) < 1)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4468 return startpoint;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4469
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4470 startpoint++;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4471
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4472 if(startpoint < 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4473 startpoint = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4474
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4475 GetWindowText(handle, tmpbuf, MLE_MAX);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4476
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4477 len = strlen(tmpbuf);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4478 if(len)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4479 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4480 char *dest = &tmpbuf[startpoint+strlen(buffer)-1], *start = &tmpbuf[startpoint];
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4481 int copylen = len - startpoint;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4482
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4483 if(copylen > 0)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4484 memcpy(dest, start, copylen);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4485 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4486 memcpy(&tmpbuf[startpoint], buffer, strlen(buffer));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4487
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4488 SetWindowText(handle, tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4489
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4490 free(tmpbuf);
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
4491 return startpoint+strlen(buffer) - 1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4492 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4493
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4494 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4495 * Grabs text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4496 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4497 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4498 * buffer: Text buffer to be exported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4499 * startpoint: Point to start grabbing text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4500 * length: Amount of text to be grabbed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4501 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4502 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4503 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4504 char *tmpbuf = malloc(MLE_MAX+1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4505
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4506 GetWindowText(handle, tmpbuf, MLE_MAX);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4507 tmpbuf[MLE_MAX] = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4508
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4509 memcpy(buffer, &tmpbuf[startpoint], length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4510
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4511 free(tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4512 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4513
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4514 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4515 * Obtains information about an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4516 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4517 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4518 * bytes: A pointer to a variable to return the total bytes.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4519 * lines: A pointer to a variable to return the number of lines.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4520 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4521 void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4522 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4523 char *tmpbuf = malloc(MLE_MAX+1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4524
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4525 GetWindowText(handle, tmpbuf, MLE_MAX);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4526 tmpbuf[MLE_MAX] = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4527
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4528 if(bytes)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4529 *bytes = strlen(tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4530 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4531 *lines = (unsigned long)SendMessage(handle, EM_GETLINECOUNT, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4532
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4533 free(tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4534 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4535
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4536 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4537 * Deletes text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4538 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4539 * handle: Handle to the MLE to be deleted from.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4540 * startpoint: Point to start deleting text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4541 * length: Amount of text to be deleted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4542 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4543 void dw_mle_delete(HWND handle, int startpoint, int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4544 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4545 char *tmpbuf = malloc(MLE_MAX+1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4546 int len;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4547
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4548 GetWindowText(handle, tmpbuf, MLE_MAX);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4549 tmpbuf[MLE_MAX] = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4550
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4551 len = strlen(tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4552
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4553 strcpy(&tmpbuf[startpoint], &tmpbuf[startpoint+length]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4554
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4555 SetWindowText(handle, tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4556
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4557 free(tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4558 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4559
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4560 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4561 * Clears all text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4562 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4563 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4564 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4565 void dw_mle_clear(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4566 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4567 SetWindowText(handle, "");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4568 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4569
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4570 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4571 * Sets the visible line of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4572 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4573 * handle: Handle to the MLE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4574 * line: Line to be visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4575 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4576 void dw_mle_set_visible(HWND handle, int line)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4577 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4578 int point = (int)SendMessage(handle, EM_LINEINDEX, (WPARAM)line, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4579 dw_mle_set(handle, point);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4580 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4581
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4582 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4583 * Sets the editablity of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4584 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4585 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4586 * state: TRUE if it can be edited, FALSE for readonly.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4587 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4588 void dw_mle_set_editable(HWND handle, int state)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4589 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4590 SendMessage(handle, EM_SETREADONLY, (WPARAM)(state ? FALSE : TRUE), 0);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4591 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4592
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4593 /*
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4594 * Sets the word wrap state of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4595 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4596 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4597 * state: TRUE if it wraps, FALSE if it doesn't.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4598 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4599 void dw_mle_set_word_wrap(HWND handle, int state)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4600 {
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4601 /* If ES_AUTOHSCROLL is not set and there is not
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4602 * horizontal scrollbar it word wraps.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4603 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4604 if(state)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4605 dw_window_set_style(handle, 0, ES_AUTOHSCROLL);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4606 else
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4607 dw_window_set_style(handle, ES_AUTOHSCROLL, ES_AUTOHSCROLL);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4608 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4609
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4610 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4611 * Sets the current cursor position of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4612 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4613 * handle: Handle to the MLE to be positioned.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4614 * point: Point to position cursor.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4615 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4616 void dw_mle_set(HWND handle, int point)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4617 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4618 SendMessage(handle, EM_SETSEL, (WPARAM)point, (LPARAM)point);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4619 SendMessage(handle, EM_SCROLLCARET, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4620 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4621
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4622 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4623 * Finds text in an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4624 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4625 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4626 * text: Text to search for.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4627 * point: Start point of search.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4628 * flags: Search specific flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4629 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4630 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4631 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4632 char *tmpbuf = malloc(MLE_MAX+1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4633 int z, len, textlen, retval = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4634
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4635 GetWindowText(handle, tmpbuf, MLE_MAX);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4636 tmpbuf[MLE_MAX] = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4637
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4638 len = strlen(tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4639 textlen = strlen(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4640
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4641 if(flags & DW_MLE_CASESENSITIVE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4642 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4643 for(z=point;z<(len-textlen) && !retval;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4644 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4645 if(strncmp(&tmpbuf[z], text, textlen) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4646 retval = z + textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4647 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4648 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4649 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4650 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4651 for(z=point;z<(len-textlen) && !retval;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4652 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4653 if(strnicmp(&tmpbuf[z], text, textlen) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4654 retval = z + textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4655 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4656 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4657
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4658 if(retval)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4659 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4660 SendMessage(handle, EM_SETSEL, (WPARAM)retval - textlen, (LPARAM)retval);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4661 SendMessage(handle, EM_SCROLLCARET, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4662 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4663
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4664 free(tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4665
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4666 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4667 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4668
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4669 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4670 * Stops redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4671 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4672 * handle: Handle to the MLE to freeze.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4673 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4674 void dw_mle_freeze(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4675 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4676 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4677
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4678 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4679 * Resumes redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4680 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4681 * handle: Handle to the MLE to thaw.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4682 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4683 void dw_mle_thaw(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4684 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4685 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4686
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4687 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
4688 * Returns the range of the percent bar.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4689 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4690 * handle: Handle to the slider to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4691 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
4692 unsigned int dw_percent_query_range(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4693 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4694 return (unsigned int)SendMessage(handle, PBM_GETRANGE, (WPARAM)FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4695 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4696
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4697 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
4698 * Sets the percent bar position.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4699 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4700 * handle: Handle to the slider to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4701 * position: Position of the slider withing the range.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4702 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
4703 void dw_percent_set_pos(HWND handle, unsigned int position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4704 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4705 SendMessage(handle, PBM_SETPOS, (WPARAM)position, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4706 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4707
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4708 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4709 * Sets the spinbutton value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4710 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4711 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4712 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4713 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4714 void dw_spinbutton_set_pos(HWND handle, long position)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4715 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4716 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4717 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4718
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4719 sprintf(tmpbuf, "%d", position);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4720
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4721 if(cinfo && cinfo->buddy)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4722 SetWindowText(cinfo->buddy, tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4723
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4724 if(IS_WIN98PLUS)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4725 SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4726 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4727 SendMessage(handle, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)position, 0));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4728 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4729
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4730 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4731 * Sets the spinbutton limits.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4732 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4733 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4734 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4735 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4736 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4737 void dw_spinbutton_set_limits(HWND handle, long upper, long lower)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4738 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4739 if(IS_WIN98PLUS)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4740 SendMessage(handle, UDM_SETRANGE32, (WPARAM)lower,(LPARAM)upper);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4741 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4742 SendMessage(handle, UDM_SETRANGE32, (WPARAM)((short)lower),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4743 (LPARAM)((short)upper));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4744 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4745
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4746 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4747 * Sets the entryfield character limit.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4748 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4749 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4750 * limit: Number of characters the entryfield will take.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4751 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4752 void dw_entryfield_set_limit(HWND handle, ULONG limit)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4753 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4754 SendMessage(handle, EM_SETLIMITTEXT, (WPARAM)limit, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4755 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4756
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4757 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4758 * Returns the current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4759 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4760 * handle: Handle to the spinbutton to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4761 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4762 long dw_spinbutton_query(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4763 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4764 if(IS_WIN98PLUS)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4765 return (long)SendMessage(handle, UDM_GETPOS32, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4766 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4767 return (long)SendMessage(handle, UDM_GETPOS, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4768 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4769
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4770 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4771 * Returns the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4772 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4773 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4774 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4775 int dw_checkbox_query(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4776 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4777 if(SendMessage(handle, BM_GETCHECK, 0, 0) == BST_CHECKED)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4778 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4779 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4780 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4781
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4782 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4783 * Sets the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4784 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4785 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4786 * value: TRUE for checked, FALSE for unchecked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4787 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4788 void dw_checkbox_set(HWND handle, int value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4789 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4790 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4791
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4792 if(cinfo && !cinfo->user)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4793 SendMessage(handle, BM_CLICK, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4794 SendMessage(handle, BM_SETCHECK, (WPARAM)value, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4795 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4796
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4797 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4798 * Inserts an item into a tree window (widget).
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4799 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4800 * handle: Handle to the tree to be inserted.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4801 * title: The text title of the entry.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4802 * icon: Handle to coresponding icon.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4803 * parent: Parent handle or 0 if root.
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4804 * itemdata: Item specific data.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4805 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4806 HWND dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent, void *itemdata)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4807 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4808 TVITEM tvi;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4809 TVINSERTSTRUCT tvins;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4810 HTREEITEM hti;
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4811 void **ptrs= malloc(sizeof(void *) * 2);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4812
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4813 ptrs[0] = title;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4814 ptrs[1] = itemdata;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4815
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4816 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4817 tvi.pszText = title;
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4818 tvi.lParam = (LONG)ptrs;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4819 tvi.cchTextMax = strlen(title);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4820 tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4821
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4822 tvins.item = tvi;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4823 tvins.hParent = (HTREEITEM)parent;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4824 tvins.hInsertAfter = TVI_LAST;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4825
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4826 hti = TreeView_InsertItem(handle, &tvins);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4827
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4828 return (HWND)hti;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4829 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4830
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
4831 /*
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4832 * Sets the text and icon of an item in a tree window (widget).
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4833 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4834 * handle: Handle to the tree containing the item.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4835 * item: Handle of the item to be modified.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4836 * title: The text title of the entry.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4837 * icon: Handle to coresponding icon.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4838 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4839 void dw_tree_set(HWND handle, HWND item, char *title, unsigned long icon)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4840 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4841 TVITEM tvi;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4842 void **ptrs;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4843
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4844 tvi.mask = TVIF_HANDLE;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4845 tvi.hItem = (HTREEITEM)item;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4846
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4847 TreeView_GetItem(handle, &tvi);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4848
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4849 ptrs = (void **)tvi.lParam;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4850 ptrs[0] = title;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4851
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4852 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4853 tvi.pszText = title;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4854 tvi.cchTextMax = strlen(title);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4855 tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4856 tvi.hItem = (HTREEITEM)item;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4857
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4858 TreeView_SetItem(handle, &tvi);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4859 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4860
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4861 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4862 * Sets the item data of a tree item.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4863 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4864 * handle: Handle to the tree containing the item.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4865 * item: Handle of the item to be modified.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4866 * itemdata: User defined data to be associated with item.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4867 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4868 void dw_tree_set_data(HWND handle, HWND item, void *itemdata)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4869 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4870 TVITEM tvi;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4871 void **ptrs;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4872
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4873 tvi.mask = TVIF_HANDLE;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4874 tvi.hItem = (HTREEITEM)item;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4875
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4876 TreeView_GetItem(handle, &tvi);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4877
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4878 ptrs = (void **)tvi.lParam;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4879 ptrs[1] = itemdata;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4880 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4881
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4882 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4883 * Sets this item as the active selection.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4884 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4885 * handle: Handle to the tree window (widget) to be selected.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4886 * item: Handle to the item to be selected.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4887 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4888 void dw_tree_item_select(HWND handle, HWND item)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4889 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4890 TreeView_SelectItem(handle, (HTREEITEM)item);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4891 SetFocus(handle);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4892 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4893
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4894 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4895 * Removes all nodes from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4896 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4897 * handle: Handle to the window (widget) to be cleared.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4898 */
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4899 void dw_tree_clear(HWND handle)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4900 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4901 TreeView_DeleteAllItems(handle);
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4902 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4903
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4904 /*
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4905 * Expands a node on a tree.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4906 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4907 * handle: Handle to the tree window (widget).
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4908 * item: Handle to node to be expanded.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4909 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4910 void dw_tree_expand(HWND handle, HWND item)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4911 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4912 TreeView_Expand(handle, (HTREEITEM)item, TVE_EXPAND);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4913 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4914
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4915 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4916 * Collapses a node on a tree.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4917 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4918 * handle: Handle to the tree window (widget).
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4919 * item: Handle to node to be collapsed.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4920 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4921 void dw_tree_collapse(HWND handle, HWND item)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4922 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4923 TreeView_Expand(handle, (HTREEITEM)item, TVE_COLLAPSE);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4924 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4925
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4926 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4927 * Removes a node from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4928 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4929 * handle: Handle to the window (widget) to be cleared.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4930 * item: Handle to node to be deleted.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4931 */
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4932 void dw_tree_delete(HWND handle, HWND item)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4933 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4934 TreeView_DeleteItem(handle, (HTREEITEM)item);
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4935 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4936
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4937 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4938 * Sets up the container columns.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4939 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4940 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4941 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4942 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4943 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4944 * separator: The column number that contains the main separator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4945 * (only used on OS/2 but must be >= 0 on all)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4946 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4947 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4948 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4949 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4950 int z, l = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4951 unsigned long *tempflags = malloc(sizeof(unsigned long) * (count + 2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4952 LV_COLUMN lvc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4953
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4954 if(separator == -1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4955 l = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4956
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4957 memcpy(&tempflags[l], flags, sizeof(unsigned long) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4958 tempflags[count + l] = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4959 cinfo->flags = tempflags;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4960
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4961
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4962 for(z=0;z<count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4963 {
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
4964 if(titles[z])
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
4965 {
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
4966 lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM /*| LVCF_FORMAT*/;
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
4967 lvc.pszText = titles[z];
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
4968 lvc.cchTextMax = strlen(titles[z]);
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
4969 lvc.fmt = flags[z];
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
4970 lvc.cx = 75;
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
4971 lvc.iSubItem = count;
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
4972 SendMessage(handle, LVM_INSERTCOLUMN, (WPARAM)z + l, (LPARAM)&lvc);
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
4973 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4974 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4975 ListView_SetExtendedListViewStyle(handle, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4976 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4977 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4978
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4979 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4980 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4981 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4982 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4983 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4984 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4985 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4986 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4987 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4988 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4989 LV_COLUMN lvc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4990
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4991 lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4992 lvc.pszText = "Filename";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4993 lvc.cchTextMax = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4994 lvc.fmt = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4995 if(!count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4996 lvc.cx = 300;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4997 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4998 lvc.cx = 150;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4999 lvc.iSubItem = count;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5000 SendMessage(handle, LVM_INSERTCOLUMN, (WPARAM)0, (LPARAM)&lvc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5001 dw_container_setup(handle, flags, titles, count, -1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5002 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5003 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5004
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5005 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5006 * Obtains an icon from a module (or header in GTK).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5007 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5008 * module: Handle to module (DLL) in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5009 * id: A unsigned long id int the resources on OS/2 and
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5010 * Windows, on GTK this is converted to a pointer
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5011 * to an embedded XPM.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5012 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5013 unsigned long dw_icon_load(unsigned long module, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5014 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5015 return (unsigned long)LoadIcon(DWInstance, MAKEINTRESOURCE(id));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5016 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5017
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5018 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5019 * Frees a loaded resource in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5020 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5021 * handle: Handle to icon returned by dw_icon_load().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5022 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5023 void dw_icon_free(unsigned long handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5024 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5025 DestroyIcon((HICON)handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5026 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5027
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5028 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5029 * Allocates memory used to populate a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5030 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5031 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5032 * rowcount: The number of items to be populated.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5033 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5034 void *dw_container_alloc(HWND handle, int rowcount)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5035 {
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5036 LV_ITEM lvi;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5037 int z;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5038
32
f3bf96c2786d Added missing exports, added new tree functions and signals, fixed Win32
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
5039 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT | LVIF_IMAGE;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5040 lvi.iSubItem = 0;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5041 /* Insert at the end */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5042 lvi.iItem = 1000000;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5043 lvi.pszText = "";
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5044 lvi.cchTextMax = 1;
32
f3bf96c2786d Added missing exports, added new tree functions and signals, fixed Win32
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
5045 lvi.iImage = -1;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5046
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5047 for(z=0;z<rowcount;z++)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5048 ListView_InsertItem(handle, &lvi);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5049 return (void *)handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5050 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5051
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5052 /* Finds a icon in the table, otherwise it adds it to the table
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5053 * and returns the index in the table.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5054 */
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5055 int _lookup_icon(HWND handle, HICON hicon, int type)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5056 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5057 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5058 static HWND lasthwnd = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5059
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5060 if(!hSmall || !hLarge)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5061 {
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
5062 hSmall = ImageList_Create(16, 16, ILC_COLOR16, ICON_INDEX_LIMIT, 0);
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
5063 hLarge = ImageList_Create(32, 32, ILC_COLOR16, ICON_INDEX_LIMIT, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5064 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5065 for(z=0;z<ICON_INDEX_LIMIT;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5066 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5067 if(!lookup[z])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5068 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5069 lookup[z] = hicon;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5070 ImageList_AddIcon(hSmall, hicon);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5071 ImageList_AddIcon(hLarge, hicon);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5072 if(type)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5073 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5074 TreeView_SetImageList(handle, hSmall, TVSIL_NORMAL);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5075 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5076 else
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5077 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5078 ListView_SetImageList(handle, hSmall, LVSIL_SMALL);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5079 ListView_SetImageList(handle, hLarge, LVSIL_NORMAL);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5080 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5081 lasthwnd = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5082 return z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5083 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5084
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5085 if(hicon == lookup[z])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5086 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5087 if(lasthwnd != handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5088 {
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5089 if(type)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5090 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5091 TreeView_SetImageList(handle, hSmall, TVSIL_NORMAL);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5092 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5093 else
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5094 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5095 ListView_SetImageList(handle, hSmall, LVSIL_SMALL);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5096 ListView_SetImageList(handle, hLarge, LVSIL_NORMAL);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5097 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5098 lasthwnd = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5099 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5100 return z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5101 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5102 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5103 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5104 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5105
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5106 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5107 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5108 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5109 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5110 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5111 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5112 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5113 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5114 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5115 void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5116 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5117 LV_ITEM lvi;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5118
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5119 lvi.iItem = row;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5120 lvi.iSubItem = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5121 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE | LVIF_TEXT;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5122 lvi.pszText = filename;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5123 lvi.cchTextMax = strlen(filename);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5124 lvi.iImage = _lookup_icon(handle, (HICON)icon, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5125
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5126 ListView_SetItem(handle, &lvi);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5127 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5128
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5129 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5130 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5131 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5132 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5133 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5134 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5135 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5136 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5137 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5138 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5139 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5140 dw_container_set_item(handle, pointer, column + 1, row, data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5141 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5142
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5143 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5144 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5145 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5146 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5147 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5148 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5149 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5150 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5151 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5152 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5153 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5154 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5155 ULONG *flags;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5156 LV_ITEM lvi;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5157 char textbuffer[100], *destptr = textbuffer;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5158
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5159 if(!cinfo || !cinfo->flags || !data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5160 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5161
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5162 flags = cinfo->flags;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5163
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5164 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5165 lvi.iItem = row;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5166 lvi.iSubItem = column;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5167
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5168 if(flags[column] & DW_CFA_BITMAPORICON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5169 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5170 HICON hicon = *((HICON *)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5171
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5172 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5173 lvi.pszText = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5174 lvi.cchTextMax = 0;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5175
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5176 lvi.iImage = _lookup_icon(handle, hicon, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5177 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5178 else if(flags[column] & DW_CFA_STRING)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5179 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5180 char *tmp = *((char **)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5181
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5182 if(!tmp)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5183 tmp = "";
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5184
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5185 lvi.pszText = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5186 lvi.cchTextMax = strlen(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5187 destptr = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5188 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5189 else if(flags[column] & DW_CFA_ULONG)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5190 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5191 ULONG tmp = *((ULONG *)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5192
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5193 sprintf(textbuffer, "%lu", tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5194
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5195 lvi.pszText = textbuffer;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5196 lvi.cchTextMax = strlen(textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5197 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5198 else if(flags[column] & DW_CFA_DATE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5199 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5200 CDATE fdate = *((CDATE *)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5201
46
30d091bc7899 Fixed an error in the container date code on Windows and Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 45
diff changeset
5202 if(fdate.month > 0)
30d091bc7899 Fixed an error in the container date code on Windows and Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 45
diff changeset
5203 sprintf(textbuffer, "%s %d, %d", monthlist[fdate.month-1], fdate.day, fdate.year);
30d091bc7899 Fixed an error in the container date code on Windows and Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 45
diff changeset
5204 else
30d091bc7899 Fixed an error in the container date code on Windows and Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 45
diff changeset
5205 strcpy(textbuffer, "");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5206 lvi.pszText = textbuffer;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5207 lvi.cchTextMax = strlen(textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5208 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5209 else if(flags[column] & DW_CFA_TIME)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5210 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5211 CTIME ftime = *((CTIME *)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5212
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5213 if(ftime.hours > 12)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5214 sprintf(textbuffer, "%d:%s%dpm", ftime.hours - 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5215 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5216 sprintf(textbuffer, "%d:%s%dam", ftime.hours ? ftime.hours : 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5217 lvi.pszText = textbuffer;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5218 lvi.cchTextMax = strlen(textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5219 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5220
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5221 ListView_SetItem(handle, &lvi);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5222 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5223
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5224 /*
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5225 * Sets the width of a column in the container.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5226 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5227 * handle: Handle to window (widget) of container.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5228 * column: Zero based column of width being set.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5229 * width: Width of column in pixels.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5230 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5231 void dw_container_set_column_width(HWND handle, int column, int width)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5232 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5233 ListView_SetColumnWidth(handle, column, width);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5234 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5235
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5236 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5237 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5238 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5239 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5240 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5241 * title: String title of the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5242 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5243 void dw_container_set_row_title(void *pointer, int row, char *title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5244 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5245 LV_ITEM lvi;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5246 HWND container = (HWND)pointer;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5247
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5248 lvi.iItem = row;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5249 lvi.iSubItem = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5250 lvi.mask = LVIF_PARAM;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5251 lvi.lParam = (LPARAM)title;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5252
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5253 if(!ListView_SetItem(container, &lvi) && lvi.lParam)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5254 lvi.lParam = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5255
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5256 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5257
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5258 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5259 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5260 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5261 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5262 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5263 * rowcount: The number of rows to be inserted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5264 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5265 void dw_container_insert(HWND handle, void *pointer, int rowcount)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5266 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5267 /* This isn't a separate step in windows. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5268 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5269
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5270 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5271 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5272 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5273 * handle: Handle to the window (widget) to be cleared.
52
0804483f6320 Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 49
diff changeset
5274 * redraw: TRUE to cause the container to redraw immediately.
0804483f6320 Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 49
diff changeset
5275 */
0804483f6320 Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 49
diff changeset
5276 void dw_container_clear(HWND handle, int redraw)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5277 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5278 ListView_DeleteAllItems(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5279 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5280
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5281 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5282 * Removes the first x rows from a container.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5283 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5284 * handle: Handle to the window (widget) to be deleted from.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5285 * rowcount: The number of rows to be deleted.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5286 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5287 void dw_container_delete(HWND handle, int rowcount)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5288 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5289 int z;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5290
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5291 for(z=0;z<rowcount;z++)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5292 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5293 ListView_DeleteItem(handle, 0);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5294 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5295 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5296
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5297 /*
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5298 * Scrolls container up or down.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5299 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5300 * handle: Handle to the window (widget) to be scrolled.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5301 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5302 * DW_SCROLL_BOTTOM. (rows is ignored for last two)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5303 * rows: The number of rows to be scrolled.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5304 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5305 void dw_container_scroll(HWND handle, int direction, long rows)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5306 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5307 switch(direction)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5308 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5309 case DW_SCROLL_TOP:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5310 ListView_Scroll(handle, 0, -10000000);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5311 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5312 case DW_SCROLL_BOTTOM:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5313 ListView_Scroll(handle, 0, 10000000);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5314 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5315 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5316 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5317
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5318 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5319 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5320 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5321 * handle: Handle to the window (widget) to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5322 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5323 void dw_container_set_view(HWND handle, unsigned long flags, int iconwidth, int iconheight)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5324 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5325 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5326
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5327 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5328 * Starts a new query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5329 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5330 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5331 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5332 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5333 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5334 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5335 char *dw_container_query_start(HWND handle, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5336 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5337 LV_ITEM lvi;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5338
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5339 if(flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5340 _index = ListView_GetNextItem(handle, -1, LVNI_SELECTED);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5341 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5342 _index = ListView_GetNextItem(handle, -1, LVNI_ALL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5343
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5344
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5345 lvi.iItem = _index;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5346 lvi.mask = LVIF_PARAM;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5347
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5348 ListView_GetItem(handle, &lvi);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5349
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5350 return (char *)lvi.lParam;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5351 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5352
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5353 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5354 * Continues an existing query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5355 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5356 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5357 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5358 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5359 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5360 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5361 char *dw_container_query_next(HWND handle, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5362 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5363 LV_ITEM lvi;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5364
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5365 if(flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5366 _index = ListView_GetNextItem(handle, _index, LVNI_SELECTED);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5367 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5368 _index = ListView_GetNextItem(handle, _index, LVNI_ALL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5369
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5370 if(_index == -1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5371 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5372
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5373 lvi.iItem = _index;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5374 lvi.mask = LVIF_PARAM;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5375
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5376 ListView_GetItem(handle, &lvi);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5377
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5378 return (char *)lvi.lParam;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5379 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5380
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5381 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5382 * Creates a rendering context widget (window) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5383 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5384 * id: An id to be used with dw_window_from_id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5385 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5386 * A handle to the widget or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5387 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5388 HWND dw_render_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5389 {
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
5390 Box *newbox = malloc(sizeof(Box));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5391 HWND tmp = CreateWindow(ObjectClassName,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5392 "",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5393 WS_CHILD | WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5394 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5395 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5396 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5397 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5398 NULL);
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
5399 newbox->pad = 0;
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
5400 newbox->type = 0;
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
5401 newbox->count = 0;
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
5402 newbox->grouphwnd = (HWND)NULL;
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
5403 newbox->cinfo.pOldProc = SubclassWindow(tmp, _rendwndproc);
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
5404 newbox->cinfo.fore = newbox->cinfo.back = -1;
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
5405
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
5406 SetWindowLong(tmp, GWL_USERDATA, (ULONG)newbox);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5407 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5408 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5409
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5410 /* Sets the current foreground drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5411 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5412 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5413 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5414 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5415 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5416 void dw_color_foreground_set(unsigned long value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5417 {
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5418 int threadid = dw_thread_id();
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5419
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5420 if(threadid < 0 || threadid >= THREAD_LIMIT)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5421 threadid = 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5422
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5423 DeleteObject(_hPen[threadid]);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5424 DeleteObject(_hBrush[threadid]);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5425 _foreground[threadid] = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value));
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5426 _hPen[threadid] = CreatePen(PS_SOLID, 1, _foreground[threadid]);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5427 _hBrush[threadid] = CreateSolidBrush(_foreground[threadid]);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5428 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5429
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5430 /* Sets the current background drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5431 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5432 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5433 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5434 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5435 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5436 void dw_color_background_set(unsigned long value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5437 {
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5438 int threadid = dw_thread_id();
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5439
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5440 if(threadid < 0 || threadid >= THREAD_LIMIT)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5441 threadid = 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5442
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5443 _background[threadid] = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5444 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5445
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5446 /* Draw a point on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5447 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5448 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5449 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5450 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5451 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5452 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5453 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5454 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5455 HDC hdcPaint;
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5456 int threadid = dw_thread_id();
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5457
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5458 if(threadid < 0 || threadid >= THREAD_LIMIT)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5459 threadid = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5460
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5461 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5462 hdcPaint = GetDC(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5463 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5464 hdcPaint = pixmap->hdc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5465 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5466 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5467
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5468 SetPixel(hdcPaint, x, y, _foreground[threadid]);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5469 if(!pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5470 ReleaseDC(handle, hdcPaint);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5471 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5472
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5473 /* Draw a line on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5474 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5475 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5476 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5477 * x1: First X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5478 * y1: First Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5479 * x2: Second X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5480 * y2: Second Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5481 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5482 void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5483 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5484 HDC hdcPaint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5485 HPEN oldPen;
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5486 int threadid = dw_thread_id();
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5487
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5488 if(threadid < 0 || threadid >= THREAD_LIMIT)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5489 threadid = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5490
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5491 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5492 hdcPaint = GetDC(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5493 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5494 hdcPaint = pixmap->hdc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5495 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5496 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5497
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5498 oldPen = SelectObject(hdcPaint, _hPen[threadid]);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5499 MoveToEx(hdcPaint, x1, y1, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5500 LineTo(hdcPaint, x2, y2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5501 SelectObject(hdcPaint, oldPen);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5502 /* For some reason Win98 (at least) fails
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5503 * to draw the last pixel. So I do it myself.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5504 */
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5505 SetPixel(hdcPaint, x2, y2, _foreground[threadid]);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5506 if(!pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5507 ReleaseDC(handle, hdcPaint);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5508 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5509
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5510 /* Draw a rectangle on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5511 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5512 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5513 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5514 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5515 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5516 * width: Width of rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5517 * height: Height of rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5518 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5519 void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5520 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5521 HDC hdcPaint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5522 HPEN oldPen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5523 HBRUSH oldBrush;
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5524 int threadid = dw_thread_id();
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5525
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5526 if(threadid < 0 || threadid >= THREAD_LIMIT)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5527 threadid = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5528
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5529 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5530 hdcPaint = GetDC(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5531 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5532 hdcPaint = pixmap->hdc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5533 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5534 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5535
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5536 oldPen = SelectObject(hdcPaint, _hPen[threadid]);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5537 oldBrush = SelectObject(hdcPaint, _hBrush[threadid]);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5538 Rectangle(hdcPaint, x, y, x + width, y + height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5539 SelectObject(hdcPaint, oldPen);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5540 SelectObject(hdcPaint, oldBrush);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5541 if(!pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5542 ReleaseDC(handle, hdcPaint);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5543 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5544
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5545 /* Draw text on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5546 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5547 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5548 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5549 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5550 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5551 * text: Text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5552 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5553 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5554 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5555 HDC hdc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5556 int size = 9, z, mustdelete = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5557 HFONT hFont, oldFont;
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5558 int threadid = dw_thread_id();
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5559
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5560 if(threadid < 0 || threadid >= THREAD_LIMIT)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5561 threadid = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5562
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5563 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5564 hdc = GetDC(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5565 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5566 hdc = pixmap->hdc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5567 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5568 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5569
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5570 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5571 ColorInfo *cinfo;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5572
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5573 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5574 cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5575 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5576 cinfo = (ColorInfo *)GetWindowLong(pixmap->handle, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5577
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5578 if(cinfo)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5579 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5580 hFont = _aquire_font(cinfo->fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5581 mustdelete = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5582 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5583 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5584 oldFont = SelectObject(hdc, hFont);
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5585 SetTextColor(hdc, _foreground[threadid]);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5586 SetBkMode(hdc, TRANSPARENT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5587 TextOut(hdc, x, y, text, strlen(text));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5588 SelectObject(hdc, oldFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5589 if(mustdelete)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5590 DeleteObject(hFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5591 if(!pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5592 ReleaseDC(handle, hdc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5593 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5594
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5595 /* Query the width and height of a text string.
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5596 * Parameters:
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5597 * handle: Handle to the window.
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5598 * pixmap: Handle to the pixmap. (choose only one of these)
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5599 * text: Text to be queried.
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5600 * width: Pointer to a variable to be filled in with the width.
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5601 * height Pointer to a variable to be filled in with the height.
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5602 */
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5603 void dw_font_text_extents(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height)
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5604 {
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5605 HDC hdc;
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5606 int mustdelete = 0;
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5607 HFONT hFont, oldFont;
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5608 SIZE sz;
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5609
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5610 if(handle)
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5611 hdc = GetDC(handle);
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5612 else if(pixmap)
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5613 hdc = pixmap->hdc;
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5614 else
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5615 return;
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5616
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5617 {
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5618 ColorInfo *cinfo;
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5619
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5620 if(handle)
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5621 cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5622 else
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5623 cinfo = (ColorInfo *)GetWindowLong(pixmap->handle, GWL_USERDATA);
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5624
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5625 if(cinfo)
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5626 {
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5627 hFont = _aquire_font(cinfo->fontname);
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5628 mustdelete = 1;
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5629 }
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5630 }
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5631 oldFont = SelectObject(hdc, hFont);
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5632
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5633 GetTextExtentPoint32(hdc, text, strlen(text), &sz);
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5634
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5635 if(width)
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5636 *width = sz.cx;
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5637
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5638 if(height)
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5639 *height = sz.cy;
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5640
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5641 SelectObject(hdc, oldFont);
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5642 if(mustdelete)
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5643 DeleteObject(hFont);
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5644 if(!pixmap)
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5645 ReleaseDC(handle, hdc);
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5646 }
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5647
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5648 /* Call this after drawing to the screen to make sure
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5649 * anything you have drawn is visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5650 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5651 void dw_flush(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5652 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5653 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5654
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5655 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5656 * Creates a pixmap with given parameters.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5657 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5658 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5659 * width: Width of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5660 * height: Height of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5661 * depth: Color depth of the pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5662 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5663 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5664 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5665 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5666 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5667 HPIXMAP pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5668 BITMAP bm;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5669 HDC hdc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5670
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5671 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5672 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5673
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5674 hdc = GetDC(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5675
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5676 pixmap->width = width; pixmap->height = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5677
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5678 pixmap->handle = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5679 pixmap->hbm = CreateCompatibleBitmap(hdc, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5680 pixmap->hdc = CreateCompatibleDC(hdc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5681
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5682 SelectObject(pixmap->hdc, pixmap->hbm);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5683
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5684 ReleaseDC(handle, hdc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5685
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5686 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5687 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5688
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5689 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5690 * Creates a pixmap from internal resource graphic specified by id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5691 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5692 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5693 * id: Resource ID associated with requested pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5694 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5695 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5696 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5697 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5698 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5699 HPIXMAP pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5700 BITMAP bm;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5701 HDC hdc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5702
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5703 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5704 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5705
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5706 hdc = GetDC(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5707
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5708
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5709 pixmap->hbm = LoadBitmap(DWInstance, MAKEINTRESOURCE(id));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5710 pixmap->hdc = CreateCompatibleDC(hdc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5711
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5712 GetObject(pixmap->hbm, sizeof(BITMAP), (void *)&bm);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5713
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5714 pixmap->width = bm.bmWidth; pixmap->height = bm.bmHeight;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5715
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5716 SelectObject(pixmap->hdc, pixmap->hbm);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5717
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5718 ReleaseDC(handle, hdc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5719
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5720 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5721 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5722
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5723 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5724 * Destroys an allocated pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5725 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5726 * pixmap: Handle to a pixmap returned by
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5727 * dw_pixmap_new..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5728 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5729 void dw_pixmap_destroy(HPIXMAP pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5730 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5731 if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5732 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5733 DeleteDC(pixmap->hdc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5734 DeleteObject(pixmap->hbm);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5735 free(pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5736 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5737 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5738
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5739 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5740 * Copies from one item to another.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5741 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5742 * dest: Destination window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5743 * destp: Destination pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5744 * xdest: X coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5745 * ydest: Y coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5746 * width: Width of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5747 * height: Height of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5748 * src: Source window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5749 * srcp: Source pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5750 * xsrc: X coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5751 * ysrc: Y coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5752 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5753 void dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5754 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5755 HDC hdcdest;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5756 HDC hdcsrc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5757
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5758 if(dest)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5759 hdcdest = GetDC(dest);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5760 else if(destp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5761 hdcdest = destp->hdc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5762 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5763 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5764
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5765 if(src)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5766 hdcsrc = GetDC(src);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5767 else if(srcp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5768 hdcsrc = srcp->hdc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5769 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5770 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5771
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5772 BitBlt(hdcdest, xdest, ydest, width, height, hdcsrc, xsrc, ysrc, SRCCOPY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5773
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5774 if(!destp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5775 ReleaseDC(dest, hdcdest);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5776 if(!srcp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5777 ReleaseDC(src, hdcsrc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5778 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5779
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5780 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5781 * Emits a beep.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5782 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5783 * freq: Frequency.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5784 * dur: Duration.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5785 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5786 void dw_beep(int freq, int dur)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5787 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5788 Beep(freq, dur);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5789 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5790
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5791 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5792 * Returns the handle to an unnamed mutex semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5793 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5794 HMTX dw_mutex_new(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5795 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5796 return (HMTX)CreateMutex(NULL, FALSE, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5797 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5798
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5799 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5800 * Closes a semaphore created by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5801 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5802 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5803 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5804 void dw_mutex_close(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5805 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5806 CloseHandle((HANDLE)mutex);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5807 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5808
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5809 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5810 * Tries to gain access to the semaphore, if it can't it blocks.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5811 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5812 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5813 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5814 void dw_mutex_lock(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5815 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5816 WaitForSingleObject((HANDLE)mutex, INFINITE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5817 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5818
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5819 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5820 * Reliquishes the access to the semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5821 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5822 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5823 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5824 void dw_mutex_unlock(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5825 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5826 ReleaseMutex((HANDLE)mutex);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5827 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5828
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5829 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5830 * Returns the handle to an unnamed event semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5831 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5832 HEV dw_event_new(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5833 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5834 return CreateEvent(NULL, TRUE, FALSE, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5835 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5836
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5837 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5838 * Resets a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5839 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5840 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5841 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5842 int dw_event_reset(HEV eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5843 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5844 return ResetEvent(eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5845 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5846
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5847 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5848 * Posts a semaphore created by dw_event_new(). Causing all threads
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5849 * waiting on this event in dw_event_wait to continue.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5850 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5851 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5852 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5853 int dw_event_post(HEV eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5854 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5855 return SetEvent(eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5856 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5857
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5858 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5859 * Waits on a semaphore created by dw_event_new(), until the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5860 * event gets posted or until the timeout expires.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5861 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5862 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5863 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5864 int dw_event_wait(HEV eve, unsigned long timeout)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5865 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5866 int rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5867
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5868 rc = WaitForSingleObject(eve, timeout);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5869 if(rc == WAIT_OBJECT_0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5870 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5871 if(rc == WAIT_ABANDONED)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5872 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5873 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5874 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5875
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5876 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5877 * Closes a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5878 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5879 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5880 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5881 int dw_event_close(HEV *eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5882 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5883 if(eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5884 return CloseHandle(*eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5885 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5886 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5887
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5888 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5889 * Creates a new thread with a starting point of func.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5890 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5891 * func: Function which will be run in the new thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5892 * data: Parameter(s) passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5893 * stack: Stack size of new thread (OS/2 and Windows only).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5894 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5895 DWTID dw_thread_new(void *func, void *data, int stack)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5896 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5897 #if defined(__CYGWIN__)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5898 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5899 #else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5900 return (DWTID)_beginthread((void(*)(void *))func, stack, data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5901 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5902 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5903
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5904 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5905 * Ends execution of current thread immediately.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5906 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5907 void dw_thread_end(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5908 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5909 #if !defined(__CYGWIN__)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5910 _endthread();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5911 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5912 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5913
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5914 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5915 * Returns the current thread's ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5916 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5917 DWTID dw_thread_id(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5918 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5919 #if defined(__CYGWIN__)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5920 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5921 #else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5922 return (DWTID)GetCurrentThreadId();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5923 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5924 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5925
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5926 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5927 * Cleanly terminates a DW session, should be signal handler safe.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5928 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5929 * exitcode: Exit code reported to the operating system.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5930 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5931 void dw_exit(int exitcode)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5932 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5933 exit(exitcode);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5934 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5935
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5936 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5937 * Pack a splitbar (sizer) into the specified box from the start.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5938 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5939 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5940 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5941 void dw_box_pack_splitbar_start(HWND box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5942 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5943 Box *thisbox = (Box *)GetWindowLong(box, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5944
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5945 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5946 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5947 HWND tmp = CreateWindow(SplitbarClassName,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5948 "",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5949 WS_CHILD | WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5950 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5951 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5952 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5953 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5954 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5955 if(thisbox->type == BOXVERT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5956 dw_box_pack_start(box, tmp, 1, SPLITBAR_WIDTH, TRUE, FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5957 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5958 dw_box_pack_start(box, tmp, SPLITBAR_WIDTH, 1, FALSE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5959
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5960 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5961 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5962
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5963 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5964 * Pack a splitbar (sizer) into the specified box from the end.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5965 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5966 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5967 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5968 void dw_box_pack_splitbar_end(HWND box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5969 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5970 Box *thisbox = (Box *)GetWindowLong(box, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5971
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5972 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5973 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5974 HWND tmp = CreateWindow(SplitbarClassName,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5975 "",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5976 WS_CHILD | WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5977 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5978 DW_HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5979 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5980 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5981 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5982 if(thisbox->type == BOXVERT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5983 dw_box_pack_end(box, tmp, 1, SPLITBAR_WIDTH, TRUE, FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5984 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5985 dw_box_pack_end(box, tmp, SPLITBAR_WIDTH, 1, FALSE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5986
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5987 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5988 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5989
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5990 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5991 * Pack windows (widgets) into a box from the end (or bottom).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5992 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5993 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5994 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5995 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5996 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5997 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5998 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5999 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6000 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6001 void dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6002 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6003 Box *thisbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6004
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6005 thisbox = (Box *)GetWindowLong(box, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6006 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6007 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6008 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6009 Item *tmpitem, *thisitem = thisbox->items;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6010 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6011
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6012 tmpitem = malloc(sizeof(Item)*(thisbox->count+1));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6013
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6014 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6015 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6016 tmpitem[z+1] = thisitem[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6017 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6018
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6019 GetClassName(item, tmpbuf, 99);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6020
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6021 if(strnicmp(tmpbuf, FRAMECLASSNAME, 2)==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6022 tmpitem[0].type = TYPEBOX;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6023 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6024 tmpitem[0].type = TYPEITEM;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6025
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6026 tmpitem[0].hwnd = item;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6027 tmpitem[0].origwidth = tmpitem[0].width = width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6028 tmpitem[0].origheight = tmpitem[0].height = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6029 tmpitem[0].pad = pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6030 if(hsize)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6031 tmpitem[0].hsize = SIZEEXPAND;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6032 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6033 tmpitem[0].hsize = SIZESTATIC;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6034
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6035 if(vsize)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6036 tmpitem[0].vsize = SIZEEXPAND;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6037 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6038 tmpitem[0].vsize = SIZESTATIC;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6039
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6040 thisbox->items = tmpitem;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6041
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6042 if(thisbox->count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6043 free(thisitem);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6044
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6045 thisbox->count++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6046
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6047 SetParent(item, box);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6048 ShowWindow(item, SW_SHOW);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6049 if(strncmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6050 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6051 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(item, GWL_USERDATA);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6052
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6053 if(cinfo)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6054 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6055 SetParent(cinfo->buddy, box);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6056 ShowWindow(cinfo->buddy, SW_SHOW);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6057 SendMessage(item, UDM_SETBUDDY, (WPARAM)cinfo->buddy, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6058 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6059 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6060 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6061 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6062
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6063 /*
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6064 * Sets the default focus item for a window/dialog.
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6065 * Parameters:
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6066 * window: Toplevel window or dialog.
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6067 * defaultitem: Handle to the dialog item to be default.
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6068 */
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6069 void dw_window_default(HWND window, HWND defaultitem)
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6070 {
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6071 Box *thisbox = (Box *)GetWindowLong(window, GWL_USERDATA);
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6072
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6073 if(thisbox)
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6074 thisbox->defaultitem = defaultitem;
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6075 }
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6076
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6077 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6078 * Sets window to click the default dialog item when an ENTER is pressed.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6079 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6080 * window: Window (widget) to look for the ENTER press.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6081 * next: Window (widget) to move to next (or click)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6082 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6083 void dw_window_click_default(HWND window, HWND next)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6084 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6085 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(window, GWL_USERDATA);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6086
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6087 if(cinfo)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6088 cinfo->clickdefault = next;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6089 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6090
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6091 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6092 * Returns some information about the current operating environment.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6093 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6094 * env: Pointer to a DWEnv struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6095 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6096 void dw_environment_query(DWEnv *env)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6097 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6098 if(!env)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6099 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6100
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6101 /* Get the Windows version. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6102
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6103 env->MajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6104 env->MinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6105
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6106 /* Get the build number for Windows NT/Windows 2000. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6107
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6108 env->MinorBuild = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6109
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6110 if (dwVersion < 0x80000000)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6111 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6112 if(env->MajorVersion == 5 && env->MinorVersion == 1)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6113 strcpy(env->osName, "Windows XP");
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6114 else if(env->MajorVersion == 5 && env->MinorVersion == 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6115 strcpy(env->osName, "Windows 2000");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6116 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6117 strcpy(env->osName, "Windows NT");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6118
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6119 env->MajorBuild = (DWORD)(HIWORD(dwVersion));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6120 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6121 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6122 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6123 strcpy(env->osName, "Windows 95/98/ME");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6124 env->MajorBuild = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6125 }
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
6126
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
6127 strcpy(env->buildDate, __DATE__);
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
6128 strcpy(env->buildTime, __TIME__);
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
6129 env->DWMajorVersion = DW_MAJOR_VERSION;
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
6130 env->DWMinorVersion = DW_MINOR_VERSION;
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
6131 env->DWSubVersion = DW_SUB_VERSION;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6132 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6133
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6134 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6135 * Opens a file dialog and queries user selection.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6136 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6137 * title: Title bar text for dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6138 * defpath: The default path of the open dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6139 * ext: Default file extention.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6140 * flags: DW_FILE_OPEN or DW_FILE_SAVE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6141 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6142 * NULL on error. A malloced buffer containing
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6143 * the file path on success.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6144 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6145 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6146 char *dw_file_browse(char *title, char *defpath, char *ext, int flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6147 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6148 OPENFILENAME of;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6149 char filenamebuf[1001] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6150 int rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6151
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6152 if(ext)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6153 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6154 strcpy(filenamebuf, "*.");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6155 strcat(filenamebuf, ext);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6156 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6157
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6158 memset(&of, 0, sizeof(OPENFILENAME));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6159
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6160 of.lStructSize = sizeof(OPENFILENAME);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6161 of.hwndOwner = HWND_DESKTOP;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6162 of.hInstance = DWInstance;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6163 of.lpstrInitialDir = defpath;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6164 of.lpstrTitle = title;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6165 of.lpstrFile = filenamebuf;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6166 of.nMaxFile = 1000;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6167 of.lpstrDefExt = ext;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6168 of.Flags = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6169
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6170 if(flags & DW_FILE_SAVE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6171 rc = GetSaveFileName(&of);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6172 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6173 rc = GetOpenFileName(&of);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6174
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6175 if(rc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6176 return strdup(of.lpstrFile);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6177
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6178 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6179 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6180
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6181 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6182 * Execute and external program in a seperate session.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6183 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6184 * program: Program name with optional path.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6185 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6186 * params: An array of pointers to string arguements.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6187 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6188 * -1 on error.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6189 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6190 int dw_exec(char *program, int type, char **params)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6191 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6192 char **newparams;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6193 int retcode, count = 0, z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6194
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6195 while(params[count])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6196 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6197 count++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6198 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6199
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6200 newparams = (char **)malloc(sizeof(char *) * (count+1));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6201
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6202 for(z=0;z<count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6203 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6204 newparams[z] = malloc(strlen(params[z])+3);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6205 strcpy(newparams[z], "\"");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6206 strcat(newparams[z], params[z]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6207 strcat(newparams[z], "\"");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6208 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6209 newparams[count] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6210
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6211 retcode = spawnvp(P_NOWAIT, program, newparams);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6212
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6213 for(z=0;z<count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6214 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6215 free(newparams[z]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6216 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6217 free(newparams);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6218
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6219 return retcode;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6220 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6221
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6222 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6223 * Loads a web browser pointed at the given URL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6224 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6225 * url: Uniform resource locator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6226 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6227 int dw_browse(char *url)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6228 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6229 char *browseurl = url;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6230 int retcode;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6231
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6232 if(strlen(url) > 7 && strncmp(url, "file://", 7) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6233 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6234 int len, z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6235
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6236 browseurl = &url[7];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6237 len = strlen(browseurl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6238
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6239 for(z=0;z<len;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6240 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6241 if(browseurl[z] == '|')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6242 browseurl[z] = ':';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6243 if(browseurl[z] == '/')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6244 browseurl[z] = '\\';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6245 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6246 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6247
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6248 retcode = (int)ShellExecute(NULL, "open", browseurl, NULL, NULL, SW_SHOWNORMAL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6249 if(retcode<33 && retcode != 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6250 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6251 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6252 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6253
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6254 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6255 * Returns a pointer to a static buffer which containes the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6256 * current user directory. Or the root directory (C:\ on
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6257 * OS/2 and Windows).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6258 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6259 char *dw_user_dir(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6260 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6261 static char _user_dir[1024] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6262
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6263 if(!_user_dir[0])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6264 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6265 /* Figure out how to do this the "Windows way" */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6266 char *home = getenv("HOME");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6267
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6268 if(home)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6269 strcpy(_user_dir, home);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6270 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6271 strcpy(_user_dir, "C:\\");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6272 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6273 return _user_dir;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6274 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6275
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6276 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6277 * Call a function from the window (widget)'s context.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6278 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6279 * handle: Window handle of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6280 * function: Function pointer to be called.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6281 * data: Pointer to the data to be passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6282 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6283 void dw_window_function(HWND handle, void *function, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6284 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6285 SendMessage(handle, WM_USER, (WPARAM)function, (LPARAM)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6286 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6287
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6288 #ifndef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6289 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6290 * Add a callback to a window event.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6291 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6292 * window: Window handle of signal to be called back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6293 * signame: A string pointer identifying which signal to be hooked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6294 * sigfunc: The pointer to the function to be used as the callback.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6295 * data: User data to be passed to the handler function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6296 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6297 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6298 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6299 ULONG message = 0L;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6300
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6301 if(window && signame && sigfunc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6302 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6303 if(stricmp(signame, "set-focus") == 0)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6304 window = _normalize_handle(window);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6305
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6306 if((message = _findsigmessage(signame)) != 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6307 _new_signal(message, window, sigfunc, data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6308 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6309 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6310
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6311 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6312 * Removes callbacks for a given window with given name.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6313 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6314 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6315 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6316 void dw_signal_disconnect_by_name(HWND window, char *signame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6317 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6318 SignalHandler *prev = NULL, *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6319 ULONG message;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6320
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6321 if(!window || !signame || (message = _findsigmessage(signame)) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6322 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6323
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6324 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6325 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6326 if(tmp->window == window && tmp->message == message)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6327 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6328 if(prev)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6329 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6330 prev->next = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6331 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6332 tmp = prev->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6333 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6334 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6335 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6336 Root = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6337 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6338 tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6339 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6340 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6341 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6342 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6343 prev = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6344 tmp = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6345 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6346 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6347 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6348
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6349 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6350 * Removes all callbacks for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6351 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6352 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6353 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6354 void dw_signal_disconnect_by_window(HWND window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6355 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6356 SignalHandler *prev = NULL, *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6357
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6358 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6359 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6360 if(tmp->window == window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6361 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6362 if(prev)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6363 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6364 prev->next = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6365 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6366 tmp = prev->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6367 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6368 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6369 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6370 Root = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6371 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6372 tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6373 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6374 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6375 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6376 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6377 prev = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6378 tmp = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6379 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6380 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6381 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6382
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6383 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6384 * Removes all callbacks for a given window with specified data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6385 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6386 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6387 * data: Pointer to the data to be compared against.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6388 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6389 void dw_signal_disconnect_by_data(HWND window, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6390 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6391 SignalHandler *prev = NULL, *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6392
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6393 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6394 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6395 if(tmp->window == window && tmp->data == data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6396 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6397 if(prev)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6398 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6399 prev->next = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6400 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6401 tmp = prev->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6402 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6403 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6404 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6405 Root = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6406 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6407 tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6408 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6409 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6410 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6411 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6412 prev = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6413 tmp = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6414 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6415 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6416 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6417 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6418
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6419 #ifdef TEST
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6420 HWND mainwindow,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6421 listbox,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6422 okbutton,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6423 cancelbutton,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6424 lbbox,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6425 stext,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6426 buttonbox,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6427 testwindow,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6428 testbox,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6429 testok,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6430 testcancel,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6431 testbox2,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6432 testok2,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6433 testcancel2,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6434 notebook;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6435 int count = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6436
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6437 #ifdef USE_FILTER
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6438 /* Do any handling you need in the filter function */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6439 LONG testfilter(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6440 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6441 switch(msg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6442 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6443 case WM_COMMAND:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6444 switch (COMMANDMSG(&msg)->cmd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6445 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6446 case 1001L:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6447 case 1002L:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6448 dw_window_destroy(mainwindow);;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6449 count--;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6450 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6451 case 1003L:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6452 case 1004L:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6453 dw_window_destroy(testwindow);;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6454 count--;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6455 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6456 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6457 if(!count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6458 exit(0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6459 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6460 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6461 /* Return -1 to allow the default handlers to return. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6462 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6463 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6464 #else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6465 int test_callback(HWND window, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6466 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6467 dw_window_destroy((HWND)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6468 /* Return -1 to allow the default handlers to return. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6469 count--;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6470 if(!count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6471 exit(0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6472 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6473 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6474 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6475
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6476 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6477 * Let's demonstrate the functionality of this library. :)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6478 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6479 int WINAPI WinMain(
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6480 HINSTANCE hInstance,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6481 HINSTANCE hPrevInstance,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6482 LPSTR lpCmdLine,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6483 int nCmdShow
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6484 )
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6485 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6486 ULONG flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6487 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6488 int pageid;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6489
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6490 dw_init(TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6491
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6492 /* Try a little server dialog. :) */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6493 mainwindow = dw_window_new(HWND_DESKTOP, "Server", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6494
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6495 lbbox = dw_box_new(BOXVERT, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6496
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6497 dw_box_pack_start(mainwindow, lbbox, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6498
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6499 stext = dw_text_new("Choose a server:", 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6500
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6501 dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6502
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6503 dw_box_pack_start(lbbox, stext, 130, 15, FALSE, FALSE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6504
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6505 listbox = dw_listbox_new(100L, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6506
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6507 dw_box_pack_start(lbbox, listbox, 130, 200, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6508
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6509 buttonbox = dw_box_new(BOXHORZ, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6510
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6511 dw_box_pack_start(lbbox, buttonbox, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6512
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6513 okbutton = dw_button_new("Ok", 1001L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6514
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6515 dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, TRUE, 5);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6516
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6517 cancelbutton = dw_button_new("Cancel", 1002L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6518
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6519 dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, TRUE, 5);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6520
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6521 /* Set some nice fonts and colors */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6522 dw_window_set_color(lbbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6523 dw_window_set_color(buttonbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6524 dw_window_set_font(stext, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6525 dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6526 dw_window_set_font(listbox, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6527 dw_window_set_font(okbutton, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6528 dw_window_set_font(cancelbutton, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6529
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6530 dw_window_show(mainwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6531
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6532 dw_window_set_usize(mainwindow, 170, 340);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6533
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6534 /* Another small example */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6535 flStyle |= DW_FCF_MINMAX | DW_FCF_SIZEBORDER;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6536
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6537 testwindow = dw_window_new(HWND_DESKTOP, "Wow a test dialog! :) yay!", flStyle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6538
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6539 testbox = dw_box_new(BOXVERT, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6540
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6541 dw_box_pack_start(testwindow, testbox, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6542
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6543 notebook = dw_notebook_new(1010L, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6544
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6545 dw_box_pack_start(testbox, notebook, 100, 100, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6546
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6547 testbox = dw_box_new(BOXVERT, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6548
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6549 pageid = dw_notebook_page_new(notebook, 0L, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6550
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6551 dw_notebook_page_set_text(notebook, pageid, "Test page");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6552 dw_notebook_page_set_status_text(notebook, pageid, "Test page");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6553
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6554 dw_notebook_pack(notebook, pageid, testbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6555
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6556 testok = dw_button_new("Ok", 1003L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6557
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6558 dw_box_pack_start(testbox, testok, 60, 40, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6559
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6560 testcancel = dw_button_new("Cancel", 1004L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6561
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6562 dw_box_pack_start(testbox, testcancel, 60, 40, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6563
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6564 testbox2 = dw_box_new(BOXHORZ, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6565
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6566 dw_box_pack_start(testbox, testbox2, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6567
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6568 testok2 = dw_button_new("Ok", 1003L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6569
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6570 dw_box_pack_start(testbox2, testok2, 60, 40, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6571
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6572 dw_box_pack_splitbar_start(testbox2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6573
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6574 testcancel2 = dw_button_new("Cancel", 1004L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6575
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6576 dw_box_pack_start(testbox2, testcancel2, 60, 40, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6577
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6578 /* Set some nice fonts and colors */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6579 dw_window_set_color(testbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6580 dw_window_set_color(testbox2, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6581 dw_window_set_font(testok, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6582 dw_window_set_font(testcancel, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6583 dw_window_set_font(testok2, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6584 dw_window_set_font(testcancel2, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6585
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6586 dw_window_show(testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6587
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6588 #ifdef USE_FILTER
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6589
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6590 dw_main(0L, (void *)testfilter);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6591 #else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6592 /* Setup the function callbacks */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6593 dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6594 dw_signal_connect(cancelbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6595 dw_signal_connect(testok, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6596 dw_signal_connect(testcancel, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6597 dw_signal_connect(testok2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6598 dw_signal_connect(testcancel2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6599 dw_signal_connect(mainwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6600 dw_signal_connect(testwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6601
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6602 dw_main(0L, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6603 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6604
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6605 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6606 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6607 #endif