]> git.saurik.com Git - wxWidgets.git/blob - samples/xrc/rc/derivdlg.xrc
fix for monolithic build
[wxWidgets.git] / samples / xrc / rc / derivdlg.xrc
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2
3 <resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.3.0.1">
4
5 <object class="wxDialog" name="derived_dialog">
6 <title>Derived Dialog Example</title>
7 <centered>1</centered>
8 <object class="wxFlexGridSizer">
9 <cols>1</cols>
10 <rows>0</rows>
11 <vgap>0</vgap>
12 <hgap>0</hgap>
13 <growablecols>0</growablecols>
14 <growablerows>0</growablerows>
15 <object class="sizeritem">
16 <flag>wxGROW|wxALIGN_CENTER_VERTICAL|wxALL</flag>
17 <border>5</border>
18 <object class="wxTextCtrl" name="message_textctrl">
19 <size>500,150</size>
20 <style>wxTE_MULTILINE</style>
21 <value>This is a derived dialog using XRC. This type of derived dialog will likely be the heart of your project, and thus is the most important example in this demonstration.\n\nIt is recommended to open up derivdlg.cpp, derivdlg.h and derivdlg.xrc and follow along what is going on.\n\nThe steps to use a derived dialog are:\n\n(1) Derive your own dialog from wxDialog (derivdlg.cpp and derivdlg.h are an example).\n\n(2) In the source of the constructor of the derived dialog, load the XRC into the file, using the code as shown in the derivdlg.cpp\n\n(3)Add to the derived dilog's sourcecode some event handlers and other methods you want the dialog to do.\n\n(4)You can now just make an instance of the derived dialog and show it using ShowModal(), as is done in the MyFrame::OnDerivedDialogToolOrMenuCommand() method.\n\nThe remainder of this docuent will talk about how to use events with derived dialogs and XRC. There are 3 bits of an extra event functionality that this derived dialog can do, these will be described in turn:\n\n(A) Something to do when a user clicks on your custom button: This is straightforward. You name a control in the XRC file (in this example it is "my__button"). Then in the .cpp file, put an entry in the event table that will connect button clicks with that ID to a function that will be fired. The event table entry in the example is EVT__BUTTON( XRCID( "my__button" ), PreferencesDialog::OnMyButtonClicked ) This event table entry has 3 parts: The first part, EVT__BUTTON tells that you are describing a button click event. The final part, PreferencesDialog::OnMyButtonClicked() is what you want done in response to a button event. The middle part, XRCID( "my__button" ) is the restriction that only button events generated by a wxButton of that ID should trigger go on to do the function. This XRCID is the name of the wxButton in your XRC file. Now just describe, in the .h file and .cpp file, what you want your custom OnMyButtonClicked() function to do.\n\n(B) The second example is a very common requirement: that a checkbox or radiobutton disables some other control. The event table is set up the same as the "My Button" example above. However, it isn't an EVT__BUTTON event, it is an EVT__UPDATE__UI event: when the dialog does an updating of its UI (and thus fires this event) if the updating if of a control matching that XRCID, then it will do the specified function (which in this case looks at whether or not the checkbox is checked, and if it isn't checked, then disable the textctrl).\n\n(C) The last example shows how to handle the OK button. You will likely want to do something when the user presses OK, like save preferences or start some action (this example shows a simple case of just popping up a dialog and stopping a close). OK buttons are always named wxID__OK, so the XRC file should have it as wxID__OK also. The Event table has an EVT__BUTTON entry for wxID__OK (no XRCID though). Since this is a derived dialog with an event table, in response to an EVT__BUTTON event from a wxID__OK button, it will first look around in its own event table to see if there was any EVT__BUTTON entries, and since there is, it will do that one--if there wasn't it then checks out the base class's event table and sees if there was one there, and so on up the chain of inherited classes. Note that this is exactly what happens with the derived dialog's wxID__CANCEL button. You didn't put any EVT__BUTTON entries with an identifier of wxID__CANCEL, so after it scans your derived dialog's event table, it will then look at wxDialog's event table and see if there is one in that event table, and so on until it finds one. It will find a wxID__CANCEL handler, which will connect to the proper function (which causes the dialog to close).
22 </value>
23 </object>
24 </object>
25 <object class="sizeritem">
26 <flag>wxALIGN_CENTRE|wxALL</flag>
27 <border>5</border>
28 <object class="wxButton" name="my_button">
29 <label>My Button</label>
30 </object>
31 </object>
32 <object class="sizeritem">
33 <flag>wxALIGN_CENTRE|wxALL</flag>
34 <border>5</border>
35 <object class="wxBoxSizer">
36 <orient>wxHORIZONTAL</orient>
37 <object class="sizeritem">
38 <flag>wxALIGN_CENTRE|wxALL</flag>
39 <border>5</border>
40 <object class="wxCheckBox" name="my_checkbox">
41 <label>Enable listbox</label>
42 </object>
43 </object>
44 <object class="sizeritem">
45 <flag>wxALIGN_CENTRE|wxALL</flag>
46 <border>5</border>
47 <object class="wxTextCtrl" name="my_textctrl">
48 <size>80,-1</size>
49 <value></value>
50 </object>
51 </object>
52 </object>
53 </object>
54 <object class="sizeritem">
55 <flag>wxALIGN_CENTRE|wxALL</flag>
56 <border>5</border>
57 <object class="wxBoxSizer">
58 <orient>wxHORIZONTAL</orient>
59 <object class="sizeritem">
60 <flag>wxALIGN_CENTRE|wxALL</flag>
61 <border>5</border>
62 <object class="wxButton" name="wxID_OK">
63 <label>OK</label>
64 </object>
65 </object>
66 <object class="sizeritem">
67 <flag>wxALIGN_CENTRE|wxALL</flag>
68 <border>5</border>
69 <object class="wxButton" name="wxID_CANCEL">
70 <label>Cancel</label>
71 </object>
72 </object>
73 </object>
74 </object>
75 </object>
76 </object>
77
78 </resource>