Page 1 of 1

Document-view framework - 3 questions

Posted: Tue Nov 15, 2005 12:44 pm
by geralds
I have based my document-view interface on the sample program (basically throwing out the miniature drawing program and using a single view based on wxStyledTextControl), but some things don't seem to work as expected.

1. Is there any way of allowing multiple files to be opened when wxID_OPEN is selected?

2. My wxStyledTextControl is the first tab of a wxNotebook. Where should I handle OnActivate (if that's what I should do) to make sure the edit control rather than the first tab receives the focus? Handling OnActivate from my wxView-derived class seems to get in the way of default processing.

3. The framework always seems to call 'Save as' when I select wxID_SAVE even if the document has a name (i.e. it's not unnamed1 etc.). Where should I handle wxID_SAVE (if that's what I should do)?

I'd be very grateful for all help!

mdi and event handling

Posted: Tue Nov 15, 2005 2:50 pm
by kayaay
1) For the multiple files open, you need to use multiple doc interface, mdi.

There's an example of opening multiple docs in Samples\MDI.
Also, another one in Samples\SashTest.

2) As far as event handling, sounds like you want to do the default processing first, then do your custom handling. In MFC this was done by calling the base class then doing your own thing. However, in WxWidgets, I haven't seen a way to call the base. Yes, you can skip processing by calling event.Skip();

Looking through the src, I see something like:

m_owner->GetEventHandler()->ProcessEvent( event );

To me that seems equivalent to calling the base for processing. You might try that, first then do your SetFocus.

3) not sure what went wrong. The sample docview does the right thing when saving a doc. You might try looking at the sample again to make sure you have the event handling setup the same way. In particular, make sure to have both wxID_SAVE and wxID_SAVEAS.


Posted: Tue Nov 15, 2005 3:16 pm
by geralds
Thanks KA, I will try that. Re (1) I've checked and on Win2K at least the sample app doesn't allow multiple files to be opened at once. (It permits multiple files in sequence, but it isn't possible to hold down Shift or CTRL and select a number of files. What I'm after is the wxMULTIPLE option of the wxFileDialog, but because the document-view framework calls the dialog I'm not sure how to select it.)

correction on event handling...

Posted: Wed Nov 16, 2005 7:06 pm
by kayaay
I've gotten deeper in my own porting work and found the following that may be helpful:

How Events Are Processed

"To summarize, instead of explicitly calling the base class version as you would have done with C++ virtual functions (i.e. wxTextCtrl::OnChar()), you should instead call Skip."

Skip(); // this defaults to TRUE which will continue searching for event handlers. Skip(FALSE) could be used to stop all searching for any other handlers. Also, if you don't call Skip, then no other handlers will be searched.