readme.txt 10 KB

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