📄 txrc.tex
字号:
\begin{verbatim}
<?xml version="1.0"?>
<resource version="2.3.0.1">
<object class="wxMenuBar" name="mainmenu">
<style>wxMB_DOCKABLE</style>
<object class="wxMenu" name="menu_file">
<label>_File</label>
<style>wxMENU_TEAROFF</style>
<object class="wxMenuItem" name="menu_about">
<label>_About...</label>
<bitmap>filesave.gif</bitmap>
</object>
<object class="separator"/>
<object class="wxMenuItem" name="menu_dlg1">
<label>Dialog 1</label>
</object>
<object class="wxMenuItem" name="menu_dlg2">
<label>Dialog 2</label>
</object>
<object class="separator"/>
<object class="wxMenuItem" name="menu_quit">
<label>E_xit\tAlt-X</label>
</object>
</object>
</object>
<object class="wxToolBar" name="toolbar">
<style>wxTB_FLAT|wxTB_DOCKABLE</style>
<margins>2,2</margins>
<object class="tool" name="menu_open">
<bitmap>fileopen.gif</bitmap>
<tooltip>Open catalog</tooltip>
</object>
<object class="tool" name="menu_save">
<bitmap>filesave.gif</bitmap>
<tooltip>Save catalog</tooltip>
</object>
<object class="tool" name="menu_update">
<bitmap>update.gif</bitmap>
<tooltip>Update catalog - synchronize it with sources</tooltip>
</object>
<separator/>
<object class="tool" name="menu_quotes">
<bitmap>quotes.gif</bitmap>
<toggle>1</toggle>
<tooltip>Display quotes around the string?</tooltip>
</object>
<object class="separator"/>
<object class="tool" name="menu_fuzzy">
<bitmap>fuzzy.gif</bitmap>
<tooltip>Toggled if selected string is fuzzy translation</tooltip>
<toggle>1</toggle>
</object>
</object>
<object class="wxDialog" name="dlg1">
<object class="wxBoxSizer">
<object class="sizeritem">
<object class="wxBitmapButton">
<bitmap>fuzzy.gif</bitmap>
<focus>fileopen.gif</focus>
</object>
</object>
<object class="sizeritem">
<object class="wxPanel">
<object class="wxStaticText">
<label>fdgdfgdfgdfg</label>
</object>
<style>wxSUNKEN_BORDER</style>
</object>
<flag>wxALIGN_CENTER</flag>
</object>
<object class="sizeritem">
<object class="wxButton">
<label>Buttonek</label>
</object>
<border>10d</border>
<flag>wxALL</flag>
</object>
<object class="sizeritem">
<object class="wxHtmlWindow">
<htmlcode><h1>Hi,</h1>man</htmlcode>
<size>100,45d</size>
</object>
</object>
<object class="sizeritem">
<object class="wxNotebook">
<object class="notebookpage">
<object class="wxPanel">
<object class="wxBoxSizer">
<object class="sizeritem">
<object class="wxHtmlWindow">
<htmlcode>Hello, we are inside a <u>NOTEBOOK</u>...</htmlcode>
<size>50,50d</size>
</object>
<option>1</option>
</object>
</object>
</object>
<label>Page</label>
</object>
<object class="notebookpage">
<object class="wxPanel">
<object class="wxBoxSizer">
<object class="sizeritem">
<object class="wxHtmlWindow">
<htmlcode>Hello, we are inside a <u>NOTEBOOK</u>...</htmlcode>
<size>50,50d</size>
</object>
</object>
</object>
</object>
<label>Page 2</label>
</object>
<usenotebooksizer>1</usenotebooksizer>
</object>
<flag>wxEXPAND</flag>
</object>
<orient>wxVERTICAL</orient>
</object>
</object>
<object class="wxDialog" name="dlg2">
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem" name="dfgdfg">
<object class="wxTextCtrl">
<size>200,200d</size>
<style>wxTE_MULTILINE|wxSUNKEN_BORDER</style>
<value>Hello, this is an ordinary multiline\n textctrl....</value>
</object>
<option>1</option>
<flag>wxEXPAND|wxALL</flag>
<border>10</border>
</object>
<object class="sizeritem">
<object class="wxBoxSizer">
<object class="sizeritem">
<object class="wxButton" name="wxID_OK">
<label>Ok</label>
<default>1</default>
</object>
</object>
<object class="sizeritem">
<object class="wxButton" name="wxID_CANCEL">
<label>Cancel</label>
</object>
<border>10</border>
<flag>wxLEFT</flag>
</object>
</object>
<flag>wxLEFT|wxRIGHT|wxBOTTOM|wxALIGN_RIGHT</flag>
<border>10</border>
</object>
</object>
<title>Second testing dialog</title>
</object>
</resource>
\end{verbatim}
\subsection{XRC file format}\label{xrcfileformat}
Please see Technical Note 14 (docs/tech/tn0014.txt) in your wxWidgets
distribution.
\subsection{C++ header file generation}\label{xrccppheader}
Using the {\tt -e} switch together with {\tt -c}, a C++ header file is written
containing class definitions for the GUI windows defined in the XRC file.
This code generation can make it easier to use XRC and automate program
development.
The classes can be used as basis for development, freeing the
programmer from dealing with most of the XRC specifics (e.g. {\tt XRCCTRL}).
For each top level window defined in the XRC file a C++ class definition is
generated, containing as class members the named widgets of the window.
A default constructor for each class is also generated. Inside the constructor
all XRC loading is done and all class members representing widgets are initialized.
A simple example will help understand how the scheme works. Suppose you have
a XRC file defining a top level window {\tt TestWnd\_Base}, which subclasses {\tt wxFrame} (any
other class like {\tt wxDialog} will do also), and has subwidgets {\tt wxTextCtrl} A and {\tt wxButton} B.
The XRC file and corresponding class definition in the header file will be something like:
\begin{verbatim}
<?xml version="1.0"?>
<resource version="2.3.0.1">
<object class="wxFrame" name="TestWnd_Base">
<size>-1,-1</size>
<title>Test</title>
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<object class="wxTextCtrl" name="A">
<label>Test label</label>
</object>
</object>
<object class="sizeritem">
<object class="wxButton" name="B">
<label>Test button</label>
</object>
</object>
</object>
</object>
</resource>
class TestWnd_Base : public wxFrame {
protected:
wxTextCtrl* A;
wxButton* B;
private:
void InitWidgetsFromXRC(){
wxXmlResource::Get()->LoadObject(this,NULL,"TestWnd","wxFrame");
A = XRCCTRL(*this,"A",wxTextCtrl);
B = XRCCTRL(*this,"B",wxButton);
}
public:
TestWnd::TestWnd(){
InitWidgetsFromXRC();
}
};
\end{verbatim}
The generated window class can be used as basis for the full window class. The
class members which represent widgets may be accessed by name instead of using
{\tt XRCCTRL} every time you wish to reference them (note that they are {\tt protected} class members),
though you must still use {\tt XRCID} to refer to widget IDs in the event
table.
Example:
\begin{verbatim}
#include "resource.h"
class TestWnd : public TestWnd_Base {
public:
TestWnd(){
// A, B already initialised at this point
A->SetValue("Updated in TestWnd::TestWnd");
B->SetValue("Nice :)");
}
void OnBPressed(wxEvent& event){
Close();
}
DECLARE_EVENT_TABLE();
};
BEGIN_EVENT_TABLE(TestWnd,TestWnd_Base)
EVT_BUTTON(XRCID("B"),TestWnd::OnBPressed)
END_EVENT_TABLE()
\end{verbatim}
\subsection{Adding new resource handlers}\label{newresourcehandlers}
Coming soon.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -