Document-view framework - 3 questions Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
geralds
I live to help wx-kind
I live to help wx-kind
Posts: 186
Joined: Tue Nov 01, 2005 9:22 am
Contact:

Document-view framework - 3 questions

Post by geralds » Tue Nov 15, 2005 12:44 pm

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!

kayaay
Experienced Solver
Experienced Solver
Posts: 65
Joined: Mon Nov 14, 2005 7:21 pm

mdi and event handling

Post by kayaay » Tue Nov 15, 2005 2:50 pm

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.

KA

geralds
I live to help wx-kind
I live to help wx-kind
Posts: 186
Joined: Tue Nov 01, 2005 9:22 am
Contact:

Post by geralds » Tue Nov 15, 2005 3:16 pm

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.)

kayaay
Experienced Solver
Experienced Solver
Posts: 65
Joined: Mon Nov 14, 2005 7:21 pm

correction on event handling...

Post by kayaay » Wed Nov 16, 2005 7:06 pm

I've gotten deeper in my own porting work and found the following that may be helpful:

How Events Are Processed
http://www.wxwidgets.org/manuals/2.4.2/wx470.htm


"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.

KA

Post Reply