1 Readme for wxWindows Interface
2 updated Sat Dec 21 11:09:34 EST 2002
4 Contributors to wxWindows port:
10 wxWindows Configuration Interface
12 The wxWindows port began in June 2001 around the time of Bochs 1.2.1. Dave
13 Poirier and Bryce Denney started adding a wxWindows configuration interface.
14 We made some progress, but stopped after a while. Then in March/April 2002
15 Bryce and Psyon revived the wxWindows branch and turned it into a usable
16 interface. Psyon did most of the work to get text and graphics working, and
17 Bryce worked on event passing between threads, and keyboard mapping.
18 Starting in August 2002, Bryce added lots of dialog boxes to allow you
19 to set all the bochsrc parameters. At the time of release 2.0, there
20 are still some bugs but it is pretty stable and usable.
22 Bochs should be build with wxWindows 2.3.3 or later. It will probably
23 not compile with 2.2.x without some work. wxWindows 2.3.3 includes
24 a patch by Bryce Denney to allow us to get raw keycode data for several
27 On any UNIX platform with wxWindows installed, configure with
28 --with-wx to enable the wxWindows display library.
31 - edit .conf.win32-vcpp and add "--with-wx" to the configure line.
32 If you want different configure options from what you see, change them
34 - in cygwin, do "sh .conf.win32-vcpp" to run configure
35 - unzip build/win32/wxworkspace.zip into the main directory.
36 For cygwin: unzip build/win32/wxworkspace.zip
37 or use winzip or whatever else.
38 - open up bochs.dsw, the workspace file
39 - edit project settings so that VC++ can find the wxWindows include
40 files and libraries on your system. Bryce installed them in
41 d:/wx/wx233/include and d:/wx/wx233/lib. Specifically, edit
42 - Project>Settings>C/C++>Category=Preprocessor: include directories.
43 - Project>Settings>Link>Category=Input: additional library path.
46 Note that the project is set up for wxWindows 2.3.3. To use on other
47 wxwindows versions, you will have to change some of the names of the libraries
48 to include. Use the samples that came with that version of wxwindows for
52 - now that ParamDialog works, I may rewrite some of the other dialogs
53 as subclasses of ParamDialog. This would lead to more compact code,
55 - configure time dialog
56 - need to think about dialog layout
57 - setting of IPS (controls how much time the PIT associates with each
58 instruction for purposes of sending timer interrupts). How can we
59 name this? instructions per simulated second.
60 - enable realtime pit, realtime pit settings (?)
61 - enable/disable X windows idle hack
62 - report instructions per wall clock second in real time
63 - decide which settings can be adjusted at runtime, and figure out how
64 to disable the others. Do we need a set_enable() on the parameters
66 - the power button has always "turned off" the power. Make it also
67 turn ON the power. I think a few little green LEDs are in order.
68 - floppy config screen: on win32, both not present and ejected are selected
71 - Later: allow viewing of current log messages. Maybe this is a dialog that
72 we append to, or maybe it should periodically display the last 1K of the
73 log file (might be faster in high volume situations).
74 - Later: should we allow multiple log files with different settings? for
75 example dump cpu events to cpulog.txt and keyboard events to
78 - bug: it's possible to make the GUI stop responding to mouse and keyboard
79 input if you click the continue button in the debugger twice in very
80 close succession. I don't know why yet.
81 - probably the layout will be similar to BFE at first
82 - need to show disassembly of the next instruction to be executed
83 - clean up the biggest memory leaks and init/cleanup code. The gui allows you
84 to kill the simulator and restart, but it doesn't do well after the first
85 time. Valgrind should help with memory leak debugging, though until
86 recently it couldn't run multithreaded programes.
87 - disk change dialogs for floppy and cdrom need work.
88 http://sourceforge.net/tracker/index.php?func=detail&aid=545414&group_id=12580&atid=112580
91 ------------------------------------------------------
95 Added some sketches. I'm thinking that the control
96 panel will be able to basically show one of these screens at a time. When
97 you first start you would see ChooseConfigScreen which chooses between the
98 configurations that you have loaded recently (which it would remember
99 by the pathname of their bochsrc). Whether you choose an existing
100 configuration to be loaded or a new one, when you click Ok you go to
101 the first configuration screen, ConfigDiskScreen.
103 Each of the configuration screens takes up the whole control panel window.
104 We could use tabs on the top and/or "<-Prev" and "Next->" buttons to make
105 it quick to navigate the configuration screens. Each screen should
106 probably have a Prev, Next, Revert to Saved, and Accept button.
107 The menu choices like Disk..., VGA..., etc. just switch directly to
111 ------------------------------------------------------
114 events from gui to sim:
115 - [async] key pressed or released
116 - [async] mouse motion with button state
117 - [sync] query parameter
118 - [sync] change parameter
119 - [async] start, pause, stop, reset simulation. Can be implemented
120 as changing a parameter.
121 - [async] request notification when some param changes
123 events from sim to gui:
124 - [async] log message to be displayed (or not)
125 - [async] ask user how to proceed (like panic: action=ask)
126 - [async] param value changed
127 - make my thread sleep for X microseconds (call wxThread::sleep then return)
129 In a synchronous event, the event object will contain space for the entire
130 response. The sender allocates memory for the event and builds it. The
131 receiver fills in blanks in the event structure (or could overwrite parts)
132 and returns the same event pointer as a response. For async events, probably
133 the sender will allocate and the receiver will have to delete it.
135 implement the floppyA and floppyB change buttons using new event
136 structure. How should it work?
138 vga gui detects a click on floppyA bitmap
139 construct a BxEvent type BX_EVT_ASK_PARAM
140 post the event to the wxwindows gui thread (somehow) and block for response
141 when it arrives in the gui thread, show a modal dialog box
142 get the answer back to the simulator thread
145 right now, this is working ok within the simulator thread using
146 wxMutexGuiEnter/Leave. Still I'm going to change it so that the
147 siminterface.cc code builds an event structure and the gui code
148 fills in the blank in the structure, instead of the stupid
149 notify_get_int_arg stuff.
152 Starting and Killing Threads
154 When a detachable (default) thread finishes (returns from its Entry()
155 function), wxwindows frees the memory associated with that thread.
156 Unless the thread is never going to end, it is potentially dangerous to have a
157 pointer to it at all. Even if you try to "check if it's alive" first, you may
158 be dereferencing the pointer after it has already been deleted, leading to it
159 claiming to be alive when it's not, or a segfault. To solve this, the approach
160 used in the wxwindows threads example is to have code in the thread's OnExit()
161 method remove the thread's pointer from the list of usable threads. In
162 addition, any references or changes to the list of threads is controlled by a
163 critical section to ensure that it stays correct. This post finally
164 explained what I was seeing.
166 +-----------------------
167 | From: Pieter van der Meulen (pgmvdm@yahoo.com)
168 | Subject: Re: Thread Sample program - bug
169 | Newsgroups: comp.soft-sys.wxwindows
170 | Date: 2001-06-28 17:51:35 PST
173 | At 06:24 PM 6/28/2001, you wrote:
175 | >I have wxWindows 2.2.7 (wxMSW) installed.
177 | >I just found in the thread.cpp sample code this section:
180 | >void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
182 | > size_t count = wxGetApp().m_threads.Count();
183 | > for ( size_t i = 0; i < count; i++ )
185 | >===> wxGetApp().m_threads[0]->Delete(); <=====
191 | >The indecated line should probably rather have a
192 | >m_threads[i] rather than m_threads[0] .
194 | No, it should not, although it is not immediately obvious. When Delete() is
195 | called, the thread will eventually delete itself, but not before it calls
196 | MyThread::Exit(), which will remove itself from m_threads[] using
197 | wxArray::Remove(this). wxArray::Remove (RemoveAt) will compact the array to
198 | remove the element, it is now size-1. After this wxThread::Delete() returns.
201 | >I have have a further question to this:
202 | >Does this mean that a detached thread created with new
203 | >HAS to be deleted manually ? Or is this only in case it might still
206 | Firstly, you must create every detached thread using new since it will
207 | delete itself, literally calling delete this.
208 | Calling wxThread::Delete() is a correct way to terminate a thread, but
209 | manually deleting (using delete) a detached wxThread object is not.
210 | wxThread::Delete() will ask the thread to exit, the thread should check for
211 | this in wxThread::Entry() regularly using wxThread::TestDestroy() and exit
212 | when asked to do so.
214 | >(In general I have a unsatisfied felling about when delete is
215 | >neccessary and when not -- "I only know, it's not , if the class is
216 | >derived from wxWindows")
218 | For wxThreads: joinable threads must be deleted (when allocated on the
219 | heap), detached threads may never be deleted. For other classes, consult
220 | the documentation ;)
223 | >Thanks for some feedback,
229 +-----------------------
231 tracking some kind of deadlock bug in Linux.
233 seems to be in ReadMailcap, src/unix/mimetypes.cpp in wxwindows sources
234 src/unix/mimetype.cpp:2312
236 SOLUTION: compile with -pthread on every compile and link line.
240 ----------------------------------------------
241 Suggested solution for putting sizers inside a scrolled window
243 From: Thaddaeus Frogley (codemonkey_uk@users.sourceforge.net)
244 Subject: RE: Using sizers inside of a scrolled window
245 Newsgroups: comp.soft-sys.wxwindows
246 Date: 2001-10-02 02:41:04 PST
248 I have solved that same problem (scrolled windows / sizers) like so:
250 In the constructor for your wxFrame derived class,
252 //create a scrolling window
253 myScrolledWindow = new wxScrolledWindow(this, -1);
255 //in the scolling window, create a panel
256 myMainPanel = new wxPanel(myScrolledWindow, -1);
258 //place controls in the panel, laying them out with sizers
262 myMainPanel->SetAutoLayout( TRUE );
263 myMainPanel->SetSizer( sizer );
264 sizer->Fit( myMainPanel );
265 sizer->SetSizeHints( myMainPanel );
267 //set the scroll bars lengths based on the size of the inner panel
268 wxSize size = myMainPanel->GetBestSize();
269 myScrolledWindow->SetScrollbars( 1, 1, size.GetWidth(), size.GetHeight() );
271 //calculate the size of the window, and set it appropriately
272 size.Set(size.GetWidth()+16,size.GetHeight()+16);
274 //Get the physical size of the display in pixels.
275 int displaySizeX,displaySizeY;
276 wxDisplaySize(&displaySizeX,&displaySizeY);
278 //clamp window size to % of screen
279 if (size.GetWidth()>displaySizeX*0.75){
280 size.SetWidth(displaySizeX*0.75);
282 if (size.GetHeight()>displaySizeY*0.75){
283 size.SetHeight(displaySizeY*0.75);
291 How to make wxChoice as wide as the longest string in the choice box?
293 From: Vadim Zeitlin (Vadim.zeitlin@dptmaths.ens-cachan.fr)
294 Subject: Re: wxChoice
295 Newsgroups: comp.soft-sys.wxwindows
296 Date: 2001-09-18 04:41:07 PST
299 On Sat, 15 Sep 2001 15:39:45 +0200 Merlijn Blaauw <merlijn@student-kmt.hku.nl> wrote:
302 MB> would like the widget's parent window to change size (width) to fit the
303 MB> widget's new content aswell.
305 You'll have to do it manually by calculating the length of the string you
306 add to the control (use wxClientDC(combobox) and set correct font before
307 calling GetTextExtent()!) and resizing the control to be slightly larger
308 (yes, I know it's not nice at all but I don't see any other way to do it).
314 Hold on, this is even better!
316 From: Yann Rouillard (Y.Rouillard@exeter.ac.uk)
317 Subject: wxChoice and wxADJUST_MINSIZE
318 Newsgroups: comp.soft-sys.wxwindows
319 Date: 2002-07-18 08:28:31 PST
321 I am trying to use a wxChoice widget in a little panel. The text length of
322 the choices in the wxChoice can change so I used the wxADJUST_MINSIZE to
323 have its width correctly set.
325 > the manual for wxSizer::Add() says:
326 Finally, you can also specify wxADJUST_MINSIZE flag to make the minimal size of
327 the control dynamically adjust to the value returned by its GetBestSize()
328 method - this allows, for example, for correct relayouting of a static text
329 control even if its text is changed during run-time.
331 relayouting? sounds like s/size/layout/g gone wrong.
333 Call Add() with wxADJUST_MINSIZE flag!
335 mno-cygwin guide on mingw webpage
336 http://www.xraylith.wisc.edu/~khan/software/gnu-win32/mno-cygwin-howto.txt