]> git.saurik.com Git - wxWidgets.git/blame - docs/microwin/readme.txt
Removed accidentally left in debug code.
[wxWidgets.git] / docs / microwin / readme.txt
CommitLineData
0fd734af
JS
1wxMicroWindows port
2===================
3
25ad2ac2 4Julian Smart 2001-12-08
0fd734af 5
bd52bee1
JS
6This is a port of wxWindows to MicroWindows, under Linux.
7Widgets are supplied by the wxUniversal project, while the
8underlying port uses the Windows ports with small modifications
9for the MicroWindows API.
0fd734af
JS
10
11There are many things missing from MicroWindows that will
12make the port quite limited for the time being. I haven't
13worked out how to create bitmaps, though there is a BMP to C
bd52bee1
JS
14converter. There are no common dialogs (we will use generic ones),
15and only one WIN32 app may be run at a time.
0fd734af 16
bd52bee1
JS
17Note that you can gain confidence in the WIN32/wxUniversal
18combination by compiling wxUniversal under Windows using VC++,
19using src/wxvc_universal.dsp. You can compile the minimal
20and widgets samples in wxUniversal mode using the
21UnivDebug and UnivRelease targets. Most of the code is shared
22between this combination, and the wxMicroWindows port.
0fd734af
JS
23
24Installation
25============
26
bd52bee1 27MicroWindows:
0fd734af 28
25ad2ac2 29- unarchive MicroWindows 0.89pre8
46d0e4b2
JS
30
31- change 'config' to use X11 and any other options you feel fit.
32 Suggestions for changes to the defaults:
33
34 ERASEMOVE=N (otherwise moving windows will look messy)
35 X11=Y
36 OPTIMIZE=N
37 DEBUG=Y
38 VERBOSE=Y
39
2a7449f4
JS
40 Note: these are already applied by the patch below.
41
46d0e4b2 42- apply microwindows.patches (from wxWindows:
bd52bee1 43 docs/microwin/microwindows.patches) to fix PeekMessage
25ad2ac2 44 and other issues. If the patch doesn't apply automatically,
2a7449f4
JS
45 you may need to apply it by hand, and the relevant changed
46 functions are given at the end of this file for convenience.
47
48 Example patch command:
49
50 % cd microwindows-0.89pre8.orig
51 % patch -p0 < ~/wx2/docs/microwin/microwindows.patches
46d0e4b2 52
bd52bee1
JS
53- compile by typing 'make' from within the MicroWindows src directory
54
55wxMicroWindows:
56
25ad2ac2 57- Download wxMSW 2.3.2 or greater, or get it from CVS
c67d6888
JS
58
59- Copy include/wx/msw/setup_microwin.h to include/wx/setup.h if
60 include/wx/setup.h doesn't exist
46d0e4b2 61
d2913c40
JS
62- EITHER:
63
64 o set the MICROWINDOWS environment variable, e.g.:
65
66 % export MICROWINDOWS=/home/julians/local/microwindows/microwindows-0.89pre8/src
67
68 OR:
69
70 o change the TOP variable at the top of src/msw/makefile.mic
71 to reflect where MicroWindows is installed
46d0e4b2 72
25ad2ac2
JS
73- type 'make -f makefile.mic all' from src/msw. To clean, use
74 cleanwx and NOT clean since that will clean MicroWindows itself
46d0e4b2 75
d2913c40
JS
76- to make the sample, cd into samples/minimal, edit the TOP variable
77 (or set MICROWINDOWS) as before, and type 'make -f makefile.mic all'
0fd734af 78
0fd734af
JS
79Running 'minimal' runs the virtual MicroWindows desktop
80and the minimal sample, since in a MicroWindows WIN32 application
81they are one and the same binary.
82
83Status
84======
85
54a96d02
JS
86The minimal sample is almost fully-functional, apart from some
87presentation issues (no menu borders and status bar in the wrong
88place.
89
90The widgets sample is crashing in DeleteObject (see notes below).
91
bd52bee1
JS
92
93Implementation Notes
94====================
0fd734af 95
bd52bee1
JS
96wxMicroWindows is essentially the wxMSW port + wxUniversal
97widgets. Lots of things in include/wx/univ/setup.h are switched
98off to allow the port to compile. There are also #ifdefs
99switching off further functionality, such as most wxBitmap
100functions, pending proper implementation.
0fd734af 101
bd52bee1
JS
102There are some WIN32 API functions not implemented by MicroWindows
103that are instead stubbed out in include/wx/msw/microwin.c,
104and 'implemented' in src/msw/microwin.c. Some of these functions
105are important, some less so. They will need to be implemented
106in due course. But implementing missing functionality in this way
107is preferably to proliferating many #ifdefs in the
108wxMSW/wxMicroWindows port itself.
109
54a96d02 110
62e1ba75
JS
111Errors/warnings
112===============
113
114In file ../../src/msw/window.cpp at line 1294: 'UpdateWindow' failed with error 0x00000000 (Success).
115
116 - caused because there are no paint messages pending. Presumed
117 harmless.
118
119In file ../../src/msw/dc.cpp at line 1838: 'BitBlt' failed with error 0x00000000 (Success).
120
121 - caused because the window isn't mapped, and MwPrepareDC in wingdi.c
122 fails (hwnd->unmapcount is non-zero). Presumed harmless.
123
124Recursive paint problem, e.g. when clicking the 'Press Me!'
125button in the widgets sample a few times, until the text control
126is full.
127
128 - possibly the scrollbar is causing the text control to be
129 updated, which somehow effects the scrollbar, which causes
130 a window update, etc.
131
132Sluggish updates.
133
134 - probably because many image to bitmap conversions are being
135 done on update, and bitmaps should probably be cached.
136
137
bd52bee1
JS
138Things missing from MicroWindows that need to be worked around
139==============================================================
140
e640f823
JS
141wxImage/inline XPM/::CreateBitmap support
142-----------------------------------------
143
144This is the main obstacle to getting a good range
145of widgets working, since wxUniversal uses inline XPMs
146to implement most of the widgets.
147
148See src/engine/devimage.c for routines for loading JPEGs,
149XPMs etc. Unfortunately the XPM routines are also #ifdefed
150for FILE_IO, even though for inline XPMs we don't need file I/O.
151(Embedded systems tend not to have file I/O, anyway.)
152
153Now, wxWindows has its own XPM decoder, src/common/xpmdecod.cpp,
154so in theory we don't need to use MicroWindows' code there.
155wxImage can load an inline XPM, _but_ we need to convert to
156a wxBitmap since this is what the widgets need.
157
158There is no ::CreateBitmap or BITMAPINFO. (BMPs can be converted
159to C using convbmp, then need to use Gr... functions.)
160
161So how can we convert from wxImage to wxBitmap in MicroWindows?
162
163Well, a simple-minded way would be to use CreateCompatibleBitmap
164which returns an HBITMAP, select it into an HDC, and draw
165the pixels from the wxImage to the HDC one by one with SetPixel.
62e1ba75
JS
166This is now implemented, but there are problems with masks.
167(a) masks have to be created at screen depth because BitBlt/GrDraw
168can't cope with differing depths, and (b) masked blitting
169is still not working (try enabling mask creation in
170wxBitmap::CreateFromImage by setting USE_MASKS to 1).
e640f823
JS
171
172
173Other missing features
174----------------------
175
bd52bee1
JS
176No ::GetKeyState (see include/wx/msw/private.h). Should probably use
177GdOpenKeyboard/GdCloseKeyboard/GdReadKeyboard. Could perhaps emulate
178GetKeyState this way.
0fd734af 179
0fd734af
JS
180No ::DestroyIcon, ::DestroyCursor - use ::DestroyObject instead?
181Also no LoadCursor, LoadImage. So how do we make cursors? No ::SetCursor.
182
183wxDC: no ::GetTextColor, ::GetBkColor, ::IntersectClipRect,
184::GetClipBox
185
bd52bee1
JS
186No ::SetMenu, so no menus or menubars (now implemented by
187wxUniversal).
0fd734af
JS
188
189No ::GetObject so we can't get LOGFONT from an HFONT
bd52bee1
JS
190in wxSystemSettings (worked around by passing HFONT to
191the wxFont constructor).
0fd734af 192
2a7449f4
JS
193
194Applying patches by hand
195========================
196
197The full altered functions are given below in case you have
198to apply them by hand.
199
200src/mwin/winevent.c
201-------------------
202
203A second test has been added to this line:
204
205 if(hittest == HTCLIENT || hwnd == GetCapture()) {
206
207in MwTranslateMouseMessage below. This corrects a mouse message
208bug.
209
210/*
211 * Translate and deliver hardware mouse message to proper window.
212 */
213void
214MwTranslateMouseMessage(HWND hwnd,UINT msg,int hittest)
215{
216 POINT pt;
217 DWORD tick;
218 static UINT lastmsg = 0;
219 static HWND lasthwnd;
220 static DWORD lasttick;
221 static int lastx, lasty;
222
223 /* determine double click eligibility*/
224 if(msg == WM_LBUTTONDOWN || msg == WM_RBUTTONDOWN) {
225 tick = GetTickCount();
226 if((hwnd->pClass->style & CS_DBLCLKS) &&
227 msg == lastmsg && hwnd == lasthwnd &&
228 tick - lasttick < DBLCLICKSPEED &&
229 abs(cursorx-lastx) < mwSYSMETRICS_CXDOUBLECLK &&
230 abs(cursory-lasty) < mwSYSMETRICS_CYDOUBLECLK)
231 msg += (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN);
232 lastmsg = msg;
233 lasthwnd = hwnd;
234 lasttick = tick;
235 lastx = cursorx;
236 lasty = cursory;
237 }
238
239 /*
240 * We always send nc mouse message
241 * unlike Windows, for HTCLIENT default processing
242 */
243 PostMessage(hwnd, msg + (WM_NCMOUSEMOVE-WM_MOUSEMOVE), hittest,
244 MAKELONG(cursorx, cursory));
245
246 /* then possibly send user mouse message*/
247 if(hittest == HTCLIENT || hwnd == GetCapture()) {
248 pt.x = cursorx;
249 pt.y = cursory;
250 ScreenToClient(hwnd, &pt);
251 PostMessage(hwnd, msg, 0, MAKELONG(pt.x, pt.y));
252 }
253}
254
255winuser.c
256---------
257
258Part of PeekMessage has been factored out into PeekMessageHelper,
259and used in PeekMessage and GetMessage. The three relevant functions
260are:
261
262/*
263 * A helper function for sharing code between PeekMessage and GetMessage
264 */
265
266BOOL WINAPI
267PeekMessageHelper(LPMSG lpMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax,
268 UINT wRemoveMsg, BOOL returnIfEmptyQueue)
269{
270 HWND wp;
271 PMSG pNxtMsg;
272
273 /* check if no messages in queue*/
274 if(mwMsgHead.head == NULL) {
275 /* Added by JACS so it doesn't reach MwSelect */
276 if (returnIfEmptyQueue)
277 return FALSE;
278
279#if PAINTONCE
280 /* check all windows for pending paint messages*/
281 for(wp=listwp; wp; wp=wp->next) {
282 if(!(wp->style & WS_CHILD)) {
283 if(chkPaintMsg(wp, lpMsg))
284 return TRUE;
285 }
286 }
287 for(wp=listwp; wp; wp=wp->next) {
288 if(wp->style & WS_CHILD) {
289 if(chkPaintMsg(wp, lpMsg))
290 return TRUE;
291 }
292 }
293#endif
294 MwSelect();
295 }
296
297 if(mwMsgHead.head == NULL)
298 return FALSE;
299
300 pNxtMsg = (PMSG)mwMsgHead.head;
301 if(wRemoveMsg & PM_REMOVE)
302 GdListRemove(&mwMsgHead, &pNxtMsg->link);
303 *lpMsg = *pNxtMsg;
304 if(wRemoveMsg & PM_REMOVE)
305 GdItemFree(pNxtMsg);
306 return TRUE;
307}
308
309BOOL WINAPI
310PeekMessage(LPMSG lpMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax,
311 UINT wRemoveMsg)
312{
313 /* Never wait in MwSelect: pass TRUE */
314 return PeekMessageHelper(lpMsg, hwnd, uMsgFilterMin, uMsgFilterMax, wRemoveMsg, TRUE);
315}
316
317BOOL WINAPI
318GetMessage(LPMSG lpMsg,HWND hwnd,UINT wMsgFilterMin,UINT wMsgFilterMax)
319{
320 /*
321 * currently MwSelect() must poll for VT switch reasons,
322 * so this code will work
323 */
324 /* Always wait in MwSelect if there are messages: pass FALSE */
325 while(!PeekMessageHelper(lpMsg, hwnd, wMsgFilterMin, wMsgFilterMax,PM_REMOVE, FALSE))
326 continue;
327 return lpMsg->message != WM_QUIT;
328}