Sophie

Sophie

distrib > * > 2010.0 > * > by-pkgid > 4d4bff3fc831b905f4306148550d3c39 > files > 2799

lib64wxgtku2.8-devel-2.8.10-3mdv2010.0.x86_64.rpm

<?xml version="1.0" encoding="ISO-8859-1"?>

<resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.3.0.1">

<object class="wxDialog" name="derived_dialog">
    <title>Derived Dialog Example</title>
    <centered>1</centered>
    <object class="wxFlexGridSizer">
        <cols>1</cols>
        <rows>0</rows>
        <vgap>0</vgap>
        <hgap>0</hgap>
        <growablecols>0</growablecols>
        <growablerows>0</growablerows>
        <object class="sizeritem">
            <flag>wxGROW|wxALIGN_CENTER_VERTICAL|wxALL</flag>
            <border>5</border>
            <object class="wxTextCtrl" name="message_textctrl">
                <size>500,150</size>
                <style>wxTE_MULTILINE</style>
                <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).                                
                </value>
            </object>
        </object>
        <object class="sizeritem">
            <flag>wxALIGN_CENTRE|wxALL</flag>
            <border>5</border>
            <object class="wxButton" name="my_button">
                <label>My Button</label>
            </object>
        </object>
        <object class="sizeritem">
            <flag>wxALIGN_CENTRE|wxALL</flag>
            <border>5</border>
            <object class="wxBoxSizer">
                <orient>wxHORIZONTAL</orient>
                <object class="sizeritem">
                    <flag>wxALIGN_CENTRE|wxALL</flag>
                    <border>5</border>
                    <object class="wxCheckBox" name="my_checkbox">
                        <label>Enable listbox</label>
                    </object>
                </object>
                <object class="sizeritem">
                    <flag>wxALIGN_CENTRE|wxALL</flag>
                    <border>5</border>
                    <object class="wxTextCtrl" name="my_textctrl">
                        <size>80,-1</size>
                        <value></value>
                    </object>
                </object>
            </object>
        </object>
        <object class="sizeritem">
            <flag>wxALIGN_CENTRE|wxALL</flag>
            <border>5</border>
            <object class="wxBoxSizer">
                <orient>wxHORIZONTAL</orient>
                <object class="sizeritem">
                    <flag>wxALIGN_CENTRE|wxALL</flag>
                    <border>5</border>
                    <object class="wxButton" name="wxID_OK">
                        <label>OK</label>
                    </object>
                </object>
                <object class="sizeritem">
                    <flag>wxALIGN_CENTRE|wxALL</flag>
                    <border>5</border>
                    <object class="wxButton" name="wxID_CANCEL">
                        <label>Cancel</label>
                    </object>
                </object>
            </object>
        </object>
    </object>
</object>

</resource>