4 Julian Smart 2001-12-08
6 This is a port of wxWindows to MicroWindows, under Linux.
7 Widgets are supplied by the wxUniversal project, while the
8 underlying port uses the Windows ports with small modifications
9 for the MicroWindows API.
11 There are many things missing from MicroWindows that will
12 make the port quite limited for the time being. I haven't
13 worked out how to create bitmaps, though there is a BMP to C
14 converter. There are no common dialogs (we will use generic ones),
15 and only one WIN32 app may be run at a time.
17 Note that you can gain confidence in the WIN32/wxUniversal
18 combination by compiling wxUniversal under Windows using VC++,
19 using src/wxvc_universal.dsp. You can compile the minimal
20 and widgets samples in wxUniversal mode using the
21 UnivDebug and UnivRelease targets. Most of the code is shared
22 between this combination, and the wxMicroWindows port.
29 - unarchive MicroWindows 0.89pre8
31 - change 'config' to use X11 and any other options you feel fit.
32 Suggestions for changes to the defaults:
34 ERASEMOVE=N (otherwise moving windows will look messy)
40 Note: these are already applied by the patch below.
42 - apply microwindows.patches (from wxWindows:
43 docs/microwin/microwindows.patches) to fix PeekMessage
44 and other issues. If the patch doesn't apply automatically,
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.
48 Example patch command:
50 % cd microwindows-0.89pre8.orig
51 % patch -p0 < ~/wx2/docs/microwin/microwindows.patches
53 - compile by typing 'make' from within the MicroWindows src directory
57 - Download wxMSW 2.3.2 or greater, or get it from CVS
59 - Copy include/wx/msw/setup_microwin.h to include/wx/setup.h if
60 include/wx/setup.h doesn't exist
62 - change the TOP variable at the top of src/msw/makefile.mic
63 to reflect where MicroWindows is installed
65 - type 'make -f makefile.mic all' from src/msw. To clean, use
66 cleanwx and NOT clean since that will clean MicroWindows itself
68 - to make the sample, cd into samples/minimal, edit the TOP variable,
69 and type 'make -f makefile.mic all'
71 Running 'minimal' runs the virtual MicroWindows desktop
72 and the minimal sample, since in a MicroWindows WIN32 application
73 they are one and the same binary.
78 The minimal sample is almost fully-functional, apart from minor
79 menu presentation issues (no borders, for example).
84 wxMicroWindows is essentially the wxMSW port + wxUniversal
85 widgets. Lots of things in include/wx/univ/setup.h are switched
86 off to allow the port to compile. There are also #ifdefs
87 switching off further functionality, such as most wxBitmap
88 functions, pending proper implementation.
90 There are some WIN32 API functions not implemented by MicroWindows
91 that are instead stubbed out in include/wx/msw/microwin.c,
92 and 'implemented' in src/msw/microwin.c. Some of these functions
93 are important, some less so. They will need to be implemented
94 in due course. But implementing missing functionality in this way
95 is preferably to proliferating many #ifdefs in the
96 wxMSW/wxMicroWindows port itself.
98 Things missing from MicroWindows that need to be worked around
99 ==============================================================
101 No ::GetKeyState (see include/wx/msw/private.h). Should probably use
102 GdOpenKeyboard/GdCloseKeyboard/GdReadKeyboard. Could perhaps emulate
103 GetKeyState this way.
105 No ::CreateBitmap or BITMAPINFO. But BMPs can be converted
106 to C using convbmp, then need to use Gr... functions.
107 We MUST implement creation from XPMs, since wxUniversal
108 makes use of XPMs, or else create our own bitmaps for
109 drawing radioboxes, checkboxes etc.: see renderers
112 No ::DestroyIcon, ::DestroyCursor - use ::DestroyObject instead?
113 Also no LoadCursor, LoadImage. So how do we make cursors? No ::SetCursor.
115 wxDC: no ::GetTextColor, ::GetBkColor, ::IntersectClipRect,
118 No ::SetMenu, so no menus or menubars (now implemented by
121 No ::GetObject so we can't get LOGFONT from an HFONT
122 in wxSystemSettings (worked around by passing HFONT to
123 the wxFont constructor).
126 Applying patches by hand
127 ========================
129 The full altered functions are given below in case you have
130 to apply them by hand.
135 A second test has been added to this line:
137 if(hittest == HTCLIENT || hwnd == GetCapture()) {
139 in MwTranslateMouseMessage below. This corrects a mouse message
143 * Translate and deliver hardware mouse message to proper window.
146 MwTranslateMouseMessage(HWND hwnd,UINT msg,int hittest)
150 static UINT lastmsg = 0;
151 static HWND lasthwnd;
152 static DWORD lasttick;
153 static int lastx, lasty;
155 /* determine double click eligibility*/
156 if(msg == WM_LBUTTONDOWN || msg == WM_RBUTTONDOWN) {
157 tick = GetTickCount();
158 if((hwnd->pClass->style & CS_DBLCLKS) &&
159 msg == lastmsg && hwnd == lasthwnd &&
160 tick - lasttick < DBLCLICKSPEED &&
161 abs(cursorx-lastx) < mwSYSMETRICS_CXDOUBLECLK &&
162 abs(cursory-lasty) < mwSYSMETRICS_CYDOUBLECLK)
163 msg += (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN);
172 * We always send nc mouse message
173 * unlike Windows, for HTCLIENT default processing
175 PostMessage(hwnd, msg + (WM_NCMOUSEMOVE-WM_MOUSEMOVE), hittest,
176 MAKELONG(cursorx, cursory));
178 /* then possibly send user mouse message*/
179 if(hittest == HTCLIENT || hwnd == GetCapture()) {
182 ScreenToClient(hwnd, &pt);
183 PostMessage(hwnd, msg, 0, MAKELONG(pt.x, pt.y));
190 Part of PeekMessage has been factored out into PeekMessageHelper,
191 and used in PeekMessage and GetMessage. The three relevant functions
195 * A helper function for sharing code between PeekMessage and GetMessage
199 PeekMessageHelper(LPMSG lpMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax,
200 UINT wRemoveMsg, BOOL returnIfEmptyQueue)
205 /* check if no messages in queue*/
206 if(mwMsgHead.head == NULL) {
207 /* Added by JACS so it doesn't reach MwSelect */
208 if (returnIfEmptyQueue)
212 /* check all windows for pending paint messages*/
213 for(wp=listwp; wp; wp=wp->next) {
214 if(!(wp->style & WS_CHILD)) {
215 if(chkPaintMsg(wp, lpMsg))
219 for(wp=listwp; wp; wp=wp->next) {
220 if(wp->style & WS_CHILD) {
221 if(chkPaintMsg(wp, lpMsg))
229 if(mwMsgHead.head == NULL)
232 pNxtMsg = (PMSG)mwMsgHead.head;
233 if(wRemoveMsg & PM_REMOVE)
234 GdListRemove(&mwMsgHead, &pNxtMsg->link);
236 if(wRemoveMsg & PM_REMOVE)
242 PeekMessage(LPMSG lpMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax,
245 /* Never wait in MwSelect: pass TRUE */
246 return PeekMessageHelper(lpMsg, hwnd, uMsgFilterMin, uMsgFilterMax, wRemoveMsg, TRUE);
250 GetMessage(LPMSG lpMsg,HWND hwnd,UINT wMsgFilterMin,UINT wMsgFilterMax)
253 * currently MwSelect() must poll for VT switch reasons,
254 * so this code will work
256 /* Always wait in MwSelect if there are messages: pass FALSE */
257 while(!PeekMessageHelper(lpMsg, hwnd, wMsgFilterMin, wMsgFilterMax,PM_REMOVE, FALSE))
259 return lpMsg->message != WM_QUIT;