annotate os2/dw.c @ 30:b1d7e8a28dfa

Added tree view functions and signal.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 25 Aug 2001 05:39:33 +0000
parents d9e87e8bcf1d
children 17a08cfd45d2
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 PM 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 * (C) 2000 Achim Hasenmueller <achimha@innotek.de>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7 * (C) 2000 Peter Nielsen <peter@pmview.com>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8 * (C) 1998 Sergey I. Yevtushenko (some code borrowed from cell toolkit)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11 #define INCL_DOS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12 #define INCL_DOSERRORS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
13 #define INCL_WIN
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
14 #define INCL_GPI
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
15
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
16 #include <os2.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
17 #include <stdlib.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
18 #include <string.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
19 #include <stdio.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
20 #include <stdarg.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
21 #include <stddef.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
22 #include <ctype.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
23 #include <process.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
24 #include "dw.h"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
25
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
26 #define QWP_USER 0
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
27
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
28 char ClassName[] = "dynamicwindows";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
29 char SplitbarClassName[] = "dwsplitbar";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
30 char DefaultFont[] = "9.WarpSans";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
31
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
32 /* this is the callback handle for the window procedure
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
33 * make sure you always match the calling convention!
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
34 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
35 int (* EXPENTRY filterfunc)(HWND, ULONG, MPARAM, MPARAM) = 0L;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
36
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
37 HAB dwhab = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
38 HMQ dwhmq = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
39 DWTID _dwtid = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
40 LONG _foreground = 0xAAAAAA, _background = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
41
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
42 HWND hwndBubble = NULLHANDLE, hwndBubbleLast = NULLHANDLE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
43 PRECORDCORE pCore = NULL;
20
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
44 ULONG aulBuffer[4];
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
45
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
46 #define IS_WARP4() (aulBuffer[0] == 20 && aulBuffer[1] >= 40)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
47
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
48 #ifndef min
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
49 #define min(a, b) (((a < b) ? a : b))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
50 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
51
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
52 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
53 FILE *f;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
54
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
55 void reopen(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
56 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
57 fclose(f);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
58 f = fopen("dw.log", "a+");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
59 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
60 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
61
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
62 static LONG lColor[SPLITBAR_WIDTH] =
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
63 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
64 DW_CLR_BLACK,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
65 DW_CLR_PALEGRAY,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
66 DW_CLR_WHITE
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
67 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
68
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
69 #ifdef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
70 #define USE_FILTER
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
71 #else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
72 typedef struct _sighandler
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
73 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
74 struct _sighandler *next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
75 ULONG message;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
76 HWND window;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
77 void *signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
78 void *data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
79
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
80 } SignalHandler;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
81
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
82 SignalHandler *Root = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
83
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
84 typedef struct
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
85 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
86 ULONG message;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
87 char name[30];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
88
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
89 } SignalList;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
90
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
91 /* List of signals and their equivilent OS/2 message */
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
92 #define SIGNALMAX 13
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
93
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
94 SignalList SignalTranslate[SIGNALMAX] = {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
95 { WM_SIZE, "configure_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
96 { WM_CHAR, "key_press_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
97 { WM_BUTTON1DOWN, "button_press_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
98 { WM_BUTTON1UP, "button_release_event"},
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
99 { WM_MOUSEMOVE, "motion_notify_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
100 { WM_CLOSE, "delete_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
101 { WM_PAINT, "expose_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
102 { WM_COMMAND, "clicked" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
103 { CN_ENTER, "container-select" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
104 { CN_CONTEXTMENU, "container-context" },
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
105 { LN_SELECT, "item-select" },
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
106 { WM_USER+1, "tree-select" },
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
107 { WM_SETFOCUS, "set-focus" }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
108 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
109
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
110 /* This function adds a signal handler callback into the linked list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
111 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
112 void _new_signal(ULONG message, HWND window, void *signalfunction, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
113 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
114 SignalHandler *new = malloc(sizeof(SignalHandler));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
115
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
116 new->message = message;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
117 new->window = window;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
118 new->signalfunction = signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
119 new->data = data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
120 new->next = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
121
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
122 if (!Root)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
123 Root = new;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
124 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
125 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
126 SignalHandler *prev = NULL, *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
127 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
128 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
129 prev = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
130 tmp = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
131 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
132 if(prev)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
133 prev->next = new;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
134 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
135 Root = new;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
136 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
137 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
138
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
139 /* Finds the message number for a given signal name */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
140 ULONG _findsigmessage(char *signame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
141 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
142 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
143
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
144 for(z=0;z<SIGNALMAX;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
145 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
146 if(stricmp(signame, SignalTranslate[z].name) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
147 return SignalTranslate[z].message;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
148 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
149 return 0L;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
150 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
151 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
152
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
153 /* This function removes and handlers on windows and frees
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
154 * the user memory allocated to it.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
155 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
156 void _free_window_memory(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
157 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
158 HENUM henum;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
159 HWND child;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
160
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
161 #ifndef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
162 dw_signal_disconnect_by_window(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
163 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
164
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
165 henum = WinBeginEnumWindows(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
166 while((child = WinGetNextWindow(henum)) != NULLHANDLE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
167 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
168 void *ptr = (void *)WinQueryWindowPtr(handle, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
169
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
170 if(ptr)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
171 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
172 WinSetWindowPtr(handle, QWP_USER, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
173 free(ptr);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
174 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
175
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
176 _free_window_memory(child);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
177 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
178 WinEndEnumWindows(henum);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
179 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
180 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
181
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
182 /* This function returns 1 if the window (widget) handle
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
183 * passed to it is a valid window that can gain input focus.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
184 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
185 int _validate_focus(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
186 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
187 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
188
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
189 if(!handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
190 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
191
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
192 WinQueryClassName(handle, 99, tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
193
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
194 /* These are the window classes which can
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
195 * obtain input focus.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
196 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
197 if(strncmp(tmpbuf, "#2", 2)==0 || /* Entryfield */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
198 strncmp(tmpbuf, "#3", 2)==0 || /* Button */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
199 strncmp(tmpbuf, "#6", 2)==0 || /* Combobox */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
200 strncmp(tmpbuf, "#7", 2)==0 || /* List box */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
201 strncmp(tmpbuf, "#10", 3)==0 || /* MLE */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
202 strncmp(tmpbuf, "#32", 3)==0 || /* Spinbutton */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
203 strncmp(tmpbuf, "#37", 3)== 0) /* Container */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
204 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
205 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
206 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
207
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
208 int _focus_check_box(Box *box, HWND handle, int start)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
209 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
210 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
211 static HWND lasthwnd, firsthwnd;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
212 static int finish_searching;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
213
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
214 /* Start is 2 when we have cycled completely and
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
215 * need to set the focus to the last widget we found
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
216 * that was valid.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
217 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
218 if(start == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
219 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
220 if(lasthwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
221 WinSetFocus(HWND_DESKTOP, lasthwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
222 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
223 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
224
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
225 /* Start is 1 when we are entering the function
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
226 * for the first time, it is zero when entering
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
227 * the function recursively.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
228 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
229 if(start == 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
230 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
231 lasthwnd = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
232 finish_searching = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
233 firsthwnd = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
234 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
235
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
236 /* Vertical boxes are inverted on OS/2 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
237 if(box->type == BOXVERT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
238 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
239 for(z=0;z<box->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
240 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
241 if(box->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
242 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
243 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
244
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
245 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
246 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
247 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
248 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
249 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
250 if(box->items[z].hwnd == handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
251 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
252 if(lasthwnd == handle && firsthwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
253 WinSetFocus(HWND_DESKTOP, firsthwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
254 else if(lasthwnd == handle && !firsthwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
255 finish_searching = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
256 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
257 WinSetFocus(HWND_DESKTOP, lasthwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
258
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
259 /* If we aren't looking for the last handle,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
260 * return immediately.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
261 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
262 if(!finish_searching)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
263 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
264 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
265 if(_validate_focus(box->items[z].hwnd))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
266 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
267 /* Start is 3 when we are looking for the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
268 * first valid item in the layout.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
269 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
270 if(start == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
271 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
272 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
273 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
274 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
275
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
276 if(!firsthwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
277 firsthwnd = box->items[z].hwnd;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
278
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
279 lasthwnd = box->items[z].hwnd;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
280 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
281 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
282 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
283 char tmpbuf[100] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
284
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
285 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
286 if(strncmp(tmpbuf, "#40", 3)==0) /* Notebook */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
287 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
288 Box *notebox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
289 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
290 (MPARAM)dw_notebook_page_query(box->items[z].hwnd), 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
291
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
292 if(page)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
293 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
294 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
295
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
296 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
297 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
298 }
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 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
302 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
303 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
304 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
305 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
306 for(z=box->count-1;z>-1;z--)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
307 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
308 if(box->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
309 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
310 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
311
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
312 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
313 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
314 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
315 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
316 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
317 if(box->items[z].hwnd == handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
318 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
319 if(lasthwnd == handle && firsthwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
320 WinSetFocus(HWND_DESKTOP, firsthwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
321 else if(lasthwnd == handle && !firsthwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
322 finish_searching = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
323 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
324 WinSetFocus(HWND_DESKTOP, lasthwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
325
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
326 /* If we aren't looking for the last handle,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
327 * return immediately.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
328 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
329 if(!finish_searching)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
330 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
331 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
332 if(_validate_focus(box->items[z].hwnd))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
333 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
334 /* Start is 3 when we are looking for the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
335 * first valid item in the layout.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
336 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
337 if(start == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
338 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
339 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
340 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
341 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
342
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
343 if(!firsthwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
344 firsthwnd = box->items[z].hwnd;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
345
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
346 lasthwnd = box->items[z].hwnd;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
347 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
348 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
349 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
350 char tmpbuf[100] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
351
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
352 WinQueryClassName(box->items[z].hwnd, 99, tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
353 if(strncmp(tmpbuf, "#40", 3)==0) /* Notebook */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
354 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
355 Box *notebox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
356 HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
357 (MPARAM)dw_notebook_page_query(box->items[z].hwnd), 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
358
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
359 if(page)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
360 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
361 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
362
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
363 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
364 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
365 }
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 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
369 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
370 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
371 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
372 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
373
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
374 /* This function finds the first widget in the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
375 * layout and moves the current focus to it.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
376 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
377 void _initial_focus(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
378 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
379 Box *thisbox = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
380 HWND box;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
381
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
382 box = WinWindowFromID(handle, FID_CLIENT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
383 if(box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
384 thisbox = WinQueryWindowPtr(box, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
385
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
386 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
387 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
388 _focus_check_box(thisbox, handle, 3);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
389 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
390 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
391
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
392 /* This function finds the current widget in the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
393 * layout and moves the current focus to the next item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
394 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
395 void _shift_focus(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
396 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
397 Box *thisbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
398 HWND box, lastbox = WinQueryWindow(handle, QW_PARENT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
399
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
400 /* Find the toplevel window */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
401 while((box = WinQueryWindow(lastbox, QW_PARENT)) > 0x80000001)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
402 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
403 lastbox = box;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
404 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
405
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
406 box = WinWindowFromID(lastbox, FID_CLIENT);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
407 if(box)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
408 thisbox = WinQueryWindowPtr(box, QWP_USER);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
409 else
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
410 thisbox = WinQueryWindowPtr(lastbox, QWP_USER);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
411
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
412 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
413 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
414 if(_focus_check_box(thisbox, handle, 1) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
415 _focus_check_box(thisbox, handle, 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
416 }
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 /* ResetWindow:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
420 * Resizes window to the exact same size to trigger
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
421 * recalculation of frame.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
422 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
423 void _ResetWindow(HWND hwndFrame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
424 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
425 SWP swp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
426
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
427 WinQueryWindowPos(hwndFrame, &swp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
428 WinSetWindowPos(hwndFrame, HWND_TOP, 0, 0, swp.cx, swp.cy-1, SWP_SIZE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
429 WinSetWindowPos(hwndFrame, HWND_TOP, 0, 0, swp.cx, swp.cy, SWP_SIZE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
430 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
431
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
432 /* This function will recursively search a box and add up the total height of it */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
433 void _count_size(HWND box, int type, int *xsize, int *xorigsize)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
434 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
435 int size = 0, origsize = 0, z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
436 Box *tmp = WinQueryWindowPtr(box, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
437
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
438 if(!tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
439 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
440 *xsize = *xorigsize = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
441 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
442 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
443
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
444 if(type == tmp->type)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
445 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
446 /* If the box is going in the direction we want, then we
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
447 * return the entire sum of the items.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
448 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
449 for(z=0;z<tmp->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
450 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
451 if(tmp->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
452 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
453 int s, os;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
454
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
455 _count_size(tmp->items[z].hwnd, type, &s, &os);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
456 size += s;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
457 origsize += os;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
458 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
459 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
460 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
461 size += (type == BOXHORZ ? tmp->items[z].width : tmp->items[z].height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
462 origsize += (type == BOXHORZ ? tmp->items[z].origwidth : tmp->items[z].origheight);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
463 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
464 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
465 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
466 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
467 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
468 /* If the box is not going in the direction we want, then we only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
469 * want to return the maximum value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
470 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
471 int tmpsize = 0, tmporigsize = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
472
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
473 for(z=0;z<tmp->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
474 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
475 if(tmp->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
476 _count_size(tmp->items[z].hwnd, type, &tmpsize, &tmporigsize);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
477 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
478 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
479 tmpsize = (type == BOXHORZ ? tmp->items[z].width : tmp->items[z].height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
480 tmporigsize = (type == BOXHORZ ? tmp->items[z].origwidth : tmp->items[z].origheight);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
481 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
482
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
483 if(tmpsize > size)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
484 size = tmpsize;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
485 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
486 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
487
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
488 *xsize = size;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
489 *xorigsize = origsize;
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 /* Function: TrackRectangle
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
494 * Abstract: Tracks given rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
495 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
496 * If rclBounds is NULL, then track rectangle on entire desktop.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
497 * rclTrack is in window coorditates and will be mapped to
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
498 * desktop.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
499 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
500
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
501 BOOL _TrackRectangle(HWND hwndBase, RECTL* rclTrack, RECTL* rclBounds)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
502 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
503 TRACKINFO track;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
504 APIRET rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
505
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
506 track.cxBorder = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
507 track.cyBorder = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
508 track.cxGrid = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
509 track.cyGrid = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
510 track.cxKeyboard = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
511 track.cyKeyboard = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
512
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
513 if(!rclTrack)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
514 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
515
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
516 if(rclBounds)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
517 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
518 track.rclBoundary = *rclBounds;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
519 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
520 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
521 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
522 track.rclBoundary.yTop =
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
523 track.rclBoundary.xRight = 3000;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
524 track.rclBoundary.yBottom =
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
525 track.rclBoundary.xLeft = -3000;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
526 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
527
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
528 track.rclTrack = *rclTrack;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
529
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
530 WinMapWindowPoints(hwndBase,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
531 HWND_DESKTOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
532 (PPOINTL)&track.rclTrack,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
533 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
534
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
535 track.ptlMinTrackSize.x = track.rclTrack.xRight
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
536 - track.rclTrack.xLeft;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
537 track.ptlMinTrackSize.y = track.rclTrack.yTop
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
538 - track.rclTrack.yBottom;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
539 track.ptlMaxTrackSize.x = track.rclTrack.xRight
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
540 - track.rclTrack.xLeft;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
541 track.ptlMaxTrackSize.y = track.rclTrack.yTop
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
542 - track.rclTrack.yBottom;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
543
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
544 track.fs = TF_MOVE | TF_ALLINBOUNDARY;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
545
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
546 rc = WinTrackRect(HWND_DESKTOP, 0, &track);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
547
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
548 if(rc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
549 *rclTrack = track.rclTrack;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
550
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
551 return rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
552 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
553
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
554 /* This function calculates how much space the widgets and boxes require
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
555 * and does expansion as necessary.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
556 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
557 int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
558 int pass, int *usedpadx, int *usedpady)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
559 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
560 int z, currentx = 0, currenty = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
561 int vectorx = 0, vectory = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
562 int uymax = 0, uxmax = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
563 int upymax = 0, upxmax = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
564 /* Used for the SIZEEXPAND */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
565 int nux = *usedx, nuy = *usedy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
566 int nupx = *usedpadx, nupy = *usedpady;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
567
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
568 (*usedx) += (thisbox->pad * 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
569 (*usedy) += (thisbox->pad * 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
570
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
571 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
572 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
573 if(thisbox->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
574 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
575 int initialx, initialy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
576 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
577
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
578 initialx = x - (*usedx);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
579 initialy = y - (*usedy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
580
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
581 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
582 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
583 int newx, newy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
584 int nux = *usedx, nuy = *usedy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
585 int upx = *usedpadx + (tmp->pad*2), upy = *usedpady + (tmp->pad*2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
586
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
587 /* On the second pass we know how big the box needs to be and how
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
588 * much space we have, so we can calculate a ratio for the new box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
589 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
590 if(pass == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
591 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
592 int deep = *depth + 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
593
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
594 _resize_box(tmp, &deep, x, y, &nux, &nuy, 1, &upx, &upy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
595
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
596 tmp->upx = upx - *usedpadx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
597 tmp->upy = upy - *usedpady;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
598
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
599 newx = x - nux;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
600 newy = y - nuy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
601
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
602 tmp->width = thisbox->items[z].width = initialx - newx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
603 tmp->height = thisbox->items[z].height = initialy - newy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
604
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
605 tmp->parentxratio = thisbox->xratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
606 tmp->parentyratio = thisbox->yratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
607
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
608 tmp->parentpad = tmp->pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
609
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
610 /* Just in case */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
611 tmp->xratio = thisbox->xratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
612 tmp->yratio = thisbox->yratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
613
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
614 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
615 if(pass > 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
616 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
617 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
618 *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
619 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
620 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
621 #endif
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
622
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
623 if(thisbox->type == BOXVERT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
624 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
625 if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
626 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
627 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
628 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
629 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
630 if((thisbox->items[z].width-tmp->upx)!=0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
631 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
632 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
633 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
634 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
635 if((thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
636 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
637 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
638 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
639 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
640 if((thisbox->items[z].height-tmp->upy)!=0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
641 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
642 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
643
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
644 nux = *usedx; nuy = *usedy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
645 upx = *usedpadx + (tmp->pad*2); upy = *usedpady + (tmp->pad*2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
646 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
647
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
648 (*depth)++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
649
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
650 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
651 if(pass > 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
652 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
653 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
654 *depth, x, y, *usedx, *usedy, *usedpadx, *usedpady, tmp->xratio, tmp->yratio);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
655 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
656 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
657 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
658
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
659 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
660
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
661 (*depth)--;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
662
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
663 newx = x - nux;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
664 newy = y - nuy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
665
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
666 tmp->minwidth = thisbox->items[z].width = initialx - newx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
667 tmp->minheight = thisbox->items[z].height = initialy - newy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
668
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
669 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
670 if(pass > 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
671 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
672 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
673 *depth, x, y, *usedx, *usedy, *usedpadx, *usedpady, thisbox->items[z].width, thisbox->items[z].height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
674 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
675 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
676 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
677 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
678 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
679
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
680 if(pass > 1 && *depth > 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
681 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
682 if(thisbox->type == BOXVERT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
683 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
684 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
685 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
686
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
687 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
688 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
689 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
690 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: 21
diff changeset
691
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
692 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: 21
diff changeset
693 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
694 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
695
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
696 if(tmp)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
697 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
698 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: 21
diff changeset
699 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: 21
diff changeset
700 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
701 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
702
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
703 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
704 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
705 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
706 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
707 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
708 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
709 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
710 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
711 thisbox->items[z].xratio = thisbox->xratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
712 thisbox->items[z].yratio = thisbox->yratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
713 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
714
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
715 if(thisbox->type == BOXVERT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
716 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
717 if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
718 uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
719 if(thisbox->items[z].hsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
720 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
721 if(((thisbox->items[z].pad*2) + thisbox->items[z].width) > upxmax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
722 upxmax = (thisbox->items[z].pad*2) + thisbox->items[z].width;
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 if(thisbox->items[z].pad*2 > upxmax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
727 upxmax = thisbox->items[z].pad*2;
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 else
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 == -1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
733 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
734 /* figure out how much space this item requires */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
735 /* thisbox->items[z].width = */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
736 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
737 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
738 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
739 (*usedx) += thisbox->items[z].width + (thisbox->items[z].pad*2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
740 if(thisbox->items[z].hsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
741 (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
742 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
743 (*usedpadx) += thisbox->items[z].pad*2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
744 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
745 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
746 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
747 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
748 if((thisbox->items[z].height + (thisbox->items[z].pad*2)) > uymax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
749 uymax = (thisbox->items[z].height + (thisbox->items[z].pad*2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
750 if(thisbox->items[z].vsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
751 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
752 if(((thisbox->items[z].pad*2) + thisbox->items[z].height) > upymax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
753 upymax = (thisbox->items[z].pad*2) + thisbox->items[z].height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
754 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
755 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
756 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
757 if(thisbox->items[z].pad*2 > upymax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
758 upymax = 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 else
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 == -1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
764 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
765 /* figure out how much space this item requires */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
766 /* thisbox->items[z].height = */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
767 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
768 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
769 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
770 (*usedy) += thisbox->items[z].height + (thisbox->items[z].pad*2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
771 if(thisbox->items[z].vsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
772 (*usedpady) += (thisbox->items[z].pad*2) + thisbox->items[z].height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
773 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
774 (*usedpady) += thisbox->items[z].pad*2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
775 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
776 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
777 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
778
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
779 (*usedx) += uxmax;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
780 (*usedy) += uymax;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
781 (*usedpadx) += upxmax;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
782 (*usedpady) += upymax;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
783
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
784 currentx += thisbox->pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
785 currenty += thisbox->pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
786
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
787 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
788 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
789 *depth, *usedx, *usedy, *usedpadx, *usedpady, currentx, currenty, uxmax, uymax);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
790 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
791 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
792
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
793 /* The second pass is for expansion and actual placement. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
794 if(pass > 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
795 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
796 /* Any SIZEEXPAND items should be set to uxmax/uymax */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
797 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
798 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
799 if(thisbox->items[z].hsize == SIZEEXPAND && thisbox->type == BOXVERT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
800 thisbox->items[z].width = uxmax-(thisbox->items[z].pad*2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
801 if(thisbox->items[z].vsize == SIZEEXPAND && thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
802 thisbox->items[z].height = uymax-(thisbox->items[z].pad*2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
803 /* Run this code segment again to finalize the sized after setting uxmax/uymax values. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
804 if(thisbox->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
805 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
806 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
807
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
808 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
809 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
810 if(*depth > 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
811 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
812 if(thisbox->type == BOXVERT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
813 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
814 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
815 tmp->width = thisbox->items[z].width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
816 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
817 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
818 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
819 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
820 tmp->height = thisbox->items[z].height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
821 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
822 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
823
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
824 (*depth)++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
825
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
826 /*tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx) )/((float)(tmp->minwidth-tmp->upx));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
827 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(tmp->minheight-tmp->upy));*/
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
828
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
829 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
830 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
831 *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
832 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
833 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
834
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
835 _resize_box(tmp, depth, x, y, &nux, &nuy, 3, &nupx, &nupy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
836
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
837 (*depth)--;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
838
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
839 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
840 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
841 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
842
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
843 for(z=0;z<(thisbox->count);z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
844 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
845 int height = thisbox->items[z].height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
846 int width = thisbox->items[z].width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
847 int pad = thisbox->items[z].pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
848 HWND handle = thisbox->items[z].hwnd;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
849
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
850 /* When upxmax != pad*2 then ratios are incorrect. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
851 vectorx = (int)((width*thisbox->items[z].xratio)-width);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
852 vectory = (int)((height*thisbox->items[z].yratio)-height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
853
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
854 if(width > 0 && height > 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
855 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
856 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
857 /* This is a hack to fix rounding of the sizing */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
858 if(*depth == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
859 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
860 vectorx++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
861 vectory++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
862 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
863
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
864 /* If this item isn't going to expand... reset the vectors to 0 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
865 if(thisbox->items[z].vsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
866 vectory = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
867 if(thisbox->items[z].hsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
868 vectorx = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
869
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
870 WinQueryClassName(handle, 99, tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
871
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
872 if(strncmp(tmpbuf, "#2", 2)==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
873 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
874 /* Make the combobox big enough to drop down. :) */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
875 WinSetWindowPos(handle, HWND_TOP, currentx + pad, (currenty + pad) - 100,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
876 width + vectorx, (height + vectory) + 100, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
877 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
878 else if(strncmp(tmpbuf, "#6", 2)==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
879 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
880 /* Entryfields on OS/2 have a thick border that isn't on Windows and GTK */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
881 WinSetWindowPos(handle, HWND_TOP, (currentx + pad) + 3, (currenty + pad) + 3,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
882 (width + vectorx) - 6, (height + vectory) - 6, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
883 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
884 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
885 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
886 WinSetWindowPos(handle, HWND_TOP, currentx + pad, currenty + pad,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
887 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
888 if(thisbox->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
889 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
890 Box *boxinfo = WinQueryWindowPtr(handle, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
891
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
892 if(boxinfo && boxinfo->grouphwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
893 WinSetWindowPos(boxinfo->grouphwnd, HWND_TOP, 0, 0,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
894 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
895
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
896 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
897
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
898 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
899
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
900 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
901 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
902 *depth, currentx, currenty, pad, width, height, vectorx, vectory,thisbox->type == BOXHORZ ? "Horizontal" : "Vertical");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
903 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
904 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
905
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
906 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
907 currentx += width + vectorx + (pad * 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
908 if(thisbox->type == BOXVERT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
909 currenty += height + vectory + (pad * 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
910 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
911 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
912 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
913 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
914 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
915
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
916 void _do_resize(Box *thisbox, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
917 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
918 if(x != 0 && y != 0) {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
919 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
920 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
921 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
922
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
923 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
924
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
925 if(usedx-usedpadx == 0 || usedy-usedpady == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
926 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
927
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
928 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
929 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
930
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
931 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
932 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
933 x, y, usedx, usedy, usedpadx, usedpady, thisbox->xratio, thisbox->yratio);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
934 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
935 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
936
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
937 usedx = usedy = usedpadx = usedpady = depth = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
938
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
939 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
940 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
941 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
942 x, y, usedx, usedy, usedpadx, usedpady);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
943 reopen();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
944 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
945 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
946 }
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 /* This procedure handles WM_QUERYTRACKINFO requests from the frame */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
950 MRESULT EXPENTRY _sizeproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
951 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
952 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
953
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
954 switch(msg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
955 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
956 case WM_QUERYTRACKINFO:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
957 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
958 if(blah && *blah)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
959 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
960 PTRACKINFO ptInfo;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
961 int res;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
962 PFNWP myfunc = *blah;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
963 res = (int)myfunc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
964
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
965 ptInfo = (PTRACKINFO)(mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
966
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
967 ptInfo->ptlMinTrackSize.y = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
968 ptInfo->ptlMinTrackSize.x = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
969
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
970 return (MRESULT)res;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
971 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
972 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
973 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
974 if(blah && *blah)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
975 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
976 PFNWP myfunc = *blah;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
977 return myfunc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
978 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
979
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
980 return WinDefWindowProc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
981 }
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
982 /* This procedure handles drawing of a status border */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
983 MRESULT EXPENTRY _statusproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
984 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
985 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
986
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
987 if(blah && *blah)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
988 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
989 PFNWP myfunc = *blah;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
990
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
991 switch(msg)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
992 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
993 case WM_PAINT:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
994 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
995 HPS hpsPaint;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
996 RECTL rclPaint;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
997 POINTL ptl1, ptl2;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
998 char buf[1024];
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
999
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1000 hpsPaint = WinBeginPaint(hWnd, 0, 0);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1001 WinQueryWindowRect(hWnd, &rclPaint);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1002 WinFillRect(hpsPaint, &rclPaint, CLR_PALEGRAY);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1003
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1004 GpiSetColor(hpsPaint, CLR_DARKGRAY);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1005 ptl1.x = 0;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1006 ptl2.y = ptl1.y = rclPaint.yTop - rclPaint.yBottom;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1007 ptl2.x = rclPaint.xRight - rclPaint.xLeft;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1008 GpiMove(hpsPaint, &ptl1);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1009 GpiLine(hpsPaint, &ptl2);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1010 ptl2.y = ptl2.x = 0;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1011 GpiMove(hpsPaint, &ptl1);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1012 GpiLine(hpsPaint, &ptl2);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1013
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1014 GpiSetColor(hpsPaint, CLR_WHITE);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1015 ptl2.x = ptl1.x = rclPaint.xRight - rclPaint.xLeft;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1016 ptl1.y = 0;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1017 ptl2.y = rclPaint.yTop - rclPaint.yBottom;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1018 GpiMove(hpsPaint, &ptl1);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1019 GpiLine(hpsPaint, &ptl2);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1020 ptl2.y = ptl2.x = 0;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1021 GpiMove(hpsPaint, &ptl1);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1022 GpiLine(hpsPaint, &ptl2);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1023
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1024 WinQueryWindowText(hWnd, 1024, buf);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1025 rclPaint.xLeft += 3;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1026 rclPaint.xRight--;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1027 rclPaint.yTop--;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1028 rclPaint.yBottom++;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1029
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1030 GpiSetColor(hpsPaint, CLR_BLACK);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1031 WinDrawText(hpsPaint, -1, buf, &rclPaint, DT_TEXTATTRS, DT_TEXTATTRS, DT_VCENTER | DT_LEFT | DT_TEXTATTRS);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1032 WinEndPaint(hpsPaint);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1033
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1034 return (MRESULT)TRUE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1035 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1036 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1037 return myfunc(hWnd, msg, mp1, mp2);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1038 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1039
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1040 return WinDefWindowProc(hWnd, msg, mp1, mp2);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1041 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1042
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1043 /* Originally just intended for entryfields, it now serves as a generic
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1044 * procedure for handling TAB presses to change input focus on controls.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1045 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1046 MRESULT EXPENTRY _entryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1047 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1048 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1049
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1050 switch(msg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1051 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1052 case WM_CHAR:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1053 if(SHORT1FROMMP(mp2) == '\t')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1054 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1055 _shift_focus(hWnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1056 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1057 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1058 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1059 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1060 if(blah && *blah)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1061 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1062 PFNWP myfunc = *blah;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1063 return myfunc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1064 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1065
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1066 return WinDefWindowProc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1067 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1068
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1069 /* Handle correct painting of a combobox with the WS_CLIPCHILDREN
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1070 * flag enabled, and also handle TABs to switch input focus.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1071 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1072 MRESULT EXPENTRY _comboproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1073 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1074 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1075
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1076 switch(msg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1077 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1078 case WM_CHAR:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1079 if(SHORT1FROMMP(mp2) == '\t')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1080 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1081 _shift_focus(hWnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1082 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1083 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1084 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1085 case WM_PAINT:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1086 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1087 HWND parent = WinQueryWindow(hWnd, QW_PARENT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1088 ULONG bcol, av[32];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1089 HPS hpsPaint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1090 POINTL ptl; /* Add 6 because it has a thick border like the entryfield */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1091 unsigned long width, height, thumbheight = WinQuerySysValue(HWND_DESKTOP, SV_CYVSCROLLARROW) + 6;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1092
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1093 WinQueryPresParam(parent, PP_BACKGROUNDCOLORINDEX, 0, &bcol, sizeof(ULONG), &av, QPF_ID1COLORINDEX | QPF_NOINHERIT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1094 dw_window_get_pos_size(hWnd, 0, 0, &width, &height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1095
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1096 hpsPaint = WinGetPS(hWnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1097 GpiSetColor(hpsPaint, CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1098
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1099 ptl.x = 0;
24
d9e87e8bcf1d Updated dynamic windows to build with EMX.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 23
diff changeset
1100 ptl.y = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1101 GpiMove(hpsPaint, &ptl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1102
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1103 ptl.x = width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1104 ptl.y = height - thumbheight;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1105 GpiBox(hpsPaint, DRO_FILL, &ptl, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1106
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1107 WinReleasePS(hpsPaint);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1108 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1109 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1110 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1111 if(blah && *blah)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1112 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1113 PFNWP myfunc = *blah;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1114 return myfunc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1115 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1116
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1117 return WinDefWindowProc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1118 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1119
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1120 void _GetPPFont(HWND hwnd, char *buff)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1121 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1122 ULONG AttrFound;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1123 BYTE AttrValue[128];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1124 ULONG cbRetLen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1125
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1126 cbRetLen = WinQueryPresParam(hwnd,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1127 PP_FONTNAMESIZE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1128 0,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1129 &AttrFound,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1130 sizeof(AttrValue),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1131 &AttrValue,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1132 QPF_NOINHERIT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1133
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1134 if(PP_FONTNAMESIZE == AttrFound && cbRetLen)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1135 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1136 memcpy(buff, AttrValue, cbRetLen);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1137 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1138 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1139
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1140 /* Returns height of specified window. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1141 int _get_height(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1142 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1143 unsigned long height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1144 dw_window_get_pos_size(handle, NULL, NULL, NULL, &height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1145 return (int)height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1146 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1147
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1148 /* Find the height of the frame a desktop style window is sitting on */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1149 int _get_frame_height(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1150 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1151 while(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1152 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1153 HWND client;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1154 if((client = WinWindowFromID(handle, FID_CLIENT)) != NULLHANDLE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1155 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1156 return _get_height(WinQueryWindow(handle, QW_PARENT));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1157 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1158 handle = WinQueryWindow(handle, QW_PARENT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1159 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1160 return dw_screen_height();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1161 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1162
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1163 #ifndef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1164 MRESULT EXPENTRY _run_event(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1165 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1166 int result = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1167 SignalHandler *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1168 ULONG origmsg = msg;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1169
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1170 if(msg == WM_BUTTON2DOWN || msg == WM_BUTTON3DOWN)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1171 msg = WM_BUTTON1DOWN;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1172 if(msg == WM_BUTTON2UP || msg == WM_BUTTON3UP)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1173 msg = WM_BUTTON1UP;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1174
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1175 /* Find any callbacks for this function */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1176 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1177 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1178 if(tmp->message == msg || msg == WM_CONTROL)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1179 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1180 switch(msg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1181 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1182 case WM_SETFOCUS:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1183 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1184 if(mp2)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1185 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1186 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
1187
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1188 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1189 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1190 result = setfocusfunc(tmp->window, tmp->data);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1191 tmp = NULL;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1192 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1193 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1194 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1195 break;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1196 case WM_SIZE:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1197 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1198 int (*sizefunc)(HWND, int, int, void *) = (int (*)(HWND, int, int, void *))tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1199
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1200 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1201 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1202 result = sizefunc(tmp->window, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1203 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1204 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1205 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1206 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1207 case WM_BUTTON1DOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1208 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1209 POINTS pts = (*((POINTS*)&mp1));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1210 int (*buttonfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1211
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1212 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1213 {
24
d9e87e8bcf1d Updated dynamic windows to build with EMX.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 23
diff changeset
1214 int button = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1215
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1216 switch(origmsg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1217 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1218 case WM_BUTTON1DOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1219 button = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1220 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1221 case WM_BUTTON2DOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1222 button = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1223 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1224 case WM_BUTTON3DOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1225 button = 3;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1226 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1227 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1228
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1229 result = buttonfunc(tmp->window, pts.x, _get_frame_height(tmp->window) - pts.y, button, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1230 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1231 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1232 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1233 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1234 case WM_BUTTON1UP:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1235 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1236 POINTS pts = (*((POINTS*)&mp1));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1237 int (*buttonfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1238
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1239 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1240 {
24
d9e87e8bcf1d Updated dynamic windows to build with EMX.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 23
diff changeset
1241 int button = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1242
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1243 switch(origmsg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1244 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1245 case WM_BUTTON1UP:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1246 button = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1247 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1248 case WM_BUTTON2UP:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1249 button = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1250 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1251 case WM_BUTTON3UP:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1252 button = 3;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1253 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1254 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1255
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1256 result = buttonfunc(tmp->window, pts.x, WinQueryWindow(tmp->window, QW_PARENT) == HWND_DESKTOP ? dw_screen_height() - pts.y : _get_height(tmp->window) - pts.y, button, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1257 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1258 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1259 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1260 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1261 case WM_MOUSEMOVE:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1262 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1263 int (*motionfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1264
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1265 if(hWnd == tmp->window || WinWindowFromID(tmp->window, FID_CLIENT) == hWnd || WinQueryCapture(HWND_DESKTOP) == tmp->window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1266 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1267 int keys = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1268 SHORT x = SHORT1FROMMP(mp1), y = SHORT2FROMMP(mp1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1269
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1270 if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1271 keys = DW_BUTTON1_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1272 if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1273 keys |= DW_BUTTON2_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1274 if (WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1275 keys |= DW_BUTTON3_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1276
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1277 result = motionfunc(tmp->window, x, _get_frame_height(tmp->window) - y, keys, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1278 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1279 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1280 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1281 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1282 case WM_CHAR:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1283 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1284 int (*keypressfunc)(HWND, int, void *) = (int (*)(HWND, int, void *))tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1285
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1286 if(hWnd == tmp->window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1287 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1288 result = keypressfunc(tmp->window, SHORT1FROMMP(mp2), tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1289 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1290 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1291 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1292 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1293 case WM_CLOSE:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1294 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1295 int (*closefunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1296
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1297 if(hWnd == tmp->window || hWnd == WinWindowFromID(tmp->window, FID_CLIENT))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1298 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1299 result = closefunc(tmp->window, tmp->data);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
1300 if(result)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
1301 result = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1302 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1303 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1304 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1305 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1306 case WM_PAINT:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1307 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1308 HPS hps;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1309 DWExpose exp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1310 int (*exposefunc)(HWND, DWExpose *, void *) = (int (*)(HWND, DWExpose *, void *))tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1311 RECTL rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1312
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1313 if(hWnd == tmp->window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1314 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1315 int height = _get_height(hWnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1316
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1317 hps = WinBeginPaint(hWnd, 0L, &rc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1318 exp.x = rc.xLeft;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1319 exp.y = height - rc.yTop - 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1320 exp.width = rc.xRight - rc. xLeft;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1321 exp.height = rc.yTop - rc.yBottom;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1322 result = exposefunc(hWnd, &exp, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1323 WinEndPaint(hps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1324 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1325 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1326 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1327 case WM_COMMAND:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1328 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1329 int (*clickfunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1330 ULONG command = COMMANDMSG(&msg)->cmd;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1331
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1332 if(tmp->window < 65536 && command == tmp->window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1333 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1334 result = clickfunc(tmp->window, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1335 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1336 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1337 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1338 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1339 case WM_CONTROL:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1340 if(tmp->message == SHORT2FROMMP(mp1))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1341 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1342 switch(SHORT2FROMMP(mp1))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1343 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1344 case CN_ENTER:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1345 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1346 int (*containerselectfunc)(HWND, char *, void *) = (int (*)(HWND, char *, void *))tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1347 int id = SHORT1FROMMP(mp1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1348 HWND conthwnd = dw_window_from_id(hWnd, id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1349 char *text = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1350
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1351 if(mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1352 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1353 PRECORDCORE pre;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1354
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1355 pre = ((PNOTIFYRECORDENTER)mp2)->pRecord;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1356 if(pre)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1357 text = pre->pszIcon;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1358 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1359
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1360 if(tmp->window == conthwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1361 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1362 result = containerselectfunc(tmp->window, text, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1363 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1364 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1365 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1366 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1367 case CN_CONTEXTMENU:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1368 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1369 int (*containercontextfunc)(HWND, char *, int, int, void *) = (int (*)(HWND, char *, int, int, void *))tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1370 int id = SHORT1FROMMP(mp1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1371 HWND conthwnd = dw_window_from_id(hWnd, id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1372 char *text = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1373 LONG x,y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1374
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1375 if(mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1376 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1377 PRECORDCORE pre;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1378
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1379 pre = (PRECORDCORE)mp2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1380 text = pre->pszIcon;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1381 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1382
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1383
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1384 dw_pointer_query_pos(&x, &y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1385
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1386 if(tmp->window == conthwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1387 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1388 result = containercontextfunc(tmp->window, text, x, y, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1389 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1390 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1391 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1392 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1393 case LN_SELECT:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1394 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1395 int (*listboxselectfunc)(HWND, int, void *) = (int (*)(HWND, int, void *))tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1396 int id = SHORT1FROMMP(mp1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1397 HWND conthwnd = dw_window_from_id(hWnd, id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1398
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1399 if(tmp->window == conthwnd || (!id && tmp->window == (HWND)mp2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1400 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1401 char buf1[500], classbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1402 unsigned int index = dw_listbox_selected(tmp->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1403
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1404 dw_listbox_query_text(tmp->window, index, buf1, 500);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1405
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1406 WinQueryClassName(tmp->window, 99, classbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1407
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
1408 if(id && strncmp(classbuf, "#2", 2)==0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1409 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1410 char *buf2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1411
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1412 buf2 = dw_window_get_text(tmp->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1413
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1414 /* This is to make sure the listboxselect function doesn't
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1415 * get called if the user is modifying the entry text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1416 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1417 if(buf2 && *buf2 && *buf1 && strncmp(buf1, buf2, 500) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1418 result = listboxselectfunc(tmp->window, index, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1419
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1420 if(buf2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1421 free(buf2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1422 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1423 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1424 result = listboxselectfunc(tmp->window, index, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1425
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1426 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1427 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1428 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1429 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1430 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1431 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1432 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1433 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1434 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1435
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1436 if(origmsg == WM_BUTTON1DOWN)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1437 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1438 if(tmp->message == WM_USER+1)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1439 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1440 if(tmp->window == hWnd)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1441 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1442 QUERYRECFROMRECT rc;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1443 POINTS pts = (*((POINTS*)&mp1));
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1444 RECORDCORE *prc;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1445
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1446 rc.cb = sizeof(QUERYRECFROMRECT);
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1447 rc.rect.xLeft = pts.x;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1448 rc.rect.xRight = pts.x + 1;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1449 rc.rect.yTop = pts.y;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1450 rc.rect.yBottom = pts.y - 1;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1451 rc.fsSearch = CMA_PARTIAL | CMA_ITEMORDER;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1452
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1453 prc = (RECORDCORE *)WinSendMsg(hWnd, CM_QUERYRECORDFROMRECT, (MPARAM)CMA_FIRST, MPFROMP(&rc));
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1454
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1455 if(prc)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1456 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1457 int (*treeselectfunc)(HWND, HWND, char *, void *) = (int (*)(HWND, HWND, char *, void *))tmp->signalfunction;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1458
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1459 result = treeselectfunc(tmp->window, (HWND)prc, prc->pszIcon, tmp->data);
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1460
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1461 tmp = NULL;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1462 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1463 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1464 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1465 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1466
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1467 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1468 tmp = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1469
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1470 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1471
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1472 return (MRESULT)result;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1473 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1474 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1475
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1476 /* Handles control messages sent to the box (owner). */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1477 MRESULT EXPENTRY _controlproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1478 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1479 Box *blah = WinQueryWindowPtr(hWnd, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1480
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1481 #ifndef NO_SIGNALS
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1482 switch(msg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1483 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1484 case WM_CONTROL:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1485 _run_event(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1486 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1487 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
1488 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1489 if(blah && blah->oldproc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1490 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1491 return blah->oldproc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1492 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1493
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1494 return WinDefWindowProc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1495 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1496
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1497 /* The main window procedure for Dynamic Windows, all the resizing code is done here. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1498 MRESULT EXPENTRY _wndproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1499 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1500 int result = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1501 static int command_active = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1502 void (* windowfunc)(PVOID) = 0L;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1503
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1504 if(filterfunc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1505 result = filterfunc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1506
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1507 #ifndef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1508 if(result == -1 && !command_active)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1509 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1510 /* Make sure we don't end up in infinite recursion */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1511 command_active = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1512
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1513 result = (int)_run_event(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1514
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1515 command_active = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1516 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1517 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1518
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1519 /* Now that any handlers are done... do normal processing */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1520 switch( msg )
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1521 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1522 case WM_ERASEBACKGROUND:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1523 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1524
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1525 case WM_PAINT:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1526 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1527 HPS hps;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1528 RECTL rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1529
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1530 hps = WinBeginPaint( hWnd, 0L, &rc );
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1531 WinEndPaint( hps );
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1532 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1533 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1534
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1535 case WM_SIZE:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1536 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1537 Box *mybox = (Box *)WinQueryWindowPtr(hWnd, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1538
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1539 if(!SHORT1FROMMP(mp2) && !SHORT2FROMMP(mp2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1540 return (MPARAM)TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1541
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1542 if(mybox && mybox->flags != DW_MINIMIZED)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1543 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1544 /* Hide the window when recalculating to reduce
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1545 * CPU load.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1546 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1547 WinShowWindow(hWnd, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1548
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1549 _do_resize(mybox, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1550
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1551 WinShowWindow(hWnd, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1552 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1553 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1554 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1555 case WM_MINMAXFRAME:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1556 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1557 Box *mybox = (Box *)WinQueryWindowPtr(hWnd, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1558 SWP *swp = (SWP *)mp1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1559
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1560 if(mybox && (swp->fl & SWP_MINIMIZE))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1561 mybox->flags = DW_MINIMIZED;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1562
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1563 if(mybox && (swp->fl & SWP_RESTORE))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1564 mybox->flags = 0;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1565
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1566 if(mybox && (swp->fl & SWP_MAXIMIZE))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1567 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1568 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1569
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1570 mybox->flags = 0;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1571
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1572 /* Hide the window when recalculating to reduce
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1573 * CPU load.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1574 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1575 WinShowWindow(hWnd, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1576
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1577 _do_resize(mybox, swp->cx, swp->cy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1578
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1579 if(mybox->count == 1 && mybox->items[0].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1580 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1581 mybox = (Box *)WinQueryWindowPtr(mybox->items[0].hwnd, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1582
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1583 for(z=0;z<mybox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1584 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1585 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1586
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1587 WinQueryClassName(mybox->items[z].hwnd, 99, tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1588
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1589 /* If we have a notebook we resize the page again. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1590 if(strncmp(tmpbuf, "#40", 3)==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1591 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1592 unsigned long x, y, width, height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1593 int page = dw_notebook_page_query(mybox->items[z].hwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1594 HWND pagehwnd = (HWND)WinSendMsg(mybox->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND, MPFROMLONG(page), 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1595 RECTL rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1596
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1597 Box *pagebox = (Box *)WinQueryWindowPtr(pagehwnd, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1598 if(pagebox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1599 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1600 dw_window_get_pos_size(mybox->items[z].hwnd, &x, &y, &width, &height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1601
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1602 rc.xLeft = x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1603 rc.yBottom = y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1604 rc.xRight = x + width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1605 rc.yTop = y + height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1606
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1607 WinSendMsg(mybox->items[z].hwnd, BKM_CALCPAGERECT, (MPARAM)&rc, (MPARAM)TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1608
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1609 _do_resize(pagebox, rc.xRight - rc.xLeft, rc.yTop - rc.yBottom);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1610 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1611
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1612 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1613 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1614
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1615 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1616
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1617 WinShowWindow(hWnd, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1618 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1619 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1620 break;
20
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1621 case WM_CONTROL:
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1622 switch(SHORT2FROMMP(mp1))
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1623 {
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1624 case BKN_PAGESELECTEDPENDING:
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1625 {
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1626 PAGESELECTNOTIFY *psn = (PAGESELECTNOTIFY *)mp2;
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1627 HWND pagehwnd = (HWND)WinSendMsg(psn->hwndBook, BKM_QUERYPAGEWINDOWHWND, MPFROMLONG(psn->ulPageIdNew), 0);
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1628 Box *pagebox = (Box *)WinQueryWindowPtr(pagehwnd, QWP_USER);
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1629 unsigned long x, y, width, height;
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1630 RECTL rc;
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1631
21
c6e76b796b28 Stopped unnecessary redrawing when switching to the same page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 20
diff changeset
1632 if(pagebox && psn->ulPageIdNew != psn->ulPageIdCur)
20
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1633 {
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1634 dw_window_get_pos_size(psn->hwndBook, &x, &y, &width, &height);
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1635
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1636 rc.xLeft = x;
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1637 rc.yBottom = y;
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1638 rc.xRight = x + width;
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1639 rc.yTop = y + height;
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1640
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1641 WinSendMsg(psn->hwndBook, BKM_CALCPAGERECT, (MPARAM)&rc, (MPARAM)TRUE);
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1642
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1643 _do_resize(pagebox, rc.xRight - rc.xLeft, rc.yTop - rc.yBottom);
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1644 }
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1645 }
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1646 break;
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1647 }
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
1648 break;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1649 case WM_CLOSE:
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
1650 if(result == -1)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
1651 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
1652 dw_window_destroy(WinQueryWindow(hWnd, QW_PARENT));
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
1653 return (MRESULT)TRUE;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
1654 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
1655 break;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1656 case WM_USER:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1657 windowfunc = (void (*)(void *))mp1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1658
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1659 if(windowfunc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1660 windowfunc((void *)mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1661 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1662 case WM_CHAR:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1663 if(SHORT1FROMMP(mp2) == '\t')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1664 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1665 _shift_focus(hWnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1666 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1667 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1668 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1669 case WM_DESTROY:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1670 /* Free memory before destroying */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1671 _free_window_memory(hWnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1672 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1673 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
1674 if(result != -1)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1675 return (MRESULT)result;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1676 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1677 return WinDefWindowProc(hWnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1678 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1679
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1680 void _changebox(Box *thisbox, int percent, int type)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1681 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1682 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1683
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1684 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1685 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1686 if(thisbox->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1687 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1688 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1689 _changebox(tmp, percent, type);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1690 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1691 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1692 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1693 if(type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1694 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1695 if(thisbox->items[z].hsize == SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1696 thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0)));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1697 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1698 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1699 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1700 if(thisbox->items[z].vsize == SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1701 thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0)));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1702 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1703 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1704 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1705 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1706
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1707 /* This handles any activity on the splitbars (sizers) */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1708 MRESULT EXPENTRY _splitwndproc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1709 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1710 HWND hwndFrame = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1711 Box *thisbox = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1712
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1713 hwndFrame = WinQueryWindow(hwnd, QW_PARENT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1714 if(hwndFrame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1715 thisbox = WinQueryWindowPtr(hwndFrame, QWL_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1716
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1717 switch (msg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1718 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1719 case WM_ACTIVATE:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1720 case WM_SETFOCUS:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1721 return (MRESULT)(FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1722
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1723 case WM_PAINT:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1724 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1725 HPS hpsPaint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1726 RECTL rclPaint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1727 POINTL ptlStart[SPLITBAR_WIDTH];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1728 POINTL ptlEnd[SPLITBAR_WIDTH];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1729 USHORT i;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1730
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1731 hpsPaint = WinBeginPaint(hwnd, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1732 WinQueryWindowRect(hwnd, &rclPaint);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1733
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1734 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1735 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1736 for(i = 0; i < SPLITBAR_WIDTH; i++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1737 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1738 ptlStart[i].x = rclPaint.xLeft + i;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1739 ptlStart[i].y = rclPaint.yTop;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1740
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1741 ptlEnd[i].x = rclPaint.xLeft + i;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1742 ptlEnd[i].y = rclPaint.yBottom;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1743 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1744 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1745 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1746 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1747 for(i = 0; i < SPLITBAR_WIDTH; i++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1748 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1749 ptlStart[i].x = rclPaint.xLeft;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1750 ptlStart[i].y = rclPaint.yBottom + i;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1751
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1752 ptlEnd[i].x = rclPaint.xRight;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1753 ptlEnd[i].y = rclPaint.yBottom + i;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1754 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1755 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1756
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1757 for(i = 0; i < SPLITBAR_WIDTH; i++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1758 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1759 GpiSetColor( hpsPaint, lColor[i]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1760 GpiMove(hpsPaint, &ptlStart[i]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1761 GpiLine(hpsPaint, &ptlEnd[i]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1762 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1763 WinEndPaint(hpsPaint);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1764 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1765 return MRFROMSHORT(FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1766
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1767 case WM_MOUSEMOVE:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1768 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1769 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1770 WinSetPointer(HWND_DESKTOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1771 WinQuerySysPointer(HWND_DESKTOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1772 SPTR_SIZEWE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1773 FALSE));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1774 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1775 WinSetPointer(HWND_DESKTOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1776 WinQuerySysPointer(HWND_DESKTOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1777 SPTR_SIZENS,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1778 FALSE));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1779 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1780 return MRFROMSHORT(FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1781 case WM_BUTTON1DOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1782 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1783 APIRET rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1784 RECTL rclFrame;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1785 RECTL rclBounds;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1786 RECTL rclStart;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1787 USHORT startSize, orig, actual;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1788
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1789 WinQueryWindowRect(hwnd, &rclFrame);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1790 WinQueryWindowRect(hwnd, &rclStart);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1791
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1792 WinQueryWindowRect(hwndFrame, &rclBounds);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1793
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1794 WinMapWindowPoints(hwndFrame, HWND_DESKTOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1795 (PPOINTL)&rclBounds, 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1796 WinMapWindowPoints(hwnd, HWND_DESKTOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1797 (PPOINTL)&rclStart, 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1798
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1799 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1800 int z, pastsplitbar = FALSE, found = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1801 orig = actual = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1802
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1803 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1804 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1805 if(thisbox->items[z].hwnd == hwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1806 pastsplitbar = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1807 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1808 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1809 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1810 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1811 int tmpwidth, tmporigwidth;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1812
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1813 if(thisbox->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1814 _count_size(thisbox->items[z].hwnd, BOXHORZ, &tmpwidth, &tmporigwidth);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1815 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1816 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1817 tmpwidth = thisbox->items[z].width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1818 tmporigwidth = thisbox->items[z].origwidth;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1819 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1820
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1821 if(thisbox->items[z].hsize != SIZESTATIC && tmpwidth > actual && tmporigwidth)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1822 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1823 found = pastsplitbar;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1824 orig = tmporigwidth;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1825 actual = tmpwidth;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1826 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1827 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1828 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1829 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1830 int tmpheight, tmporigheight;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1831
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1832 if(thisbox->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1833 _count_size(thisbox->items[z].hwnd, BOXVERT, &tmpheight, &tmporigheight);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1834 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1835 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1836 tmpheight = thisbox->items[z].height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1837 tmporigheight = thisbox->items[z].origheight;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1838 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1839
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1840 if(thisbox->items[z].vsize != SIZESTATIC && tmpheight > actual && tmporigheight)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1841 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1842 found = pastsplitbar;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1843 orig = tmporigheight;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1844 actual = tmpheight;
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 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1848 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1849
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1850 /* If we couldn't determine a valid scale... then abort */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1851 if(!orig || !actual)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1852 return MRFROMSHORT(FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1853
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1854 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1855 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1856 if(found)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1857 startSize = (rclStart.xLeft - rclBounds.xLeft)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1858 * (((float)actual)/((float)orig));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1859 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1860 startSize = (rclStart.xLeft - rclBounds.xLeft)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1861 * (((float)orig)/((float)actual));
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(found)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1866 startSize = (rclStart.yBottom - rclBounds.yBottom)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1867 * (((float)actual)/((float)orig));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1868 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1869 startSize = (rclStart.yBottom - rclBounds.yBottom)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1870 * (((float)orig)/((float)actual));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1871 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1872 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1873
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1874 rc = _TrackRectangle(hwnd, &rclFrame, &rclBounds);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1875
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1876 if(rc == TRUE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1877 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1878 USHORT usNewRB;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1879 USHORT percent;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1880 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1881
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1882 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1883 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1884 usNewRB = rclFrame.xLeft
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1885 - rclBounds.xLeft;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1886 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1887 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1888 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1889 usNewRB = rclFrame.yBottom
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1890 - rclBounds.yBottom;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1891 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1892
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1893 /* We don't want the item to disappear completely */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1894 if(!usNewRB)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1895 usNewRB++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1896
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1897 if(!startSize)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1898 startSize++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1899
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1900 percent = (usNewRB*100)/startSize;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1901
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1902 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1903 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1904 if(thisbox->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1905 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1906 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
1907
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
1908 if(tmp)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
1909 _changebox(tmp, percent, thisbox->type);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1910 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1911 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1912 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1913 if(thisbox->items[z].hwnd == hwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1914 percent = (startSize*100)/usNewRB;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1915
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1916 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1917 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1918 if(thisbox->items[z].hsize == SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1919 thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0)));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1920 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1921 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1922 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1923 if(thisbox->items[z].vsize == SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1924 thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0)));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1925 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1926 }
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 _ResetWindow(WinQueryWindow(hwnd, QW_OWNER));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1930 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1931 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1932 return MRFROMSHORT(FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1933 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1934 return WinDefWindowProc(hwnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1935 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1936
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1937 /* Function: BubbleProc
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1938 * Abstract: Subclass procedure for bubble help
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1939 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1940 MRESULT EXPENTRY _BubbleProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1941 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1942 MRESULT res;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1943 PFNWP proc = (PFNWP)WinQueryWindowPtr(hwnd, QWL_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1944
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1945 if(proc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1946 res = proc(hwnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1947 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1948 res = WinDefWindowProc(hwnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1949
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1950 if(msg == WM_PAINT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1951 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1952 POINTL ptl;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1953 HPS hpsTemp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1954 RECTL rcl;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1955 int height, width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1956
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1957 WinQueryWindowRect(hwnd, &rcl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1958 height = rcl.yTop - rcl.yBottom - 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1959 width = rcl.xRight - rcl.xLeft - 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1960
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1961 /* Draw a border around the bubble help */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1962 hpsTemp = WinGetPS(hwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1963 GpiSetColor(hpsTemp, DW_CLR_BLACK);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1964 ptl.x = ptl.y = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1965 GpiMove(hpsTemp, &ptl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1966 ptl.x = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1967 ptl.y = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1968 GpiLine(hpsTemp, &ptl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1969 ptl.x = ptl.y = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1970 GpiMove(hpsTemp, &ptl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1971 ptl.y = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1972 ptl.x = width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1973 GpiLine(hpsTemp, &ptl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1974 ptl.x = width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1975 ptl.y = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1976 GpiMove(hpsTemp, &ptl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1977 ptl.x = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1978 ptl.y = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1979 GpiLine(hpsTemp, &ptl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1980 ptl.x = width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1981 ptl.y = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1982 GpiMove(hpsTemp, &ptl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1983 ptl.y = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1984 ptl.x = width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1985 GpiLine(hpsTemp, &ptl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1986 WinReleasePS(hpsTemp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1987 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1988 return res;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1989 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1990
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1991 /* Function: BtProc
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1992 * Abstract: Subclass procedure for buttons
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1993 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1994
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1995 MRESULT EXPENTRY _BtProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1996 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1997 BubbleButton *bubble;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1998
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1999 bubble = (BubbleButton *)WinQueryWindowPtr(hwnd, QWL_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2000
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2001 if(!bubble)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2002 return WinDefWindowProc(hwnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2003
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2004 switch(msg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2005 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2006 #ifndef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2007 case WM_BUTTON1UP:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2008 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2009 SignalHandler *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2010
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2011 if(WinIsWindowEnabled(hwnd))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2012 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2013 /* Find any callbacks for this function */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2014 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2015 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2016 if(tmp->message == WM_COMMAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2017 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2018 /* Make sure it's the right window, and the right ID */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2019 if(tmp->window == hwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2020 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2021 /* Due to the fact that if we run the function
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2022 * here, finishing actions on the button will occur
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2023 * after we run the signal handler. So we post the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2024 * message so the button can finish what it needs to
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2025 * do before we run our handler.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2026 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2027 WinPostMsg(hwnd, WM_USER, (MPARAM)tmp, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2028 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2029 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2030 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2031 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2032 tmp= tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2033 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2034 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2035 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2036 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2037 case WM_USER:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2038 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2039 SignalHandler *tmp = (SignalHandler *)mp1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2040 int (*clickfunc)(HWND, void *) = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2041
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2042 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2043 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2044 clickfunc = (int (*)(HWND, void *))tmp->signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2045
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2046 clickfunc(tmp->window, tmp->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2047 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2048 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2049 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2050 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2051 case WM_CHAR:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2052 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2053 #ifndef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2054 /* A button press should also occur for an ENTER or SPACE press
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2055 * while the button has the active input focus.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2056 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2057 if(SHORT1FROMMP(mp2) == '\r' || SHORT1FROMMP(mp2) == ' ')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2058 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2059 SignalHandler *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2060
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2061 /* Find any callbacks for this function */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2062 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2063 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2064 if(tmp->message == WM_COMMAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2065 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2066 /* Make sure it's the right window, and the right ID */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2067 if(tmp->window == hwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2068 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2069 WinPostMsg(hwnd, WM_USER, (MPARAM)tmp, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2070 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2071 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2072 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2073 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2074 tmp= tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2075 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2076 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2077 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2078 if(SHORT1FROMMP(mp2) == '\t')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2079 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2080 _shift_focus(hwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2081 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2082 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2083 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2084 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2085 case 0x041f:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2086 if (hwndBubble)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2087 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2088 WinDestroyWindow(hwndBubble);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2089 hwndBubble = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2090 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2091 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2092
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2093 case 0x041e:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2094
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2095 if(!*bubble->bubbletext)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2096 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2097
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2098
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2099 if(hwndBubble)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2100 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2101 WinDestroyWindow(hwndBubble);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2102 hwndBubble = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2103 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2104
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2105 if(!hwndBubble)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2106 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2107 HPS hpsTemp = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2108 LONG lHight;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2109 LONG lWidth;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2110 POINTL txtPointl[TXTBOX_COUNT];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2111 POINTL ptlWork = {0,0};
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2112 ULONG ulColor = DW_CLR_YELLOW;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2113 void *blah;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2114
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2115 hwndBubbleLast = hwnd;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2116 hwndBubble = WinCreateWindow(HWND_DESKTOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2117 WC_STATIC,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2118 "",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2119 SS_TEXT |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2120 DT_CENTER |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2121 DT_VCENTER,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2122 0,0,0,0,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2123 HWND_DESKTOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2124 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2125 0,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2126 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2127 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2128
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2129 WinSetPresParam(hwndBubble,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2130 PP_FONTNAMESIZE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2131 sizeof(DefaultFont),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2132 DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2133
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2134
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2135 WinSetPresParam(hwndBubble,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2136 PP_BACKGROUNDCOLORINDEX,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2137 sizeof(ulColor),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2138 &ulColor);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2139
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2140 WinSetWindowText(hwndBubble,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2141 bubble->bubbletext);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2142
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2143 WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptlWork, 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2144
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2145 hpsTemp = WinGetPS(hwndBubble);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2146 GpiQueryTextBox(hpsTemp,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2147 strlen(bubble->bubbletext),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2148 bubble->bubbletext,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2149 TXTBOX_COUNT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2150 txtPointl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2151 WinReleasePS(hpsTemp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2152
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2153 lWidth = txtPointl[TXTBOX_TOPRIGHT].x -
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2154 txtPointl[TXTBOX_TOPLEFT ].x + 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2155
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2156 lHight = txtPointl[TXTBOX_TOPLEFT].y -
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2157 txtPointl[TXTBOX_BOTTOMLEFT].y + 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2158
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2159 ptlWork.y -= lHight;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2160
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2161 blah = (void *)WinSubclassWindow(hwndBubble, _BubbleProc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2162
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2163 if(blah)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2164 WinSetWindowPtr(hwndBubble, QWP_USER, blah);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2165
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2166 WinSetWindowPos(hwndBubble,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2167 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2168 ptlWork.x,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2169 ptlWork.y,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2170 lWidth,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2171 lHight,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2172 SWP_SIZE | SWP_MOVE | SWP_SHOW);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2173 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2174 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2175 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2176
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2177 if(!bubble->pOldProc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2178 return WinDefWindowProc(hwnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2179 return bubble->pOldProc(hwnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2180 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2181
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2182 MRESULT EXPENTRY _RendProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2183 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2184 int res = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2185 #ifndef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2186 res = (int)_run_event(hwnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2187 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2188 switch(msg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2189 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2190 case WM_BUTTON1DOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2191 case WM_BUTTON2DOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2192 case WM_BUTTON3DOWN:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2193 if(!res)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2194 WinSetFocus(HWND_DESKTOP, hwnd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2195 return (MPARAM)TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2196 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2197 return WinDefWindowProc(hwnd, msg, mp1, mp2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2198 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2199
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
2200 MRESULT EXPENTRY _TreeProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
2201 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
2202 Box *blah = WinQueryWindowPtr(hwnd, QWP_USER);
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
2203
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
2204 #ifndef NO_SIGNALS
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
2205 _run_event(hwnd, msg, mp1, mp2);
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
2206 #endif
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
2207 if(blah && blah->oldproc)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
2208 return blah->oldproc(hwnd, msg, mp1, mp2);
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
2209 return WinDefWindowProc(hwnd, msg, mp1, mp2);
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
2210 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
2211
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2212 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2213 * Initializes the Dynamic Windows engine.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2214 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2215 * newthread: True if this is the only thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2216 * False if there is already a message loop running.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2217 */
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2218 int dw_init(int newthread, int argc, char *argv[])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2219 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2220 APIRET rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2221
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2222 if(newthread)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2223 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2224 dwhab = WinInitialize(0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2225 dwhmq = WinCreateMsgQueue(dwhab, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2226 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2227
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2228 rc = WinRegisterClass(dwhab, ClassName, _wndproc, CS_SIZEREDRAW | CS_CLIPCHILDREN, 32);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2229 rc = WinRegisterClass(dwhab, SplitbarClassName, _splitwndproc, 0L, 32);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2230
20
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
2231 /* Get the OS/2 version. */
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
2232 DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_MS_COUNT,(void *)aulBuffer, 4*sizeof(ULONG));
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
2233
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2234 #ifdef DWDEBUG
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2235 f = fopen("dw.log", "w");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2236 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2237 return rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2238 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2239
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2240 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2241 * Runs a message loop for Dynamic Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2242 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2243 * currenthab: The handle to the current anchor block
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2244 * or NULL if this DW is handling the message loop.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2245 * func: Function pointer to the message filter function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2246 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2247 void dw_main(HAB currenthab, void *func)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2248 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2249 QMSG qmsg;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2250 HAB habtouse;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2251
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2252 if(!currenthab)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2253 habtouse = dwhab;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2254 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2255 habtouse = currenthab;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2256
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2257 /* Setup the filter function */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2258 filterfunc = (int (* EXPENTRY)(HWND, ULONG, MPARAM, MPARAM))func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2259
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2260 _dwtid = dw_thread_id();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2261
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2262 while (WinGetMsg(habtouse, &qmsg, 0, 0, 0))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2263 WinDispatchMsg(habtouse, &qmsg);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2264
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2265 #ifdef DWDEBUG
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2266 fclose(f);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2267 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2268
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2269 if(!currenthab)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2270 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2271 WinDestroyMsgQueue(dwhmq);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2272 WinTerminate(dwhab);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2273 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2274 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2275
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2276 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2277 * Free's memory allocated by dynamic windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2278 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2279 * ptr: Pointer to dynamic windows allocated
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2280 * memory to be free()'d.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2281 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2282 void dw_free(void *ptr)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2283 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2284 free(ptr);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2285 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2286
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2287 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2288 * Allocates and initializes a dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2289 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2290 * data: User defined data to be passed to functions.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2291 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2292 DWDialog *dw_dialog_new(void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2293 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2294 DWDialog *tmp = malloc(sizeof(DWDialog));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2295
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2296 tmp->eve = dw_event_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2297 dw_event_reset(tmp->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2298 tmp->data = data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2299 tmp->done = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2300 tmp->result = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2301
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2302 return tmp;
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 * Accepts a dialog struct and returns the given data to the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2307 * initial called of dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2308 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2309 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2310 * result: Data to be returned by dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2311 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2312 int dw_dialog_dismiss(DWDialog *dialog, void *result)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2313 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2314 dialog->result = result;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2315 dw_event_post(dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2316 dialog->done = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2317 return 0;
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 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2321 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2322 * called by a signal handler with the given dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2323 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2324 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2325 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2326 void *dw_dialog_wait(DWDialog *dialog)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2327 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2328 QMSG qmsg;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2329 void *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2330
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2331 while (WinGetMsg(dwhab, &qmsg, 0, 0, 0))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2332 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2333 WinDispatchMsg(dwhab, &qmsg);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2334 if(dialog->done)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2335 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2336 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2337 dw_event_close(&dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2338 tmp = dialog->result;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2339 free(dialog);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2340 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2341 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2342
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2343
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2344 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2345 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2346 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2347 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2348 * format: printf style format string.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2349 * ...: Additional variables for use in the format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2350 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2351 int dw_messagebox(char *title, char *format, ...)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2352 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2353 va_list args;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2354 char outbuf[1024];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2355
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2356 va_start(args, format);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2357 vsprintf(outbuf, format, args);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2358 va_end(args);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2359
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2360 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, outbuf, title, 0, MB_OK | MB_INFORMATION | MB_MOVEABLE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2361
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2362 return strlen(outbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2363 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2364
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2365 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2366 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2367 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2368 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2369 * text: The text to display in the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2370 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2371 * True if YES False of NO.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2372 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2373 int dw_yesno(char *title, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2374 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2375 if(WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, title, 0, MB_YESNO | MB_INFORMATION | MB_MOVEABLE | MB_SYSTEMMODAL)==MBID_YES)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2376 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2377 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2378 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2379
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2380 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2381 * Makes the window visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2382 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2383 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2384 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2385 int dw_window_show(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2386 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2387 int rc = WinSetWindowPos(handle, NULLHANDLE, 0, 0, 0, 0, SWP_SHOW);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2388 HSWITCH hswitch;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2389 SWCNTRL swcntrl;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2390
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2391 WinSetFocus(HWND_DESKTOP, handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2392 _initial_focus(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2393
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2394 /* If this window has a switch list entry make sure it is visible */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2395 hswitch = WinQuerySwitchHandle(handle, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2396 if(hswitch)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2397 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2398 WinQuerySwitchEntry(hswitch, &swcntrl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2399 swcntrl.uchVisibility = SWL_VISIBLE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2400 WinChangeSwitchEntry(hswitch, &swcntrl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2401 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2402 return rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2403
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2404 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2405
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2406 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2407 * 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
2408 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2409 * handle: The window handle to minimize.
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2410 */
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2411 int dw_window_minimize(HWND handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2412 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2413 return WinSetWindowPos(handle, NULLHANDLE, 0, 0, 0, 0, SWP_MINIMIZE);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2414 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2415
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2416 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2417 * Makes the window invisible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2418 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2419 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2420 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2421 int dw_window_hide(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2422 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2423 HSWITCH hswitch;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2424 SWCNTRL swcntrl;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2425
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2426 /* If this window has a switch list entry make sure it is invisible */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2427 hswitch = WinQuerySwitchHandle(handle, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2428 if(hswitch)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2429 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2430 WinQuerySwitchEntry(hswitch, &swcntrl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2431 swcntrl.uchVisibility = SWL_INVISIBLE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2432 WinChangeSwitchEntry(hswitch, &swcntrl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2433 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2434 return WinShowWindow(handle, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2435 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2436
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2437 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2438 * Destroys a window and all of it's children.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2439 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2440 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2441 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2442 int dw_window_destroy(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2443 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2444 return WinDestroyWindow(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2445 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2446
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2447 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2448 * Changes a window's parent to newparent.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2449 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2450 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2451 * newparent: The window's new parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2452 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2453 void dw_window_reparent(HWND handle, HWND newparent)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2454 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2455 HWND blah = WinWindowFromID(newparent, FID_CLIENT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2456 WinSetParent(handle, blah ? blah : newparent, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2457 }
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 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2461 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2462 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2463 * fontname: Name and size of the font in the form "size.fontname"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2464 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2465 int dw_window_set_font(HWND handle, char *fontname)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2466 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2467 return WinSetPresParam(handle, PP_FONTNAMESIZE, strlen(fontname)+1, fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2468 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2469
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2470 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2471 * Sets the colors used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2472 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2473 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2474 * fore: Foreground color in DW_RGB format or a default color index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2475 * back: Background color in DW_RGB format or a default color index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2476 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2477 int dw_window_set_color(HWND handle, ULONG fore, ULONG back)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2478 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2479 if((fore & DW_RGB_COLOR) == DW_RGB_COLOR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2480 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2481 RGB2 rgb2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2482
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2483 rgb2.bBlue = DW_BLUE_VALUE(fore);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2484 rgb2.bGreen = DW_GREEN_VALUE(fore);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2485 rgb2.bRed = DW_RED_VALUE(fore);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2486 rgb2.fcOptions = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2487
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2488 WinSetPresParam(handle, PP_FOREGROUNDCOLOR, sizeof(RGB2), &rgb2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2489
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2490 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2491 if((back & DW_RGB_COLOR) == DW_RGB_COLOR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2492 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2493 RGB2 rgb2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2494
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2495 rgb2.bBlue = DW_BLUE_VALUE(back);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2496 rgb2.bGreen = DW_GREEN_VALUE(back);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2497 rgb2.bRed = DW_RED_VALUE(back);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2498 rgb2.fcOptions = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2499
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2500 WinSetPresParam(handle, PP_BACKGROUNDCOLOR, sizeof(RGB2), &rgb2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2501 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2502 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2503 if((fore & DW_RGB_COLOR) == DW_RGB_COLOR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2504 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2505
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2506 /* Slight conversion */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2507 if(fore == DW_CLR_BLACK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2508 fore = CLR_BLACK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2509 if(fore == DW_CLR_WHITE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2510 fore = CLR_WHITE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2511
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2512 if(back == DW_CLR_BLACK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2513 back = CLR_BLACK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2514 if(back == DW_CLR_WHITE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2515 back = CLR_WHITE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2516
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2517 return (WinSetPresParam(handle, PP_FOREGROUNDCOLORINDEX, sizeof(ULONG), &fore) |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2518 WinSetPresParam(handle, PP_BACKGROUNDCOLORINDEX, sizeof(ULONG), &back));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2519 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2520
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2521 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2522 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2523 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2524 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2525 * border: Size of the window border in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2526 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2527 int dw_window_set_border(HWND handle, int border)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2528 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2529 WinSendMsg(handle, WM_SETBORDERSIZE, MPFROMSHORT(border), MPFROMSHORT(border));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2530 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2531 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2532
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2533 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2534 * Captures the mouse input to this window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2535 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2536 * handle: Handle to receive mouse input.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2537 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2538 void dw_window_capture(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2539 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2540 WinSetCapture(HWND_DESKTOP, handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2541 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2542
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2543 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2544 * Releases previous mouse capture.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2545 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2546 void dw_window_release(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2547 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2548 WinSetCapture(HWND_DESKTOP, NULLHANDLE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2549 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2550
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2551 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2552 * Tracks this window movement.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2553 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2554 * handle: Handle to frame to be tracked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2555 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2556 void dw_window_track(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2557 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2558 WinSendMsg(handle, WM_TRACKFRAME, MPFROMSHORT(TF_MOVE), 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2559 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2560
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2561 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2562 * 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: 21
diff changeset
2563 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2564 * 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: 21
diff changeset
2565 * 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: 21
diff changeset
2566 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2567 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: 21
diff changeset
2568 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2569 WinSetPointer(handle,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2570 WinQuerySysPointer(HWND_DESKTOP,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2571 pointertype,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2572 FALSE));
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2573 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2574
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2575 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2576 * Create a new Window Frame.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2577 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2578 * owner: The Owner's window handle or HWND_DESKTOP.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2579 * title: The Window title.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2580 * flStyle: Style flags, see the PM reference.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2581 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2582 HWND dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2583 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2584 HWND hwndclient = 0, hwndframe;
8
e22584460709 Switched allocating the box structs with calloc instead of malloc so
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2585 Box *newbox = calloc(1, sizeof(Box));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2586 PFNWP *blah = malloc(sizeof(PFNWP));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2587
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2588 newbox->pad = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2589 newbox->type = BOXVERT;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2590 newbox->count = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2591
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2592 flStyle |= FCF_NOBYTEALIGN;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2593
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2594 hwndframe = WinCreateStdWindow(hwndOwner, 0L, &flStyle, ClassName, title, 0L, NULLHANDLE, 0L, &hwndclient);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2595 *blah = WinSubclassWindow(hwndframe, _sizeproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2596 WinSetWindowPtr(hwndframe, QWP_USER, blah);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2597 WinSetWindowPtr(hwndclient, QWP_USER, newbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2598
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2599 return hwndframe;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2600 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2601
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2602 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2603 * Create a new Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2604 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2605 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2606 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2607 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2608 HWND dw_box_new(int type, int pad)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2609 {
8
e22584460709 Switched allocating the box structs with calloc instead of malloc so
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2610 Box *newbox = calloc(1, sizeof(Box));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2611 HWND hwndframe;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2612
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2613 newbox->pad = pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2614 newbox->type = type;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2615 newbox->count = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2616 newbox->grouphwnd = NULLHANDLE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2617
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2618 hwndframe = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2619 WC_FRAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2620 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2621 WS_VISIBLE | WS_CLIPCHILDREN,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2622 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2623 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2624 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2625 0L,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2626 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2627 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2628
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2629 newbox->oldproc = WinSubclassWindow(hwndframe, _controlproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2630 WinSetWindowPtr(hwndframe, QWP_USER, newbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2631 dw_window_set_color(hwndframe, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2632 return hwndframe;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2633 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2634
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2635 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2636 * Create a new Group Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2637 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2638 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2639 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2640 * title: Text to be displayined in the group outline.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2641 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2642 HWND dw_groupbox_new(int type, int pad, char *title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2643 {
8
e22584460709 Switched allocating the box structs with calloc instead of malloc so
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2644 Box *newbox = calloc(1, sizeof(Box));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2645 HWND hwndframe;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2646
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2647 newbox->pad = pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2648 newbox->type = type;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2649 newbox->count = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2650
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2651 hwndframe = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2652 WC_FRAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2653 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2654 WS_VISIBLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2655 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2656 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2657 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2658 0L,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2659 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2660 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2661
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2662 newbox->grouphwnd = WinCreateWindow(hwndframe,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2663 WC_STATIC,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2664 title,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2665 WS_VISIBLE | SS_GROUPBOX |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2666 WS_GROUP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2667 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2668 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2669 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2670 0L,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2671 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2672 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2673
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2674 WinSetWindowPtr(hwndframe, QWP_USER, newbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2675 dw_window_set_color(hwndframe, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2676 dw_window_set_color(newbox->grouphwnd, DW_CLR_BLACK, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2677 dw_window_set_font(newbox->grouphwnd, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2678 return hwndframe;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2679 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2680
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2681 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2682 * 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
2683 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2684 * 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
2685 */
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2686 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
2687 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2688 HWND hwndframe;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2689
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2690 hwndframe = WinCreateWindow(HWND_OBJECT,
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2691 WC_FRAME,
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2692 NULL,
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2693 WS_VISIBLE | WS_CLIPCHILDREN,
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2694 0,0,2000,1000,
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2695 NULLHANDLE,
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2696 HWND_TOP,
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2697 0L,
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2698 NULL,
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2699 NULL);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2700 return hwndframe;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2701 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2702
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2703 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2704 * Create a bitmap object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2705 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2706 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2707 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2708 HWND dw_bitmap_new(ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2709 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2710 return WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2711 WC_STATIC,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2712 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2713 WS_VISIBLE | SS_TEXT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2714 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2715 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2716 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2717 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2718 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2719 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2720 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2721
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2722 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2723 * Create a notebook object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2724 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2725 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2726 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2727 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2728 HWND dw_notebook_new(ULONG id, int top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2729 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2730 ULONG flags;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2731 HWND tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2732
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2733 if(top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2734 flags = BKS_MAJORTABTOP;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2735 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2736 flags = BKS_MAJORTABBOTTOM;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2737
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2738 tmp = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2739 WC_NOTEBOOK,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2740 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2741 WS_VISIBLE |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2742 BKS_TABBEDDIALOG |
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2743 flags,
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2744 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2745 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2746 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2747 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2748 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2749 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2750
20
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
2751 /* Fix tab sizes on Warp 3 */
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
2752 if(!IS_WARP4())
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
2753 {
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
2754 /* best sizes to be determined by trial and error */
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
2755 WinSendMsg(tmp, BKM_SETDIMENSIONS,MPFROM2SHORT(102, 28), MPFROMSHORT( BKA_MAJORTAB));
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
2756 }
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
2757
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2758 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2759 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2760 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2761
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2762 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2763 * Create a menu object to be popped up.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2764 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2765 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2766 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2767 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2768 HMENUI dw_menu_new(ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2769 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2770 HMENUI tmp = malloc(sizeof(struct _hmenui));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2771
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2772 if(!tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2773 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2774
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2775 tmp->menu = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2776 WC_MENU,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2777 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2778 WS_VISIBLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2779 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2780 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2781 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2782 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2783 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2784 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2785 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2786 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2787
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2788 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2789 * Create a menubar on a window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2790 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2791 * location: Handle of a window frame to be attached to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2792 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2793 HMENUI dw_menubar_new(HWND location)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2794 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2795 HMENUI tmp = malloc(sizeof(struct _hmenui));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2796
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2797 if(!tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2798 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2799
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2800 tmp->menu = WinCreateWindow(location,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2801 WC_MENU,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2802 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2803 WS_VISIBLE | MS_ACTIONBAR,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2804 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2805 location,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2806 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2807 FID_MENU,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2808 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2809 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2810 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2811 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2812
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2813 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2814 * Destroys a menu created with dw_menubar_new or dw_menu_new.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2815 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2816 * menu: Handle of a menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2817 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2818 void dw_menu_destroy(HMENUI *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2819 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2820 if(menu && *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2821 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2822 WinDestroyWindow((*menu)->menu);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2823 free(*menu);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2824 *menu = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2825 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2826 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2827
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2828 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2829 * Adds a menuitem or submenu to an existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2830 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2831 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2832 * title: The title text on the menu item to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2833 * id: An ID to be used for message passing.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2834 * flags: Extended attributes to set on the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2835 * end: If TRUE memu is positioned at the end of the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2836 * check: If TRUE menu is "check"able.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2837 * submenu: Handle to an existing menu to be a submenu or NULL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2838 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2839 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
2840 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2841 MENUITEM miSubMenu;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2842 HWND menu;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2843
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2844 if(!menux)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2845 return NULLHANDLE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2846
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2847 menu = menux->menu;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2848
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2849 if(end)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2850 miSubMenu.iPosition=MIT_END;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2851 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2852 miSubMenu.iPosition=0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2853
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2854 if(strlen(title) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2855 miSubMenu.afStyle=MIS_SEPARATOR | flags;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2856 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2857 miSubMenu.afStyle=MIS_TEXT | flags;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2858 miSubMenu.afAttribute=0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2859 miSubMenu.id=id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2860 miSubMenu.hwndSubMenu = submenu ? submenu->menu : 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2861 miSubMenu.hItem=NULLHANDLE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2862
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2863 WinSendMsg(menu,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2864 MM_INSERTITEM,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2865 MPFROMP(&miSubMenu),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2866 MPFROMP(title));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2867 return (HWND)id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2868 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2869
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2870 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2871 * Sets the state of a menu item check.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2872 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2873 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2874 * id: Menuitem id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2875 * check: TRUE for checked FALSE for not checked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2876 */
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 9
diff changeset
2877 void dw_menu_item_set_check(HMENUI menux, unsigned long id, int check)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2878 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2879 HWND menu;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2880
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2881 if(!menux)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2882 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2883
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2884 menu = menux->menu;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2885
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2886 if(check)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2887 WinSendMsg(menu, MM_SETITEMATTR, MPFROM2SHORT(id, TRUE),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2888 MPFROM2SHORT(MIA_CHECKED, MIA_CHECKED));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2889 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2890 WinSendMsg(menu, MM_SETITEMATTR, MPFROM2SHORT(id, TRUE),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2891 MPFROM2SHORT(MIA_CHECKED, 0));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2892 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2893
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2894 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2895 * Pops up a context menu at given x and y coordinates.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2896 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2897 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2898 * parent: Handle to the window initiating the popup.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2899 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2900 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2901 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2902 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2903 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2904 if(menu && *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2905 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2906 WinPopupMenu(HWND_DESKTOP, parent, (*menu)->menu, x, dw_screen_height() - y, 0, PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_VCONSTRAIN | PU_HCONSTRAIN);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2907 free(*menu);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2908 *menu = NULL;
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 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2913 * Returns the current X and Y coordinates of the mouse pointer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2914 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2915 * x: Pointer to variable to store X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2916 * y: Pointer to variable to store Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2917 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2918 void dw_pointer_query_pos(long *x, long *y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2919 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2920 POINTL ptl;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2921
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2922 WinQueryPointerPos(HWND_DESKTOP, &ptl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2923 if(x && y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2924 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2925 *x = ptl.x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2926 *y = dw_screen_height() - ptl.y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2927 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2928 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2929
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2930 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2931 * Sets the X and Y coordinates of the mouse pointer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2932 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2933 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2934 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2935 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2936 void dw_pointer_set_pos(long x, long y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2937 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2938 WinSetPointerPos(HWND_DESKTOP, x, dw_screen_height() - y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2939 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2940
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2941 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2942 * Create a container object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2943 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2944 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2945 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2946 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2947 HWND dw_container_new(ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2948 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2949 HWND tmp = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2950 WC_CONTAINER,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2951 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2952 WS_VISIBLE | CCS_READONLY |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2953 CCS_SINGLESEL | CCS_AUTOPOSITION,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2954 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2955 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2956 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2957 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2958 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2959 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2960 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2961 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2962 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2963
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2964 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2965 * 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: 21
diff changeset
2966 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2967 * 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: 21
diff changeset
2968 * resource file.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2969 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2970 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: 21
diff changeset
2971 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2972 CNRINFO cnrinfo;
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
2973 Box *newbox = calloc(1, sizeof(Box));
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2974 HWND tmp = WinCreateWindow(HWND_OBJECT,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2975 WC_CONTAINER,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2976 NULL,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2977 WS_VISIBLE | CCS_READONLY |
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2978 CCS_SINGLESEL | CCS_AUTOPOSITION,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2979 0,0,2000,1000,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2980 NULLHANDLE,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2981 HWND_TOP,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2982 id,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2983 NULL,
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2984 NULL);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2985
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2986 cnrinfo.flWindowAttr = CV_TREE | CA_TREELINE;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2987 cnrinfo.slBitmapOrIcon.cx = 16;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2988 cnrinfo.slBitmapOrIcon.cy = 16;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2989
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2990 WinSendMsg(tmp, CM_SETCNRINFO, &cnrinfo, MPFROMLONG(CMA_FLWINDOWATTR | CMA_SLBITMAPORICON));
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
2991 newbox->oldproc = WinSubclassWindow(tmp, _TreeProc);
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
2992 WinSetWindowPtr(tmp, QWP_USER, newbox);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2993 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: 21
diff changeset
2994 return tmp;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2995 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2996
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
2997 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2998 * Create a new static text window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2999 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3000 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3001 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3002 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3003 HWND dw_text_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3004 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3005 HWND tmp = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3006 WC_STATIC,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3007 text,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3008 WS_VISIBLE | SS_TEXT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3009 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3010 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3011 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3012 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3013 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3014 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3015 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3016 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3017 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3018 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3019
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3020 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3021 * 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
3022 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3023 * 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
3024 * 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
3025 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3026 HWND dw_status_text_new(char *text, ULONG id)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3027 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3028 PFNWP *blah = malloc(sizeof(PFNWP));
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3029 HWND tmp = WinCreateWindow(HWND_OBJECT,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3030 WC_STATIC,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3031 text,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3032 WS_VISIBLE | SS_TEXT,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3033 0,0,2000,1000,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3034 NULLHANDLE,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3035 HWND_TOP,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3036 id,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3037 NULL,
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3038 NULL);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3039 dw_window_set_font(tmp, DefaultFont);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3040 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3041
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3042 *blah = WinSubclassWindow(tmp, _statusproc);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3043 WinSetWindowPtr(tmp, QWP_USER, blah);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3044 return tmp;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3045 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3046
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3047 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3048 * Create a new Multiline Editbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3049 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3050 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3051 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3052 HWND dw_mle_new(ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3053 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3054 HWND tmp = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3055 WC_MLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3056 "",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3057 WS_VISIBLE |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3058 MLS_BORDER | MLS_IGNORETAB |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3059 MLS_READONLY | MLS_VSCROLL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3060 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3061 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3062 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3063 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3064 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3065 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3066 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3067 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3068 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3069 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3070
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3071 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3072 * Create a new Entryfield window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3073 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3074 * text: The default text to be in the entryfield widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3075 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3076 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3077 HWND dw_entryfield_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3078 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3079 PFNWP *blah = malloc(sizeof(PFNWP));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3080 HWND tmp = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3081 WC_ENTRYFIELD,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3082 text,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3083 WS_VISIBLE | ES_MARGIN |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3084 ES_AUTOSCROLL | WS_TABSTOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3085 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3086 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3087 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3088 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3089 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3090 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3091 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3092 *blah = WinSubclassWindow(tmp, _entryproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3093 WinSetWindowPtr(tmp, QWP_USER, blah);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3094 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3095 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3096
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3097 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3098 * Create a new Entryfield (password) window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3099 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3100 * text: The default text to be in the entryfield widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3101 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3102 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3103 HWND dw_entryfield_password_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3104 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3105 PFNWP *blah = malloc(sizeof(PFNWP));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3106 HWND tmp = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3107 WC_ENTRYFIELD,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3108 text,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3109 WS_VISIBLE | ES_MARGIN | ES_UNREADABLE |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3110 ES_AUTOSCROLL | WS_TABSTOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3111 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3112 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3113 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3114 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3115 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3116 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3117 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3118 *blah = WinSubclassWindow(tmp, _entryproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3119 WinSetWindowPtr(tmp, QWP_USER, blah);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3120 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3121 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3122
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3123 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3124 * Create a new Combobox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3125 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3126 * text: The default text to be in the combpbox widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3127 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3128 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3129 HWND dw_combobox_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3130 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3131 PFNWP *blah = malloc(sizeof(PFNWP));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3132 HWND tmp = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3133 WC_COMBOBOX,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3134 text,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3135 WS_VISIBLE | CBS_DROPDOWN | WS_GROUP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3136 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3137 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3138 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3139 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3140 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3141 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3142 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3143 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3144 *blah = WinSubclassWindow(tmp, _comboproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3145 WinSetWindowPtr(tmp, QWP_USER, blah);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3146 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3147 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3148
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3149 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3150 * Create a new button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3151 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3152 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3153 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3154 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3155 HWND dw_button_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3156 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3157 BubbleButton *bubble = malloc(sizeof(BubbleButton));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3158
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3159 HWND tmp = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3160 WC_BUTTON,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3161 text,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3162 WS_VISIBLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3163 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3164 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3165 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3166 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3167 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3168 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3169
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3170 bubble->id = id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3171 bubble->bubbletext[0] = '\0';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3172 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3173
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3174 WinSetWindowPtr(tmp, QWP_USER, bubble);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3175 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3176 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3177 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3178
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3179 /* Function: GenResIDStr
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3180 ** Abstract: Generate string '#nnnn' for a given ID for using with Button
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3181 ** controls
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3182 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3183
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3184 void _GenResIDStr(CHAR *buff, ULONG ulID)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3185 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3186 char *str;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3187 int slen = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3188
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3189 *buff++ = '#';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3190
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3191 str = buff;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3192
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3193 do
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3194 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3195 *str++ = (ulID % 10) + '0';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3196 ulID /= 10;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3197 slen++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3198 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3199 while(ulID);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3200
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3201 *str-- = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3202
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3203 for(; str > buff; str--, buff++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3204 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3205 *buff ^= *str;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3206 *str ^= *buff;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3207 *buff ^= *str;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3208 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3209 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3210
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3211
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3212 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3213 * Create a new bitmap button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3214 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3215 * text: Bubble help text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3216 * id: An ID of a bitmap in the resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3217 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3218 HWND dw_bitmapbutton_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3219 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3220 char idbuf[256];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3221 HWND tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3222 BubbleButton *bubble = malloc(sizeof(BubbleButton));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3223
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3224 _GenResIDStr(idbuf, id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3225
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3226 tmp = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3227 WC_BUTTON,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3228 idbuf,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3229 WS_VISIBLE | BS_PUSHBUTTON |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3230 BS_BITMAP | BS_AUTOSIZE |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3231 BS_NOPOINTERFOCUS,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3232 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3233 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3234 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3235 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3236 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3237 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3238
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3239 bubble->id = id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3240 strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3241 bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3242 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3243
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3244 WinSetWindowPtr(tmp, QWP_USER, bubble);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3245 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3246 }
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 * Create a new spinbutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3250 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3251 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3252 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3253 */
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3254 HWND dw_spinbutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3255 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3256 PFNWP *blah = malloc(sizeof(PFNWP));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3257 HWND tmp = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3258 WC_SPINBUTTON,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3259 text,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3260 WS_VISIBLE | SPBS_MASTER,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3261 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3262 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3263 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3264 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3265 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3266 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3267 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3268 *blah = WinSubclassWindow(tmp, _entryproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3269 WinSetWindowPtr(tmp, QWP_USER, blah);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3270 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3271 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3272
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3273 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3274 * Create a new radiobutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3275 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3276 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3277 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3278 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3279 HWND dw_radiobutton_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3280 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3281 PFNWP *blah = malloc(sizeof(PFNWP));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3282 HWND tmp = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3283 WC_BUTTON,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3284 text,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3285 WS_VISIBLE |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3286 BS_AUTORADIOBUTTON,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3287 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3288 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3289 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3290 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3291 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3292 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3293 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3294 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3295 *blah = WinSubclassWindow(tmp, _entryproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3296 WinSetWindowPtr(tmp, QWP_USER, blah);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3297 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3298 }
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 * Create a new slider window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3302 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3303 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3304 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3305 HWND dw_slider_new(ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3306 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3307 return WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3308 WC_SLIDER,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3309 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3310 WS_VISIBLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3311 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3312 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3313 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3314 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3315 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3316 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3317 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3318
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3319 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3320 * Create a new checkbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3321 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3322 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3323 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3324 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3325 HWND dw_checkbox_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3326 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3327 PFNWP *blah = malloc(sizeof(PFNWP));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3328 HWND tmp = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3329 WC_BUTTON,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3330 text,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3331 WS_VISIBLE | BS_AUTOCHECKBOX,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3332 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3333 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3334 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3335 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3336 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3337 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3338 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3339 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3340 *blah = WinSubclassWindow(tmp, _entryproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3341 WinSetWindowPtr(tmp, QWP_USER, blah);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3342 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3343 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3344
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3345 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3346 * Create a new listbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3347 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3348 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3349 * multi: Multiple select TRUE or FALSE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3350 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3351 HWND dw_listbox_new(ULONG id, int multi)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3352 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3353 PFNWP *blah = malloc(sizeof(PFNWP));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3354 HWND tmp = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3355 WC_LISTBOX,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3356 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3357 WS_VISIBLE | LS_NOADJUSTPOS |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3358 (multi ? LS_MULTIPLESEL : 0),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3359 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3360 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3361 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3362 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3363 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3364 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3365 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3366 *blah = WinSubclassWindow(tmp, _entryproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3367 WinSetWindowPtr(tmp, QWP_USER, blah);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3368 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3369 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3370
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3371 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3372 * Sets the icon used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3373 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3374 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3375 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3376 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3377 void dw_window_set_icon(HWND handle, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3378 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3379 HPOINTER icon;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3380
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3381 icon = WinLoadPointer(HWND_DESKTOP,NULLHANDLE,id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3382 WinSendMsg(handle, WM_SETICON, (MPARAM)icon, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3383 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3384
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3385 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3386 * Sets the bitmap used for a given static window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3387 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3388 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3389 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3390 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3391 void dw_window_set_bitmap(HWND handle, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3392 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3393 HBITMAP hbm;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3394 HPS hps = WinGetPS(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3395
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3396 hbm = GpiLoadBitmap(hps, NULLHANDLE, id, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3397 WinSetWindowBits(handle,QWL_STYLE,SS_BITMAP,SS_BITMAP | 0x7f);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3398 WinSendMsg( handle, SM_SETHANDLE, MPFROMP(hbm), NULL );
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3399 /*WinSetWindowULong( hwndDlg, QWL_USER, (ULONG) hbm );*/
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3400 WinReleasePS(hps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3401 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3402
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3403 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3404 * Sets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3405 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3406 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3407 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3408 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3409 void dw_window_set_text(HWND handle, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3410 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3411 WinSetWindowText(handle, text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3412 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3413
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3414 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3415 * Gets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3416 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3417 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3418 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3419 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3420 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3421 char *dw_window_get_text(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3422 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3423 char tempbuf[4096] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3424
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3425 WinQueryWindowText(handle, 4095, tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3426 tempbuf[4095] = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3427
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3428 return strdup(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3429 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3430
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3431 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3432 * Disables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3433 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3434 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3435 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3436 void dw_window_disable(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3437 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3438 WinEnableWindow(handle, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3439 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3440
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3441 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3442 * Enables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3443 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3444 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3445 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3446 void dw_window_enable(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3447 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3448 WinEnableWindow(handle, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3449 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3450
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3451 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3452 * Gets the child window handle with specified ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3453 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3454 * handle: Handle to the parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3455 * id: Integer ID of the child.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3456 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3457 HWND dw_window_from_id(HWND handle, int id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3458 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3459 HENUM henum;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3460 HWND child;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3461 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3462
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3463 henum = WinBeginEnumWindows(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3464 while((child = WinGetNextWindow(henum)) != NULLHANDLE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3465 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3466 int windowid = WinQueryWindowUShort(child, QWS_ID);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3467 HWND found;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3468
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3469 WinQueryClassName(child, 99, tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3470
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3471 /* If the child is a box (frame) then recurse into it */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3472 if(strncmp(tmpbuf, "#1", 2)==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3473 if((found = dw_window_from_id(child, id)) != NULLHANDLE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3474 return found;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3475
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3476 if(windowid && windowid == id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3477 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3478 WinEndEnumWindows(henum);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3479 return child;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3480 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3481 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3482 WinEndEnumWindows(henum);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3483 return NULLHANDLE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3484 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3485
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3486 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3487 * Pack windows (widgets) into a box from the end (or bottom).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3488 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3489 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3490 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3491 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3492 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3493 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3494 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3495 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3496 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3497 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
3498 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3499 Box *thisbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3500
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3501 if(WinWindowFromID(box, FID_CLIENT))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3502 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3503 box = WinWindowFromID(box, FID_CLIENT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3504 thisbox = WinQueryWindowPtr(box, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3505 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3506 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3507 thisbox = WinQueryWindowPtr(box, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3508 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3509 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3510 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3511 dw_box_pack_start_stub(box, item, width, height, hsize, vsize, pad);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3512 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3513 dw_box_pack_end_stub(box, item, width, height, hsize, vsize, pad);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3514 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3515 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3516
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3517 void dw_box_pack_end_stub(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3518 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3519 HWND boxowner = NULLHANDLE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3520 Box *thisbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3521
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3522 if(WinWindowFromID(box, FID_CLIENT))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3523 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3524 box = WinWindowFromID(box, FID_CLIENT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3525 thisbox = WinQueryWindowPtr(box, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3526 hsize = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3527 vsize = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3528 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3529 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3530 thisbox = WinQueryWindowPtr(box, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3531 if(!thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3532 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3533 box = WinWindowFromID(box, FID_CLIENT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3534 if(box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3535 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3536 thisbox = WinQueryWindowPtr(box, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3537 hsize = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3538 vsize = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3539 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3540 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3541 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3542 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3543 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3544 Item *tmpitem, *thisitem = thisbox->items;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3545 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3546
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3547 tmpitem = malloc(sizeof(Item)*(thisbox->count+1));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3548
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3549 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3550 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3551 tmpitem[z] = thisitem[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3552 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3553
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3554 WinQueryClassName(item, 99, tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3555
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3556 if(strncmp(tmpbuf, "#1", 2)==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3557 tmpitem[thisbox->count].type = TYPEBOX;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3558 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3559 tmpitem[thisbox->count].type = TYPEITEM;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3560
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3561 tmpitem[thisbox->count].hwnd = item;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3562 tmpitem[thisbox->count].origwidth = tmpitem[thisbox->count].width = width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3563 tmpitem[thisbox->count].origheight = tmpitem[thisbox->count].height = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3564 tmpitem[thisbox->count].pad = pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3565 if(hsize)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3566 tmpitem[thisbox->count].hsize = SIZEEXPAND;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3567 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3568 tmpitem[thisbox->count].hsize = SIZESTATIC;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3569
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3570 if(vsize)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3571 tmpitem[thisbox->count].vsize = SIZEEXPAND;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3572 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3573 tmpitem[thisbox->count].vsize = SIZESTATIC;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3574
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3575 thisbox->items = tmpitem;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3576
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3577 if(thisbox->count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3578 free(thisitem);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3579
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3580 thisbox->count++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3581
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3582 /* Don't set the ownership if it's an entryfield or combobox */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3583 WinQueryClassName(item, 99, tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3584 if(strncmp(tmpbuf, "#6", 2)!=0 /*&& strncmp(tmpbuf, "#2", 2)!=0*/)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3585 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3586 if((boxowner = WinQueryWindow(box, QW_OWNER)) != 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3587 WinSetOwner(item, boxowner);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3588 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3589 WinSetOwner(item, box);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3590 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3591 WinSetParent(item, box, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3592 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3593 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3594
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3595 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3596 * Sets the size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3597 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3598 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3599 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3600 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3601 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3602 void dw_window_set_usize(HWND handle, ULONG width, ULONG height)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3603 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3604 WinSetWindowPos(handle, NULLHANDLE, 0, 0, width, height, SWP_SHOW | SWP_SIZE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3605 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3606
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3607 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3608 * Returns the width of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3609 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3610 int dw_screen_width(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3611 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3612 return WinQuerySysValue(HWND_DESKTOP,SV_CXSCREEN);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3613 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3614
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3615 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3616 * Returns the height of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3617 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3618 int dw_screen_height(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3619 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3620 return WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3621 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3622
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3623 /* This should return the current color depth */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3624 unsigned long dw_color_depth(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3625 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3626 HDC hdc = WinOpenWindowDC(HWND_DESKTOP);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3627 long colors;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3628
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3629 DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, &colors);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3630 DevCloseDC(hdc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3631 return colors;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3632 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3633
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 * Sets the position of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3637 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3638 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3639 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3640 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3641 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3642 void dw_window_set_pos(HWND handle, ULONG x, ULONG y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3643 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3644 int myy = _get_frame_height(handle) - (y + _get_height(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3645
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3646 WinSetWindowPos(handle, NULLHANDLE, x, myy, 0, 0, SWP_MOVE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3647 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3648
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3649 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3650 * Sets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3651 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3652 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3653 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3654 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3655 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3656 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3657 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3658 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
3659 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3660 int myy = _get_frame_height(handle) - (y + height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3661
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3662 WinSetWindowPos(handle, NULLHANDLE, x, myy, width, height, SWP_MOVE | SWP_SIZE | SWP_SHOW);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3663 }
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 * Gets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3667 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3668 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3669 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3670 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3671 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3672 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3673 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3674 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
3675 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3676 SWP swp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3677 WinQueryWindowPos(handle, &swp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3678 if(x)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3679 *x = swp.x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3680 if(y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3681 *y = _get_frame_height(handle) - (swp.y + swp.cy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3682 if(width)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3683 *width = swp.cx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3684 if(height)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3685 *height = swp.cy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3686 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3687
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3688 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3689 * Sets the style of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3690 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3691 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3692 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3693 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3694 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3695 void dw_window_set_style(HWND handle, ULONG style, ULONG mask)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3696 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3697 WinSetWindowBits(handle, QWL_STYLE, style, mask);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3698 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3699
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3700 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3701 * Adds a new page to specified notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3702 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3703 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3704 * flags: Any additional page creation flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3705 * front: If TRUE page is added at the beginning.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3706 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3707 ULONG dw_notebook_page_new(HWND handle, ULONG flags, int front)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3708 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3709 if(front)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3710 return (ULONG)WinSendMsg(handle, BKM_INSERTPAGE, 0L,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3711 MPFROM2SHORT((BKA_STATUSTEXTON | BKA_AUTOPAGESIZE | BKA_MAJOR | flags), BKA_FIRST));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3712 return (ULONG)WinSendMsg(handle, BKM_INSERTPAGE, 0L,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3713 MPFROM2SHORT((BKA_STATUSTEXTON | BKA_AUTOPAGESIZE | BKA_MAJOR | flags), BKA_LAST));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3714 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3715
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3716 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3717 * Remove a page from a notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3718 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3719 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3720 * pageid: ID of the page to be destroyed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3721 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3722 void dw_notebook_page_destroy(HWND handle, unsigned int pageid)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3723 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3724 WinSendMsg(handle, BKM_DELETEPAGE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3725 MPFROMLONG(pageid), (MPARAM)BKA_SINGLE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3726 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3727
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3728 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3729 * Queries the currently visible page ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3730 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3731 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3732 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3733 unsigned int dw_notebook_page_query(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3734 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3735 return (int)WinSendMsg(handle, BKM_QUERYPAGEID,0L, MPFROM2SHORT(BKA_TOP, BKA_MAJOR));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3736 }
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 * Sets the currently visibale page ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3740 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3741 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3742 * pageid: ID of the page to be made visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3743 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3744 void dw_notebook_page_set(HWND handle, unsigned int pageid)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3745 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3746 WinSendMsg(handle, BKM_TURNTOPAGE, MPFROMLONG(pageid), 0L);
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 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3750 * Sets the text on the specified notebook tab.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3751 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3752 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3753 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3754 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3755 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3756 void dw_notebook_page_set_text(HWND handle, ULONG pageid, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3757 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3758 WinSendMsg(handle, BKM_SETTABTEXT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3759 MPFROMLONG(pageid), MPFROMP(text));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3760 }
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 * Sets the text on the specified notebook tab status area.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3764 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3765 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3766 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3767 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3768 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3769 void dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3770 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3771 WinSendMsg(handle, BKM_SETSTATUSLINETEXT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3772 MPFROMLONG(pageid), MPFROMP(text));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3773 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3774
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3775 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3776 * Packs the specified box into the notebook page.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3777 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3778 * handle: Handle to the notebook to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3779 * pageid: Page ID in the notebook which is being packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3780 * page: Box handle to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3781 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3782 void dw_notebook_pack(HWND handle, ULONG pageid, HWND page)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3783 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3784 HWND tmpbox = dw_box_new(BOXVERT, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3785
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3786 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3787 WinSubclassWindow(tmpbox, _wndproc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3788 WinSendMsg(handle, BKM_SETPAGEWINDOWHWND,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3789 MPFROMLONG(pageid), MPFROMHWND(tmpbox));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3790 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3791
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3792 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3793 * Appends the specified text to the listbox's (or combobox) entry list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3794 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3795 * handle: Handle to the listbox to be appended to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3796 * text: Text to append into listbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3797 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3798 void dw_listbox_append(HWND handle, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3799 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3800 WinSendMsg(handle,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3801 LM_INSERTITEM,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3802 MPFROMSHORT(LIT_END),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3803 MPFROMP(text));
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 * Clears the listbox's (or combobox) list of all entries.
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 listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3810 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3811 void dw_listbox_clear(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3812 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3813 WinSendMsg(handle,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3814 LM_DELETEALL, 0L, 0L);
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 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3818 * Returns the listbox's item count.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3819 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3820 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3821 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3822 int dw_listbox_count(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3823 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3824 return (int)WinSendMsg(handle,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3825 LM_QUERYITEMCOUNT,0L, 0L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3826 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3827
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3828 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3829 * Sets the topmost item in the viewport.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3830 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3831 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3832 * top: Index to the top item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3833 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3834 void dw_listbox_set_top(HWND handle, int top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3835 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3836 WinSendMsg(handle,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3837 LM_SETTOPINDEX,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3838 MPFROMSHORT(top),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3839 0L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3840 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3841
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3842 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3843 * Copies the given index item's text into buffer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3844 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3845 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3846 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3847 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3848 * length: Length of the buffer (including NULL).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3849 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3850 void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3851 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3852 WinSendMsg(handle, LM_QUERYITEMTEXT, MPFROM2SHORT(index, length), (MPARAM)buffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3853 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3854
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3855 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3856 * Sets the text of a given listbox entry.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3857 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3858 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3859 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3860 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3861 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3862 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3863 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3864 WinSendMsg(handle, LM_SETITEMTEXT, MPFROMSHORT(index), (MPARAM)buffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3865 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3866
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3867 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3868 * Returns the index to the item in the list currently selected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3869 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3870 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3871 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3872 unsigned int dw_listbox_selected(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3873 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3874 return (unsigned int)WinSendMsg(handle,
18
f1002d51d959 Fixed a container problem on OS/2 with separator set to 0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 16
diff changeset
3875 LM_QUERYSELECTION,
f1002d51d959 Fixed a container problem on OS/2 with separator set to 0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 16
diff changeset
3876 MPFROMSHORT(LIT_CURSOR),
f1002d51d959 Fixed a container problem on OS/2 with separator set to 0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 16
diff changeset
3877 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3878 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3879
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3880 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3881 * Returns the index to the current selected item or -1 when done.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3882 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3883 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3884 * where: Either the previous return or -1 to restart.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3885 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3886 int dw_listbox_selected_multi(HWND handle, int where)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3887 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3888 int place = where;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3889
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3890 if(where == -1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3891 place = LIT_FIRST;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3892
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3893 place = (int)WinSendMsg(handle,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3894 LM_QUERYSELECTION,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3895 MPFROMSHORT(place),0L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3896 if(place == LIT_NONE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3897 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3898 return place;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3899 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3900
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3901 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3902 * Sets the selection state of a given index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3903 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3904 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3905 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3906 * state: TRUE if selected FALSE if unselected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3907 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3908 void dw_listbox_select(HWND handle, int index, int state)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3909 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3910 WinSendMsg(handle, LM_SELECTITEM, MPFROMSHORT(index), (MPARAM)state);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3911 _run_event(handle, WM_CONTROL, MPFROM2SHORT(0, LN_SELECT), (MPARAM)handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3912 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3913
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3914 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3915 * Deletes the item with given index from the list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3916 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3917 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3918 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3919 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3920 void dw_listbox_delete(HWND handle, int index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3921 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3922 WinSendMsg(handle, LM_DELETEITEM, MPFROMSHORT(index), 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3923 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3924
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3925 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3926 * Adds text to an MLE box and returns the current point.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3927 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3928 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3929 * buffer: Text buffer to be imported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3930 * startpoint: Point to start entering text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3931 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3932 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3933 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3934 unsigned long point = startpoint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3935 PBYTE mlebuf;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3936
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3937 /* Work around 64K limit */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3938 if(!DosAllocMem((PPVOID) &mlebuf, 65536, PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_TILE))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3939 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3940 int amount, len = strlen(buffer), written = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3941
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3942 while(written < len)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3943 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3944 if((len - written) > 65535)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3945 amount = 65535;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3946 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3947 amount = len - written;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3948
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3949 memcpy(mlebuf, &buffer[written], amount);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3950 mlebuf[amount] = '\0';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3951
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3952 WinSendMsg(handle, MLM_SETIMPORTEXPORT, MPFROMP(mlebuf), MPFROMLONG(amount+1));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3953 WinSendMsg(handle, MLM_IMPORT, MPFROMP(&point), MPFROMLONG(amount + 1));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3954 dw_mle_delete(handle, point, 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3955
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3956 written += amount;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3957 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3958 DosFreeMem(mlebuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3959 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3960 return point - 1;
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 * Grabs text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3965 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3966 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3967 * buffer: Text buffer to be exported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3968 * startpoint: Point to start grabbing text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3969 * length: Amount of text to be grabbed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3970 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3971 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3972 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3973 PBYTE mlebuf;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3974
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3975 /* Work around 64K limit */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3976 if(!DosAllocMem((PPVOID) &mlebuf, 65535, PAG_COMMIT | PAG_READ | PAG_WRITE | OBJ_TILE))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3977 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3978 int amount, copied, written = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3979
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3980 while(written < length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3981 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3982 if((length - written) > 65535)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3983 amount = 65535;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3984 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3985 amount = length - written;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3986
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3987 WinSendMsg(handle, MLM_SETIMPORTEXPORT, MPFROMP(mlebuf), MPFROMLONG(amount));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3988 copied = (int)WinSendMsg(handle, MLM_EXPORT, MPFROMP(&startpoint), MPFROMLONG(&amount));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3989
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3990 if(copied)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3991 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3992 memcpy(&buffer[written], mlebuf, copied);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3993
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3994 written += copied;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3995 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3996 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3997 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3998 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3999 DosFreeMem(mlebuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4000 }
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 * Obtains information about an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4005 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4006 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4007 * bytes: A pointer to a variable to return the total bytes.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4008 * lines: A pointer to a variable to return the number of lines.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4009 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4010 void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4011 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4012 if(bytes)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4013 *bytes = (unsigned long)WinSendMsg(handle, MLM_QUERYTEXTLENGTH, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4014 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4015 *lines = (unsigned long)WinSendMsg(handle, MLM_QUERYLINECOUNT, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4016 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4017
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4018 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4019 * Deletes text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4020 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4021 * handle: Handle to the MLE to be deleted from.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4022 * startpoint: Point to start deleting text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4023 * length: Amount of text to be deleted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4024 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4025 void dw_mle_delete(HWND handle, int startpoint, int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4026 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4027 char *buf = malloc(length+1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4028 int z, dellen = length;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4029
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4030 dw_mle_export(handle, buf, startpoint, length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4031
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4032 for(z=0;z<length-1;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4033 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4034 if(strncmp(&buf[z], "\r\n", 2) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4035 dellen--;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4036 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4037 WinSendMsg(handle, MLM_DELETE, MPFROMLONG(startpoint), MPFROMLONG(dellen));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4038 free(buf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4039 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4040
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4041 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4042 * Clears all text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4043 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4044 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4045 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4046 void dw_mle_clear(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4047 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4048 unsigned long bytes;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4049
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4050 dw_mle_query(handle, &bytes, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4051
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4052 WinSendMsg(handle, MLM_DELETE, MPFROMLONG(0), MPFROMLONG(bytes));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4053 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4054
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4055 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4056 * Sets the visible line of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4057 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4058 * handle: Handle to the MLE to be positioned.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4059 * line: Line to be visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4060 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4061 void dw_mle_set_visible(HWND handle, int line)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4062 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4063 int tmppnt;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4064
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4065 if(line > 10)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4066 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4067 tmppnt = (int)WinSendMsg(handle, MLM_CHARFROMLINE, MPFROMLONG(line - 10), 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4068 WinSendMsg(handle, MLM_SETFIRSTCHAR, MPFROMLONG(tmppnt), 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4069 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4070 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4071
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4072 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4073 * Sets the editablity of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4074 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4075 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4076 * 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
4077 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4078 void dw_mle_set_editable(HWND handle, int state)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4079 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4080 WinSendMsg(handle, MLM_SETREADONLY, MPFROMLONG(state ? FALSE : TRUE), 0);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4081 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4082
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4083 /*
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4084 * Sets the word wrap state of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4085 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4086 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4087 * 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
4088 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4089 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
4090 {
16
ca7a8215487a Removed structure packing option to fix a crash in dw_mle_search() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
4091 WinSendMsg(handle, MLM_SETWRAP, MPFROMLONG(state), 0);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4092 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4093
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4094 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4095 * Sets the current cursor position of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4096 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4097 * handle: Handle to the MLE to be positioned.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4098 * point: Point to position cursor.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4099 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4100 void dw_mle_set(HWND handle, int point)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4101 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4102 WinSendMsg(handle, MLM_SETSEL, MPFROMLONG(point), MPFROMLONG(point));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4103 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4104
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4105 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4106 * Finds text in an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4107 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4108 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4109 * text: Text to search for.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4110 * point: Start point of search.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4111 * flags: Search specific flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4112 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4113 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4114 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4115 MLE_SEARCHDATA msd;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4116
16
ca7a8215487a Removed structure packing option to fix a crash in dw_mle_search() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
4117 /* This code breaks with structure packing set to 1 (/Sp1 in VAC)
ca7a8215487a Removed structure packing option to fix a crash in dw_mle_search() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
4118 * if this is needed we need to add a pragma here.
ca7a8215487a Removed structure packing option to fix a crash in dw_mle_search() when
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
4119 */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4120 msd.cb = sizeof(msd);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4121 msd.pchFind = text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4122 msd.pchReplace = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4123 msd.cchFind = strlen(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4124 msd.cchReplace = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4125 msd.iptStart = point;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4126 msd.iptStop = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4127
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4128 if(WinSendMsg(handle, MLM_SEARCH, MPFROMLONG(MLFSEARCH_SELECTMATCH | flags), (MPARAM)&msd))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4129 return (int)WinSendMsg(handle, MLM_QUERYSEL,(MPARAM)MLFQS_MAXSEL, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4130 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4131 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4132
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4133 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4134 * Stops redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4135 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4136 * handle: Handle to the MLE to freeze.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4137 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4138 void dw_mle_freeze(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4139 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4140 WinSendMsg(handle, MLM_DISABLEREFRESH, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4141 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4142
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4143 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4144 * Resumes redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4145 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4146 * handle: Handle to the MLE to thaw.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4147 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4148 void dw_mle_thaw(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4149 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4150 WinSendMsg(handle, MLM_ENABLEREFRESH, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4151 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4152
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4153 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4154 * Returns the range of the slider.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4155 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4156 * handle: Handle to the slider to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4157 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4158 unsigned int dw_slider_query_range(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4159 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4160 return SHORT2FROMMP(WinSendMsg(handle, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), 0));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4161 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4162
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4163 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4164 * Sets the slider position.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4165 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4166 * handle: Handle to the slider to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4167 * position: Position of the slider withing the range.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4168 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4169 void dw_slider_set_pos(HWND handle, unsigned int position)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4170 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4171 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)position);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4172 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4173
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4174 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4175 * Sets the spinbutton value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4176 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4177 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4178 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4179 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4180 void dw_spinbutton_set_pos(HWND handle, long position)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4181 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4182 WinSendMsg(handle, SPBM_SETCURRENTVALUE, MPFROMLONG((long)position), 0L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4183 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4184
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4185 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4186 * Sets the spinbutton limits.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4187 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4188 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4189 * upper: Upper limit.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4190 * lower: Lower limit.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4191 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4192 void dw_spinbutton_set_limits(HWND handle, long upper, long lower)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4193 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4194 WinSendMsg(handle, SPBM_SETLIMITS, MPFROMLONG(upper), MPFROMLONG(lower));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4195 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4196
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4197 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4198 * Sets the entryfield character limit.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4199 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4200 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4201 * limit: Number of characters the entryfield will take.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4202 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4203 void dw_entryfield_set_limit(HWND handle, ULONG limit)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4204 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4205 WinSendMsg(handle, EM_SETTEXTLIMIT, (MPARAM)limit, (MPARAM)0);
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
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4209 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4210 * Returns the current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4211 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4212 * handle: Handle to the spinbutton to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4213 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4214 long dw_spinbutton_query(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4215 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4216 long tmpval = 0L;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4217
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4218 WinSendMsg(handle, SPBM_QUERYVALUE, (MPARAM)&tmpval,0L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4219 return tmpval;
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 * Returns the state of the checkbox.
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 checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4226 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4227 int dw_checkbox_query(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4228 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4229 return (int)WinSendMsg(handle,BM_QUERYCHECK,0,0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4230 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4231
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4232 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4233 * Sets the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4234 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4235 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4236 * value: TRUE for checked, FALSE for unchecked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4237 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4238 void dw_checkbox_set(HWND handle, int value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4239 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4240 WinSendMsg(handle,BM_SETCHECK,MPFROMSHORT(value),0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4241 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4242
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4243 typedef struct _CNRITEM
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4244 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4245 MINIRECORDCORE rc;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4246 HPOINTER hptrIcon;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4247
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4248 } CNRITEM, *PCNRITEM;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4249
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4250 /*
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4251 * 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: 21
diff changeset
4252 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4253 * 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: 21
diff changeset
4254 * 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: 21
diff changeset
4255 * 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: 21
diff changeset
4256 * parent: Parent handle or 0 if root.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4257 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4258 HWND dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4259 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4260 ULONG cbExtra;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4261 PCNRITEM pci;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4262 RECORDINSERT ri;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4263
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4264 /* Calculate extra bytes needed for each record besides that needed for the
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4265 * MINIRECORDCORE structure
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4266 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4267
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4268 cbExtra = sizeof(CNRITEM) - sizeof(MINIRECORDCORE);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4269
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4270 /* Allocate memory for the parent record */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4271
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4272 pci = WinSendMsg(handle, CM_ALLOCRECORD, MPFROMLONG(cbExtra), MPFROMSHORT(1));
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4273
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4274 /* Fill in the parent record data */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4275
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4276 pci->rc.cb = sizeof(MINIRECORDCORE);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4277 pci->rc.pszIcon = title;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4278 pci->rc.hptrIcon = icon;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4279
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4280 pci->hptrIcon = icon;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4281
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4282 memset(&ri, 0, sizeof(RECORDINSERT));
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4283
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4284 ri.cb = sizeof(RECORDINSERT);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4285 ri.pRecordOrder = (PRECORDCORE)CMA_END;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4286 ri.pRecordParent = (PRECORDCORE)NULL;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4287 ri.zOrder = (USHORT)CMA_TOP;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4288 ri.cRecordsInsert = 1;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4289 ri.fInvalidateRecord = TRUE;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4290
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4291 /* We are about to insert the child records. Set the parent record to be
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4292 * the one we just inserted.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4293 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4294 ri.pRecordParent = (PRECORDCORE)parent;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4295
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4296 /* Insert the record */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4297 WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri));
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4298
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4299 return (HWND)pci;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4300 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4301
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4302 /*
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4303 * Removes all nodes from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4304 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4305 * handle: Handle to the window (widget) to be cleared.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4306 */
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4307 void dw_tree_clear(HWND handle)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4308 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4309 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)0L, MPFROM2SHORT(0, CMA_INVALIDATE | CMA_FREE));
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4310 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4311
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4312 /*
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4313 * Removes a node from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4314 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4315 * handle: Handle to the window (widget) to be cleared.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4316 * item: Handle to node to be deleted.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4317 */
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4318 void dw_tree_delete(HWND handle, HWND item)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4319 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4320 PCNRITEM pci = (PCNRITEM)item;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4321 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)&pci, MPFROM2SHORT(1, CMA_INVALIDATE | CMA_FREE));
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4322 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 24
diff changeset
4323
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4324 /* Some OS/2 specific container structs */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4325 typedef struct _containerinfo {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4326 int count;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4327 void *data;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4328 HWND handle;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4329 } ContainerInfo;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4330
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4331 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4332 * Sets up the container columns.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4333 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4334 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4335 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4336 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4337 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4338 * separator: The column number that contains the main separator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4339 * (this item may only be used in OS/2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4340 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4341 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4342 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4343 PFIELDINFO details, first, left = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4344 FIELDINFOINSERT detin;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4345 CNRINFO cnri;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4346 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4347 ULONG size = sizeof(RECORDCORE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4348 ULONG *offStruct = malloc(count * sizeof(ULONG));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4349 ULONG *tempflags = malloc((count+1) * sizeof(ULONG));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4350 ULONG *oldflags = (ULONG *)WinQueryWindowPtr(handle, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4351
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4352 if(!offStruct || !tempflags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4353 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4354
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4355 memcpy(tempflags, flags, count * sizeof(ULONG));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4356 tempflags[count] = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4357
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4358 WinSetWindowPtr(handle, 0, tempflags);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4359
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4360 if(oldflags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4361 free(oldflags);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4362
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4363 while((first = (PFIELDINFO)WinSendMsg(handle, CM_QUERYDETAILFIELDINFO, 0, MPFROMSHORT(CMA_FIRST))) != NULL)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4364 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4365 WinSendMsg(handle, CM_REMOVEDETAILFIELDINFO, (MPARAM)&first, MPFROM2SHORT(1, CMA_FREE));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4366 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4367
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4368 /* Figure out the offsets to the items in the struct */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4369 for(z=0;z<count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4370 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4371 offStruct[z] = size;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4372 if(flags[z] & DW_CFA_BITMAPORICON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4373 size += sizeof(HPOINTER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4374 else if(flags[z] & DW_CFA_STRING)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4375 size += sizeof(char *);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4376 else if(flags[z] & DW_CFA_ULONG)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4377 size += sizeof(ULONG);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4378 else if(flags[z] & DW_CFA_DATE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4379 size += sizeof(CDATE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4380 else if(flags[z] & DW_CFA_TIME)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4381 size += sizeof(CTIME);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4382 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4383
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4384 first = details = (PFIELDINFO)WinSendMsg(handle, CM_ALLOCDETAILFIELDINFO, MPFROMLONG(count), 0L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4385
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4386 if(!first)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4387 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4388 free(offStruct);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4389 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4390 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4391
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4392 for(z=0;z<count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4393 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4394 if(z==separator-1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4395 left=details;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4396 details->cb = sizeof(FIELDINFO);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4397 details->flData = flags[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4398 details->flTitle = CFA_FITITLEREADONLY;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4399 details->pTitleData = titles[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4400 details->offStruct = offStruct[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4401 details = details->pNextFieldInfo;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4402 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4403
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4404 detin.cb = sizeof(FIELDINFOINSERT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4405 detin.fInvalidateFieldInfo = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4406 detin.pFieldInfoOrder = (PFIELDINFO) CMA_FIRST;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4407 detin.cFieldInfoInsert = (ULONG)count;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4408
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4409 WinSendMsg(handle, CM_INSERTDETAILFIELDINFO, MPFROMP(first), MPFROMP(&detin));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4410
18
f1002d51d959 Fixed a container problem on OS/2 with separator set to 0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 16
diff changeset
4411 if(count > separator && separator > 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4412 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4413 cnri.cb = sizeof(CNRINFO);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4414 cnri.pFieldInfoLast = left;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4415 cnri.xVertSplitbar = 150;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4416
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4417 WinSendMsg(handle, CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_PFIELDINFOLAST | CMA_XVERTSPLITBAR));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4418 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4419
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4420 free(offStruct);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4421 return TRUE;
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 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
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 container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4428 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4429 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4430 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4431 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4432 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4433 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4434 char **newtitles = malloc(sizeof(char *) * (count + 2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4435 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4436
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4437 newtitles[0] = "Icon";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4438 newtitles[1] = "Filename";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4439
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4440 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4441 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4442
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4443 memcpy(&newtitles[2], titles, sizeof(char *) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4444 memcpy(&newflags[2], flags, sizeof(unsigned long) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4445
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4446 dw_container_setup(handle, newflags, newtitles, count + 2, 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4447
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4448 free(newtitles);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4449 free(newflags);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4450 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4451 }
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 * Obtains an icon from a module (or header in GTK).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4455 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4456 * module: Handle to module (DLL) in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4457 * id: A unsigned long id int the resources on OS/2 and
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4458 * Windows, on GTK this is converted to a pointer
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4459 * to an embedded XPM.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4460 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4461 unsigned long dw_icon_load(unsigned long module, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4462 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4463 return WinLoadPointer(HWND_DESKTOP,module,id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4464 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4465
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4466 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4467 * Frees a loaded resource in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4468 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4469 * handle: Handle to icon returned by dw_icon_load().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4470 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4471 void dw_icon_free(unsigned long handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4472 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4473 WinDestroyPointer(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4474 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4475
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4476 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4477 * Allocates memory used to populate a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4478 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4479 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4480 * rowcount: The number of items to be populated.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4481 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4482 void *dw_container_alloc(HWND handle, int rowcount)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4483 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4484 ULONG *flags = (ULONG *)WinQueryWindowPtr(handle, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4485 int z, size = 0, totalsize, count = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4486 PRECORDCORE temp;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4487 ContainerInfo *ci;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4488 void *blah;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4489
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4490 if(!flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4491 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4492
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4493 while(flags[count])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4494 count++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4495
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4496 /* Figure out the offsets to the items in the struct */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4497 for(z=0;z<count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4498 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4499 if(flags[z] & DW_CFA_BITMAPORICON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4500 size += sizeof(HPOINTER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4501 else if(flags[z] & DW_CFA_STRING)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4502 size += sizeof(char *);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4503 else if(flags[z] & DW_CFA_ULONG)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4504 size += sizeof(ULONG);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4505 else if(flags[z] & DW_CFA_DATE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4506 size += sizeof(CDATE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4507 else if(flags[z] & DW_CFA_TIME)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4508 size += sizeof(CTIME);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4509 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4510
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4511 totalsize = size + sizeof(RECORDCORE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4512
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4513 blah = (void *)WinSendMsg(handle, CM_ALLOCRECORD, MPFROMLONG(size), MPFROMLONG(rowcount));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4514
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4515 if(!blah)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4516 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4517
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4518 temp = (PRECORDCORE)blah;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4519
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4520 for(z=0;z<rowcount;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4521 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4522 temp->cb = totalsize;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4523 temp = temp->preccNextRecord;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4524 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4525
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4526 ci = malloc(sizeof(struct _containerinfo));
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4527
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4528 ci->count = rowcount;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4529 ci->data = blah;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4530 ci->handle = handle;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4531
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4532 return (void *)ci;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4533 }
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 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4537 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4538 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4539 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4540 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4541 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4542 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4543 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4544 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4545 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4546 ULONG totalsize, size = 0, *flags = (ULONG *)WinQueryWindowPtr(handle, 0);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4547 int z, currentcount;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4548 ContainerInfo *ci = (ContainerInfo *)pointer;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4549 PRECORDCORE temp;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4550 CNRINFO cnr;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4551 void *dest;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4552
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4553 if(!ci)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4554 return;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4555
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4556 if(!flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4557 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4558
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4559 temp = (PRECORDCORE)ci->data;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4560
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4561 WinSendMsg(handle, CM_QUERYCNRINFO, (MPARAM)&cnr, MPFROMSHORT(sizeof(CNRINFO)));
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4562 currentcount = cnr.cRecords;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4563
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4564 /* Figure out the offsets to the items in the struct */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4565 for(z=0;z<column;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4566 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4567 if(flags[z] & DW_CFA_BITMAPORICON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4568 size += sizeof(HPOINTER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4569 else if(flags[z] & DW_CFA_STRING)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4570 size += sizeof(char *);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4571 else if(flags[z] & DW_CFA_ULONG)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4572 size += sizeof(ULONG);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4573 else if(flags[z] & DW_CFA_DATE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4574 size += sizeof(CDATE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4575 else if(flags[z] & DW_CFA_TIME)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4576 size += sizeof(CTIME);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4577 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4578
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4579 totalsize = size + sizeof(RECORDCORE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4580
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4581 for(z=0;z<(row-currentcount);z++)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4582 temp = temp->preccNextRecord;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4583
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4584 dest = (void *)(((ULONG)temp)+((ULONG)totalsize));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4585
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4586 if(flags[column] & DW_CFA_BITMAPORICON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4587 memcpy(dest, data, sizeof(HPOINTER));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4588 else if(flags[column] & DW_CFA_STRING)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4589 memcpy(dest, data, sizeof(char *));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4590 else if(flags[column] & DW_CFA_ULONG)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4591 memcpy(dest, data, sizeof(ULONG));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4592 else if(flags[column] & DW_CFA_DATE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4593 memcpy(dest, data, sizeof(CDATE));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4594 else if(flags[column] & DW_CFA_TIME)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4595 memcpy(dest, data, sizeof(CTIME));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4596 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4597
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4598 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4599 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4600 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4601 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4602 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4603 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4604 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4605 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4606 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4607 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
4608 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4609 dw_container_set_item(handle, pointer, 0, row, (void *)&icon);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4610 dw_container_set_item(handle, pointer, 1, row, (void *)&filename);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4611 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4612
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4613 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4614 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4615 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4616 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4617 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4618 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4619 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4620 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4621 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4622 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4623 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4624 dw_container_set_item(handle, pointer, column + 2, row, data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4625 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4626
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4627 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4628 * 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: 21
diff changeset
4629 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4630 * 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: 21
diff changeset
4631 * 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: 21
diff changeset
4632 * 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: 21
diff changeset
4633 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4634 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: 21
diff changeset
4635 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4636 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4637
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4638 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4639 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4640 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4641 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4642 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4643 * title: String title of the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4644 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4645 void dw_container_set_row_title(void *pointer, int row, char *title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4646 {
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4647 ContainerInfo *ci = (ContainerInfo *)pointer;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4648 PRECORDCORE temp = (PRECORDCORE)ci->data;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4649 int z, currentcount;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4650 CNRINFO cnr;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4651
23
2932f9d2c7d5 New OS/2 code from FX changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4652 if(!ci)
2932f9d2c7d5 New OS/2 code from FX changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4653 return;
2932f9d2c7d5 New OS/2 code from FX changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4654
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4655 WinSendMsg(ci->handle, CM_QUERYCNRINFO, (MPARAM)&cnr, MPFROMSHORT(sizeof(CNRINFO)));
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4656 currentcount = cnr.cRecords;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4657
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4658 for(z=0;z<(row-currentcount);z++)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4659 temp = temp->preccNextRecord;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4660
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4661 temp->pszIcon = title;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4662 temp->pszName = title;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4663 temp->pszText = title;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4664 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4665
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4666 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4667 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4668 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4669 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4670 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4671 * rowcount: The number of rows to be inserted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4672 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4673 void dw_container_insert(HWND handle, void *pointer, int rowcount)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4674 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4675 RECORDINSERT recin;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4676 ContainerInfo *ci = (ContainerInfo *)pointer;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4677
23
2932f9d2c7d5 New OS/2 code from FX changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4678 if(!ci)
2932f9d2c7d5 New OS/2 code from FX changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4679 return;
2932f9d2c7d5 New OS/2 code from FX changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4680
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4681 recin.cb = sizeof(RECORDINSERT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4682 recin.pRecordOrder = (PRECORDCORE)CMA_END;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4683 recin.pRecordParent = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4684 recin.zOrder = CMA_TOP;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4685 recin.fInvalidateRecord = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4686 recin.cRecordsInsert = rowcount;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4687
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4688 WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(ci->data), MPFROMP(&recin));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4689 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4690
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4691 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4692 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4693 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4694 * handle: Handle to the window (widget) to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4695 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4696 void dw_container_clear(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4697 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4698 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)0L, MPFROM2SHORT(0, CMA_INVALIDATE | CMA_FREE));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4699 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4700
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4701 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4702 * 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: 21
diff changeset
4703 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4704 * 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: 21
diff changeset
4705 * 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: 21
diff changeset
4706 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4707 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: 21
diff changeset
4708 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4709 RECORDCORE *last, **prc = malloc(sizeof(RECORDCORE *) * rowcount);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4710 int current = 1;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4711
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4712 prc[0] = last = (RECORDCORE *)WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4713
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4714 while(last && current < rowcount)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4715 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4716 prc[current] = last = (RECORDCORE *)WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)last, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4717 current++;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4718 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4719 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)prc, MPFROM2SHORT(current, CMA_INVALIDATE | CMA_FREE));
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4720 free(prc);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4721 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4722
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4723 /*
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4724 * 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: 21
diff changeset
4725 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4726 * 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: 21
diff changeset
4727 * 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: 21
diff changeset
4728 * 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: 21
diff changeset
4729 * 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: 21
diff changeset
4730 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4731 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: 21
diff changeset
4732 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4733 switch(direction)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4734 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4735 case DW_SCROLL_TOP:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4736 WinSendMsg(handle, CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(-10000000));
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4737 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4738 case DW_SCROLL_BOTTOM:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4739 WinSendMsg(handle, CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(10000000));
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4740 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4741 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4742 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4743
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 21
diff changeset
4744 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4745 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4746 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4747 * handle: Handle to the window (widget) to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4748 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4749 void dw_container_set_view(HWND handle, unsigned long flags, int iconwidth, int iconheight)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4750 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4751 CNRINFO cnrinfo;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4752
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4753 cnrinfo.flWindowAttr = flags;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4754 cnrinfo.slBitmapOrIcon.cx = iconwidth;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4755 cnrinfo.slBitmapOrIcon.cy = iconheight;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4756
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4757 WinSendMsg(handle, CM_SETCNRINFO, &cnrinfo, MPFROMLONG(CMA_FLWINDOWATTR | CMA_SLBITMAPORICON));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4758 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4759
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4760 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4761 * Starts a new query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4762 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4763 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4764 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4765 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4766 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4767 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4768 char *dw_container_query_start(HWND handle, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4769 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4770 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4771 if(pCore)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4772 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4773 if(flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4774 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4775 while(pCore)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4776 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4777 if(pCore->flRecordAttr & CRA_SELECTED)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4778 return pCore->pszIcon;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4779 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
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 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4783 return pCore->pszIcon;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4784 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4785 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4786 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4787
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4788 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4789 * Continues an existing query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4790 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4791 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4792 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4793 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4794 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4795 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4796 char *dw_container_query_next(HWND handle, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4797 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4798 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4799 if(pCore)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4800 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4801 if(flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4802 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4803 while(pCore)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4804 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4805 if(pCore->flRecordAttr & CRA_SELECTED)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4806 return pCore->pszIcon;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4807
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4808 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4809 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4810 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4811 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4812 return pCore->pszIcon;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4813 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4814 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4815 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4816
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4817 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4818 * Creates a rendering context widget (window) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4819 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4820 * id: An id to be used with dw_window_from_id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4821 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4822 * A handle to the widget or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4823 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4824 HWND dw_render_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4825 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4826 HWND hwndframe = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4827 WC_FRAME,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4828 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4829 WS_VISIBLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4830 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4831 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4832 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4833 id,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4834 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4835 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4836 WinSubclassWindow(hwndframe, _RendProc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4837 return hwndframe;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4838 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4839
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4840 /* Sets the current foreground drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4841 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4842 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4843 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4844 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4845 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4846 void dw_color_foreground_set(unsigned long value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4847 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4848 _foreground = DW_RED_VALUE(value) << 16 | DW_GREEN_VALUE(value) << 8 | DW_BLUE_VALUE(value);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4849 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4850
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4851 /* Sets the current background drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4852 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4853 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4854 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4855 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4856 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4857 void dw_color_background_set(unsigned long value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4858 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4859 _background = DW_RED_VALUE(value) << 16 | DW_GREEN_VALUE(value) << 8 | DW_BLUE_VALUE(value);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4860 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4861
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4862 HPS _set_hps(HPS hps)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4863 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4864 LONG alTable[18];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4865
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4866 GpiQueryLogColorTable(hps, 0L, 0L, 18L, alTable);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4867
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4868 alTable[16] = _foreground;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4869 alTable[17] = _background;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4870
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4871 GpiCreateLogColorTable(hps,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4872 0L,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4873 LCOLF_CONSECRGB,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4874 0L,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4875 18,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4876 alTable);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4877 GpiSetColor(hps, 16);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4878 GpiSetBackColor(hps, 17);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4879 return hps;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4880 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4881
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4882 HPS _set_colors(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4883 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4884 HPS hps = WinGetPS(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4885
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4886 _set_hps(hps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4887 return hps;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4888 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4889
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4890 /* Draw a point on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4891 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4892 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4893 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4894 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4895 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4896 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4897 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4898 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4899 HPS hps;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4900 int height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4901 POINTL ptl;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4902
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4903 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4904 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4905 hps = _set_colors(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4906 height = _get_height(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4907 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4908 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4909 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4910 hps = _set_hps(pixmap->hps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4911 height = pixmap->height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4912 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4913 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4914 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4915
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4916 ptl.x = x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4917 ptl.y = height - y - 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4918
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4919 GpiSetPel(hps, &ptl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4920 if(!pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4921 WinReleasePS(hps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4922 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4923
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4924 /* Draw a line on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4925 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4926 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4927 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4928 * x1: First X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4929 * y1: First Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4930 * x2: Second X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4931 * y2: Second Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4932 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4933 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
4934 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4935 HPS hps;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4936 int height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4937 POINTL ptl[2];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4938
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4939 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4940 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4941 hps = _set_colors(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4942 height = _get_height(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4943 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4944 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4945 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4946 hps = _set_hps(pixmap->hps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4947 height = pixmap->height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4948 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4949 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4950 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4951
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4952 ptl[0].x = x1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4953 ptl[0].y = height - y1 - 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4954 ptl[1].x = x2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4955 ptl[1].y = height - y2 - 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4956
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4957 GpiMove(hps, &ptl[0]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4958 GpiLine(hps, &ptl[1]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4959
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4960 if(!pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4961 WinReleasePS(hps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4962 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4963
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4964
9
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4965 void _CopyFontSettings(HPS hpsSrc, HPS hpsDst)
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4966 {
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4967 FONTMETRICS fm;
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4968 FATTRS fat;
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4969 SIZEF sizf;
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4970
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4971 GpiQueryFontMetrics(hpsSrc, sizeof(FONTMETRICS), &fm);
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4972
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4973 memset(&fat, 0, sizeof(fat));
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4974
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4975 fat.usRecordLength = sizeof(FATTRS);
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4976 fat.lMatch = fm.lMatch;
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4977 strcpy(fat.szFacename, fm.szFacename);
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4978
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4979 GpiCreateLogFont(hpsDst, 0, 1L, &fat);
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4980 GpiSetCharSet(hpsDst, 1L);
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4981
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4982 sizf.cx = MAKEFIXED(fm.lEmInc,0);
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4983 sizf.cy = MAKEFIXED(fm.lMaxBaselineExt,0);
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4984 GpiSetCharBox(hpsDst, &sizf );
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4985 }
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4986
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4987 /* Draw text on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4988 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4989 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4990 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4991 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4992 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4993 * text: Text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4994 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4995 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4996 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4997 HPS hps;
9
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4998 int size = 9, z, height;
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
4999 RECTL rcl;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5000 char fontname[128];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5001
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5002 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5003 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5004 hps = _set_colors(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5005 height = _get_height(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5006 _GetPPFont(handle, fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5007 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5008 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5009 {
9
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
5010 HPS pixmaphps = WinGetPS(pixmap->handle);
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
5011
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5012 hps = _set_hps(pixmap->hps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5013 height = pixmap->height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5014 _GetPPFont(pixmap->handle, fontname);
9
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
5015 _CopyFontSettings(pixmaphps, hps);
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
5016 WinReleasePS(pixmaphps);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5017 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5018 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5019 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5020
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5021 for(z=0;z<strlen(fontname);z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5022 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5023 if(fontname[z]=='.')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5024 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5025 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5026 size = atoi(fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5027
9
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
5028 rcl.xLeft = x;
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
5029 rcl.yTop = height - y;
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
5030 rcl.yBottom = rcl.yTop - (size*2);
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
5031 rcl.xRight = rcl.xLeft + (size * strlen(text));
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
5032
3383ed751a7e New font rendering code in dw_draw_text(). Slightly less flexible but
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 8
diff changeset
5033 WinDrawText(hps, -1, text, &rcl, DT_TEXTATTRS, DT_TEXTATTRS, DT_VCENTER | DT_LEFT | DT_TEXTATTRS);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5034
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5035 if(!pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5036 WinReleasePS(hps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5037 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5038
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5039
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5040
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5041
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5042 /* Draw a rectangle on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5043 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5044 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5045 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5046 * fill: Fill box TRUE or FALSE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5047 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5048 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5049 * width: Width of rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5050 * height: Height of rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5051 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5052 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
5053 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5054 HPS hps;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5055 int thisheight;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5056 POINTL ptl[2];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5057
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5058 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5059 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5060 hps = _set_colors(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5061 thisheight = _get_height(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5062 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5063 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5064 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5065 hps = _set_hps(pixmap->hps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5066 thisheight = pixmap->height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5067 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5068 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5069 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5070
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5071 ptl[0].x = x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5072 ptl[0].y = thisheight - y - 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5073 ptl[1].x = x + width - 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5074 ptl[1].y = thisheight - y - height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5075
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5076 GpiMove(hps, &ptl[0]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5077 GpiBox(hps, fill ? DRO_OUTLINEFILL : DRO_OUTLINE, &ptl[1], 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5078
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5079 if(!pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5080 WinReleasePS(hps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5081 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5082
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5083 /* Call this after drawing to the screen to make sure
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5084 * anything you have drawn is visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5085 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5086 void dw_flush(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5087 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5088 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5089
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5090 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5091 * Creates a pixmap with given parameters.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5092 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5093 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5094 * width: Width of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5095 * height: Height of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5096 * depth: Color depth of the pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5097 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5098 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5099 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5100 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5101 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5102 BITMAPINFOHEADER bmih;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5103 SIZEL sizl = { 0, 0 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5104 HPIXMAP pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5105 HDC hdc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5106 HPS hps;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5107 ULONG ulFlags;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5108 LONG cPlanes, cBitCount;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5109
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5110 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5111 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5112
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5113 hps = WinGetPS(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5114
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5115 hdc = GpiQueryDevice(hps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5116 ulFlags = GpiQueryPS(hps, &sizl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5117
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5118 pixmap->handle = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5119 pixmap->hdc = DevOpenDC(dwhab, OD_MEMORY, "*", 0L, NULL, hdc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5120 pixmap->hps = GpiCreatePS (dwhab, pixmap->hdc, &sizl, ulFlags | GPIA_ASSOC);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5121
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5122 DevQueryCaps(hdc, CAPS_COLOR_PLANES , 1L, &cPlanes);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5123 if (!depth)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5124 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5125 DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1L, &cBitCount);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5126 depth = cBitCount;
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 memset(&bmih, 0, sizeof(BITMAPINFOHEADER));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5130 bmih.cbFix = sizeof(BITMAPINFOHEADER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5131 bmih.cx = (SHORT)width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5132 bmih.cy = (SHORT)height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5133 bmih.cPlanes = (SHORT)cPlanes;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5134 bmih.cBitCount = (SHORT)depth;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5135
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5136 pixmap->width = width; pixmap->height = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5137
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5138 pixmap->hbm = GpiCreateBitmap(pixmap->hps, (PBITMAPINFOHEADER2)&bmih, 0L, NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5139
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5140 GpiSetBitmap(pixmap->hps, pixmap->hbm);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5141
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5142 if (depth>8)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5143 GpiCreateLogColorTable(pixmap->hps, LCOL_PURECOLOR, LCOLF_RGB, 0, 0, NULL );
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5144
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5145 WinReleasePS(hps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5146
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5147 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5148 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5149
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5150 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5151 * Creates a pixmap from internal resource graphic specified by id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5152 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5153 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5154 * id: Resource ID associated with requested pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5155 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5156 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5157 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5158 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5159 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5160 BITMAPINFOHEADER bmih;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5161 SIZEL sizl = { 0, 0 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5162 HPIXMAP pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5163 HDC hdc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5164 HPS hps;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5165 ULONG ulFlags;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5166
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5167 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5168 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5169
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5170 hps = WinGetPS(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5171
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5172 hdc = GpiQueryDevice(hps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5173 ulFlags = GpiQueryPS(hps, &sizl);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5174
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5175 pixmap->hdc = DevOpenDC(dwhab, OD_MEMORY, "*", 0L, NULL, hdc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5176 pixmap->hps = GpiCreatePS (dwhab, pixmap->hdc, &sizl, ulFlags | GPIA_ASSOC);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5177
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5178 pixmap->hbm = GpiLoadBitmap(pixmap->hps, NULLHANDLE, id, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5179
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5180 GpiQueryBitmapParameters(pixmap->hbm, &bmih);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5181
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5182 GpiSetBitmap(pixmap->hps, pixmap->hbm);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5183
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5184 pixmap->width = bmih.cx; pixmap->height = bmih.cy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5185
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5186 WinReleasePS(hps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5187
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5188 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5189 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5190
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5191 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5192 * Destroys an allocated pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5193 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5194 * pixmap: Handle to a pixmap returned by
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5195 * dw_pixmap_new..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5196 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5197 void dw_pixmap_destroy(HPIXMAP pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5198 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5199 GpiSetBitmap(pixmap->hps, NULLHANDLE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5200 GpiDeleteBitmap(pixmap->hbm);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5201 GpiAssociate(pixmap->hps, NULLHANDLE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5202 GpiDestroyPS(pixmap->hps);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5203 DevCloseDC(pixmap->hdc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5204 free(pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5205 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5206
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5207 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5208 * Copies from one item to another.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5209 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5210 * dest: Destination window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5211 * destp: Destination pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5212 * xdest: X coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5213 * ydest: Y coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5214 * width: Width of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5215 * height: Height of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5216 * src: Source window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5217 * srcp: Source pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5218 * xsrc: X coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5219 * ysrc: Y coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5220 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5221 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
5222 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5223 HPS hpsdest;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5224 HPS hpssrc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5225 POINTL ptl[4];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5226 int destheight, srcheight;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5227
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5228 if(dest)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5229 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5230 hpsdest = WinGetPS(dest);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5231 destheight = _get_height(dest);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5232 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5233 else if(destp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5234 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5235 hpsdest = destp->hps;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5236 destheight = destp->height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5237 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5238 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5239 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5240
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5241 if(src)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5242 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5243 hpssrc = WinGetPS(src);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5244 srcheight = _get_height(src);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5245 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5246 else if(srcp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5247 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5248 hpssrc = srcp->hps;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5249 srcheight = srcp->height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5250 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5251 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5252 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5253 if(!destp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5254 WinReleasePS(hpsdest);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5255 return;
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 ptl[0].x = xdest;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5259 ptl[0].y = (destheight - ydest) - height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5260 ptl[1].x = ptl[0].x + width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5261 ptl[1].y = destheight - ydest;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5262 ptl[2].x = xsrc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5263 ptl[2].y = srcheight - (ysrc + height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5264 ptl[3].x = ptl[2].x + width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5265 ptl[3].y = ptl[2].y + height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5266
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5267 GpiBitBlt(hpsdest, hpssrc, 4, ptl, ROP_SRCCOPY, BBO_IGNORE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5268
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5269 if(!destp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5270 WinReleasePS(hpsdest);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5271 if(!srcp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5272 WinReleasePS(hpssrc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5273 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5274
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5275 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5276 * Emits a beep.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5277 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5278 * freq: Frequency.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5279 * dur: Duration.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5280 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5281 void dw_beep(int freq, int dur)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5282 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5283 DosBeep(freq, dur);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5284 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5285
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5286 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5287 * Returns the handle to an unnamed mutex semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5288 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5289 HMTX dw_mutex_new(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5290 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5291 HMTX mutex;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5292
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5293 DosCreateMutexSem(NULL, &mutex, 0, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5294 return mutex;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5295 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5296
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5297 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5298 * Closes a semaphore created by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5299 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5300 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5301 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5302 void dw_mutex_close(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5303 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5304 DosCloseMutexSem(mutex);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5305 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5306
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5307 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5308 * Tries to gain access to the semaphore, if it can't it blocks.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5309 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5310 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5311 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5312 void dw_mutex_lock(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5313 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5314 DosRequestMutexSem(mutex, SEM_INDEFINITE_WAIT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5315 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5316
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5317 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5318 * Reliquishes the access to the semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5319 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5320 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5321 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5322 void dw_mutex_unlock(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5323 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5324 DosReleaseMutexSem(mutex);
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 * Returns the handle to an unnamed event semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5329 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5330 HEV dw_event_new(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5331 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5332 HEV blah;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5333
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5334 if(DosCreateEventSem (NULL, &blah, 0L, FALSE))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5335 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5336
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5337 return blah;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5338 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5339
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5340 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5341 * Resets a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5342 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5343 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5344 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5345 int dw_event_reset(HEV eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5346 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5347 ULONG count;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5348
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5349 if(DosResetEventSem(eve, &count))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5350 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5351 return TRUE;
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 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5355 * Posts a semaphore created by dw_event_new(). Causing all threads
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5356 * waiting on this event in dw_event_wait to continue.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5357 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5358 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5359 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5360 int dw_event_post(HEV eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5361 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5362 if(DosPostEventSem(eve))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5363 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5364 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5365 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5366
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5367
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5368 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5369 * Waits on a semaphore created by dw_event_new(), until the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5370 * event gets posted or until the timeout expires.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5371 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5372 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5373 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5374 int dw_event_wait(HEV eve, unsigned long timeout)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5375 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5376 int rc = DosWaitEventSem(eve, timeout);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5377 if(!rc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5378 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5379 if(rc == ERROR_TIMEOUT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5380 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5381 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5382 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5383
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5384 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5385 * Closes a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5386 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5387 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5388 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5389 int dw_event_close(HEV *eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5390 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5391 if(!eve || ~DosCloseEventSem(*eve))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5392 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5393 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5394 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5395
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5396 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5397 * Encapsulate the message queues on OS/2.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5398 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5399 void _dwthreadstart(void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5400 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5401 HAB thishab = WinInitialize(0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5402 HMQ thishmq = WinCreateMsgQueue(dwhab, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5403 void (*threadfunc)(void *) = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5404 void **tmp = (void **)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5405
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5406 threadfunc = (void (*)(void *))tmp[0];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5407 threadfunc(tmp[1]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5408
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5409 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5410
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5411 WinDestroyMsgQueue(thishmq);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5412 WinTerminate(thishab);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5413 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5414
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5415 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5416 * Creates a new thread with a starting point of func.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5417 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5418 * func: Function which will be run in the new thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5419 * data: Parameter(s) passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5420 * stack: Stack size of new thread (OS/2 and Windows only).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5421 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5422 DWTID dw_thread_new(void *func, void *data, int stack)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5423 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5424 void **tmp = malloc(sizeof(void *) * 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5425
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5426 tmp[0] = func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5427 tmp[1] = data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5428
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5429 return (DWTID)_beginthread((void (*)(void *))_dwthreadstart, NULL, stack, (void *)tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5430 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5431
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5432 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5433 * Ends execution of current thread immediately.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5434 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5435 void dw_thread_end(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5436 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5437 _endthread();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5438 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5439
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5440 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5441 * Returns the current thread's ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5442 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5443 DWTID dw_thread_id(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5444 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5445 return (DWTID)_threadid;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5446 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5447
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5448 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5449 * Cleanly terminates a DW session, should be signal handler safe.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5450 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5451 * exitcode: Exit code reported to the operating system.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5452 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5453 void dw_exit(int exitcode)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5454 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5455 /* In case we are in a signal handler, don't
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5456 * try to free memory that could possibly be
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5457 * free()'d by the runtime already.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5458 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5459 #ifndef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5460 Root = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5461 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5462 exit(exitcode);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5463 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5464
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5465 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5466 * Pack a splitbar (sizer) into the specified box from the start.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5467 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5468 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5469 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5470 void dw_box_pack_splitbar_start(HWND box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5471 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5472 Box *thisbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5473
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5474 if(WinWindowFromID(box, FID_CLIENT))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5475 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5476 box = WinWindowFromID(box, FID_CLIENT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5477 thisbox = WinQueryWindowPtr(box, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5478 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5479 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5480 thisbox = WinQueryWindowPtr(box, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5481 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5482 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5483 HWND tmp = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5484 SplitbarClassName,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5485 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5486 WS_VISIBLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5487 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5488 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5489 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5490 0L,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5491 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5492 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5493 if(thisbox->type == BOXVERT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5494 dw_box_pack_start(box, tmp, 1, SPLITBAR_WIDTH, TRUE, FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5495 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5496 dw_box_pack_start(box, tmp, SPLITBAR_WIDTH, 1, FALSE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5497
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5498 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5499 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5500
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5501 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5502 * Pack a splitbar (sizer) into the specified box from the end.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5503 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5504 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5505 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5506 void dw_box_pack_splitbar_end(HWND box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5507 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5508 Box *thisbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5509
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5510 if(WinWindowFromID(box, FID_CLIENT))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5511 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5512 box = WinWindowFromID(box, FID_CLIENT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5513 thisbox = WinQueryWindowPtr(box, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5514 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5515 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5516 thisbox = WinQueryWindowPtr(box, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5517 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5518 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5519 HWND tmp = WinCreateWindow(HWND_OBJECT,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5520 SplitbarClassName,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5521 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5522 WS_VISIBLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5523 0,0,2000,1000,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5524 NULLHANDLE,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5525 HWND_TOP,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5526 0L,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5527 NULL,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5528 NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5529 if(thisbox->type == BOXVERT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5530 dw_box_pack_end(box, tmp, 1, SPLITBAR_WIDTH, TRUE, FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5531 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5532 dw_box_pack_end(box, tmp, SPLITBAR_WIDTH, 1, FALSE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5533
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5534 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5535 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5536
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5537 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5538 * Pack windows (widgets) into a box from the start (or top).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5539 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5540 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5541 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5542 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5543 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5544 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5545 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5546 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5547 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5548 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
5549 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5550 Box *thisbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5551
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5552 if(WinWindowFromID(box, FID_CLIENT))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5553 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5554 box = WinWindowFromID(box, FID_CLIENT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5555 thisbox = WinQueryWindowPtr(box, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5556 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5557 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5558 thisbox = WinQueryWindowPtr(box, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5559 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5560 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5561 if(thisbox->type == BOXHORZ)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5562 dw_box_pack_end_stub(box, item, width, height, hsize, vsize, pad);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5563 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5564 dw_box_pack_start_stub(box, item, width, height, hsize, vsize, pad);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5565 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5566 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5567
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5568 void dw_box_pack_start_stub(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5569 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5570 HWND boxowner = NULLHANDLE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5571 Box *thisbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5572
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5573 if(WinWindowFromID(box, FID_CLIENT))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5574 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5575 box = WinWindowFromID(box, FID_CLIENT);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5576 thisbox = WinQueryWindowPtr(box, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5577 hsize = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5578 vsize = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5579 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5580 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5581 thisbox = WinQueryWindowPtr(box, QWP_USER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5582 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5583 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5584 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5585 Item *tmpitem, *thisitem = thisbox->items;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5586 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5587
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5588 tmpitem = malloc(sizeof(Item)*(thisbox->count+1));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5589
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5590 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5591 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5592 tmpitem[z+1] = thisitem[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5593 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5594
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5595 WinQueryClassName(item, 99, tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5596
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5597 if(strncmp(tmpbuf, "#1", 2)==0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5598 tmpitem[0].type = TYPEBOX;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5599 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5600 tmpitem[0].type = TYPEITEM;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5601
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5602 tmpitem[0].hwnd = item;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5603 tmpitem[0].origwidth = tmpitem[0].width = width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5604 tmpitem[0].origheight = tmpitem[0].height = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5605 tmpitem[0].pad = pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5606 if(hsize)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5607 tmpitem[0].hsize = SIZEEXPAND;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5608 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5609 tmpitem[0].hsize = SIZESTATIC;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5610
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5611 if(vsize)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5612 tmpitem[0].vsize = SIZEEXPAND;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5613 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5614 tmpitem[0].vsize = SIZESTATIC;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5615
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5616 thisbox->items = tmpitem;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5617
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5618 if(thisbox->count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5619 free(thisitem);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5620
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5621 thisbox->count++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5622
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5623 WinQueryClassName(item, 99, tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5624 /* Don't set the ownership if it's an entryfield or combobox */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5625 if(strncmp(tmpbuf, "#6", 2)!=0 /*&& strncmp(tmpbuf, "#2", 2)!=0*/)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5626 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5627 if((boxowner = WinQueryWindow(box, QW_OWNER)) != 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5628 WinSetOwner(item, boxowner);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5629 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5630 WinSetOwner(item, box);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5631 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5632 WinSetParent(item, box, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5633 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5634 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5635
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5636 /* The following two functions graciously contributed by Peter Nielsen. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5637 static ULONG _ParseBuildLevel (char* pchBuffer, ULONG ulSize) {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5638 char* pchStart = pchBuffer;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5639 char* pchEnd = pchStart + ulSize - 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5640
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5641 while (pchEnd >= pchStart)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5642 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5643 if ((pchEnd[0] == '#') && (pchEnd[1] == '@'))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5644 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5645 *pchEnd-- = '\0';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5646 while (pchEnd >= pchStart)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5647 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5648 if ((pchEnd[0] == '@') && (pchEnd[1] == '#'))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5649 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5650 ULONG ulMajor = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5651 ULONG ulMinor = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5652
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5653 char* pch = pchEnd + 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5654 while (!isdigit (*pch) && *pch)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5655 pch++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5656
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5657 while (isdigit (*pch))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5658 ulMajor = ulMajor * 10 + *pch++ - '0';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5659
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5660 if (*pch == '.')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5661 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5662 while (isdigit (*++pch))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5663 ulMinor = ulMinor * 10 + *pch - '0';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5664 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5665 return ((ulMajor << 16) | ulMinor);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5666 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5667 pchEnd--;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5668 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5669 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5670 pchEnd--;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5671 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5672 return (0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5673 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5674
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5675 ULONG _GetSystemBuildLevel(void) {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5676 /* The build level info is normally available in the end of the OS2KRNL file. However, this is not the case in some beta versions of OS/2.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5677 * We first try to find the info in the 256 last bytes of the file. If that fails, we load the entire file and search it completely.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5678 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5679 ULONG ulBootDrive = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5680 ULONG ulBuild = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5681 if (DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive, sizeof (ulBootDrive)) == NO_ERROR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5682 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5683 char achFileName[11] = { (char)('A'+ulBootDrive-1),':','\\','O','S','2','K','R','N','L','\0' };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5684 HFILE hfile;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5685 ULONG ulResult;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5686 if (DosOpen (achFileName, &hfile, &ulResult, 0, 0, OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL) == NO_ERROR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5687 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5688 ULONG ulFileSize = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5689 if (DosSetFilePtr (hfile, 0, FILE_END, &ulFileSize) == NO_ERROR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5690 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5691 const ULONG ulFirstTry = min (256, ulFileSize);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5692 if (DosSetFilePtr (hfile, -(LONG)ulFirstTry, FILE_END, &ulResult) == NO_ERROR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5693 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5694 char *pchBuffer = malloc(ulFirstTry);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5695 if (DosRead (hfile, pchBuffer, ulFirstTry, &ulResult) == NO_ERROR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5696 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5697 ulBuild = _ParseBuildLevel (pchBuffer, ulFirstTry);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5698 if (ulBuild == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5699 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5700 if (DosSetFilePtr (hfile, 0, FILE_BEGIN, &ulResult) == NO_ERROR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5701 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5702 free(pchBuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5703 pchBuffer = malloc(ulFileSize);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5704
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5705 if (DosRead (hfile, pchBuffer, ulFileSize, &ulResult) == NO_ERROR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5706 ulBuild = _ParseBuildLevel (pchBuffer, ulFileSize);
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 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5710 free(pchBuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5711 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5712 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5713 DosClose (hfile);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5714 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5715 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5716 return (ulBuild);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5717 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5718
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5719
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5720 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5721 * Returns some information about the current operating environment.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5722 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5723 * env: Pointer to a DWEnv struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5724 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5725 void dw_environment_query(DWEnv *env)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5726 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5727 ULONG Build;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5728
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5729 if(!env)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5730 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5731
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5732 /* The default is OS/2 2.0 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5733 strcpy(env->osName,"OS/2");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5734 env->MajorVersion = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5735 env->MinorVersion = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5736
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5737 Build = _GetSystemBuildLevel();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5738 env->MinorBuild = Build & 0xFFFF;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5739 env->MajorBuild = Build >> 16;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5740
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5741 if (aulBuffer[0] == 20)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5742 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5743 int i = (unsigned int)aulBuffer[1];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5744 if (i > 20)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5745 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5746 strcpy(env->osName,"Warp");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5747 env->MajorVersion = (int)i/10;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5748 env->MinorVersion = i-(((int)i/10)*10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5749 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5750 else if (i == 10)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5751 env->MinorVersion = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5752 }
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
5753 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
5754 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
5755 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
5756 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
5757 env->DWSubVersion = DW_SUB_VERSION;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5758 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5759
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5760 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5761 * Opens a file dialog and queries user selection.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5762 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5763 * title: Title bar text for dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5764 * defpath: The default path of the open dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5765 * ext: Default file extention.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5766 * flags: DW_FILE_OPEN or DW_FILE_SAVE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5767 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5768 * NULL on error. A malloced buffer containing
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5769 * the file path on success.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5770 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5771 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5772 char *dw_file_browse(char *title, char *defpath, char *ext, int flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5773 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5774 FILEDLG fild;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5775 HWND hwndFile;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5776 int len;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5777
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5778 if(defpath)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5779 strcpy(fild.szFullFile, defpath);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5780 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5781 strcpy(fild.szFullFile, "");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5782
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5783 len = strlen(fild.szFullFile);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5784
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5785 if(len)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5786 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5787 if(fild.szFullFile[len-1] != '\\')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5788 strcat(fild.szFullFile, "\\");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5789 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5790 strcat(fild.szFullFile, "*");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5791
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5792 if(ext)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5793 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5794 strcat(fild.szFullFile, ".");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5795 strcat(fild.szFullFile, ext);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5796 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5797
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5798 fild.cbSize = sizeof(FILEDLG);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5799 fild.fl = /*FDS_HELPBUTTON |*/ FDS_CENTER | FDS_OPEN_DIALOG;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5800 fild.pszTitle = title;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5801 fild.pszOKButton = ((flags & DW_FILE_SAVE) ? "Save" : "Open");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5802 fild.ulUser = 0L;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5803 fild.pfnDlgProc = (PFNWP)WinDefFileDlgProc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5804 fild.lReturn = 0L;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5805 fild.lSRC = 0L;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5806 fild.hMod = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5807 fild.x = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5808 fild.y = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5809 fild.pszIType = (PSZ)NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5810 fild.papszITypeList = (PAPSZ)NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5811 fild.pszIDrive = (PSZ)NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5812 fild.papszIDriveList= (PAPSZ)NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5813 fild.sEAType = (SHORT)0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5814 fild.papszFQFilename= (PAPSZ)NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5815 fild.ulFQFCount = 0L;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5816
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5817 hwndFile = WinFileDlg(HWND_DESKTOP, HWND_DESKTOP, &fild);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5818 if(hwndFile)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5819 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5820 switch(fild.lReturn)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5821 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5822 case DID_OK:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5823 return strdup(fild.szFullFile);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5824 case DID_CANCEL:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5825 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5826 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5827 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5828 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5829 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5830
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5831 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5832 * Execute and external program in a seperate session.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5833 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5834 * program: Program name with optional path.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5835 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5836 * params: An array of pointers to string arguements.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5837 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5838 * -1 on error.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5839 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5840 int dw_exec(char *program, int type, char **params)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5841 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5842 return spawnvp(P_NOWAIT, program, params);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5843 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5844
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5845 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5846 * Loads a web browser pointed at the given URL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5847 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5848 * url: Uniform resource locator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5849 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5850 int dw_browse(char *url)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5851 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5852 /* Is there a way to find the webbrowser in Unix? */
20
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5853 char *execargs[3], browser[1024], *newurl = NULL;
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5854 int len;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5855
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5856 PrfQueryProfileString(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5857 "DefaultBrowserExe", NULL, browser, 1024);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5858
20
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5859 len = strlen(browser) - strlen("explore.exe");
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5860
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5861 execargs[0] = browser;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5862 execargs[1] = url;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5863 execargs[2] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5864
20
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5865 /* Special case for Web Explorer, it requires file:/// instead
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5866 * of file:// so I am handling it here.
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5867 */
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5868 if(len > 0)
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5869 {
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5870 if(stricmp(&browser[len], "explore.exe") == 0)
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5871 {
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5872 int newlen, z;
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5873 newurl = alloca(strlen(url) + 2);
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5874 sprintf(newurl, "file:///%s", &url[7]);
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5875 newlen = strlen(newurl);
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5876 for(z=8;z<(newlen-8);z++)
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5877 {
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5878 if(newurl[z] == '|')
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5879 newurl[z] = ':';
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5880 if(newurl[z] == '/')
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5881 newurl[z] = '\\';
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5882 }
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5883 execargs[1] = newurl;
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5884 }
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5885 }
38295c8d06d5 Added notebook, Warp 3 and WebExplorer fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 18
diff changeset
5886
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5887 return dw_exec(browser, DW_EXEC_GUI, execargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5888 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5889
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5890 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5891 * Returns a pointer to a static buffer which containes the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5892 * current user directory. Or the root directory (C:\ on
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5893 * OS/2 and Windows).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5894 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5895 char *dw_user_dir(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5896 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5897 static char _user_dir[1024] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5898
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5899 if(!_user_dir[0])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5900 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5901 char *home = getenv("HOME");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5902
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5903 if(home)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5904 strcpy(_user_dir, home);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5905 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5906 strcpy(_user_dir, "C:\\");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5907 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5908 return _user_dir;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5909 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5910
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5911 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5912 * Call a function from the window (widget)'s context.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5913 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5914 * handle: Window handle of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5915 * function: Function pointer to be called.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5916 * data: Pointer to the data to be passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5917 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5918 void dw_window_function(HWND handle, void *function, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5919 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5920 WinSendMsg(handle, WM_USER, (MPARAM)function, (MPARAM)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5921 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5922
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5923 #ifndef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5924 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5925 * Add a callback to a window event.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5926 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5927 * window: Window handle of signal to be called back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5928 * signame: A string pointer identifying which signal to be hooked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5929 * sigfunc: The pointer to the function to be used as the callback.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5930 * data: User data to be passed to the handler function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5931 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5932 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5933 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5934 ULONG message = 0L;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5935
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5936 if(window && signame && sigfunc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5937 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5938 if((message = _findsigmessage(signame)) != 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5939 _new_signal(message, window, sigfunc, data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5940 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5941 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5942
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5943 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5944 * Removes callbacks for a given window with given name.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5945 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5946 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5947 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5948 void dw_signal_disconnect_by_name(HWND window, char *signame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5949 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5950 SignalHandler *prev = NULL, *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5951 ULONG message;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5952
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5953 if(!window || !signame || (message = _findsigmessage(signame)) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5954 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5955
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5956 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5957 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5958 if(tmp->window == window && tmp->message == message)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5959 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5960 if(prev)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5961 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5962 prev->next = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5963 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5964 tmp = prev->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5965 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5966 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5967 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5968 Root = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5969 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5970 tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5971 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5972 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5973 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5974 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5975 prev = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5976 tmp = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5977 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5978 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5979 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5980
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5981 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5982 * Removes all callbacks for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5983 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5984 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5985 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5986 void dw_signal_disconnect_by_window(HWND window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5987 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5988 SignalHandler *prev = NULL, *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5989
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5990 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5991 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5992 if(tmp->window == window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5993 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5994 if(prev)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5995 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5996 prev->next = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5997 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5998 tmp = prev->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5999 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6000 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6001 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6002 Root = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6003 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6004 tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6005 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6006 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6007 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6008 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6009 prev = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6010 tmp = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6011 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6012 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6013 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6014
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6015 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6016 * Removes all callbacks for a given window with specified data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6017 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6018 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6019 * data: Pointer to the data to be compared against.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6020 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6021 void dw_signal_disconnect_by_data(HWND window, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6022 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6023 SignalHandler *prev = NULL, *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6024
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6025 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6026 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6027 if(tmp->window == window && tmp->data == data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6028 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6029 if(prev)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6030 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6031 prev->next = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6032 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6033 tmp = prev->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6034 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6035 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6036 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6037 Root = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6038 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6039 tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6040 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6041 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6042 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6043 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6044 prev = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6045 tmp = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6046 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6047 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6048 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6049 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6050
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6051 #ifdef TEST
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6052 HWND mainwindow,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6053 listbox,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6054 okbutton,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6055 cancelbutton,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6056 lbbox,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6057 stext,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6058 buttonbox,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6059 testwindow,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6060 testbox,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6061 testok,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6062 testcancel,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6063 testbox2,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6064 testok2,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6065 testcancel2,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6066 notebook;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6067 int count = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6068
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6069 #ifdef USE_FILTER
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6070 /* Do any handling you need in the filter function */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6071 LONG testfilter(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6072 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6073 switch(msg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6074 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6075 case WM_COMMAND:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6076 switch (COMMANDMSG(&msg)->cmd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6077 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6078 case 1001L:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6079 case 1002L:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6080 dw_window_destroy(mainwindow);;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6081 count--;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6082 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6083 case 1003L:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6084 case 1004L:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6085 dw_window_destroy(testwindow);;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6086 count--;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6087 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6088 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6089 if(!count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6090 exit(0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6091 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6092 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6093 /* Return -1 to allow the default handlers to return. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6094 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6095 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6096 #else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6097 int test_callback(HWND window, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6098 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6099 dw_window_destroy((HWND)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6100 /* Return -1 to allow the default handlers to return. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6101 count--;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6102 if(!count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6103 exit(0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6104 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6105 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6106 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6107
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6108 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6109 * Let's demonstrate the functionality of this library. :)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6110 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6111 int main(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6112 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6113 ULONG flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6114 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6115 int pageid;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6116
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6117 dw_init(TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6118
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6119 /* Try a little server dialog. :) */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6120 mainwindow = dw_window_new(HWND_DESKTOP, "Server", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6121
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6122 lbbox = dw_box_new(BOXVERT, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6123
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6124 dw_box_pack_start(mainwindow, lbbox, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6125
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6126 stext = dw_text_new("Choose a server:", 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6127
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6128 dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6129
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6130 dw_box_pack_start(lbbox, stext, 130, 15, FALSE, FALSE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6131
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6132 listbox = dw_listbox_new(100L, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6133
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6134 dw_box_pack_start(lbbox, listbox, 130, 200, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6135
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6136 buttonbox = dw_box_new(BOXHORZ, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6137
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6138 dw_box_pack_start(lbbox, buttonbox, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6139
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6140 okbutton = dw_button_new("Ok", 1001L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6141
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6142 dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, TRUE, 5);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6143
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6144 cancelbutton = dw_button_new("Cancel", 1002L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6145
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6146 dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, TRUE, 5);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6147
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6148 /* Set some nice fonts and colors */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6149 dw_window_set_color(lbbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6150 dw_window_set_color(buttonbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6151 dw_window_set_font(stext, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6152 dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6153 dw_window_set_font(listbox, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6154 dw_window_set_font(okbutton, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6155 dw_window_set_font(cancelbutton, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6156
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6157 dw_window_show(mainwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6158
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6159 dw_window_set_usize(mainwindow, 170, 340);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6160
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6161 /* Another small example */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6162 flStyle |= FCF_MINMAX | FCF_SIZEBORDER;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6163
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6164 testwindow = dw_window_new(HWND_DESKTOP, "Wow a test dialog! :) yay!", flStyle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6165
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6166 testbox = dw_box_new(BOXVERT, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6167
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6168 dw_box_pack_start(testwindow, testbox, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6169
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6170 notebook = dw_notebook_new(1010L, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6171
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6172 dw_box_pack_start(testbox, notebook, 100, 100, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6173
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6174 testbox = dw_box_new(BOXVERT, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6175
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6176 pageid = dw_notebook_page_new(notebook, 0L, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6177
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6178 dw_notebook_page_set_text(notebook, pageid, "Test page");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6179 dw_notebook_page_set_status_text(notebook, pageid, "Test page");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6180
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6181 dw_notebook_pack(notebook, pageid, testbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6182
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6183 testok = dw_button_new("Ok", 1003L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6184
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6185 dw_box_pack_start(testbox, testok, 60, 40, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6186
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6187 testcancel = dw_button_new("Cancel", 1004L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6188
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6189 dw_box_pack_start(testbox, testcancel, 60, 40, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6190
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6191 testbox2 = dw_box_new(BOXHORZ, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6192
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6193 dw_box_pack_start(testbox, testbox2, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6194
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6195 testok2 = dw_button_new("Ok", 1003L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6196
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6197 dw_box_pack_start(testbox2, testok2, 60, 40, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6198
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6199 dw_box_pack_splitbar_start(testbox2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6200
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6201 testcancel2 = dw_button_new("Cancel", 1004L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6202
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6203 dw_box_pack_start(testbox2, testcancel2, 60, 40, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6204
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6205 /* Set some nice fonts and colors */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6206 dw_window_set_color(testbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6207 dw_window_set_color(testbox2, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6208 dw_window_set_font(testok, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6209 dw_window_set_font(testcancel, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6210 dw_window_set_font(testok2, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6211 dw_window_set_font(testcancel2, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6212
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6213 dw_window_show(testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6214
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6215 #ifdef USE_FILTER
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6216 dw_main(0L, (void *)testfilter);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6217 #else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6218 /* Setup the function callbacks */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6219 dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6220 dw_signal_connect(cancelbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6221 dw_signal_connect(testok, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6222 dw_signal_connect(testcancel, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6223 dw_signal_connect(testok2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6224 dw_signal_connect(testcancel2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6225 dw_signal_connect(mainwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6226 dw_signal_connect(testwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6227
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6228 dw_main(0L, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6229 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6230
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6231 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6232 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6233 #endif