wxID_ANY, wxDefaultSize, wxDefaultPosition, wxNOT_FOUND, true, false, tabs replacements.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27745 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2004-06-11 13:14:23 +00:00
parent df135587ad
commit f80ea77b4a
135 changed files with 1720 additions and 1720 deletions

View File

@@ -24,7 +24,7 @@
class WXDLLIMPEXP_XRC wxGaugeXmlHandler : public wxXmlResourceHandler class WXDLLIMPEXP_XRC wxGaugeXmlHandler : public wxXmlResourceHandler
{ {
DECLARE_DYNAMIC_CLASS(wxGaugeXmlHandler) DECLARE_DYNAMIC_CLASS(wxGaugeXmlHandler)
enum enum
{ {
wxGAUGE_DEFAULT_RANGE = 100 wxGAUGE_DEFAULT_RANGE = 100

View File

@@ -31,7 +31,7 @@ private:
class WXDLLIMPEXP_XRC wxMenuBarXmlHandler : public wxXmlResourceHandler class WXDLLIMPEXP_XRC wxMenuBarXmlHandler : public wxXmlResourceHandler
{ {
DECLARE_DYNAMIC_CLASS(wxMenuBarXmlHandler) DECLARE_DYNAMIC_CLASS(wxMenuBarXmlHandler)
public: public:
wxMenuBarXmlHandler(); wxMenuBarXmlHandler();
virtual wxObject *DoCreateResource(); virtual wxObject *DoCreateResource();

View File

@@ -22,7 +22,7 @@
class WXDLLIMPEXP_XRC wxScrollBarXmlHandler : public wxXmlResourceHandler class WXDLLIMPEXP_XRC wxScrollBarXmlHandler : public wxXmlResourceHandler
{ {
DECLARE_DYNAMIC_CLASS(wxScrollBarXmlHandler) DECLARE_DYNAMIC_CLASS(wxScrollBarXmlHandler)
enum enum
{ {
wxSL_DEFAULT_VALUE = 0, wxSL_DEFAULT_VALUE = 0,

View File

@@ -33,7 +33,7 @@ public:
private: private:
bool m_isInside; bool m_isInside;
bool m_isGBS; bool m_isGBS;
wxSizer *m_parentSizer; wxSizer *m_parentSizer;
bool IsSizerNode(wxXmlNode *node); bool IsSizerNode(wxXmlNode *node);
@@ -52,7 +52,7 @@ private:
wxGBSpan GetGBSpan(const wxString& param); wxGBSpan GetGBSpan(const wxString& param);
wxSizerItem* MakeSizerItem(); wxSizerItem* MakeSizerItem();
void SetSizerItemAttributes(wxSizerItem* sitem); void SetSizerItemAttributes(wxSizerItem* sitem);
void AddSizerItem(wxSizerItem* sitem); void AddSizerItem(wxSizerItem* sitem);
}; };

View File

@@ -22,7 +22,7 @@
class WXDLLIMPEXP_XRC wxSliderXmlHandler : public wxXmlResourceHandler class WXDLLIMPEXP_XRC wxSliderXmlHandler : public wxXmlResourceHandler
{ {
DECLARE_DYNAMIC_CLASS(wxSliderXmlHandler) DECLARE_DYNAMIC_CLASS(wxSliderXmlHandler)
enum enum
{ {
wxSL_DEFAULT_VALUE = 0, wxSL_DEFAULT_VALUE = 0,

View File

@@ -21,7 +21,7 @@
#if wxUSE_SPINBTN #if wxUSE_SPINBTN
class WXDLLIMPEXP_XRC wxSpinButtonXmlHandler : public wxXmlResourceHandler class WXDLLIMPEXP_XRC wxSpinButtonXmlHandler : public wxXmlResourceHandler
{ {
DECLARE_DYNAMIC_CLASS(wxSpinButtonXmlHandler) DECLARE_DYNAMIC_CLASS(wxSpinButtonXmlHandler)
enum enum
{ {
wxSP_DEFAULT_VALUE = 0, wxSP_DEFAULT_VALUE = 0,
@@ -39,7 +39,7 @@ public:
#if wxUSE_SPINCTRL #if wxUSE_SPINCTRL
class WXDLLIMPEXP_XRC wxSpinCtrlXmlHandler : public wxXmlResourceHandler class WXDLLIMPEXP_XRC wxSpinCtrlXmlHandler : public wxXmlResourceHandler
{ {
DECLARE_DYNAMIC_CLASS(wxSpinCtrlXmlHandler) DECLARE_DYNAMIC_CLASS(wxSpinCtrlXmlHandler)
enum enum
{ {
wxSP_DEFAULT_VALUE = 0, wxSP_DEFAULT_VALUE = 0,

View File

@@ -240,7 +240,7 @@ protected:
bool UpdateResources(); bool UpdateResources();
// Finds a resource (calls UpdateResources) and returns a node containing it. // Finds a resource (calls UpdateResources) and returns a node containing it.
wxXmlNode *FindResource(const wxString& name, const wxString& classname, bool recursive = FALSE); wxXmlNode *FindResource(const wxString& name, const wxString& classname, bool recursive = false);
// Helper function: finds a resource (calls UpdateResources) and returns a node containing it. // Helper function: finds a resource (calls UpdateResources) and returns a node containing it.
wxXmlNode *DoFindResource(wxXmlNode *parent, const wxString& name, const wxString& classname, bool recursive); wxXmlNode *DoFindResource(wxXmlNode *parent, const wxString& name, const wxString& classname, bool recursive);
@@ -329,8 +329,8 @@ public:
// were filled. // were filled.
virtual wxObject *DoCreateResource() = 0; virtual wxObject *DoCreateResource() = 0;
// Returns TRUE if it understands this node and can create // Returns true if it understands this node and can create
// a resource from it, FALSE otherwise. // a resource from it, false otherwise.
virtual bool CanHandle(wxXmlNode *node) = 0; virtual bool CanHandle(wxXmlNode *node) = 0;
// Sets the parent resource. // Sets the parent resource.
@@ -385,7 +385,7 @@ protected:
// - replaces \n, \r, \t by respective chars (according to C syntax) // - replaces \n, \r, \t by respective chars (according to C syntax)
// - replaces _ by & and __ by _ (needed for _File => &File because of XML) // - replaces _ by & and __ by _ (needed for _File => &File because of XML)
// - calls wxGetTranslations (unless disabled in wxXmlResource) // - calls wxGetTranslations (unless disabled in wxXmlResource)
wxString GetText(const wxString& param, bool translate = TRUE); wxString GetText(const wxString& param, bool translate = true);
// Returns the XRCID. // Returns the XRCID.
int GetID(); int GetID();
@@ -393,8 +393,8 @@ protected:
// Returns the resource name. // Returns the resource name.
wxString GetName(); wxString GetName();
// Gets a bool flag (1, t, yes, on, true are TRUE, everything else is FALSE). // Gets a bool flag (1, t, yes, on, true are true, everything else is false).
bool GetBool(const wxString& param, bool defaultv = FALSE); bool GetBool(const wxString& param, bool defaultv = false);
// Gets the integer value from the parameter. // Gets the integer value from the parameter.
long GetLong( const wxString& param, long defaultv = 0 ); long GetLong( const wxString& param, long defaultv = 0 );
@@ -428,7 +428,7 @@ protected:
void SetupWindow(wxWindow *wnd); void SetupWindow(wxWindow *wnd);
// Creates children. // Creates children.
void CreateChildren(wxObject *parent, bool this_hnd_only = FALSE); void CreateChildren(wxObject *parent, bool this_hnd_only = false);
// Helper function. // Helper function.
void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL); void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL);

View File

@@ -42,18 +42,18 @@
// Internal constants // Internal constants
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Popup menu (PU) item control IDs. In this example, they aren't hooked up // Popup menu (PU) item control IDs. In this example, they aren't hooked up
// to any functions. Normally you would use these IDs in your event table, so // to any functions. Normally you would use these IDs in your event table, so
// that if one of these menu items is clicked, then a certain function is // that if one of these menu items is clicked, then a certain function is
// called. // called.
enum { enum {
PU_ADD_RECORD = wxID_HIGHEST + 1, PU_ADD_RECORD = wxID_HIGHEST + 1,
PU_EDIT_RECORD, PU_EDIT_RECORD,
PU_DELETE_RECORD PU_DELETE_RECORD
}; };
// Columns of the listctrl (the leftmost one starts at 0, and so on). // Columns of the listctrl (the leftmost one starts at 0, and so on).
// Allows easier code maintenance if want to add/rearrangement of listctrl's // Allows easier code maintenance if want to add/rearrangement of listctrl's
// columns. // columns.
enum { enum {
RECORD_COLUMN = 0, RECORD_COLUMN = 0,
@@ -71,9 +71,9 @@ IMPLEMENT_DYNAMIC_CLASS( MyResizableListCtrl, wxListCtrl )
// Event table: connect the events to the handler functions to process them // Event table: connect the events to the handler functions to process them
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
BEGIN_EVENT_TABLE( MyResizableListCtrl, wxListCtrl ) BEGIN_EVENT_TABLE( MyResizableListCtrl, wxListCtrl )
// Something to do when right mouse down // Something to do when right mouse down
EVT_RIGHT_DOWN( MyResizableListCtrl::ContextSensitiveMenu ) EVT_RIGHT_DOWN( MyResizableListCtrl::ContextSensitiveMenu )
// Something to do when resized // Something to do when resized
EVT_SIZE( MyResizableListCtrl::OnSize ) EVT_SIZE( MyResizableListCtrl::OnSize )
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -90,15 +90,15 @@ MyResizableListCtrl::MyResizableListCtrl( wxWindow *parent, wxWindowID id,
const wxString& name ) const wxString& name )
: wxListCtrl( parent, id, pos, size, style, validator, name ) : wxListCtrl( parent, id, pos, size, style, validator, name )
{ {
// This listctrl needs to insert its columns in the constructor, since // This listctrl needs to insert its columns in the constructor, since
// as soon as the listctrl is built, it is resized and grafted onto an // as soon as the listctrl is built, it is resized and grafted onto an
// "unknown" XRC placeholder. This induces an OnSize() event, calling the // "unknown" XRC placeholder. This induces an OnSize() event, calling the
// overrriden OnSize function for this class, which needs to have 3 // overrriden OnSize function for this class, which needs to have 3
// columns to resize (else an assert on WXGTK debug build). // columns to resize (else an assert on WXGTK debug build).
InsertColumn( RECORD_COLUMN, _("Record"), wxLIST_FORMAT_LEFT, 140); InsertColumn( RECORD_COLUMN, _("Record"), wxLIST_FORMAT_LEFT, 140);
InsertColumn( ACTION_COLUMN, _("Action"), wxLIST_FORMAT_LEFT, 70); InsertColumn( ACTION_COLUMN, _("Action"), wxLIST_FORMAT_LEFT, 70);
InsertColumn( PRIORITY_COLUMN, _("Priority"), wxLIST_FORMAT_LEFT, 70 ); InsertColumn( PRIORITY_COLUMN, _("Priority"), wxLIST_FORMAT_LEFT, 70 );
} }
@@ -115,16 +115,16 @@ void MyResizableListCtrl::ContextSensitiveMenu( wxMouseEvent& event )
a_menu.Append( PU_ADD_RECORD, _( "Add a new record...") ); a_menu.Append( PU_ADD_RECORD, _( "Add a new record...") );
a_menu.Append( PU_EDIT_RECORD, _( "Edit selected record..." ) ); a_menu.Append( PU_EDIT_RECORD, _( "Edit selected record..." ) );
a_menu.Append( PU_DELETE_RECORD, _( "Delete selected record" ) ); a_menu.Append( PU_DELETE_RECORD, _( "Delete selected record" ) );
// If no listctrl rows selected, then disable the menu items that // If no listctrl rows selected, then disable the menu items that
// require selection // require selection
if ( GetSelectedItemCount() == 0 ) { if ( GetSelectedItemCount() == 0 ) {
a_menu.Enable( PU_EDIT_RECORD, FALSE ); a_menu.Enable( PU_EDIT_RECORD, false );
a_menu.Enable( PU_DELETE_RECORD, FALSE ); a_menu.Enable( PU_DELETE_RECORD, false );
} }
// Show the popup menu (wxWindow::PopupMenu ), at the x,y position // Show the popup menu (wxWindow::PopupMenu ), at the x,y position
// of the click event // of the click event
PopupMenu( &a_menu, event.GetPosition() ); PopupMenu( &a_menu, event.GetPosition() );
} }
@@ -133,28 +133,28 @@ void MyResizableListCtrl::OnSize( wxSizeEvent &event )
{ {
// Call our custom width setting function. // Call our custom width setting function.
SetColumnWidths(); SetColumnWidths();
// REQURED event.Skip() call to allow this event to propagate // REQURED event.Skip() call to allow this event to propagate
// upwards so others can do what they need to do in response to // upwards so others can do what they need to do in response to
// this size event. // this size event.
event.Skip(); event.Skip();
} }
void MyResizableListCtrl::SetColumnWidths() void MyResizableListCtrl::SetColumnWidths()
{ {
// Get width of entire listctrl // Get width of entire listctrl
int leftmostColumnWidth = GetSize().x; int leftmostColumnWidth = GetSize().x;
// Subtract width of other columns, scrollbar, and some padding // Subtract width of other columns, scrollbar, and some padding
leftmostColumnWidth -= GetColumnWidth( ACTION_COLUMN ); leftmostColumnWidth -= GetColumnWidth( ACTION_COLUMN );
leftmostColumnWidth -= GetColumnWidth( PRIORITY_COLUMN ); leftmostColumnWidth -= GetColumnWidth( PRIORITY_COLUMN );
leftmostColumnWidth -= wxSystemSettings::GetSystemMetric( wxSYS_VSCROLL_X ); leftmostColumnWidth -= wxSystemSettings::GetSystemMetric( wxSYS_VSCROLL_X );
leftmostColumnWidth -= 5; leftmostColumnWidth -= 5;
// Set the column width to the new value. // Set the column width to the new value.
SetColumnWidth( RECORD_COLUMN, leftmostColumnWidth ); SetColumnWidth( RECORD_COLUMN, leftmostColumnWidth );
// This is just a debug message in case you want to watch the // This is just a debug message in case you want to watch the
// events scroll by as you resize. // events scroll by as you resize.
wxLogDebug( wxT("Successfully set column widths") ); wxLogDebug( wxT("Successfully set column widths") );
} }

View File

@@ -38,14 +38,14 @@ class MyResizableListCtrl : public wxListCtrl
// Very helpful wxWidgets macro required for wxWidgets-RTTI tracing: By using this // Very helpful wxWidgets macro required for wxWidgets-RTTI tracing: By using this
// you will see "Leaked one object of type myResizeableListCtrl" in the debug log, // you will see "Leaked one object of type myResizeableListCtrl" in the debug log,
// along with which line you if was created, but you forget to free the memory. // along with which line you if was created, but you forget to free the memory.
// NOTE: Using this REQUIRES a default constructor: that means either: giving a // NOTE: Using this REQUIRES a default constructor: that means either: giving a
// default value for all parameters in your constructor, or else having a dummy // default value for all parameters in your constructor, or else having a dummy
// MyResizableListCtrl(){} constructor in addition to your regular one. // MyResizableListCtrl(){} constructor in addition to your regular one.
DECLARE_DYNAMIC_CLASS( MyResizableListCtrl ) DECLARE_DYNAMIC_CLASS( MyResizableListCtrl )
public: public:
// Constructor. // Constructor.
/* /*
These parameters are the same as a wxWidgets constructor. These parameters are the same as a wxWidgets constructor.
\param parent The parent window. \param parent The parent window.
@@ -60,33 +60,33 @@ public:
column. column.
*/ */
MyResizableListCtrl( wxWindow *parent = NULL, MyResizableListCtrl( wxWindow *parent = NULL,
wxWindowID id = -1, wxWindowID id = wxID_ANY,
const wxPoint &pos = wxDefaultPosition, const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize, const wxSize &size = wxDefaultSize,
long style = wxLC_REPORT, long style = wxLC_REPORT,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString &name = wxT("myResizableListCtrl") const wxString &name = wxT("myResizableListCtrl")
); );
// Destuctor. // Destuctor.
~MyResizableListCtrl(); ~MyResizableListCtrl();
protected: protected:
// A custom function for a context sensitive menu.
void ContextSensitiveMenu( wxMouseEvent& event );
// A custom function for a context sensitive menu.
void ContextSensitiveMenu( wxMouseEvent& event );
// This is a wxWidgets function that we are going to override with our own behaviour. // This is a wxWidgets function that we are going to override with our own behaviour.
void OnSize( wxSizeEvent &event ); void OnSize( wxSizeEvent &event );
// A custom function. What is called in the constructor, and in an OnSize() // A custom function. What is called in the constructor, and in an OnSize()
void SetColumnWidths(); void SetColumnWidths();
private: private:
// wxWidgets macro, required to be able to use Event tables in the .cpp file. // wxWidgets macro, required to be able to use Event tables in the .cpp file.
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------

View File

@@ -49,7 +49,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(PreferencesDialog, wxDialog) BEGIN_EVENT_TABLE(PreferencesDialog, wxDialog)
EVT_BUTTON( XRCID( "my_button" ), PreferencesDialog::OnMyButtonClicked ) EVT_BUTTON( XRCID( "my_button" ), PreferencesDialog::OnMyButtonClicked )
EVT_UPDATE_UI(XRCID( "my_checkbox" ), PreferencesDialog::OuUpdateUIMyCheckbox ) EVT_UPDATE_UI(XRCID( "my_checkbox" ), PreferencesDialog::OuUpdateUIMyCheckbox )
// Note that the ID here isn't a XRCID, it is one of the standard wx ID's. // Note that the ID here isn't a XRCID, it is one of the standard wx ID's.
EVT_BUTTON( wxID_OK, PreferencesDialog::OnOK ) EVT_BUTTON( wxID_OK, PreferencesDialog::OnOK )
@@ -60,7 +60,7 @@ END_EVENT_TABLE()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Constructor (Notice how small and easy it is) // Constructor (Notice how small and easy it is)
PreferencesDialog::PreferencesDialog(wxWindow* parent) PreferencesDialog::PreferencesDialog(wxWindow* parent)
{ {
wxXmlResource::Get()->LoadDialog(this, parent, wxT("derived_dialog")); wxXmlResource::Get()->LoadDialog(this, parent, wxT("derived_dialog"));
} }
@@ -76,29 +76,29 @@ PreferencesDialog::~PreferencesDialog()
void PreferencesDialog::OnMyButtonClicked( wxCommandEvent &WXUNUSED(event) ) void PreferencesDialog::OnMyButtonClicked( wxCommandEvent &WXUNUSED(event) )
{ {
// Construct a message dialog. // Construct a message dialog.
wxMessageDialog msgDlg(this, _("You clicked on My Button")); wxMessageDialog msgDlg(this, _("You clicked on My Button"));
// Show it modally. // Show it modally.
msgDlg.ShowModal(); msgDlg.ShowModal();
} }
// Update the enabled/disabled state of the edit/delete buttons depending on // Update the enabled/disabled state of the edit/delete buttons depending on
// whether a row (item) is selected in the listctrl // whether a row (item) is selected in the listctrl
void PreferencesDialog::OuUpdateUIMyCheckbox( wxUpdateUIEvent &WXUNUSED(event) ) void PreferencesDialog::OuUpdateUIMyCheckbox( wxUpdateUIEvent &WXUNUSED(event) )
{ {
// Get a boolean value of whether the checkbox is checked // Get a boolean value of whether the checkbox is checked
bool myCheckBoxIsChecked; bool myCheckBoxIsChecked;
// You could just write: // You could just write:
// myCheckBoxIsChecked = event.IsChecked(); // myCheckBoxIsChecked = event.IsChecked();
// since the event that was passed into this function already has the // since the event that was passed into this function already has the
// is a pointer to the right control. However, // is a pointer to the right control. However,
// this is the XRCCTRL way (which is more obvious as to what is going on). // this is the XRCCTRL way (which is more obvious as to what is going on).
myCheckBoxIsChecked = XRCCTRL(*this, "my_checkbox", wxCheckBox)->IsChecked(); myCheckBoxIsChecked = XRCCTRL(*this, "my_checkbox", wxCheckBox)->IsChecked();
// Now call either Enable(TRUE) or Enable(FALSE) on the textctrl, depending // Now call either Enable(true) or Enable(false) on the textctrl, depending
// on the value of that boolean. // on the value of that boolean.
XRCCTRL(*this, "my_textctrl", wxTextCtrl)->Enable(myCheckBoxIsChecked); XRCCTRL(*this, "my_textctrl", wxTextCtrl)->Enable(myCheckBoxIsChecked);
} }
@@ -108,16 +108,16 @@ void PreferencesDialog::OnOK( wxCommandEvent& WXUNUSED(event) )
wxMessageDialog msgDlg2(this, _("Press OK to close Derived dialog, or Cancel to abort"), wxMessageDialog msgDlg2(this, _("Press OK to close Derived dialog, or Cancel to abort"),
_("Overriding base class OK button handler"), _("Overriding base class OK button handler"),
wxOK | wxCANCEL | wxCENTER ); wxOK | wxCANCEL | wxCENTER );
// Show the message dialog, and if it returns wxID_OK (ie they clicked on OK button)... // Show the message dialog, and if it returns wxID_OK (ie they clicked on OK button)...
if (msgDlg2.ShowModal() == wxID_OK) if (msgDlg2.ShowModal() == wxID_OK)
{ {
// ...then end this Preferences dialog. // ...then end this Preferences dialog.
EndModal( wxID_OK ); EndModal( wxID_OK );
// You could also have used event.Skip() which would then skip up // You could also have used event.Skip() which would then skip up
// to the wxDialog's event table and see if there was a EVT_BUTTON // to the wxDialog's event table and see if there was a EVT_BUTTON
// handler for wxID_OK and if there was, then execute that code. // handler for wxID_OK and if there was, then execute that code.
} }
// Otherwise do nothing. // Otherwise do nothing.
} }

View File

@@ -36,26 +36,26 @@
class PreferencesDialog : public wxDialog class PreferencesDialog : public wxDialog
{ {
public: public:
// Constructor. // Constructor.
/* /*
\param parent The parent window. Simple constructor. \param parent The parent window. Simple constructor.
*/ */
PreferencesDialog( wxWindow* parent ); PreferencesDialog( wxWindow* parent );
// Destructor. // Destructor.
~PreferencesDialog(); ~PreferencesDialog();
private: private:
// Stuff to do when "My Button" gets clicked // Stuff to do when "My Button" gets clicked
void OnMyButtonClicked( wxCommandEvent &event ); void OnMyButtonClicked( wxCommandEvent &event );
// Stuff to do when a "My Checkbox" gets updated // Stuff to do when a "My Checkbox" gets updated
// (drawn, or it changes its value) // (drawn, or it changes its value)
void OuUpdateUIMyCheckbox( wxUpdateUIEvent &event ); void OuUpdateUIMyCheckbox( wxUpdateUIEvent &event );
// Override base class functions of a wxDialog. // Override base class functions of a wxDialog.
void OnOK( wxCommandEvent &event ); void OnOK( wxCommandEvent &event );

View File

@@ -76,18 +76,18 @@
// The event tables connect the wxWidgets events with the functions (event // The event tables connect the wxWidgets events with the functions (event
// handlers) which process them. It can be also done at run-time, but for the // handlers) which process them. It can be also done at run-time, but for the
// simple menu events like this the static method is much simpler. // simple menu events like this the static method is much simpler.
// The reason why the menuitems and tools are given the same name in the // The reason why the menuitems and tools are given the same name in the
// XRC file, is that both a tool (a toolbar item) and a menuitem are designed // XRC file, is that both a tool (a toolbar item) and a menuitem are designed
// to fire the same kind of event (an EVT_MENU) and thus I give them the same // to fire the same kind of event (an EVT_MENU) and thus I give them the same
// ID name to help new users emphasize this point which is often overlooked // ID name to help new users emphasize this point which is often overlooked
// when starting out with wxWidgets. // when starting out with wxWidgets.
BEGIN_EVENT_TABLE(MyFrame, wxFrame) BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(XRCID("exit_tool_or_menuitem"), MyFrame::OnExitToolOrMenuCommand) EVT_MENU(XRCID("exit_tool_or_menuitem"), MyFrame::OnExitToolOrMenuCommand)
EVT_MENU(XRCID("non_derived_dialog_tool_or_menuitem"), MyFrame::OnNonDerivedDialogToolOrMenuCommand) EVT_MENU(XRCID("non_derived_dialog_tool_or_menuitem"), MyFrame::OnNonDerivedDialogToolOrMenuCommand)
EVT_MENU(XRCID("derived_tool_or_menuitem"), MyFrame::OnDerivedDialogToolOrMenuCommand) EVT_MENU(XRCID("derived_tool_or_menuitem"), MyFrame::OnDerivedDialogToolOrMenuCommand)
EVT_MENU(XRCID("controls_tool_or_menuitem"), MyFrame::OnControlsToolOrMenuCommand) EVT_MENU(XRCID("controls_tool_or_menuitem"), MyFrame::OnControlsToolOrMenuCommand)
EVT_MENU(XRCID("uncentered_tool_or_menuitem"), MyFrame::OnUncenteredToolOrMenuCommand) EVT_MENU(XRCID("uncentered_tool_or_menuitem"), MyFrame::OnUncenteredToolOrMenuCommand)
EVT_MENU(XRCID("custom_class_tool_or_menuitem"), MyFrame::OnCustomClassToolOrMenuCommand) EVT_MENU(XRCID("custom_class_tool_or_menuitem"), MyFrame::OnCustomClassToolOrMenuCommand)
EVT_MENU(XRCID("platform_property_tool_or_menuitem"), MyFrame::OnPlatformPropertyToolOrMenuCommand) EVT_MENU(XRCID("platform_property_tool_or_menuitem"), MyFrame::OnPlatformPropertyToolOrMenuCommand)
EVT_MENU(XRCID("art_provider_tool_or_menuitem"), MyFrame::OnArtProviderToolOrMenuCommand) EVT_MENU(XRCID("art_provider_tool_or_menuitem"), MyFrame::OnArtProviderToolOrMenuCommand)
EVT_MENU(XRCID("variable_expansion_tool_or_menuitem"), MyFrame::OnVariableExpansionToolOrMenuCommand) EVT_MENU(XRCID("variable_expansion_tool_or_menuitem"), MyFrame::OnVariableExpansionToolOrMenuCommand)
@@ -102,12 +102,12 @@ END_EVENT_TABLE()
MyFrame::MyFrame(wxWindow* parent) MyFrame::MyFrame(wxWindow* parent)
{ {
// Load up this frame from XRC. [Note, instead of making a class's // Load up this frame from XRC. [Note, instead of making a class's
// constructor take a wxWindow* parent with a default value of NULL, // constructor take a wxWindow* parent with a default value of NULL,
// we could have just had designed MyFrame class with an empty // we could have just had designed MyFrame class with an empty
// constructor and then written here: // constructor and then written here:
// wxXmlResource::Get()->LoadFrame(this, (wxWindow* )NULL, "main_frame"); // wxXmlResource::Get()->LoadFrame(this, (wxWindow* )NULL, "main_frame");
// since this frame will always be the top window, and thus parentless. // since this frame will always be the top window, and thus parentless.
// However, the current approach has source code that can be recycled // However, the current approach has source code that can be recycled
// for other frames that aren't the top level window.] // for other frames that aren't the top level window.]
wxXmlResource::Get()->LoadFrame(this, parent, wxT("main_frame")); wxXmlResource::Get()->LoadFrame(this, parent, wxT("main_frame"));
@@ -121,9 +121,9 @@ MyFrame::MyFrame(wxWindow* parent)
// With toolbars, you currently can't create one, and set it later. It // With toolbars, you currently can't create one, and set it later. It
// needs to be all in one step. // needs to be all in one step.
SetToolBar(wxXmlResource::Get()->LoadToolBar(this, wxT("main_toolbar"))); SetToolBar(wxXmlResource::Get()->LoadToolBar(this, wxT("main_toolbar")));
// Give the frame a optional statusbar. The '1' just means one field. // Give the frame a optional statusbar. The '1' just means one field.
// A gripsizer will automatically get put on into the corner, if that // A gripsizer will automatically get put on into the corner, if that
// is the normal OS behaviour for frames on that platform. Helptext // is the normal OS behaviour for frames on that platform. Helptext
// for menu items and toolbar tools will automatically get displayed // for menu items and toolbar tools will automatically get displayed
// here. // here.
@@ -136,8 +136,8 @@ MyFrame::MyFrame(wxWindow* parent)
void MyFrame::OnExitToolOrMenuCommand(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnExitToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{ {
// TRUE is to force the frame to close. // true is to force the frame to close.
Close(TRUE); Close(true);
} }
@@ -152,10 +152,10 @@ void MyFrame::OnNonDerivedDialogToolOrMenuCommand(wxCommandEvent& WXUNUSED(event
} }
void MyFrame::OnDerivedDialogToolOrMenuCommand(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnDerivedDialogToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{ {
// Make an instance of our derived dialog, passing it "this" window // Make an instance of our derived dialog, passing it "this" window
// (the main frame) as the parent of the dialog. This allows the dialog // (the main frame) as the parent of the dialog. This allows the dialog
// to be destructed automatically when the parent is destroyed. // to be destructed automatically when the parent is destroyed.
PreferencesDialog preferencesDialog(this); PreferencesDialog preferencesDialog(this);
// Show the instance of the dialog, modally. // Show the instance of the dialog, modally.
@@ -163,19 +163,19 @@ void MyFrame::OnDerivedDialogToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
} }
void MyFrame::OnControlsToolOrMenuCommand(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnControlsToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{ {
wxDialog dlg; wxDialog dlg;
wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("controls_dialog")); wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("controls_dialog"));
#if wxUSE_LISTCTRL #if wxUSE_LISTCTRL
// There is no data in the listctrl. This will add some columns // There is no data in the listctrl. This will add some columns
// and some data. You don't need use any pointers // and some data. You don't need use any pointers
// at all to manipulate the controls, just simply use the XRCCTL(...) macros. // at all to manipulate the controls, just simply use the XRCCTL(...) macros.
// "controls_treectrl" is the name of this control in the XRC. // "controls_treectrl" is the name of this control in the XRC.
// (1) Insert a column, with the column header of "Name" // (1) Insert a column, with the column header of "Name"
// (The '_' function around "Name" marks this string as one to translate). // (The '_' function around "Name" marks this string as one to translate).
XRCCTRL(dlg, "controls_listctrl", wxListCtrl)->InsertColumn( 0, XRCCTRL(dlg, "controls_listctrl", wxListCtrl)->InsertColumn( 0,
_("Name"), _("Name"),
wxLIST_FORMAT_LEFT, wxLIST_FORMAT_LEFT,
( 200 ) ( 200 )
@@ -186,12 +186,12 @@ void MyFrame::OnControlsToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
XRCCTRL(dlg, "controls_listctrl", wxListCtrl)->InsertItem(2,wxT("Leon Li")); XRCCTRL(dlg, "controls_listctrl", wxListCtrl)->InsertItem(2,wxT("Leon Li"));
#endif #endif
#if wxUSE_TREECTRL #if wxUSE_TREECTRL
// There is no data in the tree ctrl. These lines will add some. // There is no data in the tree ctrl. These lines will add some.
// (1) Instead of having to write out // (1) Instead of having to write out
// XRCCTRL(dlg, "controls_treectrl", wxTreeCtrl)->SomeFunction() // XRCCTRL(dlg, "controls_treectrl", wxTreeCtrl)->SomeFunction()
// each time (which is also OK), this example code will shown how // each time (which is also OK), this example code will shown how
// to make a pointer to the XRC control, so we can use // to make a pointer to the XRC control, so we can use
// treectrl->SomeFunction() as a short cut. This is useful if you // treectrl->SomeFunction() as a short cut. This is useful if you
// will be referring to this control often in the code. // will be referring to this control often in the code.
wxTreeCtrl* treectrl = XRCCTRL(dlg, "controls_treectrl", wxTreeCtrl); wxTreeCtrl* treectrl = XRCCTRL(dlg, "controls_treectrl", wxTreeCtrl);
@@ -200,15 +200,15 @@ void MyFrame::OnControlsToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
// (3)Append some items to the root node. // (3)Append some items to the root node.
treectrl->AppendItem(treectrl->GetRootItem(), _("Evil henchman 1")); treectrl->AppendItem(treectrl->GetRootItem(), _("Evil henchman 1"));
treectrl->AppendItem(treectrl->GetRootItem(), _("Evil henchman 2")); treectrl->AppendItem(treectrl->GetRootItem(), _("Evil henchman 2"));
treectrl->AppendItem(treectrl->GetRootItem(), _("Evil accountant")); treectrl->AppendItem(treectrl->GetRootItem(), _("Evil accountant"));
#endif #endif
// All done. Show the dialog. // All done. Show the dialog.
dlg.ShowModal(); dlg.ShowModal();
} }
void MyFrame::OnUncenteredToolOrMenuCommand(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnUncenteredToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{ {
wxDialog dlg; wxDialog dlg;
wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("uncentered_dialog")); wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("uncentered_dialog"));
@@ -220,16 +220,16 @@ void MyFrame::OnCustomClassToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{ {
wxDialog dlg; wxDialog dlg;
wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("custom_class_dialog")); wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("custom_class_dialog"));
// Make an instance of our new custom class. // Make an instance of our new custom class.
MyResizableListCtrl* a_myResizableListCtrl = new MyResizableListCtrl(&dlg, MyResizableListCtrl* a_myResizableListCtrl = new MyResizableListCtrl(&dlg,
-1, wxID_ANY,
wxDefaultPosition, wxDefaultPosition,
wxDefaultSize, wxDefaultSize,
wxLC_REPORT, wxLC_REPORT,
wxDefaultValidator); wxDefaultValidator);
// "custom_control_placeholder" is the name of the "unknown" tag in the // "custom_control_placeholder" is the name of the "unknown" tag in the
// custctrl.xrc XRC file. // custctrl.xrc XRC file.
wxXmlResource::Get()->AttachUnknownControl(wxT("custom_control_placeholder"), wxXmlResource::Get()->AttachUnknownControl(wxT("custom_control_placeholder"),
a_myResizableListCtrl); a_myResizableListCtrl);

View File

@@ -41,7 +41,7 @@ public:
// Constructor. // Constructor.
MyFrame( wxWindow* parent=(wxWindow *)NULL); MyFrame( wxWindow* parent=(wxWindow *)NULL);
private: private:
// Event handlers (these functions should _not_ be virtual) // Event handlers (these functions should _not_ be virtual)
void OnExitToolOrMenuCommand(wxCommandEvent& event); void OnExitToolOrMenuCommand(wxCommandEvent& event);
@@ -49,7 +49,7 @@ private:
void OnNonDerivedDialogToolOrMenuCommand(wxCommandEvent& event); void OnNonDerivedDialogToolOrMenuCommand(wxCommandEvent& event);
void OnDerivedDialogToolOrMenuCommand(wxCommandEvent& event); void OnDerivedDialogToolOrMenuCommand(wxCommandEvent& event);
void OnControlsToolOrMenuCommand(wxCommandEvent& event); void OnControlsToolOrMenuCommand(wxCommandEvent& event);
void OnUncenteredToolOrMenuCommand(wxCommandEvent& event); void OnUncenteredToolOrMenuCommand(wxCommandEvent& event);
void OnCustomClassToolOrMenuCommand(wxCommandEvent& event); void OnCustomClassToolOrMenuCommand(wxCommandEvent& event);
void OnPlatformPropertyToolOrMenuCommand(wxCommandEvent& event); void OnPlatformPropertyToolOrMenuCommand(wxCommandEvent& event);
void OnArtProviderToolOrMenuCommand(wxCommandEvent& event); void OnArtProviderToolOrMenuCommand(wxCommandEvent& event);

View File

@@ -75,18 +75,18 @@ bool MyApp::OnInit()
// you want PNGs, then add a PNG handler, etc. See wxImage::AddHandler() // you want PNGs, then add a PNG handler, etc. See wxImage::AddHandler()
// documentation for the types of image handlers available. // documentation for the types of image handlers available.
wxImage::AddHandler(new wxXPMHandler); wxImage::AddHandler(new wxXPMHandler);
// Initialize all the XRC handlers. Always required (unless you feel like // Initialize all the XRC handlers. Always required (unless you feel like
// going through and initializing a handler of each control type you will // going through and initializing a handler of each control type you will
// be using (ie initialize the spinctrl handler, initialize the textctrl // be using (ie initialize the spinctrl handler, initialize the textctrl
// handler). However, if you are only using a few control types, it will // handler). However, if you are only using a few control types, it will
// save some space to only initialize the ones you will be using. See // save some space to only initialize the ones you will be using. See
// wxXRC docs for details. // wxXRC docs for details.
wxXmlResource::Get()->InitAllHandlers(); wxXmlResource::Get()->InitAllHandlers();
// Load all of the XRC files that will be used. You can put everything // Load all of the XRC files that will be used. You can put everything
// into one giant XRC file if you wanted, but then they become more // into one giant XRC file if you wanted, but then they become more
// diffcult to manage, and harder to reuse in later projects. // diffcult to manage, and harder to reuse in later projects.
// The menubar // The menubar
wxXmlResource::Get()->Load(wxT("rc/menu.xrc")); wxXmlResource::Get()->Load(wxT("rc/menu.xrc"));
// The toolbar // The toolbar
@@ -100,7 +100,7 @@ bool MyApp::OnInit()
// Frame example // Frame example
wxXmlResource::Get()->Load(wxT("rc/frame.xrc")); wxXmlResource::Get()->Load(wxT("rc/frame.xrc"));
// Uncentered example // Uncentered example
wxXmlResource::Get()->Load(wxT("rc/uncenter.xrc")); wxXmlResource::Get()->Load(wxT("rc/uncenter.xrc"));
// Custom class example // Custom class example
wxXmlResource::Get()->Load(wxT("rc/custclas.xrc")); wxXmlResource::Get()->Load(wxT("rc/custclas.xrc"));
// wxArtProvider example // wxArtProvider example
@@ -110,15 +110,15 @@ bool MyApp::OnInit()
// Variable expansion example // Variable expansion example
wxXmlResource::Get()->Load(wxT("rc/variable.xrc")); wxXmlResource::Get()->Load(wxT("rc/variable.xrc"));
// Make an instance of your derived frame. Passing NULL (the default value // Make an instance of your derived frame. Passing NULL (the default value
// of MyFrame's constructor is NULL) as the frame doesn't have a frame // of MyFrame's constructor is NULL) as the frame doesn't have a frame
// since it is the first window. // since it is the first window.
MyFrame *frame = new MyFrame(); MyFrame *frame = new MyFrame();
// Show the frame. // Show the frame.
frame->Show(TRUE); frame->Show(true);
// Return TRUE to tell program to continue (FALSE would terminate). // Return true to tell program to continue (false would terminate).
return TRUE; return true;
} }

View File

@@ -39,12 +39,12 @@ class MyApp : public wxApp
public: public:
// Override base class virtuals: // Override base class virtuals:
// wxApp::OnInit() is called on application startup and is a good place // wxApp::OnInit() is called on application startup and is a good place
// for the app initialization (doing it here and not in the ctor // for the app initialization (doing it here and not in the ctor
// allows to have an error return: if OnInit() returns false, the // allows to have an error return: if OnInit() returns false, the
// application terminates) // application terminates)
virtual bool OnInit(); virtual bool OnInit();
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Vaclav Slavik // Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_bmp.h" #pragma implementation "xh_bmp.h"
#endif #endif
@@ -24,13 +24,13 @@
IMPLEMENT_DYNAMIC_CLASS(wxBitmapXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxBitmapXmlHandler, wxXmlResourceHandler)
wxBitmapXmlHandler::wxBitmapXmlHandler() wxBitmapXmlHandler::wxBitmapXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
} }
wxObject *wxBitmapXmlHandler::DoCreateResource() wxObject *wxBitmapXmlHandler::DoCreateResource()
{ {
return new wxBitmap(GetBitmap(wxT(""))); return new wxBitmap(GetBitmap(wxT("")));
} }
@@ -41,13 +41,13 @@ bool wxBitmapXmlHandler::CanHandle(wxXmlNode *node)
IMPLEMENT_DYNAMIC_CLASS(wxIconXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxIconXmlHandler, wxXmlResourceHandler)
wxIconXmlHandler::wxIconXmlHandler() wxIconXmlHandler::wxIconXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
} }
wxObject *wxIconXmlHandler::DoCreateResource() wxObject *wxIconXmlHandler::DoCreateResource()
{ {
return new wxIcon(GetIcon(wxT(""))); return new wxIcon(GetIcon(wxT("")));
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Brian Gavin // Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_bmpbt.h" #pragma implementation "xh_bmpbt.h"
#endif #endif
@@ -24,8 +24,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButtonXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxBitmapButtonXmlHandler, wxXmlResourceHandler)
wxBitmapButtonXmlHandler::wxBitmapButtonXmlHandler() wxBitmapButtonXmlHandler::wxBitmapButtonXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxBU_AUTODRAW); XRC_ADD_STYLE(wxBU_AUTODRAW);
XRC_ADD_STYLE(wxBU_LEFT); XRC_ADD_STYLE(wxBU_LEFT);
@@ -37,7 +37,7 @@ wxBitmapButtonXmlHandler::wxBitmapButtonXmlHandler()
} }
wxObject *wxBitmapButtonXmlHandler::DoCreateResource() wxObject *wxBitmapButtonXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(button, wxBitmapButton) XRC_MAKE_INSTANCE(button, wxBitmapButton)
button->Create(m_parentAsWindow, button->Create(m_parentAsWindow,
@@ -50,14 +50,14 @@ wxObject *wxBitmapButtonXmlHandler::DoCreateResource()
if (GetBool(wxT("default"), 0)) if (GetBool(wxT("default"), 0))
button->SetDefault(); button->SetDefault();
SetupWindow(button); SetupWindow(button);
if (!GetParamValue(wxT("selected")).IsEmpty()) if (!GetParamValue(wxT("selected")).IsEmpty())
button->SetBitmapSelected(GetBitmap(wxT("selected"))); button->SetBitmapSelected(GetBitmap(wxT("selected")));
if (!GetParamValue(wxT("focus")).IsEmpty()) if (!GetParamValue(wxT("focus")).IsEmpty())
button->SetBitmapFocus(GetBitmap(wxT("focus"))); button->SetBitmapFocus(GetBitmap(wxT("focus")));
if (!GetParamValue(wxT("disabled")).IsEmpty()) if (!GetParamValue(wxT("disabled")).IsEmpty())
button->SetBitmapDisabled(GetBitmap(wxT("disabled"))); button->SetBitmapDisabled(GetBitmap(wxT("disabled")));
return button; return button;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Vaclav Slavik // Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_bttn.h" #pragma implementation "xh_bttn.h"
#endif #endif
@@ -24,8 +24,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxButtonXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxButtonXmlHandler, wxXmlResourceHandler)
wxButtonXmlHandler::wxButtonXmlHandler() wxButtonXmlHandler::wxButtonXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxBU_LEFT); XRC_ADD_STYLE(wxBU_LEFT);
XRC_ADD_STYLE(wxBU_RIGHT); XRC_ADD_STYLE(wxBU_RIGHT);
@@ -36,7 +36,7 @@ wxButtonXmlHandler::wxButtonXmlHandler()
} }
wxObject *wxButtonXmlHandler::DoCreateResource() wxObject *wxButtonXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(button, wxButton) XRC_MAKE_INSTANCE(button, wxButton)
button->Create(m_parentAsWindow, button->Create(m_parentAsWindow,
@@ -50,7 +50,7 @@ wxObject *wxButtonXmlHandler::DoCreateResource()
if (GetBool(wxT("default"), 0)) if (GetBool(wxT("default"), 0))
button->SetDefault(); button->SetDefault();
SetupWindow(button); SetupWindow(button);
return button; return button;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Brian Gavin // Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_cald.h" #pragma implementation "xh_cald.h"
#endif #endif
@@ -29,8 +29,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxCalendarCtrlXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxCalendarCtrlXmlHandler, wxXmlResourceHandler)
wxCalendarCtrlXmlHandler::wxCalendarCtrlXmlHandler() wxCalendarCtrlXmlHandler::wxCalendarCtrlXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxCAL_SUNDAY_FIRST); XRC_ADD_STYLE(wxCAL_SUNDAY_FIRST);
XRC_ADD_STYLE(wxCAL_MONDAY_FIRST); XRC_ADD_STYLE(wxCAL_MONDAY_FIRST);
@@ -45,7 +45,7 @@ wxCalendarCtrlXmlHandler::wxCalendarCtrlXmlHandler()
wxObject *wxCalendarCtrlXmlHandler::DoCreateResource() wxObject *wxCalendarCtrlXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(calendar, wxCalendarCtrl); XRC_MAKE_INSTANCE(calendar, wxCalendarCtrl);
calendar->Create(m_parentAsWindow, calendar->Create(m_parentAsWindow,
@@ -55,9 +55,9 @@ wxObject *wxCalendarCtrlXmlHandler::DoCreateResource()
GetPosition(), GetSize(), GetPosition(), GetSize(),
GetStyle(), GetStyle(),
GetName()); GetName());
SetupWindow(calendar); SetupWindow(calendar);
return calendar; return calendar;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_chckb.h" #pragma implementation "xh_chckb.h"
#endif #endif
@@ -26,14 +26,14 @@
IMPLEMENT_DYNAMIC_CLASS(wxCheckBoxXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxCheckBoxXmlHandler, wxXmlResourceHandler)
wxCheckBoxXmlHandler::wxCheckBoxXmlHandler() wxCheckBoxXmlHandler::wxCheckBoxXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
AddWindowStyles(); AddWindowStyles();
} }
wxObject *wxCheckBoxXmlHandler::DoCreateResource() wxObject *wxCheckBoxXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(control, wxCheckBox) XRC_MAKE_INSTANCE(control, wxCheckBox)
control->Create(m_parentAsWindow, control->Create(m_parentAsWindow,
@@ -46,7 +46,7 @@ wxObject *wxCheckBoxXmlHandler::DoCreateResource()
control->SetValue(GetBool( wxT("checked"))); control->SetValue(GetBool( wxT("checked")));
SetupWindow(control); SetupWindow(control);
return control; return control;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_chckl.h" #pragma implementation "xh_chckl.h"
#endif #endif
@@ -28,15 +28,15 @@
IMPLEMENT_DYNAMIC_CLASS(wxCheckListBoxXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxCheckListBoxXmlHandler, wxXmlResourceHandler)
wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler() wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler()
: wxXmlResourceHandler(), m_insideBox(FALSE) : wxXmlResourceHandler(), m_insideBox(false)
{ {
// no styles // no styles
AddWindowStyles(); AddWindowStyles();
} }
wxObject *wxCheckListBoxXmlHandler::DoCreateResource() wxObject *wxCheckListBoxXmlHandler::DoCreateResource()
{ {
if (m_class == wxT("wxCheckListBox") if (m_class == wxT("wxCheckListBox")
#if WXWIN_COMPATIBILITY_2_4 #if WXWIN_COMPATIBILITY_2_4
|| m_class == wxT("wxCheckList") || m_class == wxT("wxCheckList")
@@ -48,7 +48,7 @@ wxObject *wxCheckListBoxXmlHandler::DoCreateResource()
wxLogDebug(wxT("'wxCheckList' name is deprecated, use 'wxCheckListBox' instead.")); wxLogDebug(wxT("'wxCheckList' name is deprecated, use 'wxCheckListBox' instead."));
#endif #endif
// need to build the list of strings from children // need to build the list of strings from children
m_insideBox = TRUE; m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content"))); CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
wxString *strings = (wxString *) NULL; wxString *strings = (wxString *) NULL;
if (strList.GetCount() > 0) if (strList.GetCount() > 0)
@@ -84,17 +84,17 @@ wxObject *wxCheckListBoxXmlHandler::DoCreateResource()
wxString v = n->GetPropVal(wxT("checked"), wxEmptyString); wxString v = n->GetPropVal(wxT("checked"), wxEmptyString);
v.MakeLower(); v.MakeLower();
if (v && v == wxT("1")) if (v && v == wxT("1"))
control->Check( i, TRUE ); control->Check( i, true );
i++; i++;
n = n->GetNext(); n = n->GetNext();
} }
SetupWindow(control); SetupWindow(control);
if (strings != NULL) if (strings != NULL)
delete[] strings; delete[] strings;
strList.Clear(); // dump the strings strList.Clear(); // dump the strings
return control; return control;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_choic.h" #pragma implementation "xh_choic.h"
#endif #endif
@@ -25,22 +25,22 @@
IMPLEMENT_DYNAMIC_CLASS(wxChoiceXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxChoiceXmlHandler, wxXmlResourceHandler)
wxChoiceXmlHandler::wxChoiceXmlHandler() wxChoiceXmlHandler::wxChoiceXmlHandler()
: wxXmlResourceHandler() , m_insideBox(FALSE) : wxXmlResourceHandler() , m_insideBox(false)
{ {
XRC_ADD_STYLE(wxCB_SORT); XRC_ADD_STYLE(wxCB_SORT);
AddWindowStyles(); AddWindowStyles();
} }
wxObject *wxChoiceXmlHandler::DoCreateResource() wxObject *wxChoiceXmlHandler::DoCreateResource()
{ {
if( m_class == wxT("wxChoice")) if( m_class == wxT("wxChoice"))
{ {
// find the selection // find the selection
long selection = GetLong(wxT("selection"), -1); long selection = GetLong(wxT("selection"), -1);
// need to build the list of strings from children // need to build the list of strings from children
m_insideBox = TRUE; m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content"))); CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
wxString *strings = (wxString *) NULL; wxString *strings = (wxString *) NULL;
if (strList.GetCount() > 0) if (strList.GetCount() > 0)
@@ -69,7 +69,7 @@ wxObject *wxChoiceXmlHandler::DoCreateResource()
if (strings != NULL) if (strings != NULL)
delete[] strings; delete[] strings;
strList.Clear(); // dump the strings strList.Clear(); // dump the strings
return control; return control;
} }
@@ -77,7 +77,7 @@ wxObject *wxChoiceXmlHandler::DoCreateResource()
{ {
// on the inside now. // on the inside now.
// handle <item>Label</item> // handle <item>Label</item>
// add to the list // add to the list
wxString str = GetNodeContent(m_node); wxString str = GetNodeContent(m_node);
if (m_resource->GetFlags() & wxXRC_USE_LOCALE) if (m_resource->GetFlags() & wxXRC_USE_LOCALE)

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_combo.h" #pragma implementation "xh_combo.h"
#endif #endif
@@ -27,8 +27,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxComboBoxXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxComboBoxXmlHandler, wxXmlResourceHandler)
wxComboBoxXmlHandler::wxComboBoxXmlHandler() wxComboBoxXmlHandler::wxComboBoxXmlHandler()
: wxXmlResourceHandler() , m_insideBox(FALSE) : wxXmlResourceHandler() , m_insideBox(false)
{ {
XRC_ADD_STYLE(wxCB_SIMPLE); XRC_ADD_STYLE(wxCB_SIMPLE);
XRC_ADD_STYLE(wxCB_SORT); XRC_ADD_STYLE(wxCB_SORT);
@@ -38,14 +38,14 @@ wxComboBoxXmlHandler::wxComboBoxXmlHandler()
} }
wxObject *wxComboBoxXmlHandler::DoCreateResource() wxObject *wxComboBoxXmlHandler::DoCreateResource()
{ {
if( m_class == wxT("wxComboBox")) if( m_class == wxT("wxComboBox"))
{ {
// find the selection // find the selection
long selection = GetLong( wxT("selection"), -1 ); long selection = GetLong( wxT("selection"), -1 );
// need to build the list of strings from children // need to build the list of strings from children
m_insideBox = TRUE; m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content"))); CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
wxString *strings = (wxString *) NULL; wxString *strings = (wxString *) NULL;
if (strList.GetCount() > 0) if (strList.GetCount() > 0)
@@ -75,7 +75,7 @@ wxObject *wxComboBoxXmlHandler::DoCreateResource()
if (strings != NULL) if (strings != NULL)
delete[] strings; delete[] strings;
strList.Clear(); // dump the strings strList.Clear(); // dump the strings
return control; return control;
} }

View File

@@ -70,7 +70,7 @@ wxObject *wxDialogXmlHandler::DoCreateResource()
CreateChildren(dlg); CreateChildren(dlg);
if (GetBool(wxT("centered"), FALSE)) if (GetBool(wxT("centered"), false))
dlg->Centre(); dlg->Centre();
return dlg; return dlg;

View File

@@ -75,7 +75,7 @@ wxObject *wxFrameXmlHandler::DoCreateResource()
CreateChildren(frame); CreateChildren(frame);
if (GetBool(wxT("centered"), FALSE)) if (GetBool(wxT("centered"), false))
frame->Centre(); frame->Centre();
return frame; return frame;

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_gauge.h" #pragma implementation "xh_gauge.h"
#endif #endif
@@ -26,8 +26,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxGaugeXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxGaugeXmlHandler, wxXmlResourceHandler)
wxGaugeXmlHandler::wxGaugeXmlHandler() wxGaugeXmlHandler::wxGaugeXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxGA_HORIZONTAL); XRC_ADD_STYLE(wxGA_HORIZONTAL);
XRC_ADD_STYLE(wxGA_VERTICAL); XRC_ADD_STYLE(wxGA_VERTICAL);
@@ -37,12 +37,12 @@ wxGaugeXmlHandler::wxGaugeXmlHandler()
} }
wxObject *wxGaugeXmlHandler::DoCreateResource() wxObject *wxGaugeXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(control, wxGauge) XRC_MAKE_INSTANCE(control, wxGauge)
control->Create(m_parentAsWindow, control->Create(m_parentAsWindow,
GetID(), GetID(),
GetLong(wxT("range"), wxGAUGE_DEFAULT_RANGE), GetLong(wxT("range"), wxGAUGE_DEFAULT_RANGE),
GetPosition(), GetSize(), GetPosition(), GetSize(),
GetStyle(), GetStyle(),
wxDefaultValidator, wxDefaultValidator,

View File

@@ -41,7 +41,7 @@ wxGenericDirCtrlXmlHandler::wxGenericDirCtrlXmlHandler()
wxObject *wxGenericDirCtrlXmlHandler::DoCreateResource() wxObject *wxGenericDirCtrlXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(ctrl, wxGenericDirCtrl) XRC_MAKE_INSTANCE(ctrl, wxGenericDirCtrl)
ctrl->Create(m_parentAsWindow, ctrl->Create(m_parentAsWindow,
GetID(), GetID(),
GetText(wxT("defaultfolder")), GetText(wxT("defaultfolder")),

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_html.h" #pragma implementation "xh_html.h"
#endif #endif
@@ -28,8 +28,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindowXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindowXmlHandler, wxXmlResourceHandler)
wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler() wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxHW_SCROLLBAR_NEVER); XRC_ADD_STYLE(wxHW_SCROLLBAR_NEVER);
XRC_ADD_STYLE(wxHW_SCROLLBAR_AUTO); XRC_ADD_STYLE(wxHW_SCROLLBAR_AUTO);
@@ -56,7 +56,7 @@ wxObject *wxHtmlWindowXmlHandler::DoCreateResource()
{ {
wxString url = GetParamValue(wxT("url")); wxString url = GetParamValue(wxT("url"));
wxFileSystem& fsys = GetCurFileSystem(); wxFileSystem& fsys = GetCurFileSystem();
wxFSFile *f = fsys.OpenFile(url); wxFSFile *f = fsys.OpenFile(url);
if (f) if (f)
{ {
@@ -66,14 +66,14 @@ wxObject *wxHtmlWindowXmlHandler::DoCreateResource()
else else
control->LoadPage(url); control->LoadPage(url);
} }
else if (HasParam(wxT("htmlcode"))) else if (HasParam(wxT("htmlcode")))
{ {
control->SetPage(GetText(wxT("htmlcode"))); control->SetPage(GetText(wxT("htmlcode")));
} }
SetupWindow(control); SetupWindow(control);
return control; return control;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_listb.h" #pragma implementation "xh_listb.h"
#endif #endif
@@ -25,8 +25,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxListBoxXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxListBoxXmlHandler, wxXmlResourceHandler)
wxListBoxXmlHandler::wxListBoxXmlHandler() wxListBoxXmlHandler::wxListBoxXmlHandler()
: wxXmlResourceHandler() , m_insideBox(FALSE) : wxXmlResourceHandler() , m_insideBox(false)
{ {
XRC_ADD_STYLE(wxLB_SINGLE); XRC_ADD_STYLE(wxLB_SINGLE);
XRC_ADD_STYLE(wxLB_MULTIPLE); XRC_ADD_STYLE(wxLB_MULTIPLE);
@@ -39,14 +39,14 @@ wxListBoxXmlHandler::wxListBoxXmlHandler()
} }
wxObject *wxListBoxXmlHandler::DoCreateResource() wxObject *wxListBoxXmlHandler::DoCreateResource()
{ {
if( m_class == wxT("wxListBox")) if( m_class == wxT("wxListBox"))
{ {
// find the selection // find the selection
long selection = GetLong(wxT("selection"), -1); long selection = GetLong(wxT("selection"), -1);
// need to build the list of strings from children // need to build the list of strings from children
m_insideBox = TRUE; m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content"))); CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
wxString *strings = (wxString *) NULL; wxString *strings = (wxString *) NULL;
if (strList.GetCount() > 0) if (strList.GetCount() > 0)
@@ -75,7 +75,7 @@ wxObject *wxListBoxXmlHandler::DoCreateResource()
if (strings != NULL) if (strings != NULL)
delete[] strings; delete[] strings;
strList.Clear(); // dump the strings strList.Clear(); // dump the strings
return control; return control;
} }
@@ -83,7 +83,7 @@ wxObject *wxListBoxXmlHandler::DoCreateResource()
{ {
// on the inside now. // on the inside now.
// handle <item>Label</item> // handle <item>Label</item>
// add to the list // add to the list
wxString str = GetNodeContent(m_node); wxString str = GetNodeContent(m_node);
if (m_resource->GetFlags() & wxXRC_USE_LOCALE) if (m_resource->GetFlags() & wxXRC_USE_LOCALE)

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Brian Gavin // Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_listc.h" #pragma implementation "xh_listc.h"
#endif #endif
@@ -26,8 +26,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxListCtrlXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxListCtrlXmlHandler, wxXmlResourceHandler)
wxListCtrlXmlHandler::wxListCtrlXmlHandler() wxListCtrlXmlHandler::wxListCtrlXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxLC_LIST); XRC_ADD_STYLE(wxLC_LIST);
XRC_ADD_STYLE(wxLC_REPORT); XRC_ADD_STYLE(wxLC_REPORT);
@@ -50,7 +50,7 @@ wxListCtrlXmlHandler::wxListCtrlXmlHandler()
} }
wxObject *wxListCtrlXmlHandler::DoCreateResource() wxObject *wxListCtrlXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(list, wxListCtrl) XRC_MAKE_INSTANCE(list, wxListCtrl)
list->Create(m_parentAsWindow, list->Create(m_parentAsWindow,
@@ -61,9 +61,9 @@ wxObject *wxListCtrlXmlHandler::DoCreateResource()
GetName()); GetName());
// FIXME: add columns definition // FIXME: add columns definition
SetupWindow(list); SetupWindow(list);
return list; return list;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Vaclav Slavik // Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_menu.h" #pragma implementation "xh_menu.h"
#endif #endif
@@ -25,8 +25,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxMenuXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxMenuXmlHandler, wxXmlResourceHandler)
wxMenuXmlHandler::wxMenuXmlHandler() : wxMenuXmlHandler::wxMenuXmlHandler() :
wxXmlResourceHandler(), m_insideMenu(FALSE) wxXmlResourceHandler(), m_insideMenu(false)
{ {
XRC_ADD_STYLE(wxMENU_TEAROFF); XRC_ADD_STYLE(wxMENU_TEAROFF);
} }
@@ -38,10 +38,10 @@ wxObject *wxMenuXmlHandler::DoCreateResource()
wxMenu *menu = new wxMenu(GetStyle()); wxMenu *menu = new wxMenu(GetStyle());
wxString title = GetText(wxT("label")); wxString title = GetText(wxT("label"));
wxString help = GetText(wxT("help")); wxString help = GetText(wxT("help"));
bool oldins = m_insideMenu; bool oldins = m_insideMenu;
m_insideMenu = TRUE; m_insideMenu = true;
CreateChildren(menu, TRUE/*only this handler*/); CreateChildren(menu, true/*only this handler*/);
m_insideMenu = oldins; m_insideMenu = oldins;
wxMenuBar *p_bar = wxDynamicCast(m_parent, wxMenuBar); wxMenuBar *p_bar = wxDynamicCast(m_parent, wxMenuBar);
@@ -60,16 +60,16 @@ wxObject *wxMenuXmlHandler::DoCreateResource()
else else
{ {
wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu); wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu);
if (m_class == wxT("separator")) if (m_class == wxT("separator"))
p_menu->AppendSeparator(); p_menu->AppendSeparator();
else if (m_class == wxT("break")) else if (m_class == wxT("break"))
p_menu->Break(); p_menu->Break();
else /*wxMenuItem*/ else /*wxMenuItem*/
{ {
int id = GetID(); int id = GetID();
wxString label = GetText(wxT("label")); wxString label = GetText(wxT("label"));
wxString accel = GetText(wxT("accel"), FALSE); wxString accel = GetText(wxT("accel"), false);
wxString fullLabel = label; wxString fullLabel = label;
if (!accel.IsEmpty()) if (!accel.IsEmpty())
fullLabel << wxT("\t") << accel; fullLabel << wxT("\t") << accel;
@@ -85,13 +85,13 @@ wxObject *wxMenuXmlHandler::DoCreateResource()
wxMenuItem *mitem = new wxMenuItem(p_menu, id, fullLabel, wxMenuItem *mitem = new wxMenuItem(p_menu, id, fullLabel,
GetText(wxT("help")), kind); GetText(wxT("help")), kind);
#if wxCHECK_VERSION(2,3,0) || (defined(__WXMSW__) && wxUSE_OWNER_DRAWN) #if wxCHECK_VERSION(2,3,0) || (defined(__WXMSW__) && wxUSE_OWNER_DRAWN)
if (HasParam(wxT("bitmap"))) if (HasParam(wxT("bitmap")))
mitem->SetBitmap(GetBitmap(wxT("bitmap"), wxART_MENU)); mitem->SetBitmap(GetBitmap(wxT("bitmap"), wxART_MENU));
#endif #endif
p_menu->Append(mitem); p_menu->Append(mitem);
mitem->Enable(GetBool(wxT("enabled"), TRUE)); mitem->Enable(GetBool(wxT("enabled"), true));
if (kind == wxITEM_CHECK) if (kind == wxITEM_CHECK)
mitem->Check(GetBool(wxT("checked"))); mitem->Check(GetBool(wxT("checked")));
} }
@@ -104,7 +104,7 @@ wxObject *wxMenuXmlHandler::DoCreateResource()
bool wxMenuXmlHandler::CanHandle(wxXmlNode *node) bool wxMenuXmlHandler::CanHandle(wxXmlNode *node)
{ {
return IsOfClass(node, wxT("wxMenu")) || return IsOfClass(node, wxT("wxMenu")) ||
(m_insideMenu && (m_insideMenu &&
(IsOfClass(node, wxT("wxMenuItem")) || (IsOfClass(node, wxT("wxMenuItem")) ||
IsOfClass(node, wxT("break")) || IsOfClass(node, wxT("break")) ||
IsOfClass(node, wxT("separator"))) IsOfClass(node, wxT("separator")))

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Vaclav Slavik // Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_notbk.h" #pragma implementation "xh_notbk.h"
#endif #endif
@@ -29,8 +29,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxNotebookXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxNotebookXmlHandler, wxXmlResourceHandler)
wxNotebookXmlHandler::wxNotebookXmlHandler() wxNotebookXmlHandler::wxNotebookXmlHandler()
: wxXmlResourceHandler(), m_isInside(FALSE), m_notebook(NULL) : wxXmlResourceHandler(), m_isInside(false), m_notebook(NULL)
{ {
XRC_ADD_STYLE(wxNB_FIXEDWIDTH); XRC_ADD_STYLE(wxNB_FIXEDWIDTH);
XRC_ADD_STYLE(wxNB_LEFT); XRC_ADD_STYLE(wxNB_LEFT);
@@ -40,7 +40,7 @@ wxNotebookXmlHandler::wxNotebookXmlHandler()
} }
wxObject *wxNotebookXmlHandler::DoCreateResource() wxObject *wxNotebookXmlHandler::DoCreateResource()
{ {
if (m_class == wxT("notebookpage")) if (m_class == wxT("notebookpage"))
{ {
wxXmlNode *n = GetParamNode(wxT("object")); wxXmlNode *n = GetParamNode(wxT("object"));
@@ -51,7 +51,7 @@ wxObject *wxNotebookXmlHandler::DoCreateResource()
if (n) if (n)
{ {
bool old_ins = m_isInside; bool old_ins = m_isInside;
m_isInside = FALSE; m_isInside = false;
wxObject *item = CreateResFromNode(n, m_notebook, NULL); wxObject *item = CreateResFromNode(n, m_notebook, NULL);
m_isInside = old_ins; m_isInside = old_ins;
wxWindow *wnd = wxDynamicCast(item, wxWindow); wxWindow *wnd = wxDynamicCast(item, wxWindow);
@@ -59,8 +59,8 @@ wxObject *wxNotebookXmlHandler::DoCreateResource()
if (wnd) if (wnd)
m_notebook->AddPage(wnd, GetText(wxT("label")), m_notebook->AddPage(wnd, GetText(wxT("label")),
GetBool(wxT("selected"), 0)); GetBool(wxT("selected"), 0));
else else
wxLogError(wxT("Error in resource.")); wxLogError(wxT("Error in resource."));
return wnd; return wnd;
} }
else else
@@ -69,12 +69,12 @@ wxObject *wxNotebookXmlHandler::DoCreateResource()
return NULL; return NULL;
} }
} }
else else
{ {
XRC_MAKE_INSTANCE(nb, wxNotebook) XRC_MAKE_INSTANCE(nb, wxNotebook)
nb->Create(m_parentAsWindow, nb->Create(m_parentAsWindow,
GetID(), GetID(),
GetPosition(), GetSize(), GetPosition(), GetSize(),
GetStyle(wxT("style")), GetStyle(wxT("style")),
@@ -83,12 +83,12 @@ wxObject *wxNotebookXmlHandler::DoCreateResource()
wxNotebook *old_par = m_notebook; wxNotebook *old_par = m_notebook;
m_notebook = nb; m_notebook = nb;
bool old_ins = m_isInside; bool old_ins = m_isInside;
m_isInside = TRUE; m_isInside = true;
CreateChildren(m_notebook, TRUE/*only this handler*/); CreateChildren(m_notebook, true/*only this handler*/);
m_isInside = old_ins; m_isInside = old_ins;
m_notebook = old_par; m_notebook = old_par;
if (GetBool(wxT("usenotebooksizer"), FALSE)) if (GetBool(wxT("usenotebooksizer"), false))
return new wxNotebookSizer(nb); return new wxNotebookSizer(nb);
else else
return nb; return nb;

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Vaclav Slavik // Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_panel.h" #pragma implementation "xh_panel.h"
#endif #endif
@@ -35,7 +35,7 @@ wxPanelXmlHandler::wxPanelXmlHandler() : wxXmlResourceHandler()
} }
wxObject *wxPanelXmlHandler::DoCreateResource() wxObject *wxPanelXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(panel, wxPanel) XRC_MAKE_INSTANCE(panel, wxPanel)
panel->Create(m_parentAsWindow, panel->Create(m_parentAsWindow,
@@ -46,7 +46,7 @@ wxObject *wxPanelXmlHandler::DoCreateResource()
SetupWindow(panel); SetupWindow(panel);
CreateChildren(panel); CreateChildren(panel);
return panel; return panel;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_radbt.h" #pragma implementation "xh_radbt.h"
#endif #endif
@@ -26,21 +26,21 @@
IMPLEMENT_DYNAMIC_CLASS(wxRadioButtonXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxRadioButtonXmlHandler, wxXmlResourceHandler)
wxRadioButtonXmlHandler::wxRadioButtonXmlHandler() wxRadioButtonXmlHandler::wxRadioButtonXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxRB_GROUP); XRC_ADD_STYLE(wxRB_GROUP);
AddWindowStyles(); AddWindowStyles();
} }
wxObject *wxRadioButtonXmlHandler::DoCreateResource() wxObject *wxRadioButtonXmlHandler::DoCreateResource()
{ {
/* BOBM - implementation note. /* BOBM - implementation note.
* once the wxBitmapRadioButton is implemented. * once the wxBitmapRadioButton is implemented.
* look for a bitmap property. If not null, * look for a bitmap property. If not null,
* make it a wxBitmapRadioButton instead of the * make it a wxBitmapRadioButton instead of the
* normal radio button. * normal radio button.
*/ */
XRC_MAKE_INSTANCE(control, wxRadioButton) XRC_MAKE_INSTANCE(control, wxRadioButton)
@@ -54,7 +54,7 @@ wxObject *wxRadioButtonXmlHandler::DoCreateResource()
control->SetValue(GetBool(wxT("value"), 0)); control->SetValue(GetBool(wxT("value"), 0));
SetupWindow(control); SetupWindow(control);
return control; return control;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_radbx.h" #pragma implementation "xh_radbx.h"
#endif #endif
@@ -27,8 +27,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxRadioBoxXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxRadioBoxXmlHandler, wxXmlResourceHandler)
wxRadioBoxXmlHandler::wxRadioBoxXmlHandler() wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
: wxXmlResourceHandler(), m_insideBox(FALSE) : wxXmlResourceHandler(), m_insideBox(false)
{ {
XRC_ADD_STYLE(wxRA_SPECIFY_COLS); XRC_ADD_STYLE(wxRA_SPECIFY_COLS);
XRC_ADD_STYLE(wxRA_HORIZONTAL); XRC_ADD_STYLE(wxRA_HORIZONTAL);
@@ -38,14 +38,14 @@ wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
} }
wxObject *wxRadioBoxXmlHandler::DoCreateResource() wxObject *wxRadioBoxXmlHandler::DoCreateResource()
{ {
if( m_class == wxT("wxRadioBox")) if( m_class == wxT("wxRadioBox"))
{ {
// find the selection // find the selection
long selection = GetLong( wxT("selection"), -1 ); long selection = GetLong( wxT("selection"), -1 );
// need to build the list of strings from children // need to build the list of strings from children
m_insideBox = TRUE; m_insideBox = true;
CreateChildrenPrivately( NULL, GetParamNode(wxT("content"))); CreateChildrenPrivately( NULL, GetParamNode(wxT("content")));
wxString *strings = (wxString *) NULL; wxString *strings = (wxString *) NULL;
if( strList.GetCount() > 0 ) if( strList.GetCount() > 0 )
@@ -76,7 +76,7 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource()
if (strings != NULL) if (strings != NULL)
delete[] strings; delete[] strings;
strList.Clear(); // dump the strings strList.Clear(); // dump the strings
return control; return control;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Brian Gavin // Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_scrol.h" #pragma implementation "xh_scrol.h"
#endif #endif
@@ -24,8 +24,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxScrollBarXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxScrollBarXmlHandler, wxXmlResourceHandler)
wxScrollBarXmlHandler::wxScrollBarXmlHandler() wxScrollBarXmlHandler::wxScrollBarXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxSB_HORIZONTAL); XRC_ADD_STYLE(wxSB_HORIZONTAL);
XRC_ADD_STYLE(wxSB_VERTICAL); XRC_ADD_STYLE(wxSB_VERTICAL);
@@ -33,7 +33,7 @@ wxScrollBarXmlHandler::wxScrollBarXmlHandler()
} }
wxObject *wxScrollBarXmlHandler::DoCreateResource() wxObject *wxScrollBarXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(control, wxScrollBar) XRC_MAKE_INSTANCE(control, wxScrollBar)
control->Create(m_parentAsWindow, control->Create(m_parentAsWindow,
@@ -43,14 +43,14 @@ wxObject *wxScrollBarXmlHandler::DoCreateResource()
wxDefaultValidator, wxDefaultValidator,
GetName()); GetName());
control->SetScrollbar(GetLong( wxT("value"), 0), control->SetScrollbar(GetLong( wxT("value"), 0),
GetLong( wxT("thumbsize"),1), GetLong( wxT("thumbsize"),1),
GetLong( wxT("range"), 10), GetLong( wxT("range"), 10),
GetLong( wxT("pagesize"),1)); GetLong( wxT("pagesize"),1));
SetupWindow(control); SetupWindow(control);
CreateChildren(control); CreateChildren(control);
return control; return control;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2002 Vaclav Slavik // Copyright: (c) 2002 Vaclav Slavik
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_scwin.h" #pragma implementation "xh_scwin.h"
#endif #endif
@@ -24,8 +24,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindowXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindowXmlHandler, wxXmlResourceHandler)
wxScrolledWindowXmlHandler::wxScrolledWindowXmlHandler() wxScrolledWindowXmlHandler::wxScrolledWindowXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxHSCROLL); XRC_ADD_STYLE(wxHSCROLL);
XRC_ADD_STYLE(wxVSCROLL); XRC_ADD_STYLE(wxVSCROLL);
@@ -33,7 +33,7 @@ wxScrolledWindowXmlHandler::wxScrolledWindowXmlHandler()
} }
wxObject *wxScrolledWindowXmlHandler::DoCreateResource() wxObject *wxScrolledWindowXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(control, wxScrolledWindow) XRC_MAKE_INSTANCE(control, wxScrolledWindow)
control->Create(m_parentAsWindow, control->Create(m_parentAsWindow,
@@ -44,7 +44,7 @@ wxObject *wxScrolledWindowXmlHandler::DoCreateResource()
SetupWindow(control); SetupWindow(control);
CreateChildren(control); CreateChildren(control);
return control; return control;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Vaclav Slavik // Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_sizer.h" #pragma implementation "xh_sizer.h"
#endif #endif
@@ -32,12 +32,12 @@
IMPLEMENT_DYNAMIC_CLASS(wxSizerXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxSizerXmlHandler, wxXmlResourceHandler)
wxSizerXmlHandler::wxSizerXmlHandler() wxSizerXmlHandler::wxSizerXmlHandler()
: wxXmlResourceHandler(), : wxXmlResourceHandler(),
m_isInside(FALSE), m_isInside(false),
m_isGBS(FALSE), m_isGBS(false),
m_parentSizer(NULL) m_parentSizer(NULL)
{ {
XRC_ADD_STYLE(wxHORIZONTAL); XRC_ADD_STYLE(wxHORIZONTAL);
@@ -69,7 +69,7 @@ wxSizerXmlHandler::wxSizerXmlHandler()
XRC_ADD_STYLE(wxALIGN_CENTRE_HORIZONTAL); XRC_ADD_STYLE(wxALIGN_CENTRE_HORIZONTAL);
XRC_ADD_STYLE(wxALIGN_CENTER_VERTICAL); XRC_ADD_STYLE(wxALIGN_CENTER_VERTICAL);
XRC_ADD_STYLE(wxALIGN_CENTRE_VERTICAL); XRC_ADD_STYLE(wxALIGN_CENTRE_VERTICAL);
XRC_ADD_STYLE(wxADJUST_MINSIZE); XRC_ADD_STYLE(wxADJUST_MINSIZE);
XRC_ADD_STYLE(wxFIXED_MINSIZE); XRC_ADD_STYLE(wxFIXED_MINSIZE);
} }
@@ -80,16 +80,16 @@ bool wxSizerXmlHandler::CanHandle(wxXmlNode *node)
{ {
return ( (!m_isInside && IsSizerNode(node)) || return ( (!m_isInside && IsSizerNode(node)) ||
(m_isInside && IsOfClass(node, wxT("sizeritem"))) || (m_isInside && IsOfClass(node, wxT("sizeritem"))) ||
(m_isInside && IsOfClass(node, wxT("spacer"))) (m_isInside && IsOfClass(node, wxT("spacer")))
); );
} }
wxObject* wxSizerXmlHandler::DoCreateResource() wxObject* wxSizerXmlHandler::DoCreateResource()
{ {
if (m_class == wxT("sizeritem")) if (m_class == wxT("sizeritem"))
return Handle_sizeritem(); return Handle_sizeritem();
else if (m_class == wxT("spacer")) else if (m_class == wxT("spacer"))
return Handle_spacer(); return Handle_spacer();
@@ -122,13 +122,13 @@ wxObject* wxSizerXmlHandler::Handle_sizeritem()
{ {
// create a sizer item for it // create a sizer item for it
wxSizerItem* sitem = MakeSizerItem(); wxSizerItem* sitem = MakeSizerItem();
// now fetch the item to be managed // now fetch the item to be managed
bool old_gbs = m_isGBS; bool old_gbs = m_isGBS;
bool old_ins = m_isInside; bool old_ins = m_isInside;
wxSizer *old_par = m_parentSizer; wxSizer *old_par = m_parentSizer;
m_isInside = FALSE; m_isInside = false;
if (!IsSizerNode(n)) m_parentSizer = NULL; if (!IsSizerNode(n)) m_parentSizer = NULL;
wxObject *item = CreateResFromNode(n, m_parent, NULL); wxObject *item = CreateResFromNode(n, m_parent, NULL);
m_isInside = old_ins; m_isInside = old_ins;
m_parentSizer = old_par; m_parentSizer = old_par;
@@ -137,12 +137,12 @@ wxObject* wxSizerXmlHandler::Handle_sizeritem()
// and figure out what type it is // and figure out what type it is
wxSizer *sizer = wxDynamicCast(item, wxSizer); wxSizer *sizer = wxDynamicCast(item, wxSizer);
wxWindow *wnd = wxDynamicCast(item, wxWindow); wxWindow *wnd = wxDynamicCast(item, wxWindow);
if (sizer) if (sizer)
sitem->SetSizer(sizer); sitem->SetSizer(sizer);
else if (wnd) else if (wnd)
sitem->SetWindow(wnd); sitem->SetWindow(wnd);
else else
wxLogError(wxT("Error in resource.")); wxLogError(wxT("Error in resource."));
// finally, set other wxSizerItem attributes // finally, set other wxSizerItem attributes
@@ -166,7 +166,7 @@ wxObject* wxSizerXmlHandler::Handle_spacer()
wxSizerItem* sitem = MakeSizerItem(); wxSizerItem* sitem = MakeSizerItem();
SetSizerItemAttributes(sitem); SetSizerItemAttributes(sitem);
sitem->SetSpacer(GetSize()); sitem->SetSpacer(GetSize());
AddSizerItem(sitem); AddSizerItem(sitem);
return NULL; return NULL;
} }
@@ -174,7 +174,7 @@ wxObject* wxSizerXmlHandler::Handle_spacer()
wxObject* wxSizerXmlHandler::Handle_sizer() wxObject* wxSizerXmlHandler::Handle_sizer()
{ {
wxSizer *sizer = NULL; wxSizer *sizer = NULL;
wxXmlNode *parentNode = m_node->GetParent(); wxXmlNode *parentNode = m_node->GetParent();
wxCHECK_MSG(m_parentSizer != NULL || wxCHECK_MSG(m_parentSizer != NULL ||
@@ -191,17 +191,17 @@ wxObject* wxSizerXmlHandler::Handle_sizer()
else if (m_class == wxT("wxStaticBoxSizer")) else if (m_class == wxT("wxStaticBoxSizer"))
sizer = Handle_wxStaticBoxSizer(); sizer = Handle_wxStaticBoxSizer();
else if (m_class == wxT("wxGridSizer")) else if (m_class == wxT("wxGridSizer"))
sizer = Handle_wxGridSizer(); sizer = Handle_wxGridSizer();
else if (m_class == wxT("wxFlexGridSizer")) else if (m_class == wxT("wxFlexGridSizer"))
sizer = Handle_wxFlexGridSizer(); sizer = Handle_wxFlexGridSizer();
else if (m_class == wxT("wxGridBagSizer")) else if (m_class == wxT("wxGridBagSizer"))
sizer = Handle_wxGridBagSizer(); sizer = Handle_wxGridBagSizer();
wxSize minsize = GetSize(wxT("minsize")); wxSize minsize = GetSize(wxT("minsize"));
if (!(minsize == wxDefaultSize)) if (!(minsize == wxDefaultSize))
sizer->SetMinSize(minsize); sizer->SetMinSize(minsize);
@@ -212,10 +212,10 @@ wxObject* wxSizerXmlHandler::Handle_sizer()
// set new state // set new state
m_parentSizer = sizer; m_parentSizer = sizer;
m_isInside = TRUE; m_isInside = true;
m_isGBS = (m_class == wxT("wxGridBagSizer")); m_isGBS = (m_class == wxT("wxGridBagSizer"));
CreateChildren(m_parent, TRUE/*only this handler*/); CreateChildren(m_parent, true/*only this handler*/);
// restore state // restore state
m_isInside = old_ins; m_isInside = old_ins;
@@ -223,7 +223,7 @@ wxObject* wxSizerXmlHandler::Handle_sizer()
if (m_parentSizer == NULL) // setup window: if (m_parentSizer == NULL) // setup window:
{ {
m_parentAsWindow->SetAutoLayout(TRUE); m_parentAsWindow->SetAutoLayout(true);
m_parentAsWindow->SetSizer(sizer); m_parentAsWindow->SetSizer(sizer);
wxXmlNode *nd = m_node; wxXmlNode *nd = m_node;
@@ -235,7 +235,7 @@ wxObject* wxSizerXmlHandler::Handle_sizer()
if (m_parentAsWindow->GetWindowStyle() & (wxRESIZE_BOX | wxRESIZE_BORDER)) if (m_parentAsWindow->GetWindowStyle() & (wxRESIZE_BOX | wxRESIZE_BORDER))
sizer->SetSizeHints(m_parentAsWindow); sizer->SetSizeHints(m_parentAsWindow);
} }
return sizer; return sizer;
} }
@@ -243,8 +243,8 @@ wxObject* wxSizerXmlHandler::Handle_sizer()
wxSizer* wxSizerXmlHandler::Handle_wxBoxSizer() wxSizer* wxSizerXmlHandler::Handle_wxBoxSizer()
{ {
return new wxBoxSizer(GetStyle(wxT("orient"), wxHORIZONTAL)); return new wxBoxSizer(GetStyle(wxT("orient"), wxHORIZONTAL));
} }
wxSizer* wxSizerXmlHandler::Handle_wxStaticBoxSizer() wxSizer* wxSizerXmlHandler::Handle_wxStaticBoxSizer()
{ {
return new wxStaticBoxSizer( return new wxStaticBoxSizer(
@@ -256,7 +256,7 @@ wxSizer* wxSizerXmlHandler::Handle_wxStaticBoxSizer()
GetName()), GetName()),
GetStyle(wxT("orient"), wxHORIZONTAL)); GetStyle(wxT("orient"), wxHORIZONTAL));
} }
wxSizer* wxSizerXmlHandler::Handle_wxGridSizer() wxSizer* wxSizerXmlHandler::Handle_wxGridSizer()
{ {
return new wxGridSizer(GetLong(wxT("rows")), GetLong(wxT("cols")), return new wxGridSizer(GetLong(wxT("rows")), GetLong(wxT("cols")),
@@ -266,7 +266,7 @@ wxSizer* wxSizerXmlHandler::Handle_wxGridSizer()
wxSizer* wxSizerXmlHandler::Handle_wxFlexGridSizer() wxSizer* wxSizerXmlHandler::Handle_wxFlexGridSizer()
{ {
wxFlexGridSizer *sizer = wxFlexGridSizer *sizer =
new wxFlexGridSizer(GetLong(wxT("rows")), GetLong(wxT("cols")), new wxFlexGridSizer(GetLong(wxT("rows")), GetLong(wxT("cols")),
GetDimension(wxT("vgap")), GetDimension(wxT("hgap"))); GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
SetGrowables(sizer, wxT("growablerows"), true); SetGrowables(sizer, wxT("growablerows"), true);
@@ -277,7 +277,7 @@ wxSizer* wxSizerXmlHandler::Handle_wxFlexGridSizer()
wxSizer* wxSizerXmlHandler::Handle_wxGridBagSizer() wxSizer* wxSizerXmlHandler::Handle_wxGridBagSizer()
{ {
wxGridBagSizer *sizer = wxGridBagSizer *sizer =
new wxGridBagSizer(GetDimension(wxT("vgap")), GetDimension(wxT("hgap"))); new wxGridBagSizer(GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
SetGrowables(sizer, wxT("growablerows"), true); SetGrowables(sizer, wxT("growablerows"), true);
SetGrowables(sizer, wxT("growablecols"), false); SetGrowables(sizer, wxT("growablecols"), false);
@@ -345,13 +345,13 @@ void wxSizerXmlHandler::SetSizerItemAttributes(wxSizerItem* sitem)
sz = GetSize(wxT("ratio")); sz = GetSize(wxT("ratio"));
if (!(sz == wxDefaultSize)) if (!(sz == wxDefaultSize))
sitem->SetRatio(sz); sitem->SetRatio(sz);
if (m_isGBS) if (m_isGBS)
{ {
wxGBSizerItem* gbsitem = (wxGBSizerItem*)sitem; wxGBSizerItem* gbsitem = (wxGBSizerItem*)sitem;
gbsitem->SetPos(GetGBPos(wxT("cellpos"))); gbsitem->SetPos(GetGBPos(wxT("cellpos")));
gbsitem->SetSpan(GetGBSpan(wxT("cellspan"))); gbsitem->SetSpan(GetGBSpan(wxT("cellspan")));
} }
} }
void wxSizerXmlHandler::AddSizerItem(wxSizerItem* sitem) void wxSizerXmlHandler::AddSizerItem(wxSizerItem* sitem)
@@ -361,7 +361,7 @@ void wxSizerXmlHandler::AddSizerItem(wxSizerItem* sitem)
else else
m_parentSizer->Add(sitem); m_parentSizer->Add(sitem);
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_slidr.h" #pragma implementation "xh_slidr.h"
#endif #endif
@@ -26,8 +26,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxSliderXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxSliderXmlHandler, wxXmlResourceHandler)
wxSliderXmlHandler::wxSliderXmlHandler() wxSliderXmlHandler::wxSliderXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxSL_HORIZONTAL); XRC_ADD_STYLE(wxSL_HORIZONTAL);
XRC_ADD_STYLE(wxSL_VERTICAL); XRC_ADD_STYLE(wxSL_VERTICAL);
@@ -43,12 +43,12 @@ wxSliderXmlHandler::wxSliderXmlHandler()
} }
wxObject *wxSliderXmlHandler::DoCreateResource() wxObject *wxSliderXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(control, wxSlider) XRC_MAKE_INSTANCE(control, wxSlider)
control->Create(m_parentAsWindow, control->Create(m_parentAsWindow,
GetID(), GetID(),
GetLong(wxT("value"), wxSL_DEFAULT_VALUE), GetLong(wxT("value"), wxSL_DEFAULT_VALUE),
GetLong(wxT("min"), wxSL_DEFAULT_MIN), GetLong(wxT("min"), wxSL_DEFAULT_MIN),
GetLong(wxT("max"), wxSL_DEFAULT_MAX), GetLong(wxT("max"), wxSL_DEFAULT_MAX),
GetPosition(), GetSize(), GetPosition(), GetSize(),
@@ -82,7 +82,7 @@ wxObject *wxSliderXmlHandler::DoCreateResource()
} }
SetupWindow(control); SetupWindow(control);
return control; return control;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_spin.h" #pragma implementation "xh_spin.h"
#endif #endif
@@ -26,8 +26,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxSpinButtonXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxSpinButtonXmlHandler, wxXmlResourceHandler)
wxSpinButtonXmlHandler::wxSpinButtonXmlHandler() wxSpinButtonXmlHandler::wxSpinButtonXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxSP_HORIZONTAL); XRC_ADD_STYLE(wxSP_HORIZONTAL);
XRC_ADD_STYLE(wxSP_VERTICAL); XRC_ADD_STYLE(wxSP_VERTICAL);
@@ -37,7 +37,7 @@ wxSpinButtonXmlHandler::wxSpinButtonXmlHandler()
} }
wxObject *wxSpinButtonXmlHandler::DoCreateResource() wxObject *wxSpinButtonXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(control, wxSpinButton) XRC_MAKE_INSTANCE(control, wxSpinButton)
control->Create(m_parentAsWindow, control->Create(m_parentAsWindow,
@@ -50,7 +50,7 @@ wxObject *wxSpinButtonXmlHandler::DoCreateResource()
control->SetRange(GetLong( wxT("min"), wxSP_DEFAULT_MIN), control->SetRange(GetLong( wxT("min"), wxSP_DEFAULT_MIN),
GetLong(wxT("max"), wxSP_DEFAULT_MAX)); GetLong(wxT("max"), wxSP_DEFAULT_MAX));
SetupWindow(control); SetupWindow(control);
return control; return control;
} }
@@ -65,8 +65,8 @@ bool wxSpinButtonXmlHandler::CanHandle(wxXmlNode *node)
IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrlXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrlXmlHandler, wxXmlResourceHandler)
wxSpinCtrlXmlHandler::wxSpinCtrlXmlHandler() wxSpinCtrlXmlHandler::wxSpinCtrlXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxSP_HORIZONTAL); XRC_ADD_STYLE(wxSP_HORIZONTAL);
XRC_ADD_STYLE(wxSP_VERTICAL); XRC_ADD_STYLE(wxSP_VERTICAL);
@@ -75,9 +75,9 @@ wxSpinCtrlXmlHandler::wxSpinCtrlXmlHandler()
} }
wxObject *wxSpinCtrlXmlHandler::DoCreateResource() wxObject *wxSpinCtrlXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(control, wxSpinCtrl) XRC_MAKE_INSTANCE(control, wxSpinCtrl)
control->Create(m_parentAsWindow, control->Create(m_parentAsWindow,
GetID(), GetID(),
GetText(wxT("value")), GetText(wxT("value")),
@@ -89,7 +89,7 @@ wxObject *wxSpinCtrlXmlHandler::DoCreateResource()
GetName()); GetName());
SetupWindow(control); SetupWindow(control);
return control; return control;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2003 panga@freemail.hu, Vaclav Slavik // Copyright: (c) 2003 panga@freemail.hu, Vaclav Slavik
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_split.h" #pragma implementation "xh_split.h"
#endif #endif
@@ -60,7 +60,7 @@ wxObject *wxSplitterWindowXmlHandler::DoCreateResource()
wxXmlNode *n = m_node->GetChildren(); wxXmlNode *n = m_node->GetChildren();
while (n) while (n)
{ {
if ((n->GetType() == wxXML_ELEMENT_NODE) && if ((n->GetType() == wxXML_ELEMENT_NODE) &&
(n->GetName() == wxT("object") || (n->GetName() == wxT("object") ||
n->GetName() == wxT("object_ref"))) n->GetName() == wxT("object_ref")))
{ {
@@ -74,7 +74,7 @@ wxObject *wxSplitterWindowXmlHandler::DoCreateResource()
{ {
win2 = win; win2 = win;
break; break;
} }
} }
n = n->GetNext(); n = n->GetNext();
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Vaclav Slavik // Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_stbmp.h" #pragma implementation "xh_stbmp.h"
#endif #endif
@@ -24,14 +24,14 @@
IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmapXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmapXmlHandler, wxXmlResourceHandler)
wxStaticBitmapXmlHandler::wxStaticBitmapXmlHandler() wxStaticBitmapXmlHandler::wxStaticBitmapXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
AddWindowStyles(); AddWindowStyles();
} }
wxObject *wxStaticBitmapXmlHandler::DoCreateResource() wxObject *wxStaticBitmapXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(bmp, wxStaticBitmap) XRC_MAKE_INSTANCE(bmp, wxStaticBitmap)
bmp->Create(m_parentAsWindow, bmp->Create(m_parentAsWindow,
@@ -42,7 +42,7 @@ wxObject *wxStaticBitmapXmlHandler::DoCreateResource()
GetName()); GetName());
SetupWindow(bmp); SetupWindow(bmp);
return bmp; return bmp;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Brian Gavin // Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_stbox.h" #pragma implementation "xh_stbox.h"
#endif #endif
@@ -24,14 +24,14 @@
IMPLEMENT_DYNAMIC_CLASS(wxStaticBoxXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxStaticBoxXmlHandler, wxXmlResourceHandler)
wxStaticBoxXmlHandler::wxStaticBoxXmlHandler() wxStaticBoxXmlHandler::wxStaticBoxXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
AddWindowStyles(); AddWindowStyles();
} }
wxObject *wxStaticBoxXmlHandler::DoCreateResource() wxObject *wxStaticBoxXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(box, wxStaticBox) XRC_MAKE_INSTANCE(box, wxStaticBox)
box->Create(m_parentAsWindow, box->Create(m_parentAsWindow,
@@ -42,7 +42,7 @@ wxObject *wxStaticBoxXmlHandler::DoCreateResource()
GetName()); GetName());
SetupWindow(box); SetupWindow(box);
return box; return box;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Brian Gavin // Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_stlin.h" #pragma implementation "xh_stlin.h"
#endif #endif
@@ -26,8 +26,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxStaticLineXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxStaticLineXmlHandler, wxXmlResourceHandler)
wxStaticLineXmlHandler::wxStaticLineXmlHandler() wxStaticLineXmlHandler::wxStaticLineXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxLI_HORIZONTAL); XRC_ADD_STYLE(wxLI_HORIZONTAL);
XRC_ADD_STYLE(wxLI_VERTICAL); XRC_ADD_STYLE(wxLI_VERTICAL);
@@ -35,7 +35,7 @@ wxStaticLineXmlHandler::wxStaticLineXmlHandler()
} }
wxObject *wxStaticLineXmlHandler::DoCreateResource() wxObject *wxStaticLineXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(line, wxStaticLine) XRC_MAKE_INSTANCE(line, wxStaticLine)
line->Create(m_parentAsWindow, line->Create(m_parentAsWindow,
@@ -45,7 +45,7 @@ wxObject *wxStaticLineXmlHandler::DoCreateResource()
GetName()); GetName());
SetupWindow(line); SetupWindow(line);
return line; return line;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_sttxt.h" #pragma implementation "xh_sttxt.h"
#endif #endif
@@ -24,8 +24,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxStaticTextXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxStaticTextXmlHandler, wxXmlResourceHandler)
wxStaticTextXmlHandler::wxStaticTextXmlHandler() wxStaticTextXmlHandler::wxStaticTextXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxST_NO_AUTORESIZE); XRC_ADD_STYLE(wxST_NO_AUTORESIZE);
XRC_ADD_STYLE(wxALIGN_LEFT); XRC_ADD_STYLE(wxALIGN_LEFT);
@@ -35,7 +35,7 @@ wxStaticTextXmlHandler::wxStaticTextXmlHandler()
} }
wxObject *wxStaticTextXmlHandler::DoCreateResource() wxObject *wxStaticTextXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(text, wxStaticText) XRC_MAKE_INSTANCE(text, wxStaticText)
text->Create(m_parentAsWindow, text->Create(m_parentAsWindow,
@@ -46,7 +46,7 @@ wxObject *wxStaticTextXmlHandler::DoCreateResource()
GetName()); GetName());
SetupWindow(text); SetupWindow(text);
return text; return text;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Aleksandras Gluchovas // Copyright: (c) 2000 Aleksandras Gluchovas
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_text.h" #pragma implementation "xh_text.h"
#endif #endif
@@ -24,7 +24,7 @@
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrlXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxTextCtrlXmlHandler, wxXmlResourceHandler)
wxTextCtrlXmlHandler::wxTextCtrlXmlHandler() : wxXmlResourceHandler() wxTextCtrlXmlHandler::wxTextCtrlXmlHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxTE_NO_VSCROLL); XRC_ADD_STYLE(wxTE_NO_VSCROLL);
XRC_ADD_STYLE(wxTE_AUTO_SCROLL); XRC_ADD_STYLE(wxTE_AUTO_SCROLL);
@@ -48,7 +48,7 @@ wxTextCtrlXmlHandler::wxTextCtrlXmlHandler() : wxXmlResourceHandler()
} }
wxObject *wxTextCtrlXmlHandler::DoCreateResource() wxObject *wxTextCtrlXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(text, wxTextCtrl) XRC_MAKE_INSTANCE(text, wxTextCtrl)
text->Create(m_parentAsWindow, text->Create(m_parentAsWindow,
@@ -60,7 +60,7 @@ wxObject *wxTextCtrlXmlHandler::DoCreateResource()
GetName()); GetName());
SetupWindow(text); SetupWindow(text);
return text; return text;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Vaclav Slavik // Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_toolb.h" #pragma implementation "xh_toolb.h"
#endif #endif
@@ -27,8 +27,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxToolBarXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxToolBarXmlHandler, wxXmlResourceHandler)
wxToolBarXmlHandler::wxToolBarXmlHandler() wxToolBarXmlHandler::wxToolBarXmlHandler()
: wxXmlResourceHandler(), m_isInside(FALSE), m_toolbar(NULL) : wxXmlResourceHandler(), m_isInside(false), m_toolbar(NULL)
{ {
XRC_ADD_STYLE(wxTB_FLAT); XRC_ADD_STYLE(wxTB_FLAT);
XRC_ADD_STYLE(wxTB_DOCKABLE); XRC_ADD_STYLE(wxTB_DOCKABLE);
@@ -43,11 +43,11 @@ wxToolBarXmlHandler::wxToolBarXmlHandler()
} }
wxObject *wxToolBarXmlHandler::DoCreateResource() wxObject *wxToolBarXmlHandler::DoCreateResource()
{ {
if (m_class == wxT("tool")) if (m_class == wxT("tool"))
{ {
wxCHECK_MSG(m_toolbar, NULL, wxT("Incorrect syntax of XRC resource: tool not within a toolbar!")); wxCHECK_MSG(m_toolbar, NULL, wxT("Incorrect syntax of XRC resource: tool not within a toolbar!"));
if (GetPosition() != wxDefaultPosition) if (GetPosition() != wxDefaultPosition)
{ {
m_toolbar->AddTool(GetID(), m_toolbar->AddTool(GetID(),
@@ -61,7 +61,7 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
GetText(wxT("longhelp"))); GetText(wxT("longhelp")));
} }
else else
{ {
wxItemKind kind = wxITEM_NORMAL; wxItemKind kind = wxITEM_NORMAL;
if (GetBool(wxT("radio"))) if (GetBool(wxT("radio")))
kind = wxITEM_RADIO; kind = wxITEM_RADIO;
@@ -70,7 +70,7 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
wxASSERT_MSG( kind == wxITEM_NORMAL, wxASSERT_MSG( kind == wxITEM_NORMAL,
_T("can't have both toggleable and radion button at once") ); _T("can't have both toggleable and radion button at once") );
kind = wxITEM_CHECK; kind = wxITEM_CHECK;
} }
m_toolbar->AddTool(GetID(), m_toolbar->AddTool(GetID(),
GetText(wxT("label")), GetText(wxT("label")),
GetBitmap(wxT("bitmap"), wxART_TOOLBAR), GetBitmap(wxT("bitmap"), wxART_TOOLBAR),
@@ -81,14 +81,14 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
} }
return m_toolbar; // must return non-NULL return m_toolbar; // must return non-NULL
} }
else if (m_class == wxT("separator")) else if (m_class == wxT("separator"))
{ {
wxCHECK_MSG(m_toolbar, NULL, wxT("Incorrect syntax of XRC resource: separator not within a toolbar!")); wxCHECK_MSG(m_toolbar, NULL, wxT("Incorrect syntax of XRC resource: separator not within a toolbar!"));
m_toolbar->AddSeparator(); m_toolbar->AddSeparator();
return m_toolbar; // must return non-NULL return m_toolbar; // must return non-NULL
} }
else /*<object class="wxToolBar">*/ else /*<object class="wxToolBar">*/
{ {
int style = GetStyle(wxT("style"), wxNO_BORDER | wxTB_HORIZONTAL); int style = GetStyle(wxT("style"), wxNO_BORDER | wxTB_HORIZONTAL);
@@ -97,7 +97,7 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
#endif #endif
XRC_MAKE_INSTANCE(toolbar, wxToolBar) XRC_MAKE_INSTANCE(toolbar, wxToolBar)
toolbar->Create(m_parentAsWindow, toolbar->Create(m_parentAsWindow,
GetID(), GetID(),
GetPosition(), GetPosition(),
@@ -124,14 +124,14 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
if (children_node == NULL) return toolbar; if (children_node == NULL) return toolbar;
m_isInside = TRUE; m_isInside = true;
m_toolbar = toolbar; m_toolbar = toolbar;
wxXmlNode *n = children_node; wxXmlNode *n = children_node;
while (n) while (n)
{ {
if ((n->GetType() == wxXML_ELEMENT_NODE) && if ((n->GetType() == wxXML_ELEMENT_NODE) &&
(n->GetName() == wxT("object") || n->GetName() == wxT("object_ref"))) (n->GetName() == wxT("object") || n->GetName() == wxT("object_ref")))
{ {
wxObject *created = CreateResFromNode(n, toolbar, NULL); wxObject *created = CreateResFromNode(n, toolbar, NULL);
@@ -144,7 +144,7 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
n = n->GetNext(); n = n->GetNext();
} }
m_isInside = FALSE; m_isInside = false;
m_toolbar = NULL; m_toolbar = NULL;
toolbar->Realize(); toolbar->Realize();
@@ -163,7 +163,7 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
bool wxToolBarXmlHandler::CanHandle(wxXmlNode *node) bool wxToolBarXmlHandler::CanHandle(wxXmlNode *node)
{ {
return ((!m_isInside && IsOfClass(node, wxT("wxToolBar"))) || return ((!m_isInside && IsOfClass(node, wxT("wxToolBar"))) ||
(m_isInside && IsOfClass(node, wxT("tool"))) || (m_isInside && IsOfClass(node, wxT("tool"))) ||
(m_isInside && IsOfClass(node, wxT("separator")))); (m_isInside && IsOfClass(node, wxT("separator"))));
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Brian Gavin // Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_tree.h" #pragma implementation "xh_tree.h"
#endif #endif
@@ -24,8 +24,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrlXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrlXmlHandler, wxXmlResourceHandler)
wxTreeCtrlXmlHandler::wxTreeCtrlXmlHandler() wxTreeCtrlXmlHandler::wxTreeCtrlXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxTR_EDIT_LABELS); XRC_ADD_STYLE(wxTR_EDIT_LABELS);
XRC_ADD_STYLE(wxTR_NO_BUTTONS); XRC_ADD_STYLE(wxTR_NO_BUTTONS);
@@ -45,7 +45,7 @@ wxTreeCtrlXmlHandler::wxTreeCtrlXmlHandler()
} }
wxObject *wxTreeCtrlXmlHandler::DoCreateResource() wxObject *wxTreeCtrlXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(tree, wxTreeCtrl) XRC_MAKE_INSTANCE(tree, wxTreeCtrl)
tree->Create(m_parentAsWindow, tree->Create(m_parentAsWindow,
@@ -56,7 +56,7 @@ wxObject *wxTreeCtrlXmlHandler::DoCreateResource()
GetName()); GetName());
SetupWindow(tree); SetupWindow(tree);
return tree; return tree;
} }

View File

@@ -31,7 +31,7 @@ class wxUnknownControlContainer : public wxPanel
public: public:
wxUnknownControlContainer(wxWindow *parent, wxUnknownControlContainer(wxWindow *parent,
const wxString& controlName, const wxString& controlName,
wxWindowID id = -1, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = 0) long style = 0)
@@ -95,7 +95,7 @@ wxObject *wxUnknownWidgetXmlHandler::DoCreateResource()
wxPanel *panel = wxPanel *panel =
new wxUnknownControlContainer(m_parentAsWindow, new wxUnknownControlContainer(m_parentAsWindow,
GetName(), -1, GetName(), wxID_ANY,
GetPosition(), GetSize(), GetPosition(), GetSize(),
GetStyle(wxT("style"))); GetStyle(wxT("style")));
SetupWindow(panel); SetupWindow(panel);

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Vaclav Slavik // Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_wizrd.h" #pragma implementation "xh_wizrd.h"
#endif #endif
@@ -35,7 +35,7 @@ wxWizardXmlHandler::wxWizardXmlHandler() : wxXmlResourceHandler()
} }
wxObject *wxWizardXmlHandler::DoCreateResource() wxObject *wxWizardXmlHandler::DoCreateResource()
{ {
if (m_class == wxT("wxWizard")) if (m_class == wxT("wxWizard"))
{ {
XRC_MAKE_INSTANCE(wiz, wxWizard) XRC_MAKE_INSTANCE(wiz, wxWizard)
@@ -92,7 +92,7 @@ wxObject *wxWizardXmlHandler::DoCreateResource()
bool wxWizardXmlHandler::CanHandle(wxXmlNode *node) bool wxWizardXmlHandler::CanHandle(wxXmlNode *node)
{ {
return IsOfClass(node, wxT("wxWizard")) || return IsOfClass(node, wxT("wxWizard")) ||
(m_wizard != NULL && (m_wizard != NULL &&
(IsOfClass(node, wxT("wxWizardPage")) || (IsOfClass(node, wxT("wxWizardPage")) ||
IsOfClass(node, wxT("wxWizardPageSimple"))) IsOfClass(node, wxT("wxWizardPageSimple")))

View File

@@ -82,7 +82,7 @@ bool wxXmlResource::Load(const wxString& filemask)
wxString fnd; wxString fnd;
wxXmlResourceDataRecord *drec; wxXmlResourceDataRecord *drec;
bool iswild = wxIsWild(filemask); bool iswild = wxIsWild(filemask);
bool rt = TRUE; bool rt = true;
#if wxUSE_FILESYSTEM #if wxUSE_FILESYSTEM
wxFileSystem fsys; wxFileSystem fsys;
@@ -260,7 +260,7 @@ bool wxXmlResource::AttachUnknownControl(const wxString& name,
if (!container) if (!container)
{ {
wxLogError(_("Cannot find container for unknown control '%s'."), name.c_str()); wxLogError(_("Cannot find container for unknown control '%s'."), name.c_str());
return FALSE; return false;
} }
return control->Reparent(container); return control->Reparent(container);
} }
@@ -274,9 +274,9 @@ static void ProcessPlatformProperty(wxXmlNode *node)
wxXmlNode *c = node->GetChildren(); wxXmlNode *c = node->GetChildren();
while (c) while (c)
{ {
isok = FALSE; isok = false;
if (!c->GetPropVal(wxT("platform"), &s)) if (!c->GetPropVal(wxT("platform"), &s))
isok = TRUE; isok = true;
else else
{ {
wxStringTokenizer tkn(s, wxT(" |")); wxStringTokenizer tkn(s, wxT(" |"));
@@ -366,8 +366,8 @@ bool wxXmlResource::UpdateResources()
# if wxUSE_FILESYSTEM # if wxUSE_FILESYSTEM
file = fsys.OpenFile(m_data[i].File); file = fsys.OpenFile(m_data[i].File);
if (file) if (file)
stream = file->GetStream(); stream = file->GetStream();
# else # else
stream = new wxFileInputStream(m_data[i].File); stream = new wxFileInputStream(m_data[i].File);
# endif # endif
@@ -391,7 +391,7 @@ bool wxXmlResource::UpdateResources()
rt = false; rt = false;
} }
else else
{ {
long version; long version;
int v1, v2, v3, v4; int v1, v2, v3, v4;
wxString verstr = m_data[i].Doc->GetRoot()->GetPropVal( wxString verstr = m_data[i].Doc->GetRoot()->GetPropVal(
@@ -411,17 +411,17 @@ bool wxXmlResource::UpdateResources()
ProcessPlatformProperty(m_data[i].Doc->GetRoot()); ProcessPlatformProperty(m_data[i].Doc->GetRoot());
#if wxUSE_FILESYSTEM #if wxUSE_FILESYSTEM
m_data[i].Time = file->GetModificationTime(); m_data[i].Time = file->GetModificationTime();
#else #else
m_data[i].Time = wxDateTime(wxFileModificationTime(m_data[i].File)); m_data[i].Time = wxDateTime(wxFileModificationTime(m_data[i].File));
#endif #endif
} }
# if wxUSE_FILESYSTEM # if wxUSE_FILESYSTEM
wxDELETE(file); wxDELETE(file);
wxUnusedVar(file); wxUnusedVar(file);
# else # else
wxDELETE(stream); wxDELETE(stream);
# endif # endif
} }
} }
@@ -456,7 +456,7 @@ wxXmlNode *wxXmlResource::DoFindResource(wxXmlNode *parent,
wxString refName = node->GetPropVal(wxT("ref"), wxEmptyString); wxString refName = node->GetPropVal(wxT("ref"), wxEmptyString);
if (refName.empty()) if (refName.empty())
continue; continue;
wxXmlNode* refNode = FindResource(refName, wxEmptyString, TRUE); wxXmlNode* refNode = FindResource(refName, wxEmptyString, true);
if (refNode && if (refNode &&
refNode->GetPropVal(wxT("class"), wxEmptyString) == classname) refNode->GetPropVal(wxT("class"), wxEmptyString) == classname)
{ {
@@ -473,7 +473,7 @@ wxXmlNode *wxXmlResource::DoFindResource(wxXmlNode *parent,
(node->GetName() == wxT("object") || (node->GetName() == wxT("object") ||
node->GetName() == wxT("object_ref")) ) node->GetName() == wxT("object_ref")) )
{ {
wxXmlNode* found = DoFindResource(node, name, classname, TRUE); wxXmlNode* found = DoFindResource(node, name, classname, true);
if ( found ) if ( found )
return found; return found;
} }
@@ -565,7 +565,7 @@ wxObject *wxXmlResource::CreateResFromNode(wxXmlNode *node, wxObject *parent,
if ( node->GetName() == wxT("object_ref") ) if ( node->GetName() == wxT("object_ref") )
{ {
wxString refName = node->GetPropVal(wxT("ref"), wxEmptyString); wxString refName = node->GetPropVal(wxT("ref"), wxEmptyString);
wxXmlNode* refNode = FindResource(refName, wxEmptyString, TRUE); wxXmlNode* refNode = FindResource(refName, wxEmptyString, true);
if ( !refNode ) if ( !refNode )
{ {
@@ -1090,7 +1090,7 @@ wxFont wxXmlResourceHandler::GetFont(const wxString& param)
else if (family == wxT("swiss")) ifamily = wxSWISS; else if (family == wxT("swiss")) ifamily = wxSWISS;
else if (family == wxT("modern")) ifamily = wxMODERN; else if (family == wxT("modern")) ifamily = wxMODERN;
bool underlined = GetBool(wxT("underlined"), FALSE); bool underlined = GetBool(wxT("underlined"), false);
wxString encoding = GetParamValue(wxT("encoding")); wxString encoding = GetParamValue(wxT("encoding"));
wxFontMapper mapper; wxFontMapper mapper;
@@ -1107,7 +1107,7 @@ wxFont wxXmlResourceHandler::GetFont(const wxString& param)
wxStringTokenizer tk(faces, wxT(",")); wxStringTokenizer tk(faces, wxT(","));
while (tk.HasMoreTokens()) while (tk.HasMoreTokens())
{ {
int index = enu.GetFacenames()->Index(tk.GetNextToken(), FALSE); int index = enu.GetFacenames()->Index(tk.GetNextToken(), false);
if (index != wxNOT_FOUND) if (index != wxNOT_FOUND)
{ {
facename = (*enu.GetFacenames())[index]; facename = (*enu.GetFacenames())[index];
@@ -1136,11 +1136,11 @@ void wxXmlResourceHandler::SetupWindow(wxWindow *wnd)
if (HasParam(wxT("fg"))) if (HasParam(wxT("fg")))
wnd->SetForegroundColour(GetColour(wxT("fg"))); wnd->SetForegroundColour(GetColour(wxT("fg")));
if (GetBool(wxT("enabled"), 1) == 0) if (GetBool(wxT("enabled"), 1) == 0)
wnd->Enable(FALSE); wnd->Enable(false);
if (GetBool(wxT("focused"), 0) == 1) if (GetBool(wxT("focused"), 0) == 1)
wnd->SetFocus(); wnd->SetFocus();
if (GetBool(wxT("hidden"), 0) == 1) if (GetBool(wxT("hidden"), 0) == 1)
wnd->Show(FALSE); wnd->Show(false);
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
if (HasParam(wxT("tooltip"))) if (HasParam(wxT("tooltip")))
wnd->SetToolTip(GetText(wxT("tooltip"))); wnd->SetToolTip(GetText(wxT("tooltip")));
@@ -1309,7 +1309,7 @@ public:
{ {
AddStdXRCID_Records(); AddStdXRCID_Records();
wxXmlResource::AddSubclassFactory(new wxXmlSubclassFactoryCXX); wxXmlResource::AddSubclassFactory(new wxXmlSubclassFactoryCXX);
return TRUE; return true;
} }
void OnExit() void OnExit()
{ {

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Vaclav Slavik // Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// -- Already done in xmlres.cpp // -- Already done in xmlres.cpp
//#ifdef __GNUG__ //#ifdef __GNUG__
//#pragma implementation "xmlres.h" //#pragma implementation "xmlres.h"
@@ -56,16 +56,16 @@ void wxXmlResource::InitAllHandlers()
#endif #endif
#if wxUSE_CHECKBOX #if wxUSE_CHECKBOX
AddHandler(new wxCheckBoxXmlHandler); AddHandler(new wxCheckBoxXmlHandler);
#endif #endif
#if wxUSE_HTML #if wxUSE_HTML
AddHandler(new wxHtmlWindowXmlHandler); AddHandler(new wxHtmlWindowXmlHandler);
#endif #endif
#if wxUSE_SPINBTN #if wxUSE_SPINBTN
AddHandler(new wxSpinButtonXmlHandler); AddHandler(new wxSpinButtonXmlHandler);
#endif #endif
#if wxUSE_SPINCTRL #if wxUSE_SPINCTRL
AddHandler(new wxSpinCtrlXmlHandler); AddHandler(new wxSpinCtrlXmlHandler);
#endif #endif
#if wxUSE_SCROLLBAR #if wxUSE_SCROLLBAR
AddHandler(new wxScrollBarXmlHandler); AddHandler(new wxScrollBarXmlHandler);
#endif #endif

View File

@@ -58,17 +58,17 @@ bool wxConvertApp::OnInit()
SetAppName(_T("wxConvertApp")); SetAppName(_T("wxConvertApp"));
if (HandleCommandLine()) if (HandleCommandLine())
return TRUE; return true;
// Create the main frame window // Create the main frame window
m_pFrame = new wxMainFrame(NULL, -1, _T("wxConvertApp"), wxPoint(0, 0), wxSize(500, 400), m_pFrame = new wxMainFrame(NULL, wxID_ANY, _T("wxConvertApp"), wxPoint(0, 0), wxSize(500, 400),
wxDEFAULT_FRAME_STYLE | wxHSCROLL | wxVSCROLL); wxDEFAULT_FRAME_STYLE | wxHSCROLL | wxVSCROLL);
InitMenu(); InitMenu();
m_pFrame->Show(TRUE); m_pFrame->Show(true);
SetTopWindow(m_pFrame); SetTopWindow(m_pFrame);
return TRUE; return true;
} }
void wxConvertApp::InitMenu() void wxConvertApp::InitMenu()
@@ -122,7 +122,7 @@ wxMainFrame::~wxMainFrame()
void wxMainFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void wxMainFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{ {
Close(TRUE); Close(true);
} }
@@ -192,7 +192,7 @@ bool wxConvertApp::HandleCommandLine()
{ {
if (argc != 2) if (argc != 2)
return FALSE; return false;
//Figure out kind of conversion //Figure out kind of conversion
wxString source,target; wxString source,target;
@@ -208,18 +208,18 @@ bool wxConvertApp::HandleCommandLine()
if ((source.Find(_T(".wxr"))>0)&&(target.Find(_T(".xml"))>0)) if ((source.Find(_T(".wxr"))>0)&&(target.Find(_T(".xml"))>0))
{ {
trans_wxr2xml.Convert(source,target); trans_wxr2xml.Convert(source,target);
return TRUE; return true;
} }
else if ((source.Find(_T(".rc"))!=-1)&(target.Find(_T(".wxr"))!=-1)) else if ((source.Find(_T(".rc"))!=wxNOT_FOUND)&(target.Find(_T(".wxr"))!=wxNOT_FOUND))
{ {
trans_rc2wxr.Convert(source,target); trans_rc2wxr.Convert(source,target);
return TRUE; return true;
} }
else if ((source.Find(_T(".rc"))!=-1)&(target.Find(_T(".xml"))!=-1)) else if ((source.Find(_T(".rc"))!=wxNOT_FOUND)&(target.Find(_T(".xml"))!=wxNOT_FOUND))
{ {
trans_rc2xml.Convert(source,target); trans_rc2xml.Convert(source,target);
return TRUE; return true;
} }
return FALSE; return false;
} }

View File

@@ -21,17 +21,17 @@ public:
void OnWXR2XML(wxCommandEvent& event); void OnWXR2XML(wxCommandEvent& event);
void OnRc2Wxr(wxCommandEvent& event); void OnRc2Wxr(wxCommandEvent& event);
void OnQuit(wxCommandEvent& event); void OnQuit(wxCommandEvent& event);
wxMainFrame(wxWindow* parent, wxWindowID id, wxMainFrame(wxWindow* parent, wxWindowID id,
const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxString& title, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = _T("frame")); const wxString& name = _T("frame"));
virtual ~wxMainFrame(); virtual ~wxMainFrame();
protected: protected:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
class wxConvertApp : public wxApp class wxConvertApp : public wxApp
{ {
public: public:
bool HandleCommandLine(); bool HandleCommandLine();

View File

@@ -77,7 +77,7 @@ rc2wxr::rc2wxr()
{ {
m_done=FALSE; m_done=false;
m_controlid=6000; m_controlid=6000;
@@ -511,7 +511,7 @@ bool rc2wxr::Seperator(int ch)
if ((ch==' ')|(ch==',')|(ch==13)|(ch==10)|(ch=='|')) if ((ch==' ')|(ch==',')|(ch==13)|(ch==10)|(ch=='|'))
return TRUE; return true;
@@ -519,13 +519,13 @@ if (ch==EOF)
{ {
m_done=TRUE; m_done=true;
return TRUE; return true;
} }
return FALSE; return false;
} }
@@ -595,7 +595,7 @@ if (m_rc.Eof())
{ {
m_done=TRUE; m_done=true;
return tok; return tok;
@@ -611,7 +611,7 @@ if (ch==EOF)
{ {
m_done=TRUE; m_done=true;
return tok; return tok;
@@ -637,7 +637,7 @@ if (ch==EOF)
{ {
m_done=TRUE; m_done=true;
@@ -663,7 +663,7 @@ ReadChar(ch);
if (ch==EOF) if (ch==EOF)
m_done=TRUE; m_done=true;
@@ -719,7 +719,7 @@ void rc2wxr::ReadChar(int &ch)
{ {
int result; int result;
result=m_rc.Tell(); result=m_rc.Tell();
@@ -727,7 +727,7 @@ result=m_rc.Tell();
if((result>=m_filesize)) if((result>=m_filesize))
m_done=TRUE; m_done=true;
@@ -737,13 +737,13 @@ result=m_rc.Read(&ch,1);
if((result==-1)) if((result==-1))
m_done=TRUE; m_done=true;
if(ch==EOF) if(ch==EOF)
m_done=TRUE; m_done=true;
} }
@@ -817,13 +817,13 @@ while ((tok!=_T("END"))&(tok!=_T("}")))
if (tok==_T("POPUP")) if (tok==_T("POPUP"))
{ {
ParsePopupMenu(); ParsePopupMenu();
wxFprintf(m_wxr,_T(" ],\\\n")); wxFprintf(m_wxr,_T(" ],\\\n"));
} }
} }
@@ -1043,7 +1043,7 @@ if (tok.IsNumber())
w=GetToken(); w=GetToken();
return TRUE; return true;
} }

View File

@@ -8,7 +8,7 @@
#include "wx/file.h" #include "wx/file.h"
#include "stdio.h" #include "stdio.h"
class rc2wxr : public wxObject class rc2wxr : public wxObject
{ {
public: public:
rc2wxr(); rc2wxr();

View File

@@ -49,7 +49,7 @@ cross platform (wxGTK,etc)
rc2xml::rc2xml() rc2xml::rc2xml()
{ {
m_done=FALSE; m_done=false;
m_bitmaplist=new wxList(wxKEY_STRING); m_bitmaplist=new wxList(wxKEY_STRING);
m_stringtable=new wxList(wxKEY_STRING); m_stringtable=new wxList(wxKEY_STRING);
m_iconlist = new wxList(wxKEY_STRING); m_iconlist = new wxList(wxKEY_STRING);
@@ -83,7 +83,7 @@ bool rc2xml::Convert(wxString rcfile, wxString xmlfile)
result=m_xmlfile.Open(xmlfile.c_str(),_T("w+t")); result=m_xmlfile.Open(xmlfile.c_str(),_T("w+t"));
wxASSERT_MSG(result,_T("Couldn't create XML file")); wxASSERT_MSG(result,_T("Couldn't create XML file"));
if (!result) if (!result)
return FALSE; return false;
/* Write Basic header for XML file */ /* Write Basic header for XML file */
@@ -94,7 +94,7 @@ bool rc2xml::Convert(wxString rcfile, wxString xmlfile)
ParseResourceHeader(); ParseResourceHeader();
//Gather all the resource we need for toolbars,menus, and etc //Gather all the resource we need for toolbars,menus, and etc
FirstPass(); FirstPass();
m_done=FALSE; m_done=false;
m_rc.Seek(0); m_rc.Seek(0);
//Read in dialogs, toolbars,menus //Read in dialogs, toolbars,menus
SecondPass(); SecondPass();
@@ -105,7 +105,7 @@ bool rc2xml::Convert(wxString rcfile, wxString xmlfile)
wxMessageBox(_("Conversion complete."), _("Done"), wxMessageBox(_("Conversion complete."), _("Done"),
wxOK | wxICON_INFORMATION); wxOK | wxICON_INFORMATION);
return TRUE; return true;
} }
@@ -308,9 +308,9 @@ void rc2xml::ParseRadioButton(wxString phrase, wxString varname)
bool GotOrs; bool GotOrs;
GotOrs = ReadOrs(token); GotOrs = ReadOrs(token);
if (ReadRect(x,y,width,height)) if (ReadRect(x,y,width,height))
if (GotOrs==FALSE) if (GotOrs==false)
ReadOrs(token); ReadOrs(token);
if (token.Find(_T("WS_GROUP")) != -1) if (token.Find(_T("WS_GROUP")) != wxNOT_FOUND)
style += _T("wxRB_GROUP"); style += _T("wxRB_GROUP");
m_xmlfile.Write(_T("\t\t<object class=\"wxRadioButton\"")); m_xmlfile.Write(_T("\t\t<object class=\"wxRadioButton\""));
@@ -347,15 +347,15 @@ bool rc2xml::Seperator(int ch)
{ {
//if ((ch==' ')|(ch==',')|(ch==13)|(ch==10)|(ch=='|')|(ch=='\t')) //if ((ch==' ')|(ch==',')|(ch==13)|(ch==10)|(ch=='|')|(ch=='\t'))
if ((ch==' ')|(ch==',')|(ch==13)|(ch==10)|(ch=='\t')) if ((ch==' ')|(ch==',')|(ch==13)|(ch==10)|(ch=='\t'))
return TRUE; return true;
if (ch==EOF) if (ch==EOF)
{ {
m_done=TRUE; m_done=true;
return TRUE; return true;
} }
return FALSE; return false;
} }
void rc2xml::ParseGroupBox(wxString phrase, wxString varname) void rc2xml::ParseGroupBox(wxString phrase, wxString varname)
@@ -394,7 +394,7 @@ wxString rc2xml::GetToken(bool *listseperator)
if (m_rc.Eof()) if (m_rc.Eof())
{ {
m_done=TRUE; m_done=true;
return token; return token;
} }
@@ -402,7 +402,7 @@ wxString rc2xml::GetToken(bool *listseperator)
ReadChar(ch); ReadChar(ch);
if (ch==EOF) if (ch==EOF)
{ {
m_done=TRUE; m_done=true;
return token; return token;
} }
@@ -415,7 +415,7 @@ wxString rc2xml::GetToken(bool *listseperator)
if (ch==EOF) if (ch==EOF)
{ {
m_done=TRUE; m_done=true;
} }
@@ -426,7 +426,7 @@ wxString rc2xml::GetToken(bool *listseperator)
} }
if (ch == EOF) if (ch == EOF)
m_done = TRUE; m_done = true;
if (listseperator) if (listseperator)
*listseperator = (ch == ','); *listseperator = (ch == ',');
@@ -458,14 +458,14 @@ wxString rc2xml::GetStringQuote()
{ {
wxString phrase; wxString phrase;
//ASCII code 34 " //ASCII code 34 "
bool done=FALSE; bool done=false;
int p,ch=0,lastch=0; int p,ch=0,lastch=0;
ReadChar(ch); ReadChar(ch);
while (ch!=34) while (ch!=34)
ReadChar(ch); ReadChar(ch);
ReadChar(ch); ReadChar(ch);
while (done==FALSE) while (done==false)
{ {
if ((ch==34)&&(lastch!='\\')) if ((ch==34)&&(lastch!='\\'))
{ {
@@ -477,10 +477,10 @@ wxString rc2xml::GetStringQuote()
else else
{ {
m_rc.Seek(p); m_rc.Seek(p);
done = TRUE; done = true;
} }
} }
if (done==TRUE) if (done==true)
break; break;
if (ch=='\r') if (ch=='\r')
ReadChar(ch); // skip ReadChar(ch); // skip
@@ -501,15 +501,15 @@ void rc2xml::ReadChar(int &ch)
result=m_rc.Tell(); result=m_rc.Tell();
if((result>=m_filesize)) if((result>=m_filesize))
m_done=TRUE; m_done=true;
result=m_rc.Read(&ch,1); result=m_rc.Read(&ch,1);
if((result==-1)) if((result==-1))
m_done=TRUE; m_done=true;
if(ch==EOF) if(ch==EOF)
m_done=TRUE; m_done=true;
} }
void rc2xml::ParseComboBox(wxString varname) void rc2xml::ParseComboBox(wxString varname)
@@ -521,16 +521,16 @@ void rc2xml::ParseComboBox(wxString varname)
bool GotOrs; bool GotOrs;
GotOrs = ReadOrs(token); GotOrs = ReadOrs(token);
if (ReadRect(x,y,width,height)) if (ReadRect(x,y,width,height))
if (GotOrs==FALSE) if (GotOrs==false)
ReadOrs(token); ReadOrs(token);
m_xmlfile.Write(_T("\t\t<object class=\"wxComboBox\"")); m_xmlfile.Write(_T("\t\t<object class=\"wxComboBox\""));
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
if (token.Find(_T("CBS_SIMPLE")) != -1) if (token.Find(_T("CBS_SIMPLE")) != wxNOT_FOUND)
WriteStyle(_T("wxCB_SIMPLE")); WriteStyle(_T("wxCB_SIMPLE"));
if (token.Find(_T("CBS_SORT")) != -1) if (token.Find(_T("CBS_SORT")) != wxNOT_FOUND)
WriteStyle(_T("wxCB_SORT")); WriteStyle(_T("wxCB_SORT"));
if (token.Find(_T("CBS_DISABLENOSCROLL")) != -1) if (token.Find(_T("CBS_DISABLENOSCROLL")) != wxNOT_FOUND)
WriteStyle(_T("wxLB_ALWAYS_SB")); WriteStyle(_T("wxLB_ALWAYS_SB"));
m_xmlfile.Write(_T("\n\t\t</object>\n")); m_xmlfile.Write(_T("\n\t\t</object>\n"));
@@ -631,7 +631,7 @@ void rc2xml::ParseSlider(wxString WXUNUSED(label), wxString varname)
{ {
wxString token,style; wxString token,style;
ReadOrs(token); ReadOrs(token);
if (token.Find(_T("TBS_VERT"))!=-1) if (token.Find(_T("TBS_VERT"))!=wxNOT_FOUND)
style+=_T("wxSL_VERTICAL"); style+=_T("wxSL_VERTICAL");
//MFC RC Default is horizontal //MFC RC Default is horizontal
else else
@@ -670,7 +670,7 @@ bool rc2xml::ReadOrs(wxString & orstring)
token=PeekToken(); token=PeekToken();
if (token.IsNumber()) if (token.IsNumber())
return FALSE; return false;
orstring=GetToken(); orstring=GetToken();
while(PeekToken()==_T("|")) while(PeekToken()==_T("|"))
@@ -680,7 +680,7 @@ bool rc2xml::ReadOrs(wxString & orstring)
//Grab next token //Grab next token
orstring+=GetToken(); orstring+=GetToken();
} }
return TRUE; return true;
} }
//Is it a checkbutton or a radiobutton or a pushbutton or a groupbox //Is it a checkbutton or a radiobutton or a pushbutton or a groupbox
@@ -692,15 +692,15 @@ void rc2xml::ParseCtrlButton(wxString label, wxString varname)
ReadOrs(token); ReadOrs(token);
m_rc.Seek(p); m_rc.Seek(p);
if (token.Find(_T("BS_AUTOCHECKBOX"))!=-1) if (token.Find(_T("BS_AUTOCHECKBOX"))!=wxNOT_FOUND)
ParseCheckBox(label, varname); ParseCheckBox(label, varname);
else if ((token.Find(_T("BS_AUTORADIOBUTTON"))!=-1)|| else if ((token.Find(_T("BS_AUTORADIOBUTTON"))!=wxNOT_FOUND)||
(token.Find(_T("BS_RADIOBUTTON"))!=-1)) (token.Find(_T("BS_RADIOBUTTON"))!=wxNOT_FOUND))
ParseRadioButton(label, varname); ParseRadioButton(label, varname);
else if (token.Find(_T("BS_GROUPBOX"))!=-1) else if (token.Find(_T("BS_GROUPBOX"))!=wxNOT_FOUND)
ParseGroupBox(label, varname); ParseGroupBox(label, varname);
else // if ((token.Find("BS_PUSHBUTTON")!=-1)|| else // if ((token.Find("BS_PUSHBUTTON")!=wxNOT_FOUND)||
// (token.Find("BS_DEFPUSHBUTTON")!=-1)) // (token.Find("BS_DEFPUSHBUTTON")!=wxNOT_FOUND))
ParsePushButton(label, varname); // make default case ParsePushButton(label, varname); // make default case
} }
@@ -846,7 +846,7 @@ void rc2xml::ParseSpinCtrl(wxString WXUNUSED(label), wxString varname)
wxString token,style; wxString token,style;
ReadOrs(token); ReadOrs(token);
if (token.Find(_T("UDS_HORZ"))!=-1) if (token.Find(_T("UDS_HORZ"))!=wxNOT_FOUND)
style=_T("wxSP_HORIZONTAL"); style=_T("wxSP_HORIZONTAL");
//MFC default //MFC default
else else
@@ -928,7 +928,7 @@ void rc2xml::ParseToolBar(wxString varname)
wxLogError(_T("Unable to load bitmap:")+*bitmappath); wxLogError(_T("Unable to load bitmap:")+*bitmappath);
//Write toolbar to xml file //Write toolbar to xml file
m_xmlfile.Write(_T(" <object class=\"wxToolBar\"")); m_xmlfile.Write(_T("\t<object class=\"wxToolBar\""));
//Avoid duplicate names this way //Avoid duplicate names this way
varname.Replace(_T("IDR_"),_T("TB_")); varname.Replace(_T("IDR_"),_T("TB_"));
WriteName(varname); WriteName(varname);
@@ -962,7 +962,7 @@ void rc2xml::ParseToolBar(wxString varname)
{ {
SplitHelp(msg,tip,longhelp); SplitHelp(msg,tip,longhelp);
m_xmlfile.Write(_T("\t\t\t\t<tooltip>")+tip+_T("</tooltip>\n")); m_xmlfile.Write(_T("\t\t\t\t<tooltip>")+tip+_T("</tooltip>\n"));
m_xmlfile.Write(_T(" <longhelp>")+longhelp+_T("</longhelp>\n")); m_xmlfile.Write(_T("\t\t<longhelp>")+longhelp+_T("</longhelp>\n"));
} }
//Make a bitmap file name //Make a bitmap file name
buttonname=CleanName(buttonname); buttonname=CleanName(buttonname);
@@ -1016,19 +1016,19 @@ bool rc2xml::LookUpString(wxString strid,wxString & st)
wxNode *node=m_stringtable->Find(strid); wxNode *node=m_stringtable->Find(strid);
wxString *s; wxString *s;
if (node==NULL) if (node==NULL)
return FALSE; return false;
s=(wxString *)node->GetData(); s=(wxString *)node->GetData();
st=*s; st=*s;
return TRUE; return true;
} }
bool rc2xml::SplitHelp(wxString msg, wxString &shorthelp, wxString &longhelp) bool rc2xml::SplitHelp(wxString msg, wxString &shorthelp, wxString &longhelp)
{ {
int spot; int spot;
spot=msg.Find(_T("\\n")); spot=msg.Find(_T("\\n"));
if (spot==-1) if (spot==wxNOT_FOUND)
{ {
shorthelp=msg; shorthelp=msg;
longhelp=msg; longhelp=msg;
@@ -1037,7 +1037,7 @@ bool rc2xml::SplitHelp(wxString msg, wxString &shorthelp, wxString &longhelp)
longhelp=msg.Left(spot); longhelp=msg.Left(spot);
spot=msg.Length()-spot-2; spot=msg.Length()-spot-2;
shorthelp=msg.Right(spot); shorthelp=msg.Right(spot);
return TRUE; return true;
} }
void rc2xml::ParseMenuItem() void rc2xml::ParseMenuItem()
@@ -1191,7 +1191,7 @@ kindctrl.MakeUpper();
int p=m_rc.Tell(); int p=m_rc.Tell();
ReadOrs(token); ReadOrs(token);
m_rc.Seek(p); m_rc.Seek(p);
if (token.Find(_T("SS_BITMAP"))!=-1) if (token.Find(_T("SS_BITMAP"))!=wxNOT_FOUND)
ParseStaticBitmap(label,varname); ParseStaticBitmap(label,varname);
else else
ParseStaticText(label,varname); ParseStaticText(label,varname);
@@ -1238,7 +1238,7 @@ void rc2xml::ParseScrollBar()
ReadOrs(token); ReadOrs(token);
if (token.Find(_T("SBS_VERT"))!=-1) if (token.Find(_T("SBS_VERT"))!=wxNOT_FOUND)
style=_T("wxSB_VERTICAL"); style=_T("wxSB_VERTICAL");
//Default MFC style is horizontal //Default MFC style is horizontal
else else
@@ -1377,7 +1377,7 @@ wxTextFile r;
//Read through entire file //Read through entire file
for ( str = r.GetFirstLine(); !r.Eof(); str = r.GetNextLine() ) for ( str = r.GetFirstLine(); !r.Eof(); str = r.GetNextLine() )
{ {
if (str.Find(_T("#define"))!=-1) if (str.Find(_T("#define"))!=wxNOT_FOUND)
{ {
tok.SetString(str); tok.SetString(str);
//Just ignore #define token //Just ignore #define token

View File

@@ -10,7 +10,7 @@
#include <wx/list.h> #include <wx/list.h>
class rc2xml : public wxObject class rc2xml : public wxObject
{ {
public: public:
wxString m_workingpath; wxString m_workingpath;
@@ -22,8 +22,8 @@ public:
~rc2xml(); ~rc2xml();
protected: protected:
wxString LookUpId(wxString id); wxString LookUpId(wxString id);
void ParseResourceHeader(); void ParseResourceHeader();
void WriteBitmap(wxString bitmapname); void WriteBitmap(wxString bitmapname);
void ParseListCtrl(wxString label,wxString varname); void ParseListCtrl(wxString label,wxString varname);
@@ -37,7 +37,7 @@ protected:
wxList * m_iconlist; wxList * m_iconlist;
void ParseIconStatic(); void ParseIconStatic();
void ParseMenuItem(); void ParseMenuItem();
//Functions //Functions
bool SplitHelp(wxString msg, wxString &shorthelp, wxString &longhelp); bool SplitHelp(wxString msg, wxString &shorthelp, wxString &longhelp);
bool LookUpString(wxString strid,wxString & st); bool LookUpString(wxString strid,wxString & st);

View File

@@ -48,12 +48,12 @@ bool wxr2xml::Convert(wxString wxrfile, wxString xmlfile)
result = m_xmlfile.Open(xmlfile.c_str(), _T("w+t")); result = m_xmlfile.Open(xmlfile.c_str(), _T("w+t"));
wxASSERT_MSG(result, _T("Couldn't create XML file")); wxASSERT_MSG(result, _T("Couldn't create XML file"));
if (!result) if (!result)
return FALSE; return false;
result = m_table.ParseResourceFile(wxrfile); result = m_table.ParseResourceFile(wxrfile);
wxASSERT_MSG(result, _T("Couldn't Load WXR file")); wxASSERT_MSG(result, _T("Couldn't Load WXR file"));
if (!result) if (!result)
return FALSE; return false;
// Write basic xml header // Write basic xml header
m_xmlfile.Write(_T("<?xml version=\"1.0\" ?>\n")); m_xmlfile.Write(_T("<?xml version=\"1.0\" ?>\n"));
m_xmlfile.Write(_T("<resource>\n")); m_xmlfile.Write(_T("<resource>\n"));
@@ -71,7 +71,7 @@ bool wxr2xml::ParseResources()
wxHashTable::Node *node; wxHashTable::Node *node;
node = m_table.Next(); node = m_table.Next();
while (node) while (node)
{ {
wxItemResource *res = (wxItemResource *) node->GetData(); wxItemResource *res = (wxItemResource *) node->GetData();
wxString resType(res->GetType()); wxString resType(res->GetType());
@@ -89,7 +89,7 @@ bool wxr2xml::ParseResources()
wxLogError(_T("Found unsupported resource ") + resType); wxLogError(_T("Found unsupported resource ") + resType);
node = m_table.Next(); node = m_table.Next();
} }
return TRUE; return true;
} }
void wxr2xml::ParsePanel(wxItemResource * res) void wxr2xml::ParsePanel(wxItemResource * res)
@@ -117,7 +117,7 @@ void wxr2xml::ParseDialog(wxItemResource * res)
void wxr2xml::ParseControls(wxItemResource * res) void wxr2xml::ParseControls(wxItemResource * res)
{ {
wxNode *node = res->GetChildren().GetFirst(); wxNode *node = res->GetChildren().GetFirst();
while (node) while (node)
{ {
wxItemResource *res = (wxItemResource *) node->GetData(); wxItemResource *res = (wxItemResource *) node->GetData();
wxString resType(res->GetType()); wxString resType(res->GetType());
@@ -405,7 +405,7 @@ wxString wxr2xml::GetStyles(wxItemResource * res)
if (style & wxNO_FULL_REPAINT_ON_RESIZE) if (style & wxNO_FULL_REPAINT_ON_RESIZE)
s += _T("wxNO_FULL_REPAINT_ON_RESIZE|"); s += _T("wxNO_FULL_REPAINT_ON_RESIZE|");
if (restype == _T("wxDialog")) if (restype == _T("wxDialog"))
{ {
if (style & wxDIALOG_MODAL) if (style & wxDIALOG_MODAL)
s += _T("wxDIALOG_MODAL|"); s += _T("wxDIALOG_MODAL|");
@@ -435,7 +435,7 @@ wxString wxr2xml::GetStyles(wxItemResource * res)
s += _T("wxCLIP_CHILDREN|"); s += _T("wxCLIP_CHILDREN|");
} }
if (restype == _T("wxPanel")) if (restype == _T("wxPanel"))
{ {
if (style & wxCLIP_CHILDREN) if (style & wxCLIP_CHILDREN)
s += _T("wxCLIP_CHILDREN|"); s += _T("wxCLIP_CHILDREN|");
@@ -447,7 +447,7 @@ wxString wxr2xml::GetStyles(wxItemResource * res)
s += _T("wxWS_EX_VALIDATE_RECURSIVELY|"); s += _T("wxWS_EX_VALIDATE_RECURSIVELY|");
} }
if (restype == _T("wxComboBox")) if (restype == _T("wxComboBox"))
{ {
if (style & wxCB_SORT) if (style & wxCB_SORT)
s += _T("wxCB_SORT|"); s += _T("wxCB_SORT|");
@@ -459,7 +459,7 @@ wxString wxr2xml::GetStyles(wxItemResource * res)
s += _T("wxCB_DROPDOWN|"); s += _T("wxCB_DROPDOWN|");
} }
if (restype == _T("wxGauge")) if (restype == _T("wxGauge"))
{ {
if (style & wxGA_HORIZONTAL) if (style & wxGA_HORIZONTAL)
s += _T("wxGA_HORIZONTAL|"); s += _T("wxGA_HORIZONTAL|");
@@ -472,19 +472,19 @@ wxString wxr2xml::GetStyles(wxItemResource * res)
s += _T("wxGA_SMOOTH|"); s += _T("wxGA_SMOOTH|");
} }
if (restype == _T("wxRadioButton")) if (restype == _T("wxRadioButton"))
{ {
if (style & wxRB_GROUP) if (style & wxRB_GROUP)
s += _T("wxRB_GROUP|"); s += _T("wxRB_GROUP|");
} }
if (restype == _T("wxStaticText")) if (restype == _T("wxStaticText"))
{ {
if (style & wxST_NO_AUTORESIZE) if (style & wxST_NO_AUTORESIZE)
s += _T("wxST_NO_AUTORESIZEL|"); s += _T("wxST_NO_AUTORESIZEL|");
} }
if (restype == _T("wxRadioBox")) if (restype == _T("wxRadioBox"))
{ {
if (style & wxRA_HORIZONTAL) if (style & wxRA_HORIZONTAL)
s += _T("wxRA_HORIZONTAL|"); s += _T("wxRA_HORIZONTAL|");
@@ -496,7 +496,7 @@ wxString wxr2xml::GetStyles(wxItemResource * res)
s += _T("wxRA_VERTICAL|"); s += _T("wxRA_VERTICAL|");
} }
if (restype == _T("wxListBox")) if (restype == _T("wxListBox"))
{ {
if (style & wxLB_SINGLE) if (style & wxLB_SINGLE)
s += _T("wxLB_SINGLE|"); s += _T("wxLB_SINGLE|");
@@ -514,7 +514,7 @@ wxString wxr2xml::GetStyles(wxItemResource * res)
s += _T("wxLB_SORT|"); s += _T("wxLB_SORT|");
} }
if (restype == _T("wxTextCtrl")) if (restype == _T("wxTextCtrl"))
{ {
if (style & wxTE_PROCESS_ENTER) if (style & wxTE_PROCESS_ENTER)
s += _T("wxTE_PROCESS_ENTER|"); s += _T("wxTE_PROCESS_ENTER|");
@@ -535,7 +535,7 @@ wxString wxr2xml::GetStyles(wxItemResource * res)
{ {
if (style & wxSB_HORIZONTAL) if (style & wxSB_HORIZONTAL)
s += _T("wxSB_HORIZONTAL|"); s += _T("wxSB_HORIZONTAL|");
if (style & wxSB_VERTICAL) if (style & wxSB_VERTICAL)
s += _T("wxSB_VERTICAL|"); s += _T("wxSB_VERTICAL|");
} }
@@ -598,7 +598,7 @@ void wxr2xml::ParseMenu(wxItemResource * res)
{ {
wxItemResource *child; wxItemResource *child;
wxNode *node = res->GetChildren().GetFirst(); wxNode *node = res->GetChildren().GetFirst();
// Get Menu // Get Menu
m_xmlfile.Write(_T("\t\t\t<object class=\"wxMenu\" ")); m_xmlfile.Write(_T("\t\t\t<object class=\"wxMenu\" "));
wxString menuname; wxString menuname;
menuname << _T("name = \"menu_") << res->GetValue1() << _T("\""); menuname << _T("name = \"menu_") << res->GetValue1() << _T("\"");
@@ -632,10 +632,10 @@ void wxr2xml::ParseMenuItem(wxItemResource * res)
menuname << _T("name = \"menuitem_") << res->GetValue1() << _T("\""); menuname << _T("name = \"menuitem_") << res->GetValue1() << _T("\"");
m_xmlfile.Write(menuname); m_xmlfile.Write(menuname);
m_xmlfile.Write(_T(">\n")); m_xmlfile.Write(_T(">\n"));
m_xmlfile.Write(_T(" <label>") m_xmlfile.Write(_T("\t\t\t<label>")
+ FixMenuString(res->GetTitle()) + _T("</label>\n")); + FixMenuString(res->GetTitle()) + _T("</label>\n"));
if (res->GetValue4() != _T("")) if (res->GetValue4() != _T(""))
m_xmlfile.Write(_T(" <help>") + m_xmlfile.Write(_T("\t\t\t<help>") +
res->GetValue4() + _T("</help>\n")); res->GetValue4() + _T("</help>\n"));
if (res->GetValue2()) if (res->GetValue2())
m_xmlfile.Write(_T("\t\t\t\t<checkable>1</checkable>\n")); m_xmlfile.Write(_T("\t\t\t\t<checkable>1</checkable>\n"));
@@ -682,16 +682,16 @@ void wxr2xml::ParseBitmap(wxItemResource * res)
void wxr2xml::PanelStuff(wxItemResource * res) void wxr2xml::PanelStuff(wxItemResource * res)
{ {
if ((res->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0) if ((res->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0)
m_dlgunits = TRUE; m_dlgunits = true;
else else
m_dlgunits = FALSE; m_dlgunits = false;
// If this is true ignore fonts, background color and use system // If this is true ignore fonts, background color and use system
// defaults instead // defaults instead
if ((res->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0) if ((res->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0)
m_systemdefaults = TRUE; m_systemdefaults = true;
else else
m_systemdefaults = FALSE; m_systemdefaults = false;
} }
@@ -720,7 +720,7 @@ wxString wxr2xml::GetValue5(wxItemResource *res)
void wxr2xml::ParseBitmapButton(wxItemResource *res) void wxr2xml::ParseBitmapButton(wxItemResource *res)
{ {
m_xmlfile.Write(_T("\t\t\t<object class=\"wxBitmapButton\"")); m_xmlfile.Write(_T("\t\t\t<object class=\"wxBitmapButton\""));
WriteControlInfo(res); WriteControlInfo(res);
// value4 holds bitmap name // value4 holds bitmap name
@@ -731,7 +731,7 @@ void wxr2xml::ParseBitmapButton(wxItemResource *res)
bitmapname += _T(".bmp"); bitmapname += _T(".bmp");
bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP); bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP);
m_xmlfile.Write(_T("\t\t\t\t<bitmap>") + bitmapname + _T("</bitmap>\n")); m_xmlfile.Write(_T("\t\t\t\t<bitmap>") + bitmapname + _T("</bitmap>\n"));
m_xmlfile.Write(_T("\t\t\t</object>\n")); m_xmlfile.Write(_T("\t\t\t</object>\n"));
} }
@@ -755,10 +755,10 @@ void wxr2xml::WriteFontInfo(wxItemResource *res)
GetFontFace(font); GetFontFace(font);
GetFontStyle(font); GetFontStyle(font);
GetFontWeight(font); GetFontWeight(font);
if (font.GetUnderlined()) if (font.GetUnderlined())
m_xmlfile.Write(_T("\t\t\t\t<underlined>1</underlined>\n")); m_xmlfile.Write(_T("\t\t\t\t<underlined>1</underlined>\n"));
m_xmlfile.Write(_T("\t\t\t</font>\n")); m_xmlfile.Write(_T("\t\t\t</font>\n"));
} }
@@ -767,7 +767,7 @@ void wxr2xml::WriteFontInfo(wxItemResource *res)
void wxr2xml::GetFontFace(wxFont font) void wxr2xml::GetFontFace(wxFont font)
{ {
int family=font.GetFamily(); int family=font.GetFamily();
switch (family) switch (family)
{ {
case wxDEFAULT: case wxDEFAULT:

View File

@@ -36,7 +36,7 @@
class XRCWidgetData class XRCWidgetData
{ {
public: public:
XRCWidgetData(const wxString& vname,const wxString& vclass) XRCWidgetData(const wxString& vname,const wxString& vclass)
: m_class(vclass), m_name(vname) {} : m_class(vclass), m_name(vname) {}
const wxString& GetName() const { return m_name; } const wxString& GetName() const { return m_name; }
const wxString& GetClass() const { return m_class; } const wxString& GetClass() const { return m_class; }
@@ -50,16 +50,16 @@ WX_DEFINE_OBJARRAY(ArrayOfXRCWidgetData);
class XRCWndClassData class XRCWndClassData
{ {
private: private:
wxString m_className; wxString m_className;
wxString m_parentClassName; wxString m_parentClassName;
ArrayOfXRCWidgetData m_wdata; ArrayOfXRCWidgetData m_wdata;
void BrowseXmlNode(wxXmlNode* node) void BrowseXmlNode(wxXmlNode* node)
{ {
wxString classValue; wxString classValue;
wxString nameValue; wxString nameValue;
wxXmlNode* children; wxXmlNode* children;
while (node) while (node)
{ {
if (node->GetName() == _T("object") if (node->GetName() == _T("object")
@@ -70,19 +70,19 @@ private:
} }
children = node->GetChildren(); children = node->GetChildren();
if (children) if (children)
BrowseXmlNode(children); BrowseXmlNode(children);
node = node->GetNext(); node = node->GetNext();
} }
} }
public: public:
XRCWndClassData(const wxString& className,const wxString& parentClassName, const wxXmlNode* node) : XRCWndClassData(const wxString& className,const wxString& parentClassName, const wxXmlNode* node) :
m_className(className) , m_parentClassName(parentClassName) { m_className(className) , m_parentClassName(parentClassName) {
BrowseXmlNode(node->GetChildren()); BrowseXmlNode(node->GetChildren());
} }
const ArrayOfXRCWidgetData& GetWidgetData(){ const ArrayOfXRCWidgetData& GetWidgetData(){
return m_wdata; return m_wdata;
} }
@@ -99,26 +99,26 @@ public:
} }
file.Write(_T("\nprivate:\n void InitWidgetsFromXRC(){\n") file.Write(_T("\nprivate:\n void InitWidgetsFromXRC(){\n")
_T(" wxXmlResource::Get()->LoadObject(this,NULL,\"") _T(" wxXmlResource::Get()->LoadObject(this,NULL,\"")
+ m_className + m_className
+ _T("\",\"") + _T("\",\"")
+ m_parentClassName + m_parentClassName
+ _T("\");\n")); + _T("\");\n"));
for(i=0;i<m_wdata.Count();++i){ for(i=0;i<m_wdata.Count();++i){
const XRCWidgetData& w = m_wdata.Item(i); const XRCWidgetData& w = m_wdata.Item(i);
file.Write( _T(" ") file.Write( _T(" ")
+ w.GetName() + w.GetName()
+ _T(" = XRCCTRL(*this,\"") + _T(" = XRCCTRL(*this,\"")
+ w.GetName() + w.GetName()
+ _T("\",") + _T("\",")
+ w.GetClass() + w.GetClass()
+ _T(");\n") + _T(");\n")
); );
} }
file.Write(_T(" }\n")); file.Write(_T(" }\n"));
file.Write( file.Write(
_T("public:\n") _T("public:\n")
+ m_className + m_className
+ _T("::") + _T("::")
+ m_className + m_className
+ _T("(){\n") + _T("(){\n")
@@ -135,10 +135,10 @@ class XmlResApp : public wxAppConsole
{ {
public: public:
// don't use builtin cmd line parsing: // don't use builtin cmd line parsing:
virtual bool OnInit() { return true; } virtual bool OnInit() { return true; }
virtual int OnRun(); virtual int OnRun();
private: private:
void ParseParams(const wxCmdLineParser& cmdline); void ParseParams(const wxCmdLineParser& cmdline);
void CompileRes(); void CompileRes();
wxArrayString PrepareTempFiles(); wxArrayString PrepareTempFiles();
@@ -153,7 +153,7 @@ private:
void OutputGettext(); void OutputGettext();
wxArrayString FindStrings(); wxArrayString FindStrings();
wxArrayString FindStrings(wxXmlNode *node); wxArrayString FindStrings(wxXmlNode *node);
bool flagVerbose, flagCPP, flagPython, flagGettext; bool flagVerbose, flagCPP, flagPython, flagGettext;
wxString parOutput, parFuncname, parOutputPath; wxString parOutput, parFuncname, parOutputPath;
wxArrayString parFiles; wxArrayString parFiles;
@@ -170,7 +170,7 @@ int XmlResApp::OnRun()
{ {
static const wxCmdLineEntryDesc cmdLineDesc[] = static const wxCmdLineEntryDesc cmdLineDesc[] =
{ {
{ wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("show help message"), { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("show help message"),
wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
{ wxCMD_LINE_SWITCH, _T("v"), _T("verbose"), _T("be verbose") }, { wxCMD_LINE_SWITCH, _T("v"), _T("verbose"), _T("be verbose") },
{ wxCMD_LINE_SWITCH, _T("e"), _T("extra-cpp-code"), _T("output C++ header file with XRC derived classes") }, { wxCMD_LINE_SWITCH, _T("e"), _T("extra-cpp-code"), _T("output C++ header file with XRC derived classes") },
@@ -183,7 +183,7 @@ int XmlResApp::OnRun()
{ wxCMD_LINE_OPTION, _T("l"), _T("list-of-handlers", _T("output list of neccessary handlers to this file" }, { wxCMD_LINE_OPTION, _T("l"), _T("list-of-handlers", _T("output list of neccessary handlers to this file" },
#endif #endif
{ wxCMD_LINE_PARAM, NULL, NULL, _T("input file(s)"), { wxCMD_LINE_PARAM, NULL, NULL, _T("input file(s)"),
wxCMD_LINE_VAL_STRING, wxCMD_LINE_VAL_STRING,
wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_OPTION_MANDATORY }, wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_OPTION_MANDATORY },
{ wxCMD_LINE_NONE } { wxCMD_LINE_NONE }
@@ -235,7 +235,7 @@ void XmlResApp::ParseParams(const wxCmdLineParser& cmdline)
flagH = flagCPP && cmdline.Found(_T("e")); flagH = flagCPP && cmdline.Found(_T("e"));
if (!cmdline.Found(_T("o"), &parOutput)) if (!cmdline.Found(_T("o"), &parOutput))
{ {
if (flagGettext) if (flagGettext)
parOutput = wxEmptyString; parOutput = wxEmptyString;
@@ -258,7 +258,7 @@ void XmlResApp::ParseParams(const wxCmdLineParser& cmdline)
} }
if (!parOutputPath) parOutputPath = _T("."); if (!parOutputPath) parOutputPath = _T(".");
if (!cmdline.Found(_T("n"), &parFuncname)) if (!cmdline.Found(_T("n"), &parFuncname))
parFuncname = _T("InitXmlResource"); parFuncname = _T("InitXmlResource");
for (size_t i = 0; i < cmdline.GetParamCount(); i++) for (size_t i = 0; i < cmdline.GetParamCount(); i++)
@@ -286,7 +286,7 @@ void XmlResApp::CompileRes()
wxRemoveFile(parOutput); wxRemoveFile(parOutput);
if (!retCode) if (!retCode)
{ {
if (flagCPP){ if (flagCPP){
MakePackageCPP(files); MakePackageCPP(files);
if (flagH) if (flagH)
@@ -297,7 +297,7 @@ void XmlResApp::CompileRes()
else else
MakePackageZIP(files); MakePackageZIP(files);
} }
DeleteTempFiles(files); DeleteTempFiles(files);
} }
@@ -310,11 +310,11 @@ wxString XmlResApp::GetInternalFileName(const wxString& name, const wxArrayStrin
name2.Replace(_T("\\"), _T("_")); name2.Replace(_T("\\"), _T("_"));
name2.Replace(_T("*"), _T("_")); name2.Replace(_T("*"), _T("_"));
name2.Replace(_T("?"), _T("_")); name2.Replace(_T("?"), _T("_"));
wxString s = wxFileNameFromPath(parOutput) + _T("$") + name2; wxString s = wxFileNameFromPath(parOutput) + _T("$") + name2;
if (wxFileExists(s) && flist.Index(s) == wxNOT_FOUND) if (wxFileExists(s) && flist.Index(s) == wxNOT_FOUND)
{ {
for (int i = 0;; i++) for (int i = 0;; i++)
{ {
s.Printf(wxFileNameFromPath(parOutput) + _T("$%03i-") + name2, i); s.Printf(wxFileNameFromPath(parOutput) + _T("$%03i-") + name2, i);
@@ -328,21 +328,21 @@ wxString XmlResApp::GetInternalFileName(const wxString& name, const wxArrayStrin
wxArrayString XmlResApp::PrepareTempFiles() wxArrayString XmlResApp::PrepareTempFiles()
{ {
wxArrayString flist; wxArrayString flist;
for (size_t i = 0; i < parFiles.Count(); i++) for (size_t i = 0; i < parFiles.Count(); i++)
{ {
if (flagVerbose) if (flagVerbose)
wxPrintf(_T("processing ") + parFiles[i] + _T("...\n")); wxPrintf(_T("processing ") + parFiles[i] + _T("...\n"));
wxXmlDocument doc; wxXmlDocument doc;
if (!doc.Load(parFiles[i])) if (!doc.Load(parFiles[i]))
{ {
wxLogError(_T("Error parsing file ") + parFiles[i]); wxLogError(_T("Error parsing file ") + parFiles[i]);
retCode = 1; retCode = 1;
continue; continue;
} }
wxString name, ext, path; wxString name, ext, path;
wxSplitPath(parFiles[i], &path, &name, &ext); wxSplitPath(parFiles[i], &path, &name, &ext);
@@ -364,11 +364,11 @@ wxArrayString XmlResApp::PrepareTempFiles()
} }
} }
wxString internalName = GetInternalFileName(parFiles[i], flist); wxString internalName = GetInternalFileName(parFiles[i], flist);
doc.Save(parOutputPath + wxFILE_SEP_PATH + internalName); doc.Save(parOutputPath + wxFILE_SEP_PATH + internalName);
flist.Add(internalName); flist.Add(internalName);
} }
return flist; return flist;
} }
@@ -378,30 +378,30 @@ static bool NodeContainsFilename(wxXmlNode *node)
{ {
// Any bitmaps: // Any bitmaps:
if (node->GetName() == _T("bitmap")) if (node->GetName() == _T("bitmap"))
return TRUE; return true;
// URLs in wxHtmlWindow: // URLs in wxHtmlWindow:
if (node->GetName() == _T("url")) if (node->GetName() == _T("url"))
return TRUE; return true;
// wxBitmapButton: // wxBitmapButton:
wxXmlNode *parent = node->GetParent(); wxXmlNode *parent = node->GetParent();
if (parent != NULL && if (parent != NULL &&
parent->GetPropVal(_T("class"), _T("")) == _T("wxBitmapButton") && parent->GetPropVal(_T("class"), _T("")) == _T("wxBitmapButton") &&
(node->GetName() == _T("focus") || (node->GetName() == _T("focus") ||
node->GetName() == _T("disabled") || node->GetName() == _T("disabled") ||
node->GetName() == _T("selected"))) node->GetName() == _T("selected")))
return TRUE; return true;
// wxBitmap or wxIcon toplevel resources: // wxBitmap or wxIcon toplevel resources:
if (node->GetName() == _T("object")) if (node->GetName() == _T("object"))
{ {
wxString klass = node->GetPropVal(_T("class"), wxEmptyString); wxString klass = node->GetPropVal(_T("class"), wxEmptyString);
if (klass == _T("wxBitmap") || klass == _T("wxIcon")) if (klass == _T("wxBitmap") || klass == _T("wxIcon"))
return TRUE; return true;
} }
return FALSE; return false;
} }
// find all files mentioned in structure, e.g. <bitmap>filename</bitmap> // find all files mentioned in structure, e.g. <bitmap>filename</bitmap>
@@ -417,7 +417,7 @@ void XmlResApp::FindFilesInXML(wxXmlNode *node, wxArrayString& flist, const wxSt
while (n) while (n)
{ {
if (containsFilename && if (containsFilename &&
(n->GetType() == wxXML_TEXT_NODE || (n->GetType() == wxXML_TEXT_NODE ||
n->GetType() == wxXML_CDATA_SECTION_NODE)) n->GetType() == wxXML_CDATA_SECTION_NODE))
{ {
wxString fullname; wxString fullname;
@@ -426,7 +426,7 @@ void XmlResApp::FindFilesInXML(wxXmlNode *node, wxArrayString& flist, const wxSt
else else
fullname = inputPath + wxFILE_SEP_PATH + n->GetContent(); fullname = inputPath + wxFILE_SEP_PATH + n->GetContent();
if (flagVerbose) if (flagVerbose)
wxPrintf(_T("adding ") + fullname + _T("...\n")); wxPrintf(_T("adding ") + fullname + _T("...\n"));
wxString filename = GetInternalFileName(n->GetContent(), flist); wxString filename = GetInternalFileName(n->GetContent(), flist);
@@ -461,19 +461,19 @@ void XmlResApp::DeleteTempFiles(const wxArrayString& flist)
void XmlResApp::MakePackageZIP(const wxArrayString& flist) void XmlResApp::MakePackageZIP(const wxArrayString& flist)
{ {
wxString files; wxString files;
for (size_t i = 0; i < flist.Count(); i++) for (size_t i = 0; i < flist.Count(); i++)
files += flist[i] + _T(" "); files += flist[i] + _T(" ");
files.RemoveLast(); files.RemoveLast();
if (flagVerbose) if (flagVerbose)
wxPrintf(_T("compressing ") + parOutput + _T("...\n")); wxPrintf(_T("compressing ") + parOutput + _T("...\n"));
wxString cwd = wxGetCwd(); wxString cwd = wxGetCwd();
wxSetWorkingDirectory(parOutputPath); wxSetWorkingDirectory(parOutputPath);
int execres = wxExecute(_T("zip -9 -j ") + int execres = wxExecute(_T("zip -9 -j ") +
wxString(flagVerbose ? _T("") : _T("-q ")) + wxString(flagVerbose ? _T("") : _T("-q ")) +
parOutput + _T(" ") + files, TRUE); parOutput + _T(" ") + files, true);
wxSetWorkingDirectory(cwd); wxSetWorkingDirectory(cwd);
if (execres == -1) if (execres == -1)
{ {
@@ -493,16 +493,16 @@ static wxString FileToCppArray(wxString filename, int num)
wxString snum; wxString snum;
wxFFile file(filename, wxT("rb")); wxFFile file(filename, wxT("rb"));
size_t lng = file.Length(); size_t lng = file.Length();
snum.Printf(_T("%i"), num); snum.Printf(_T("%i"), num);
output.Printf(_T("static size_t xml_res_size_") + snum + _T(" = %i;\n"), lng); output.Printf(_T("static size_t xml_res_size_") + snum + _T(" = %i;\n"), lng);
output += _T("static unsigned char xml_res_file_") + snum + _T("[] = {\n"); output += _T("static unsigned char xml_res_file_") + snum + _T("[] = {\n");
// we cannot use string literals because MSVC is dumb wannabe compiler // we cannot use string literals because MSVC is dumb wannabe compiler
// with arbitrary limitation to 2048 strings :( // with arbitrary limitation to 2048 strings :(
unsigned char *buffer = new unsigned char[lng]; unsigned char *buffer = new unsigned char[lng];
file.Read(buffer, lng); file.Read(buffer, lng);
for (size_t i = 0, linelng = 0; i < lng; i++) for (size_t i = 0, linelng = 0; i < lng; i++)
{ {
tmp.Printf(_T("%i"), buffer[i]); tmp.Printf(_T("%i"), buffer[i]);
@@ -515,11 +515,11 @@ static wxString FileToCppArray(wxString filename, int num)
output << tmp; output << tmp;
linelng += tmp.Length()+1; linelng += tmp.Length()+1;
} }
delete[] buffer; delete[] buffer;
output += _T("};\n\n"); output += _T("};\n\n");
return output; return output;
} }
@@ -529,9 +529,9 @@ void XmlResApp::MakePackageCPP(const wxArrayString& flist)
wxFFile file(parOutput, wxT("wt")); wxFFile file(parOutput, wxT("wt"));
size_t i; size_t i;
if (flagVerbose) if (flagVerbose)
wxPrintf(_T("creating C++ source file ") + parOutput + _T("...\n")); wxPrintf(_T("creating C++ source file ") + parOutput + _T("...\n"));
file.Write(_T("") file.Write(_T("")
_T("//\n") _T("//\n")
_T("// This file was automatically generated by wxrc, do not edit by hand.\n") _T("// This file was automatically generated by wxrc, do not edit by hand.\n")
@@ -555,7 +555,7 @@ _T("\n"));
for (i = 0; i < flist.Count(); i++) for (i = 0; i < flist.Count(); i++)
file.Write( file.Write(
FileToCppArray(parOutputPath + wxFILE_SEP_PATH + flist[i], i)); FileToCppArray(parOutputPath + wxFILE_SEP_PATH + flist[i], i));
file.Write(_T("") file.Write(_T("")
_T("void ") + parFuncname + wxT("()\n") _T("void ") + parFuncname + wxT("()\n")
_T("{\n") _T("{\n")
@@ -584,7 +584,7 @@ _T("\n"));
file.Write(_T(" wxXmlResource::Get()->Load(wxT(\"memory:XRC_resource/") + file.Write(_T(" wxXmlResource::Get()->Load(wxT(\"memory:XRC_resource/") +
GetInternalFileName(parFiles[i], flist) + _T("\"));\n")); GetInternalFileName(parFiles[i], flist) + _T("\"));\n"));
} }
file.Write(_T("}\n")); file.Write(_T("}\n"));
@@ -594,7 +594,7 @@ void XmlResApp::GenCPPHeader()
{ {
wxString fileSpec = (parOutput.BeforeLast('.')).AfterLast('/'); wxString fileSpec = (parOutput.BeforeLast('.')).AfterLast('/');
wxString heaFileName = fileSpec + _T(".h"); wxString heaFileName = fileSpec + _T(".h");
wxFFile file(heaFileName, wxT("wt")); wxFFile file(heaFileName, wxT("wt"));
file.Write( file.Write(
_T("//\n") _T("//\n")
@@ -602,10 +602,10 @@ _T("// This file was automatically generated by wxrc, do not edit by hand.\n")
_T("//\n\n") _T("//\n\n")
_T("#ifndef __") + fileSpec + _T("_h__\n") _T("#ifndef __") + fileSpec + _T("_h__\n")
_T("#define __") + fileSpec + _T("_h__\n") _T("#define __") + fileSpec + _T("_h__\n")
); );
for(size_t i=0;i<aXRCWndClassData.Count();++i){ for(size_t i=0;i<aXRCWndClassData.Count();++i){
aXRCWndClassData.Item(i).GenerateHeaderCode(file); aXRCWndClassData.Item(i).GenerateHeaderCode(file);
} }
file.Write( file.Write(
_T("\nvoid \n") _T("\nvoid \n")
+ parFuncname + parFuncname
@@ -619,13 +619,13 @@ static wxString FileToPythonArray(wxString filename, int num)
wxString snum; wxString snum;
wxFFile file(filename, wxT("rb")); wxFFile file(filename, wxT("rb"));
size_t lng = file.Length(); size_t lng = file.Length();
snum.Printf(_T("%i"), num); snum.Printf(_T("%i"), num);
output = _T(" xml_res_file_") + snum + _T(" = \"\"\"\\\n"); output = _T(" xml_res_file_") + snum + _T(" = \"\"\"\\\n");
unsigned char *buffer = new unsigned char[lng]; unsigned char *buffer = new unsigned char[lng];
file.Read(buffer, lng); file.Read(buffer, lng);
for (size_t i = 0, linelng = 0; i < lng; i++) for (size_t i = 0, linelng = 0; i < lng; i++)
{ {
unsigned char c = buffer[i]; unsigned char c = buffer[i];
@@ -648,11 +648,11 @@ static wxString FileToPythonArray(wxString filename, int num)
output << tmp; output << tmp;
linelng += tmp.Length(); linelng += tmp.Length();
} }
delete[] buffer; delete[] buffer;
output += _T("\"\"\"\n\n"); output += _T("\"\"\"\n\n");
return output; return output;
} }
@@ -662,9 +662,9 @@ void XmlResApp::MakePackagePython(const wxArrayString& flist)
wxFFile file(parOutput, wxT("wt")); wxFFile file(parOutput, wxT("wt"));
size_t i; size_t i;
if (flagVerbose) if (flagVerbose)
wxPrintf(_T("creating Python source file ") + parOutput + _T("...\n")); wxPrintf(_T("creating Python source file ") + parOutput + _T("...\n"));
file.Write( file.Write(
_T("#\n") _T("#\n")
_T("# This file was automatically generated by wxrc, do not edit by hand.\n") _T("# This file was automatically generated by wxrc, do not edit by hand.\n")
@@ -673,7 +673,7 @@ void XmlResApp::MakePackagePython(const wxArrayString& flist)
_T("from wxPython.xrc import *\n\n") _T("from wxPython.xrc import *\n\n")
); );
file.Write(_T("def ") + parFuncname + _T("():\n")); file.Write(_T("def ") + parFuncname + _T("():\n"));
for (i = 0; i < flist.Count(); i++) for (i = 0; i < flist.Count(); i++)
@@ -693,16 +693,16 @@ void XmlResApp::MakePackagePython(const wxArrayString& flist)
void XmlResApp::OutputGettext() void XmlResApp::OutputGettext()
{ {
wxArrayString str = FindStrings(); wxArrayString str = FindStrings();
wxFFile fout; wxFFile fout;
if (parOutput.empty()) if (parOutput.empty())
fout.Attach(stdout); fout.Attach(stdout);
else else
fout.Open(parOutput, wxT("wt")); fout.Open(parOutput, wxT("wt"));
for (size_t i = 0; i < str.GetCount(); i++) for (size_t i = 0; i < str.GetCount(); i++)
fout.Write(_T("_(\"") + str[i] + _T("\");\n")); fout.Write(_T("_(\"") + str[i] + _T("\");\n"));
if (!parOutput) fout.Detach(); if (!parOutput) fout.Detach();
} }
@@ -714,10 +714,10 @@ wxArrayString XmlResApp::FindStrings()
for (size_t i = 0; i < parFiles.Count(); i++) for (size_t i = 0; i < parFiles.Count(); i++)
{ {
if (flagVerbose) if (flagVerbose)
wxPrintf(_T("processing ") + parFiles[i] + _T("...\n")); wxPrintf(_T("processing ") + parFiles[i] + _T("...\n"));
wxXmlDocument doc; wxXmlDocument doc;
if (!doc.Load(parFiles[i])) if (!doc.Load(parFiles[i]))
{ {
wxLogError(_T("Error parsing file ") + parFiles[i]); wxLogError(_T("Error parsing file ") + parFiles[i]);
@@ -727,7 +727,7 @@ wxArrayString XmlResApp::FindStrings()
a2 = FindStrings(doc.GetRoot()); a2 = FindStrings(doc.GetRoot());
WX_APPEND_ARRAY(arr, a2); WX_APPEND_ARRAY(arr, a2);
} }
return arr; return arr;
} }
@@ -747,7 +747,7 @@ static wxString ConvertText(const wxString& str)
else else
str2 << wxT('&') << *dt; str2 << wxT('&') << *dt;
} }
else else
{ {
switch (*dt) switch (*dt)
{ {
@@ -759,7 +759,7 @@ static wxString ConvertText(const wxString& str)
(*(dt+1) != 'r')) (*(dt+1) != 'r'))
str2 << wxT("\\\\"); str2 << wxT("\\\\");
else else
str2 << wxT("\\"); str2 << wxT("\\");
break; break;
case wxT('"') : str2 << wxT("\\\""); break; case wxT('"') : str2 << wxT("\\\""); break;
default : str2 << *dt; break; default : str2 << *dt; break;
@@ -778,12 +778,12 @@ wxArrayString XmlResApp::FindStrings(wxXmlNode *node)
wxXmlNode *n = node; wxXmlNode *n = node;
if (n == NULL) return arr; if (n == NULL) return arr;
n = n->GetChildren(); n = n->GetChildren();
while (n) while (n)
{ {
if ((node->GetType() == wxXML_ELEMENT_NODE) && if ((node->GetType() == wxXML_ELEMENT_NODE) &&
// parent is an element, i.e. has subnodes... // parent is an element, i.e. has subnodes...
(n->GetType() == wxXML_TEXT_NODE || (n->GetType() == wxXML_TEXT_NODE ||
n->GetType() == wxXML_CDATA_SECTION_NODE) && n->GetType() == wxXML_CDATA_SECTION_NODE) &&
// ...it is textnode... // ...it is textnode...
( (
@@ -801,14 +801,14 @@ wxArrayString XmlResApp::FindStrings(wxXmlNode *node)
{ {
arr.Add(ConvertText(n->GetContent())); arr.Add(ConvertText(n->GetContent()));
} }
// subnodes: // subnodes:
if (n->GetType() == wxXML_ELEMENT_NODE) if (n->GetType() == wxXML_ELEMENT_NODE)
{ {
wxArrayString a2 = FindStrings(n); wxArrayString a2 = FindStrings(n);
WX_APPEND_ARRAY(arr, a2); WX_APPEND_ARRAY(arr, a2);
} }
n = n->GetNext(); n = n->GetNext();
} }
return arr; return arr;

View File

@@ -53,9 +53,9 @@ bool MyApp::OnInit()
wxInitAllImageHandlers(); wxInitAllImageHandlers();
wxFrame *frame = new EditorFrame(NULL, arg); wxFrame *frame = new EditorFrame(NULL, arg);
SetTopWindow(frame); SetTopWindow(frame);
frame->Show(TRUE); frame->Show(true);
PreviewFrame::Get()->Show(TRUE); PreviewFrame::Get()->Show(true);
PropertiesFrame::Get()->Show(TRUE); PropertiesFrame::Get()->Show(true);
return TRUE; return true;
} }

View File

@@ -101,13 +101,13 @@ class EditorTreeCtrl : public wxTreeCtrl
public: public:
EditorTreeCtrl(wxWindow *parent, int id, EditorFrame *frame) EditorTreeCtrl(wxWindow *parent, int id, EditorFrame *frame)
: wxTreeCtrl(parent, id), m_EdFrame(frame) {} : wxTreeCtrl(parent, id), m_EdFrame(frame) {}
private: private:
EditorFrame *m_EdFrame; EditorFrame *m_EdFrame;
void OnRightClick(wxMouseEvent &event) void OnRightClick(wxMouseEvent &event)
{ {
wxTreeItemId item = wxTreeItemId item =
m_EdFrame->m_TreeCtrl->HitTest(event.GetPosition()); m_EdFrame->m_TreeCtrl->HitTest(event.GetPosition());
if (item.IsOk()) if (item.IsOk())
{ {
@@ -123,7 +123,7 @@ BEGIN_EVENT_TABLE(EditorTreeCtrl, wxTreeCtrl)
END_EVENT_TABLE() END_EVENT_TABLE()
enum enum
{ {
ID_PREVIEW = wxID_HIGHEST + 100, ID_PREVIEW = wxID_HIGHEST + 100,
ID_NEW, ID_NEW,
@@ -133,19 +133,19 @@ enum
ID_SAVEAS, ID_SAVEAS,
ID_DELETE_NODE, ID_DELETE_NODE,
ID_EXIT, ID_EXIT,
ID_TREE, ID_TREE,
ID_CUT, ID_CUT,
ID_PASTE_SYBLING, ID_PASTE_SYBLING,
ID_PASTE_CHILD, ID_PASTE_CHILD,
ID_COPY, ID_COPY,
ID_NEWDIALOG, ID_NEWDIALOG,
ID_NEWFRAME, ID_NEWFRAME,
ID_NEWPANEL, ID_NEWPANEL,
ID_NEWMENU, ID_NEWMENU,
ID_NEWMENUBAR, ID_NEWMENUBAR,
ID_NEWTOOLBAR, ID_NEWTOOLBAR,
ID_NEWNODE = wxID_HIGHEST + 10000, // safely out of XRCID range :) ID_NEWNODE = wxID_HIGHEST + 10000, // safely out of XRCID range :)
ID_NEWSYBNODE = ID_NEWNODE + 20000 ID_NEWSYBNODE = ID_NEWNODE + 20000
}; };
@@ -183,16 +183,16 @@ END_EVENT_TABLE()
EditorFrame *EditorFrame::ms_Instance = NULL; EditorFrame *EditorFrame::ms_Instance = NULL;
EditorFrame::EditorFrame(wxFrame *parent, const wxString& filename) EditorFrame::EditorFrame(wxFrame *parent, const wxString& filename)
: wxFrame(parent, -1, filename + _("- wxWidgets resources editor")) : wxFrame(parent, wxID_ANY, filename + _("- wxWidgets resources editor"))
{ {
ms_Instance = this; ms_Instance = this;
m_Clipboard = NULL; m_Clipboard = NULL;
m_Modified = FALSE; m_Modified = false;
wxConfigBase *cfg = wxConfigBase::Get(); wxConfigBase *cfg = wxConfigBase::Get();
SetSize(wxRect(wxPoint(cfg->Read(_T("editor_x"), -1), cfg->Read(_T("editor_y"), -1)), SetSize(wxRect(wxPoint(cfg->Read(_T("editor_x"), wxDefaultPosition.x), cfg->Read(_T("editor_y"), wxDefaultPosition.y)),
wxSize(cfg->Read(_T("editor_w"), 400), cfg->Read(_T("editor_h"), 400)))); wxSize(cfg->Read(_T("editor_w"), 400), cfg->Read(_T("editor_h"), 400))));
m_SelectedNode = NULL; m_SelectedNode = NULL;
@@ -215,34 +215,34 @@ EditorFrame::EditorFrame(wxFrame *parent, const wxString& filename)
menuEdit->AppendSeparator(); menuEdit->AppendSeparator();
menuEdit->Append(ID_DELETE_NODE, _T("Delete")); menuEdit->Append(ID_DELETE_NODE, _T("Delete"));
menuEdit->Enable(ID_PASTE_SYBLING, FALSE); menuEdit->Enable(ID_PASTE_SYBLING, false);
menuEdit->Enable(ID_PASTE_CHILD, FALSE); menuEdit->Enable(ID_PASTE_CHILD, false);
wxMenuBar *menuBar = new wxMenuBar(); wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(menuFile, _T("&File")); menuBar->Append(menuFile, _T("&File"));
menuBar->Append(menuEdit, _T("&Edit")); menuBar->Append(menuEdit, _T("&Edit"));
SetMenuBar(menuBar); SetMenuBar(menuBar);
// Create toolbar: // Create toolbar:
wxToolBar *toolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT); wxToolBar *toolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT);
toolBar->SetMargins(2, 2); toolBar->SetMargins(2, 2);
toolBar->SetToolBitmapSize(wxSize(24, 24)); toolBar->SetToolBitmapSize(wxSize(24, 24));
toolBar -> AddTool(ID_EXIT, wxBITMAP(close), wxNullBitmap, toolBar -> AddTool(ID_EXIT, wxBITMAP(close), wxNullBitmap,
FALSE, -1, -1, (wxObject *) NULL, false, wxDefaultPosition.x, wxDefaultPosition.y, (wxObject *) NULL,
_("Quit the editor")); _("Quit the editor"));
toolBar -> AddTool(ID_OPEN, wxBITMAP(open), wxNullBitmap, toolBar -> AddTool(ID_OPEN, wxBITMAP(open), wxNullBitmap,
FALSE, -1, -1, (wxObject *) NULL, false, wxDefaultPosition.x, wxDefaultPosition.y, (wxObject *) NULL,
_("Open XML resource file")); _("Open XML resource file"));
toolBar -> AddTool(ID_SAVE, wxBITMAP(save), wxNullBitmap, toolBar -> AddTool(ID_SAVE, wxBITMAP(save), wxNullBitmap,
FALSE, -1, -1, (wxObject *) NULL, false, wxDefaultPosition.x, wxDefaultPosition.y, (wxObject *) NULL,
_("Save XML file")); _("Save XML file"));
toolBar -> AddTool(ID_PREVIEW, wxBITMAP(preview), wxNullBitmap, toolBar -> AddTool(ID_PREVIEW, wxBITMAP(preview), wxNullBitmap,
FALSE, -1, -1, (wxObject *) NULL, false, wxDefaultPosition.x, wxDefaultPosition.y, (wxObject *) NULL,
_("Preview")); _("Preview"));
toolBar -> Realize(); toolBar -> Realize();
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL); wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
// Create tree control: // Create tree control:
m_TreeCtrl = new EditorTreeCtrl(this, ID_TREE, this); m_TreeCtrl = new EditorTreeCtrl(this, ID_TREE, this);
wxImageList *imgList = new wxImageList(16, 16); wxImageList *imgList = new wxImageList(16, 16);
@@ -255,7 +255,7 @@ EditorFrame::EditorFrame(wxFrame *parent, const wxString& filename)
m_TreeCtrl->AssignImageList(imgList); m_TreeCtrl->AssignImageList(imgList);
sizer->Add(m_TreeCtrl, 1, wxEXPAND); sizer->Add(m_TreeCtrl, 1, wxEXPAND);
SetAutoLayout(TRUE); SetAutoLayout(true);
SetSizer(sizer); SetSizer(sizer);
// Load file: // Load file:
@@ -273,7 +273,7 @@ EditorFrame::~EditorFrame()
PropertiesFrame::Get()->Close(); PropertiesFrame::Get()->Close();
wxConfigBase *cfg = wxConfigBase::Get(); wxConfigBase *cfg = wxConfigBase::Get();
cfg->Write(_T("editor_x"), (long)GetPosition().x); cfg->Write(_T("editor_x"), (long)GetPosition().x);
cfg->Write(_T("editor_y"), (long)GetPosition().y); cfg->Write(_T("editor_y"), (long)GetPosition().y);
cfg->Write(_T("editor_w"), (long)GetSize().x); cfg->Write(_T("editor_w"), (long)GetSize().x);
@@ -290,14 +290,14 @@ void EditorFrame::LoadFile(const wxString& filename)
if (!AskToSave()) return; if (!AskToSave()) return;
delete m_Resource; delete m_Resource;
// create new resource in order to handle version differences properly // create new resource in order to handle version differences properly
PreviewFrame::Get()->ResetResource(); PreviewFrame::Get()->ResetResource();
m_FileName = wxEmptyString; m_FileName = wxEmptyString;
m_Resource = new wxXmlRcEditDocument; m_Resource = new wxXmlRcEditDocument;
m_Modified = FALSE; m_Modified = false;
if (!m_Resource->Load(filename, wxLocale::GetSystemEncodingName())) if (!m_Resource->Load(filename, wxLocale::GetSystemEncodingName()))
{ {
delete m_Resource; delete m_Resource;
@@ -321,12 +321,12 @@ void EditorFrame::LoadFile(const wxString& filename)
void EditorFrame::SaveFile(const wxString& filename) void EditorFrame::SaveFile(const wxString& filename)
{ {
m_FileName = filename; m_FileName = filename;
// save it: // save it:
if (!m_Resource->Save(filename)) if (!m_Resource->Save(filename))
wxLogError(_("Error saving ") + filename); wxLogError(_("Error saving ") + filename);
else else
m_Modified = FALSE; m_Modified = false;
RefreshTitle(); RefreshTitle();
} }
@@ -334,24 +334,24 @@ void EditorFrame::SaveFile(const wxString& filename)
void EditorFrame::NewFile() void EditorFrame::NewFile()
{ {
if (!AskToSave()) return; if (!AskToSave()) return;
delete m_Resource; delete m_Resource;
m_FileName = wxEmptyString; m_FileName = wxEmptyString;
m_Resource = new wxXmlRcEditDocument; m_Resource = new wxXmlRcEditDocument;
m_Resource->SetRoot(new wxXmlNode(wxXML_ELEMENT_NODE, _("resource"))); m_Resource->SetRoot(new wxXmlNode(wxXML_ELEMENT_NODE, _("resource")));
m_Resource->SetFileEncoding(_T("utf-8")); m_Resource->SetFileEncoding(_T("utf-8"));
#if !wxUSE_UNICODE #if !wxUSE_UNICODE
m_Resource->SetEncoding(wxLocale::GetSystemEncodingName()); m_Resource->SetEncoding(wxLocale::GetSystemEncodingName());
#endif #endif
m_Resource->GetRoot()->AddProperty(_T("version"), m_Resource->GetRoot()->AddProperty(_T("version"),
WX_XMLRES_CURRENT_VERSION_STRING); WX_XMLRES_CURRENT_VERSION_STRING);
m_Modified = FALSE; m_Modified = false;
RefreshTree(); RefreshTree();
RefreshTitle(); RefreshTitle();
} }
@@ -373,12 +373,12 @@ void EditorFrame::RefreshTitle()
void EditorFrame::RefreshTree() void EditorFrame::RefreshTree()
{ {
wxXmlNode *sel = m_SelectedNode; wxXmlNode *sel = m_SelectedNode;
m_TreeCtrl->DeleteAllItems(); m_TreeCtrl->DeleteAllItems();
wxTreeItemId root = m_TreeCtrl->AddRoot(_T("Resource: ") + wxFileNameFromPath(m_FileName), 5, 5); wxTreeItemId root = m_TreeCtrl->AddRoot(_T("Resource: ") + wxFileNameFromPath(m_FileName), 5, 5);
wxXmlNode *n = m_Resource->GetRoot()->GetChildren(); wxXmlNode *n = m_Resource->GetRoot()->GetChildren();
while (n) while (n)
{ {
if (n->GetType() == wxXML_ELEMENT_NODE) if (n->GetType() == wxXML_ELEMENT_NODE)
@@ -417,32 +417,32 @@ bool EditorFrame::SelectNode(wxXmlNode *node, wxTreeItemId *root)
XmlTreeData *dt; XmlTreeData *dt;
wxXmlNode *nd; wxXmlNode *nd;
void* cookie; void* cookie;
item = m_TreeCtrl->GetFirstChild(*root, cookie); item = m_TreeCtrl->GetFirstChild(*root, cookie);
while (item.IsOk()) while (item.IsOk())
{ {
dt = (XmlTreeData*)(m_TreeCtrl->GetItemData(item)); dt = (XmlTreeData*)(m_TreeCtrl->GetItemData(item));
nd = (dt) ? dt->Node : NULL; nd = (dt) ? dt->Node : NULL;
if (nd == node) if (nd == node)
{ {
RecursivelyExpand(m_TreeCtrl, *root); RecursivelyExpand(m_TreeCtrl, *root);
m_TreeCtrl->SelectItem(item); m_TreeCtrl->SelectItem(item);
m_TreeCtrl->EnsureVisible(item); m_TreeCtrl->EnsureVisible(item);
return TRUE; return true;
} }
if (m_TreeCtrl->ItemHasChildren(item) && SelectNode(node, &item)) if (m_TreeCtrl->ItemHasChildren(item) && SelectNode(node, &item))
return TRUE; return true;
item = m_TreeCtrl->GetNextChild(*root, cookie); item = m_TreeCtrl->GetNextChild(*root, cookie);
} }
return FALSE; return false;
} }
wxTreeItemId EditorFrame::CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent, wxXmlNode *node) wxTreeItemId EditorFrame::CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent, wxXmlNode *node)
{ {
if (!node) if (!node)
{ {
wxTreeItemId invalid; wxTreeItemId invalid;
return invalid; return invalid;
@@ -461,7 +461,7 @@ void EditorFrame::NotifyChanged(int change_type)
if (change_type & CHANGED_TREE_SELECTED) if (change_type & CHANGED_TREE_SELECTED)
{ {
wxTreeItemId sel = m_TreeCtrl->GetSelection(); wxTreeItemId sel = m_TreeCtrl->GetSelection();
m_TreeCtrl->SetItemText(sel, m_TreeCtrl->SetItemText(sel,
NodeHandler::Find(m_SelectedNode)->GetTreeString(m_SelectedNode)); NodeHandler::Find(m_SelectedNode)->GetTreeString(m_SelectedNode));
} }
@@ -471,13 +471,13 @@ void EditorFrame::NotifyChanged(int change_type)
int icon = NodeHandler::Find(m_SelectedNode)->GetTreeIcon(m_SelectedNode); int icon = NodeHandler::Find(m_SelectedNode)->GetTreeIcon(m_SelectedNode);
m_TreeCtrl->SetItemImage(sel, icon); m_TreeCtrl->SetItemImage(sel, icon);
} }
if (!m_Modified) if (!m_Modified)
{ {
m_Modified = TRUE; m_Modified = true;
RefreshTitle(); RefreshTitle();
} }
PreviewFrame::Get()->MakeDirty(); PreviewFrame::Get()->MakeDirty();
} }
@@ -486,8 +486,8 @@ void EditorFrame::NotifyChanged(int change_type)
void EditorFrame::OnTreeSel(wxTreeEvent& event) void EditorFrame::OnTreeSel(wxTreeEvent& event)
{ {
XmlTreeData *dt = (XmlTreeData*)(m_TreeCtrl->GetItemData(event.GetItem())); XmlTreeData *dt = (XmlTreeData*)(m_TreeCtrl->GetItemData(event.GetItem()));
wxXmlNode *node = (dt) ? dt->Node : NULL; wxXmlNode *node = (dt) ? dt->Node : NULL;
m_SelectedNode = node; m_SelectedNode = node;
if (node) if (node)
PropertiesFrame::Get()->ShowProps(node); PropertiesFrame::Get()->ShowProps(node);
@@ -512,7 +512,7 @@ void EditorFrame::OnTreeSel(wxTreeEvent& event)
void EditorFrame::OnToolbar(wxCommandEvent& event) void EditorFrame::OnToolbar(wxCommandEvent& event)
{ {
switch (event.GetId()) switch (event.GetId())
{ {
case ID_PREVIEW : case ID_PREVIEW :
{ {
@@ -523,7 +523,7 @@ void EditorFrame::OnToolbar(wxCommandEvent& event)
} }
case ID_EXIT : case ID_EXIT :
Close(TRUE); Close(true);
break; break;
case ID_NEW : case ID_NEW :
@@ -581,7 +581,7 @@ void EditorFrame::OnNewNode(wxCommandEvent& event)
{ {
if (event.GetId() >= ID_NEWSYBNODE) if (event.GetId() >= ID_NEWSYBNODE)
{ {
XmlTreeData *pardt = XmlTreeData *pardt =
(XmlTreeData*)(m_TreeCtrl->GetItemData( (XmlTreeData*)(m_TreeCtrl->GetItemData(
m_TreeCtrl->GetItemParent(m_TreeCtrl->GetSelection()))); m_TreeCtrl->GetItemParent(m_TreeCtrl->GetSelection())));
@@ -616,21 +616,21 @@ void EditorFrame::OnNewNode(wxCommandEvent& event)
wxTreeItemId root = m_TreeCtrl->GetSelection(); wxTreeItemId root = m_TreeCtrl->GetSelection();
SelectNode(node, &root); SelectNode(node, &root);
} }
else else
{ {
wxString name; wxString name;
switch (event.GetId()) switch (event.GetId())
{ {
case ID_NEWDIALOG : name = _T("wxDialog"); break; case ID_NEWDIALOG : name = _T("wxDialog"); break;
case ID_NEWFRAME : name = _T("wxFrame"); break; case ID_NEWFRAME : name = _T("wxFrame"); break;
case ID_NEWPANEL : name = _T("wxPanel"); break; case ID_NEWPANEL : name = _T("wxPanel"); break;
case ID_NEWMENU : name = _T("wxMenu"); break; case ID_NEWMENU : name = _T("wxMenu"); break;
case ID_NEWMENUBAR : name = _T("wxMenuBar"); break; case ID_NEWMENUBAR : name = _T("wxMenuBar"); break;
case ID_NEWTOOLBAR : name = _T("wxToolBar"); break; case ID_NEWTOOLBAR : name = _T("wxToolBar"); break;
default : return; // never occurs default : return; // never occurs
} }
wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, _T("object")); wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, _T("object"));
node->AddProperty(_T("class"), name); node->AddProperty(_T("class"), name);
m_Resource->GetRoot()->AddChild(node); m_Resource->GetRoot()->AddChild(node);
@@ -644,22 +644,22 @@ void EditorFrame::OnNewNode(wxCommandEvent& event)
void EditorFrame::OnRightClickTree(wxPoint pos) void EditorFrame::OnRightClickTree(wxPoint pos)
{ {
wxMenu *popup = new wxMenu; wxMenu *popup = new wxMenu;
if (m_SelectedNode == NULL || m_SelectedNode == m_Resource->GetRoot()) if (m_SelectedNode == NULL || m_SelectedNode == m_Resource->GetRoot())
{ {
popup->Append(ID_NEWDIALOG, _("New wxDialog")); popup->Append(ID_NEWDIALOG, _("New wxDialog"));
popup->Append(ID_NEWFRAME, _("New wxFrame")); popup->Append(ID_NEWFRAME, _("New wxFrame"));
popup->Append(ID_NEWPANEL, _("New wxPanel")); popup->Append(ID_NEWPANEL, _("New wxPanel"));
popup->Append(ID_NEWMENU, _("New wxMenu")); popup->Append(ID_NEWMENU, _("New wxMenu"));
popup->Append(ID_NEWMENUBAR, _("New wxMenuBar")); popup->Append(ID_NEWMENUBAR, _("New wxMenuBar"));
popup->Append(ID_NEWTOOLBAR, _("New wxToolBar")); popup->Append(ID_NEWTOOLBAR, _("New wxToolBar"));
} }
else else
{ {
bool has_children; bool has_children;
{ {
wxArrayString& arr = wxArrayString& arr =
NodeHandler::Find(NodeHandler::Find(m_SelectedNode)->GetRealNode(m_SelectedNode))-> NodeHandler::Find(NodeHandler::Find(m_SelectedNode)->GetRealNode(m_SelectedNode))->
GetChildTypes(); GetChildTypes();
@@ -672,7 +672,7 @@ void EditorFrame::OnRightClickTree(wxPoint pos)
{ {
news2->Append(i + ID_NEWNODE, arr[i]); news2->Append(i + ID_NEWNODE, arr[i]);
#ifdef __WXGTK__ // doesn't support Break #ifdef __WXGTK__ // doesn't support Break
if (i % 20 == 19) if (i % 20 == 19)
{ {
wxMenu *m = new wxMenu; wxMenu *m = new wxMenu;
news2->Append(ID_NEWNODE+arr.GetCount(), _("More..."), m); news2->Append(ID_NEWNODE+arr.GetCount(), _("More..."), m);
@@ -687,13 +687,13 @@ void EditorFrame::OnRightClickTree(wxPoint pos)
} }
XmlTreeData *pardt = XmlTreeData *pardt =
(XmlTreeData*)(m_TreeCtrl->GetItemData( (XmlTreeData*)(m_TreeCtrl->GetItemData(
m_TreeCtrl->GetItemParent(m_TreeCtrl->GetSelection()))); m_TreeCtrl->GetItemParent(m_TreeCtrl->GetSelection())));
if (pardt && pardt->Node && pardt->Node != m_Resource->GetRoot()) if (pardt && pardt->Node && pardt->Node != m_Resource->GetRoot())
{ {
wxXmlNode *nd = pardt->Node; wxXmlNode *nd = pardt->Node;
wxArrayString& arr = wxArrayString& arr =
NodeHandler::Find(NodeHandler::Find(nd)->GetRealNode(nd))-> NodeHandler::Find(NodeHandler::Find(nd)->GetRealNode(nd))->
GetChildTypes(); GetChildTypes();
@@ -705,7 +705,7 @@ void EditorFrame::OnRightClickTree(wxPoint pos)
{ {
news2->Append(i + ID_NEWSYBNODE, arr[i]); news2->Append(i + ID_NEWSYBNODE, arr[i]);
#ifdef __WXGTK__ // doesn't support Break #ifdef __WXGTK__ // doesn't support Break
if (i % 20 == 19) if (i % 20 == 19)
{ {
wxMenu *m = new wxMenu; wxMenu *m = new wxMenu;
news2->Append(ID_NEWSYBNODE+arr.GetCount(), _("More..."), m); news2->Append(ID_NEWSYBNODE+arr.GetCount(), _("More..."), m);
@@ -730,7 +730,7 @@ void EditorFrame::OnRightClickTree(wxPoint pos)
popup->Enable(ID_PASTE_SYBLING, m_Clipboard != NULL); popup->Enable(ID_PASTE_SYBLING, m_Clipboard != NULL);
popup->Enable(ID_PASTE_CHILD, has_children && m_Clipboard != NULL); popup->Enable(ID_PASTE_CHILD, has_children && m_Clipboard != NULL);
} }
m_TreeCtrl->PopupMenu(popup, pos); m_TreeCtrl->PopupMenu(popup, pos);
delete popup; delete popup;
} }
@@ -745,14 +745,14 @@ void EditorFrame::OnClipboardAction(wxCommandEvent& event)
case ID_CUT: case ID_CUT:
delete m_Clipboard; delete m_Clipboard;
m_Clipboard = new wxXmlNode(*m_SelectedNode); m_Clipboard = new wxXmlNode(*m_SelectedNode);
GetMenuBar()->Enable(ID_PASTE_SYBLING, TRUE); GetMenuBar()->Enable(ID_PASTE_SYBLING, true);
GetMenuBar()->Enable(ID_PASTE_CHILD, TRUE); GetMenuBar()->Enable(ID_PASTE_CHILD, true);
if (event.GetId() == ID_CUT) DeleteSelectedNode(); if (event.GetId() == ID_CUT) DeleteSelectedNode();
break; break;
case ID_PASTE_SYBLING: case ID_PASTE_SYBLING:
{ {
XmlTreeData *pardt = XmlTreeData *pardt =
(XmlTreeData*)(m_TreeCtrl->GetItemData( (XmlTreeData*)(m_TreeCtrl->GetItemData(
m_TreeCtrl->GetItemParent(m_TreeCtrl->GetSelection()))); m_TreeCtrl->GetItemParent(m_TreeCtrl->GetSelection())));
@@ -769,7 +769,7 @@ void EditorFrame::OnClipboardAction(wxCommandEvent& event)
} }
} }
break; break;
case ID_PASTE_CHILD: case ID_PASTE_CHILD:
wxXmlNode *realnode = NodeHandler::Find(m_SelectedNode)->GetRealNode(m_SelectedNode); wxXmlNode *realnode = NodeHandler::Find(m_SelectedNode)->GetRealNode(m_SelectedNode);
NodeHandler *hnd = NodeHandler::Find(realnode); NodeHandler *hnd = NodeHandler::Find(realnode);
@@ -786,12 +786,12 @@ void EditorFrame::OnClipboardAction(wxCommandEvent& event)
bool EditorFrame::AskToSave() bool EditorFrame::AskToSave()
// asks the user to save current document (if modified) // asks the user to save current document (if modified)
// returns FALSE if user cancelled the action, TRUE of he choosed // returns false if user cancelled the action, true of he choosed
// 'yes' or 'no' // 'yes' or 'no'
{ {
if (!m_Modified) return TRUE; if (!m_Modified) return true;
int res = wxMessageBox(_("File modified. Do you want to save changes?"), _("Save changes"), int res = wxMessageBox(_("File modified. Do you want to save changes?"), _("Save changes"),
wxYES_NO | wxCANCEL | wxCENTRE | wxICON_QUESTION); wxYES_NO | wxCANCEL | wxCENTRE | wxICON_QUESTION);
if (res == wxYES) if (res == wxYES)
SaveFile(m_FileName); SaveFile(m_FileName);

View File

@@ -63,7 +63,7 @@ class EditorFrame : public wxFrame
{ {
public: public:
friend class EditorTreeCtrl; friend class EditorTreeCtrl;
EditorFrame(wxFrame *parent, const wxString& filename); EditorFrame(wxFrame *parent, const wxString& filename);
~EditorFrame(); ~EditorFrame();
@@ -71,31 +71,31 @@ class EditorFrame : public wxFrame
void NewFile(); void NewFile();
void SaveFile(const wxString& filename); void SaveFile(const wxString& filename);
wxString GetFileName() { return m_FileName; } wxString GetFileName() { return m_FileName; }
void RefreshTree(); void RefreshTree();
void RefreshTitle(); void RefreshTitle();
bool SelectNode(wxXmlNode *node, wxTreeItemId *root = NULL); bool SelectNode(wxXmlNode *node, wxTreeItemId *root = NULL);
wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent, wxXmlNode *node); wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent, wxXmlNode *node);
void NotifyChanged(int change_type); void NotifyChanged(int change_type);
static EditorFrame *Get() { return ms_Instance; } static EditorFrame *Get() { return ms_Instance; }
private: private:
static EditorFrame *ms_Instance; static EditorFrame *ms_Instance;
wxTreeCtrl *m_TreeCtrl; wxTreeCtrl *m_TreeCtrl;
wxXmlNode *m_SelectedNode; wxXmlNode *m_SelectedNode;
wxXmlNode *m_Clipboard; wxXmlNode *m_Clipboard;
wxString m_FileName; wxString m_FileName;
wxXmlRcEditDocument *m_Resource; wxXmlRcEditDocument *m_Resource;
bool m_Modified; bool m_Modified;
bool AskToSave(); bool AskToSave();
void DeleteSelectedNode(); void DeleteSelectedNode();

View File

@@ -33,16 +33,16 @@
wxList NodeHandler::ms_Handlers; wxList NodeHandler::ms_Handlers;
bool NodeHandler::ms_HandlersLoaded = FALSE; bool NodeHandler::ms_HandlersLoaded = false;
NodeHandler *NodeHandler::Find(wxXmlNode *node) NodeHandler *NodeHandler::Find(wxXmlNode *node)
{ {
if (!ms_HandlersLoaded) if (!ms_HandlersLoaded)
{ {
ms_HandlersLoaded = TRUE; ms_HandlersLoaded = true;
ms_Handlers.DeleteContents(TRUE); ms_Handlers.DeleteContents(true);
NodeInfoArray& arr = NodesDb::Get()->GetNodesInfo(); NodeInfoArray& arr = NodesDb::Get()->GetNodesInfo();
NodeHandler *hnd; NodeHandler *hnd;
for (size_t i = 0; i < arr.GetCount(); i++) for (size_t i = 0; i < arr.GetCount(); i++)
@@ -63,7 +63,7 @@ NodeHandler *NodeHandler::Find(wxXmlNode *node)
hnd = new NodeHandler(&(arr[i])); hnd = new NodeHandler(&(arr[i]));
if (hnd) ms_Handlers.Append(hnd); if (hnd) ms_Handlers.Append(hnd);
} }
ms_Handlers.Append(new NodeHandlerUnknown); ms_Handlers.Append(new NodeHandlerUnknown);
} }
wxNode *n = ms_Handlers.GetFirst(); wxNode *n = ms_Handlers.GetFirst();
@@ -80,7 +80,7 @@ NodeHandler *NodeHandler::Find(wxXmlNode *node)
NodeHandler::NodeHandler(NodeInfo *ni) : NodeHandler::NodeHandler(NodeInfo *ni) :
m_NodeInfo(ni) m_NodeInfo(ni)
{ {
} }
@@ -107,12 +107,12 @@ PropertyInfoArray& NodeHandler::GetPropsList(wxXmlNode *WXUNUSED(node))
wxTreeItemId NodeHandler::CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId NodeHandler::CreateTreeNode(wxTreeCtrl *treectrl,
wxTreeItemId parent, wxTreeItemId parent,
wxXmlNode *node) wxXmlNode *node)
{ {
int icon = GetTreeIcon(node); int icon = GetTreeIcon(node);
wxTreeItemId item = wxTreeItemId item =
treectrl->AppendItem(parent, GetTreeString(node), treectrl->AppendItem(parent, GetTreeString(node),
icon, icon, new XmlTreeData(node)); icon, icon, new XmlTreeData(node));
if (parent == treectrl->GetRootItem()) if (parent == treectrl->GetRootItem())
@@ -140,14 +140,14 @@ wxArrayString& NodeHandler::GetChildTypes()
{ {
wxString basetype = m_NodeInfo->ChildType; wxString basetype = m_NodeInfo->ChildType;
NodeInfoArray& arr = NodesDb::Get()->GetNodesInfo(); NodeInfoArray& arr = NodesDb::Get()->GetNodesInfo();
for (size_t i = 0; i < arr.GetCount(); i++) for (size_t i = 0; i < arr.GetCount(); i++)
{ {
NodeInfo &ni = arr[i]; NodeInfo &ni = arr[i];
if (ni.NodeClass == basetype && !ni.Abstract) if (ni.NodeClass == basetype && !ni.Abstract)
m_ChildTypes.Add(ni.NodeClass); m_ChildTypes.Add(ni.NodeClass);
if (ni.DerivedFrom.Index(basetype) != wxNOT_FOUND && !ni.Abstract) if (ni.DerivedFrom.Index(basetype) != wxNOT_FOUND && !ni.Abstract)
m_ChildTypes.Add(ni.NodeClass); m_ChildTypes.Add(ni.NodeClass);
} }
@@ -172,12 +172,12 @@ void NodeHandler::InsertNode(wxXmlNode *WXUNUSED(parent), wxXmlNode *node, wxXml
wxTreeItemId NodeHandlerPanel::CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId NodeHandlerPanel::CreateTreeNode(wxTreeCtrl *treectrl,
wxTreeItemId parent, wxTreeItemId parent,
wxXmlNode *node) wxXmlNode *node)
{ {
wxTreeItemId root = NodeHandler::CreateTreeNode(treectrl, parent, node); wxTreeItemId root = NodeHandler::CreateTreeNode(treectrl, parent, node);
wxXmlNode *n = XmlFindNode(node, _T("object")); wxXmlNode *n = XmlFindNode(node, _T("object"));
while (n) while (n)
@@ -207,7 +207,7 @@ void NodeHandlerPanel::InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode
void NodeHandlerSizer::InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before) void NodeHandlerSizer::InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before)
{ {
if (XmlGetClass(node) == _T("spacer") || XmlGetClass(node) == _T("sizeritem")) if (XmlGetClass(node) == _T("spacer") || XmlGetClass(node) == _T("sizeritem"))
{ {
if (insert_before) if (insert_before)
@@ -244,7 +244,7 @@ int NodeHandlerSizer::GetTreeIcon(wxXmlNode *node)
wxTreeItemId NodeHandlerSizerItem::CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId NodeHandlerSizerItem::CreateTreeNode(wxTreeCtrl *treectrl,
wxTreeItemId parent, wxTreeItemId parent,
wxXmlNode *node) wxXmlNode *node)
{ {
@@ -265,11 +265,11 @@ PropertyInfoArray& NodeHandlerSizerItem::GetPropsList(wxXmlNode *node)
wxXmlNode *nd = GetRealNode(node); wxXmlNode *nd = GetRealNode(node);
m_dummy.Add(PropertyInfo(wxEmptyString, wxEmptyString, wxEmptyString)); m_dummy.Add(PropertyInfo(wxEmptyString, wxEmptyString, wxEmptyString));
size_t pos = m_dummy.GetCount(); size_t pos = m_dummy.GetCount();
WX_APPEND_ARRAY(m_dummy, WX_APPEND_ARRAY(m_dummy,
Find(nd)->GetPropsList(nd)); Find(nd)->GetPropsList(nd));
for (size_t i = pos; i < m_dummy.GetCount(); i++) for (size_t i = pos; i < m_dummy.GetCount(); i++)
m_dummy[i].Name = _T("object/") + m_dummy[i].Name; m_dummy[i].Name = _T("object/") + m_dummy[i].Name;
return m_dummy; return m_dummy;
} }
@@ -302,10 +302,10 @@ wxXmlNode *NodeHandlerSizerItem::GetRealNode(wxXmlNode *node)
void NodeHandlerNotebook::InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before) void NodeHandlerNotebook::InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before)
{ {
{ {
wxXmlNode *itemnode; wxXmlNode *itemnode;
if (XmlGetClass(node) == _T("notebookpage")) if (XmlGetClass(node) == _T("notebookpage"))
itemnode = node; itemnode = node;
else else

View File

@@ -32,10 +32,10 @@ class NodeHandler : public wxObject
{ {
public: public:
static NodeHandler *Find(wxXmlNode *node); static NodeHandler *Find(wxXmlNode *node);
NodeHandler(NodeInfo *ni); NodeHandler(NodeInfo *ni);
virtual ~NodeHandler(); virtual ~NodeHandler();
virtual bool CanHandle(wxXmlNode *node); virtual bool CanHandle(wxXmlNode *node);
virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent, virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent,
wxXmlNode *node); wxXmlNode *node);
@@ -45,12 +45,12 @@ class NodeHandler : public wxObject
wxArrayString& GetChildTypes(); wxArrayString& GetChildTypes();
virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL); virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL);
virtual wxXmlNode *GetRealNode(wxXmlNode *node) { return node; } virtual wxXmlNode *GetRealNode(wxXmlNode *node) { return node; }
protected: protected:
NodeInfo *m_NodeInfo; NodeInfo *m_NodeInfo;
wxArrayString m_ChildTypes; wxArrayString m_ChildTypes;
static wxList ms_Handlers; static wxList ms_Handlers;
static bool ms_HandlersLoaded; static bool ms_HandlersLoaded;
}; };
@@ -60,7 +60,7 @@ class NodeHandlerPanel : public NodeHandler
{ {
public: public:
NodeHandlerPanel(NodeInfo *ni) : NodeHandler(ni) {} NodeHandlerPanel(NodeInfo *ni) : NodeHandler(ni) {}
virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent, virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent,
wxXmlNode *node); wxXmlNode *node);
virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL); virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL);
@@ -72,7 +72,7 @@ class NodeHandlerSizer : public NodeHandlerPanel
{ {
public: public:
NodeHandlerSizer(NodeInfo *ni) : NodeHandlerPanel(ni) {} NodeHandlerSizer(NodeInfo *ni) : NodeHandlerPanel(ni) {}
virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL); virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL);
virtual int GetTreeIcon(wxXmlNode *node); virtual int GetTreeIcon(wxXmlNode *node);
}; };
@@ -102,7 +102,7 @@ class NodeHandlerNotebook : public NodeHandlerPanel
{ {
public: public:
NodeHandlerNotebook(NodeInfo *ni) : NodeHandlerPanel(ni) {} NodeHandlerNotebook(NodeInfo *ni) : NodeHandlerPanel(ni) {}
virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL); virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL);
}; };
@@ -111,7 +111,7 @@ class NodeHandlerNotebook : public NodeHandlerPanel
class NodeHandlerNotebookPage : public NodeHandlerSizerItem class NodeHandlerNotebookPage : public NodeHandlerSizerItem
{ {
public: public:
NodeHandlerNotebookPage(NodeInfo *ni) : NodeHandlerNotebookPage(NodeInfo *ni) :
NodeHandlerSizerItem(ni) {} NodeHandlerSizerItem(ni) {}
}; };
@@ -122,9 +122,9 @@ class NodeHandlerUnknown : public NodeHandler
{ {
public: public:
NodeHandlerUnknown() : NodeHandler(new NodeInfo) {} NodeHandlerUnknown() : NodeHandler(new NodeInfo) {}
virtual bool CanHandle(wxXmlNode *WXUNUSED(node)) { return TRUE; } virtual bool CanHandle(wxXmlNode *WXUNUSED(node)) { return true; }
}; };
#endif #endif

View File

@@ -34,17 +34,17 @@ void NodeInfo::Read(const wxString& filename, wxPathList& list)
{ {
wxString tp; wxString tp;
wxString nd, cht; wxString nd, cht;
bool ab = FALSE; bool ab = false;
long icn = -1; long icn = -1;
NodeClass.Empty(); NodeClass.Empty();
wxString path = list.FindValidPath(filename); wxString path = list.FindValidPath(filename);
if (path.IsEmpty()) return; if (path.IsEmpty()) return;
wxTextFile tf; wxTextFile tf;
tf.Open(path); tf.Open(path);
if (!tf.IsOpened()) return; if (!tf.IsOpened()) return;
for (size_t i = 0; i < tf.GetLineCount(); i++) for (size_t i = 0; i < tf.GetLineCount(); i++)
@@ -80,8 +80,8 @@ void NodeInfo::Read(const wxString& filename, wxPathList& list)
tkn.GetNextToken(); tkn.GetNextToken();
pi.Type = tkn.GetNextToken(); pi.Type = tkn.GetNextToken();
if (tkn.HasMoreTokens()) pi.MoreInfo = tkn.GetNextToken(); if (tkn.HasMoreTokens()) pi.MoreInfo = tkn.GetNextToken();
bool fnd = FALSE; bool fnd = false;
for (size_t j = 0; j < Props.GetCount(); j++) for (size_t j = 0; j < Props.GetCount(); j++)
{ {
if (Props[j].Name == pi.Name) if (Props[j].Name == pi.Name)
@@ -90,14 +90,14 @@ void NodeInfo::Read(const wxString& filename, wxPathList& list)
Props[j].MoreInfo << _T(',') << pi.MoreInfo; Props[j].MoreInfo << _T(',') << pi.MoreInfo;
else else
Props[j] = pi; Props[j] = pi;
fnd = TRUE; fnd = true;
} }
} }
if (!fnd) Props.Add(pi); if (!fnd) Props.Add(pi);
} }
} }
if (!nd.IsEmpty()) NodeClass = nd; if (!nd.IsEmpty()) NodeClass = nd;
if (!cht.IsEmpty()) ChildType = cht; if (!cht.IsEmpty()) ChildType = cht;
if (!!tp) Type = tp; if (!!tp) Type = tp;
@@ -117,7 +117,7 @@ NodesDb* NodesDb::ms_Instance = NULL;
NodesDb *NodesDb::Get() NodesDb *NodesDb::Get()
{ {
if (ms_Instance == NULL) if (ms_Instance == NULL)
{ {
(void)new NodesDb; (void)new NodesDb;
} }
@@ -131,7 +131,7 @@ NodesDb::NodesDb()
m_Paths.Add(_T(".")); m_Paths.Add(_T("."));
m_Paths.Add(_T("./df")); m_Paths.Add(_T("./df"));
#ifdef __UNIX__ #ifdef __UNIX__
m_Paths.Add(wxGetHomeDir() + _T("/.wxrcedit")); m_Paths.Add(wxGetHomeDir() + _T("/.wxrcedit"));
#ifdef wxINSTALL_PREFIX #ifdef wxINSTALL_PREFIX
m_Paths.Add(wxINSTALL_PREFIX _T("/share/wx/wxrcedit")); m_Paths.Add(wxINSTALL_PREFIX _T("/share/wx/wxrcedit"));
@@ -154,7 +154,7 @@ void NodesDb::Load()
void NodesDb::LoadDir(const wxString& path) void NodesDb::LoadDir(const wxString& path)
{ {
if (!wxDirExists(path)) return; if (!wxDirExists(path)) return;
wxDir dir(path); wxDir dir(path);
wxString filename; wxString filename;
bool cont; bool cont;
@@ -171,20 +171,20 @@ void NodesDb::LoadDir(const wxString& path)
void NodesDb::LoadFile(const wxString& file) void NodesDb::LoadFile(const wxString& file)
{ {
NodeInfo *ni = new NodeInfo; NodeInfo *ni = new NodeInfo;
ni->Type = wxEmptyString; ni->Type = wxEmptyString;
ni->Icon = 0; ni->Icon = 0;
wxPathList paths; wxPathList paths;
size_t i; size_t i;
for (i = 0; i < m_Paths.GetCount(); i++) for (i = 0; i < m_Paths.GetCount(); i++)
paths.Add(m_Paths[i]); paths.Add(m_Paths[i]);
ni->Read(file, paths); ni->Read(file, paths);
// maybe we already parsed it? // maybe we already parsed it?
for (i = 0; i < m_Infos.GetCount(); i++) for (i = 0; i < m_Infos.GetCount(); i++)
if (m_Infos[i].NodeClass == ni->NodeClass) return; if (m_Infos[i].NodeClass == ni->NodeClass) return;
m_Infos.Add(ni); m_Infos.Add(ni);
} }

View File

@@ -28,13 +28,13 @@ class PropertyInfo
PropertyInfo() {} PropertyInfo() {}
PropertyInfo(const wxString& atype, const wxString& aname, const wxString& amoreinfo) PropertyInfo(const wxString& atype, const wxString& aname, const wxString& amoreinfo)
: Type(atype), Name(aname), MoreInfo(amoreinfo) {} : Type(atype), Name(aname), MoreInfo(amoreinfo) {}
PropertyInfo& operator=(const PropertyInfo& p) PropertyInfo& operator=(const PropertyInfo& p)
{ {
Type = p.Type; Name = p.Name; MoreInfo = p.MoreInfo; Type = p.Type; Name = p.Name; MoreInfo = p.MoreInfo;
return *this; return *this;
} }
wxString Type; wxString Type;
wxString Name; wxString Name;
wxString MoreInfo; wxString MoreInfo;
@@ -47,13 +47,13 @@ class NodeInfo
{ {
public: public:
wxString NodeClass; wxString NodeClass;
wxString Type; wxString Type;
PropertyInfoArray Props; PropertyInfoArray Props;
wxArrayString DerivedFrom; wxArrayString DerivedFrom;
bool Abstract; bool Abstract;
wxString ChildType; wxString ChildType;
int Icon; int Icon;
void Read(const wxString& filename, wxPathList& list); void Read(const wxString& filename, wxPathList& list);
}; };
@@ -65,15 +65,15 @@ class NodesDb
{ {
public: public:
NodesDb(); NodesDb();
void Load(); void Load();
void LoadDir(const wxString& path); void LoadDir(const wxString& path);
void LoadFile(const wxString& file); void LoadFile(const wxString& file);
NodeInfoArray& GetNodesInfo() { return m_Infos; } NodeInfoArray& GetNodesInfo() { return m_Infos; }
static NodesDb *Get(); static NodesDb *Get();
private: private:
static NodesDb *ms_Instance; static NodesDb *ms_Instance;
NodeInfoArray m_Infos; NodeInfoArray m_Infos;
@@ -82,4 +82,4 @@ class NodesDb
#endif #endif

View File

@@ -36,7 +36,7 @@
wxWindow* PropEditCtrlFont::CreateEditCtrl() wxWindow* PropEditCtrlFont::CreateEditCtrl()
{ {
PropEditCtrlTxt::CreateEditCtrl(); PropEditCtrlTxt::CreateEditCtrl();
m_TextCtrl->Enable(FALSE); m_TextCtrl->Enable(false);
return m_TextCtrl; return m_TextCtrl;
} }
@@ -61,18 +61,18 @@ wxTreeItemId PropEditCtrlFont::CreateTreeEntry(wxTreeItemId parent, const Proper
BEGIN_EVENT_TABLE(PropEditCtrlChoice, PropEditCtrl) BEGIN_EVENT_TABLE(PropEditCtrlChoice, PropEditCtrl)
EVT_CHOICE(-1, PropEditCtrlChoice::OnChoice) EVT_CHOICE(wxID_ANY, PropEditCtrlChoice::OnChoice)
END_EVENT_TABLE() END_EVENT_TABLE()
wxWindow* PropEditCtrlChoice::CreateEditCtrl() wxWindow* PropEditCtrlChoice::CreateEditCtrl()
{ {
m_Choice = new wxChoice(this, -1); m_Choice = new wxChoice(this, wxID_ANY);
return m_Choice; return m_Choice;
} }
void PropEditCtrlChoice::ReadValue() void PropEditCtrlChoice::ReadValue()
{ {
wxStringTokenizer tkn(m_PropInfo->MoreInfo, _T(",")); wxStringTokenizer tkn(m_PropInfo->MoreInfo, _T(","));
@@ -96,10 +96,10 @@ void PropEditCtrlChoice::WriteValue()
void PropEditCtrlChoice::OnChoice(wxCommandEvent& WXUNUSED(event)) void PropEditCtrlChoice::OnChoice(wxCommandEvent& WXUNUSED(event))
{ {
if (CanSave()) if (CanSave())
{ {
WriteValue(); WriteValue();
EditorFrame::Get()->NotifyChanged(CHANGED_PROPS); EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);
} }
} }
@@ -112,11 +112,11 @@ void PropEditCtrlColor::OnDetails()
wxColour clr; wxColour clr;
wxString txt = m_TextCtrl->GetValue(); wxString txt = m_TextCtrl->GetValue();
long unsigned tmp; long unsigned tmp;
if (txt.Length() == 7 && txt[0u] == _T('#') && if (txt.Length() == 7 && txt[0u] == _T('#') &&
wxSscanf(txt.c_str(), _T("#%lX"), &tmp) == 1) wxSscanf(txt.c_str(), _T("#%lX"), &tmp) == 1)
clr = wxColour((tmp & 0xFF0000) >> 16, clr = wxColour((tmp & 0xFF0000) >> 16,
(tmp & 0x00FF00) >> 8, (tmp & 0x00FF00) >> 8,
(tmp & 0x0000FF)); (tmp & 0x0000FF));
clr = wxGetColourFromUser(NULL, clr); clr = wxGetColourFromUser(NULL, clr);
@@ -143,19 +143,19 @@ void PropEditCtrlFlags::OnDetails()
wxArrayString arr; wxArrayString arr;
size_t i; size_t i;
int j; int j;
wxStringTokenizer tkn(m_PropInfo->MoreInfo, _T(",")); wxStringTokenizer tkn(m_PropInfo->MoreInfo, _T(","));
while (tkn.HasMoreTokens()) while (tkn.HasMoreTokens())
arr.Add(tkn.GetNextToken()); arr.Add(tkn.GetNextToken());
wxConfigBase *cfg = wxConfigBase::Get(); wxConfigBase *cfg = wxConfigBase::Get();
wxDialog dlg(m_PropFrame, -1, _("Flags"), wxDialog dlg(m_PropFrame, wxID_ANY, _("Flags"),
wxPoint(cfg->Read(_T("flagsdlg_x"), -1), cfg->Read(_T("flagsdlg_y"), -1)), wxPoint(cfg->Read(_T("flagsdlg_x"), wxDefaultPosition.x), cfg->Read(_T("flagsdlg_y"), wxDefaultPosition.y)),
wxSize(cfg->Read(_T("flagsdlg_w"), 300), cfg->Read(_T("flagsdlg_h"), 300)), wxSize(cfg->Read(_T("flagsdlg_w"), 300), cfg->Read(_T("flagsdlg_h"), 300)),
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER); wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
wxSizer *sz = new wxBoxSizer(wxVERTICAL); wxSizer *sz = new wxBoxSizer(wxVERTICAL);
wxCheckListBox *lbox = new wxCheckListBox(&dlg, -1); wxCheckListBox *lbox = new wxCheckListBox(&dlg, wxID_ANY);
sz->Add(lbox, 1, wxEXPAND | wxALL, 10); sz->Add(lbox, 1, wxEXPAND | wxALL, 10);
wxSizer *sz2 = new wxBoxSizer(wxHORIZONTAL); wxSizer *sz2 = new wxBoxSizer(wxHORIZONTAL);
wxButton *btnok = new wxButton(&dlg, wxID_OK, _("OK")); wxButton *btnok = new wxButton(&dlg, wxID_OK, _("OK"));
@@ -165,12 +165,12 @@ void PropEditCtrlFlags::OnDetails()
sz->Add(sz2, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 10); sz->Add(sz2, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 10);
dlg.SetSizer(sz); dlg.SetSizer(sz);
dlg.SetAutoLayout(TRUE); dlg.SetAutoLayout(true);
dlg.Layout(); dlg.Layout();
for (i = 0; i < arr.GetCount(); i++) for (i = 0; i < arr.GetCount(); i++)
lbox->Append(arr[i]); lbox->Append(arr[i]);
tkn.SetString(txt, _T("| ")); tkn.SetString(txt, _T("| "));
while (tkn.HasMoreTokens()) while (tkn.HasMoreTokens())
{ {
@@ -178,12 +178,12 @@ void PropEditCtrlFlags::OnDetails()
j = arr.Index(t); j = arr.Index(t);
if (j != wxNOT_FOUND) lbox->Check(j); if (j != wxNOT_FOUND) lbox->Check(j);
} }
if (dlg.ShowModal() != wxID_OK) return; if (dlg.ShowModal() != wxID_OK) return;
txt.Empty(); txt.Empty();
for (i = 0; i < arr.GetCount(); i++) for (i = 0; i < arr.GetCount(); i++)
if (lbox->IsChecked(i)) if (lbox->IsChecked(i))
txt << arr[i] << _T('|'); txt << arr[i] << _T('|');
@@ -216,14 +216,14 @@ void PropEditCtrlFile::OnDetails()
{ {
wxString txt = m_TextCtrl->GetValue(); wxString txt = m_TextCtrl->GetValue();
txt = wxPathOnly(EditorFrame::Get()->GetFileName()) + _T("/") + txt; txt = wxPathOnly(EditorFrame::Get()->GetFileName()) + _T("/") + txt;
wxString name = wxFileSelector(_("Choose file"), wxString name = wxFileSelector(_("Choose file"),
wxPathOnly(txt), wxPathOnly(txt),
wxFileNameFromPath(txt), wxFileNameFromPath(txt),
_T(""), _T(""),
GetFileTypes(), GetFileTypes(),
wxOPEN | wxFILE_MUST_EXIST); wxOPEN | wxFILE_MUST_EXIST);
if (!name) return; if (!name) return;
// compute relative path: // compute relative path:
wxArrayString axrc, afile; wxArrayString axrc, afile;
wxStringTokenizer tkn; wxStringTokenizer tkn;
@@ -231,7 +231,7 @@ void PropEditCtrlFile::OnDetails()
while (tkn.HasMoreTokens()) afile.Add(tkn.GetNextToken()); while (tkn.HasMoreTokens()) afile.Add(tkn.GetNextToken());
tkn.SetString(EditorFrame::Get()->GetFileName(), _T("/\\")); tkn.SetString(EditorFrame::Get()->GetFileName(), _T("/\\"));
while (tkn.HasMoreTokens()) axrc.Add(tkn.GetNextToken()); while (tkn.HasMoreTokens()) axrc.Add(tkn.GetNextToken());
if (afile.GetCount() == 0 || axrc.GetCount() == 0) if (afile.GetCount() == 0 || axrc.GetCount() == 0)
txt = name; txt = name;
else else

View File

@@ -25,7 +25,7 @@ class PropEditCtrlFont : public PropEditCtrlTxt
public: public:
PropEditCtrlFont(PropertiesFrame *propFrame) PropEditCtrlFont(PropertiesFrame *propFrame)
: PropEditCtrlTxt(propFrame) {} : PropEditCtrlTxt(propFrame) {}
virtual wxWindow* CreateEditCtrl(); virtual wxWindow* CreateEditCtrl();
virtual wxTreeItemId CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo); virtual wxTreeItemId CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo);
}; };
@@ -37,12 +37,12 @@ class PropEditCtrlChoice : public PropEditCtrl
public: public:
PropEditCtrlChoice(PropertiesFrame *propFrame) PropEditCtrlChoice(PropertiesFrame *propFrame)
: PropEditCtrl(propFrame) {} : PropEditCtrl(propFrame) {}
virtual wxWindow* CreateEditCtrl(); virtual wxWindow* CreateEditCtrl();
virtual void ReadValue(); virtual void ReadValue();
virtual void WriteValue(); virtual void WriteValue();
protected: protected:
wxChoice *m_Choice; wxChoice *m_Choice;
@@ -57,7 +57,7 @@ class PropEditCtrlColor : public PropEditCtrlTxt
PropEditCtrlColor(PropertiesFrame *propFrame) PropEditCtrlColor(PropertiesFrame *propFrame)
: PropEditCtrlTxt(propFrame) {} : PropEditCtrlTxt(propFrame) {}
virtual bool HasDetails() { return TRUE; } virtual bool HasDetails() { return true; }
virtual void OnDetails(); virtual void OnDetails();
}; };
@@ -70,7 +70,7 @@ class PropEditCtrlFlags : public PropEditCtrlTxt
PropEditCtrlFlags(PropertiesFrame *propFrame) PropEditCtrlFlags(PropertiesFrame *propFrame)
: PropEditCtrlTxt(propFrame) {} : PropEditCtrlTxt(propFrame) {}
virtual bool HasDetails() { return TRUE; } virtual bool HasDetails() { return true; }
virtual void OnDetails(); virtual void OnDetails();
}; };
@@ -82,9 +82,9 @@ class PropEditCtrlFile : public PropEditCtrlTxt
PropEditCtrlFile(PropertiesFrame *propFrame) PropEditCtrlFile(PropertiesFrame *propFrame)
: PropEditCtrlTxt(propFrame) {} : PropEditCtrlTxt(propFrame) {}
virtual bool HasDetails() { return TRUE; } virtual bool HasDetails() { return true; }
virtual void OnDetails(); virtual void OnDetails();
virtual wxString GetFileTypes(); virtual wxString GetFileTypes();
}; };

View File

@@ -28,20 +28,20 @@
BEGIN_EVENT_TABLE(PropEditCtrlTxt, PropEditCtrl) BEGIN_EVENT_TABLE(PropEditCtrlTxt, PropEditCtrl)
EVT_TEXT(-1, PropEditCtrlTxt::OnText) EVT_TEXT(wxID_ANY, PropEditCtrlTxt::OnText)
END_EVENT_TABLE() END_EVENT_TABLE()
wxWindow *PropEditCtrlTxt::CreateEditCtrl() wxWindow *PropEditCtrlTxt::CreateEditCtrl()
{ {
return (m_TextCtrl = new wxTextCtrl(this, -1)); return (m_TextCtrl = new wxTextCtrl(this, wxID_ANY));
} }
void PropEditCtrlTxt::OnText(wxCommandEvent& WXUNUSED(event)) void PropEditCtrlTxt::OnText(wxCommandEvent& WXUNUSED(event))
{ {
if (CanSave()) if (CanSave())
{ {
WriteValue(); WriteValue();
EditorFrame::Get()->NotifyChanged(CHANGED_PROPS); EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);
@@ -61,7 +61,7 @@ void PropEditCtrlTxt::WriteValue()
{ {
wxString newv = m_TextCtrl->GetValue(); wxString newv = m_TextCtrl->GetValue();
XmlWriteValue(GetNode(), m_PropInfo->Name, newv); XmlWriteValue(GetNode(), m_PropInfo->Name, newv);
m_TreeCtrl->SetItemBold(m_TreeItem, TRUE); m_TreeCtrl->SetItemBold(m_TreeItem, true);
} }
@@ -82,12 +82,12 @@ wxWindow *PropEditCtrlInt::CreateEditCtrl()
BEGIN_EVENT_TABLE(PropEditCtrlBool, PropEditCtrl) BEGIN_EVENT_TABLE(PropEditCtrlBool, PropEditCtrl)
EVT_CHOICE(-1, PropEditCtrlBool::OnChoice) EVT_CHOICE(wxID_ANY, PropEditCtrlBool::OnChoice)
END_EVENT_TABLE() END_EVENT_TABLE()
wxWindow *PropEditCtrlBool::CreateEditCtrl() wxWindow *PropEditCtrlBool::CreateEditCtrl()
{ {
m_Choice = new wxChoice(this, -1); m_Choice = new wxChoice(this, wxID_ANY);
m_Choice->Append(_T("false")); m_Choice->Append(_T("false"));
m_Choice->Append(_T("true")); m_Choice->Append(_T("true"));
return m_Choice; return m_Choice;
@@ -110,7 +110,7 @@ void PropEditCtrlBool::WriteValue()
wxString newv = m_Choice->GetSelection() == 0 ? _T("0") : _T("1"); wxString newv = m_Choice->GetSelection() == 0 ? _T("0") : _T("1");
XmlWriteValue(GetNode(), m_PropInfo->Name, newv); XmlWriteValue(GetNode(), m_PropInfo->Name, newv);
m_TreeCtrl->SetItemBold(m_TreeItem, TRUE); m_TreeCtrl->SetItemBold(m_TreeItem, true);
} }
@@ -128,7 +128,7 @@ wxString PropEditCtrlBool::GetValueAsText(wxTreeItemId ti)
void PropEditCtrlBool::OnChoice(wxCommandEvent& WXUNUSED(event)) void PropEditCtrlBool::OnChoice(wxCommandEvent& WXUNUSED(event))
{ {
if (CanSave()) if (CanSave())
{ {
WriteValue(); WriteValue();
EditorFrame::Get()->NotifyChanged(CHANGED_PROPS); EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);
@@ -145,7 +145,7 @@ class PropEditCtrlCoordXY : public PropEditCtrlInt
public: public:
PropEditCtrlCoordXY(PropertiesFrame *propFrame, int which) PropEditCtrlCoordXY(PropertiesFrame *propFrame, int which)
: PropEditCtrlInt(propFrame), m_which(which) {} : PropEditCtrlInt(propFrame), m_which(which) {}
virtual void ReadValue() virtual void ReadValue()
{ {
wxString s = XmlReadValue(GetNode(), m_PropInfo->Name); wxString s = XmlReadValue(GetNode(), m_PropInfo->Name);
@@ -161,7 +161,7 @@ class PropEditCtrlCoordXY : public PropEditCtrlInt
} }
m_TextCtrl->SetValue(m_c[m_which]); m_TextCtrl->SetValue(m_c[m_which]);
} }
virtual void WriteValue() virtual void WriteValue()
{ {
m_c[m_which] = m_TextCtrl->GetValue(); m_c[m_which] = m_TextCtrl->GetValue();
@@ -172,9 +172,9 @@ class PropEditCtrlCoordXY : public PropEditCtrlInt
wxString prev = XmlReadValue(GetNode(), m_PropInfo->Name); wxString prev = XmlReadValue(GetNode(), m_PropInfo->Name);
if (prev[prev.Len()-1] == _T('d')) s << _T('d'); if (prev[prev.Len()-1] == _T('d')) s << _T('d');
XmlWriteValue(GetNode(), m_PropInfo->Name, s); XmlWriteValue(GetNode(), m_PropInfo->Name, s);
m_TreeCtrl->SetItemBold(m_TreeCtrl->GetItemParent(m_TreeItem), TRUE); m_TreeCtrl->SetItemBold(m_TreeCtrl->GetItemParent(m_TreeItem), true);
} }
virtual wxString GetValueAsText(wxTreeItemId ti) virtual wxString GetValueAsText(wxTreeItemId ti)
{ {
PropertyInfo *pi = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo); PropertyInfo *pi = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo);
@@ -191,16 +191,16 @@ class PropEditCtrlCoordXY : public PropEditCtrlInt
} }
return m_c[m_which]; return m_c[m_which];
} }
virtual wxString GetPropName(const PropertyInfo& WXUNUSED(pinfo)) virtual wxString GetPropName(const PropertyInfo& WXUNUSED(pinfo))
{ {
if (m_which == 0) return _T("x"); else return _T("y"); if (m_which == 0) return _T("x"); else return _T("y");
} }
virtual bool HasClearButton() { return FALSE; } virtual bool HasClearButton() { return false; }
virtual bool IsPresent(const PropertyInfo& WXUNUSED(pinfo)) { return FALSE; } virtual bool IsPresent(const PropertyInfo& WXUNUSED(pinfo)) { return false; }
protected: protected:
wxString m_c[2]; wxString m_c[2];
int m_which; int m_which;
@@ -212,7 +212,7 @@ class PropEditCtrlCoordDlg : public PropEditCtrlBool
public: public:
PropEditCtrlCoordDlg(PropertiesFrame *propFrame) PropEditCtrlCoordDlg(PropertiesFrame *propFrame)
: PropEditCtrlBool(propFrame) {} : PropEditCtrlBool(propFrame) {}
virtual void ReadValue() virtual void ReadValue()
{ {
wxString s = XmlReadValue(GetNode(), m_PropInfo->Name); wxString s = XmlReadValue(GetNode(), m_PropInfo->Name);
@@ -222,15 +222,15 @@ class PropEditCtrlCoordDlg : public PropEditCtrlBool
else else
m_Choice->SetSelection(0); m_Choice->SetSelection(0);
} }
virtual void WriteValue() virtual void WriteValue()
{ {
wxString s = XmlReadValue(GetNode(), m_PropInfo->Name).BeforeFirst(_T('d')); wxString s = XmlReadValue(GetNode(), m_PropInfo->Name).BeforeFirst(_T('d'));
if (m_Choice->GetSelection() == 1) s << _T('d'); if (m_Choice->GetSelection() == 1) s << _T('d');
XmlWriteValue(GetNode(), m_PropInfo->Name, s); XmlWriteValue(GetNode(), m_PropInfo->Name, s);
m_TreeCtrl->SetItemBold(m_TreeCtrl->GetItemParent(m_TreeItem), TRUE); m_TreeCtrl->SetItemBold(m_TreeCtrl->GetItemParent(m_TreeItem), true);
} }
virtual wxString GetValueAsText(wxTreeItemId ti) virtual wxString GetValueAsText(wxTreeItemId ti)
{ {
PropertyInfo *pi = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo); PropertyInfo *pi = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo);
@@ -242,14 +242,14 @@ class PropEditCtrlCoordDlg : public PropEditCtrlBool
else else
return _("true"); return _("true");
} }
virtual wxString GetPropName(const PropertyInfo& WXUNUSED(pinfo)) virtual wxString GetPropName(const PropertyInfo& WXUNUSED(pinfo))
{ {
return _T("dlg"); return _T("dlg");
} }
virtual bool HasClearButton() { return FALSE; } virtual bool HasClearButton() { return false; }
virtual bool IsPresent(const PropertyInfo& WXUNUSED(pinfo)) { return FALSE; } virtual bool IsPresent(const PropertyInfo& WXUNUSED(pinfo)) { return false; }
}; };
@@ -293,14 +293,14 @@ class PropEditCtrlDimX : public PropEditCtrlInt
public: public:
PropEditCtrlDimX(PropertiesFrame *propFrame) PropEditCtrlDimX(PropertiesFrame *propFrame)
: PropEditCtrlInt(propFrame){} : PropEditCtrlInt(propFrame){}
virtual void ReadValue() virtual void ReadValue()
{ {
wxString s = XmlReadValue(GetNode(), m_PropInfo->Name); wxString s = XmlReadValue(GetNode(), m_PropInfo->Name);
m_c = s.BeforeFirst(_T('d')); m_c = s.BeforeFirst(_T('d'));
m_TextCtrl->SetValue(m_c); m_TextCtrl->SetValue(m_c);
} }
virtual void WriteValue() virtual void WriteValue()
{ {
wxString s = XmlReadValue(GetNode(), m_PropInfo->Name); wxString s = XmlReadValue(GetNode(), m_PropInfo->Name);
@@ -309,24 +309,24 @@ class PropEditCtrlDimX : public PropEditCtrlInt
s = m_c; s = m_c;
if (dlg) s << _T('d'); if (dlg) s << _T('d');
XmlWriteValue(GetNode(), m_PropInfo->Name, s); XmlWriteValue(GetNode(), m_PropInfo->Name, s);
m_TreeCtrl->SetItemBold(m_TreeCtrl->GetItemParent(m_TreeItem), TRUE); m_TreeCtrl->SetItemBold(m_TreeCtrl->GetItemParent(m_TreeItem), true);
} }
virtual wxString GetValueAsText(wxTreeItemId ti) virtual wxString GetValueAsText(wxTreeItemId ti)
{ {
PropertyInfo *pi = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo); PropertyInfo *pi = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo);
return XmlReadValue(GetNode(), pi->Name).BeforeFirst(_T('d')); return XmlReadValue(GetNode(), pi->Name).BeforeFirst(_T('d'));
} }
virtual wxString GetPropName(const PropertyInfo& WXUNUSED(pinfo)) virtual wxString GetPropName(const PropertyInfo& WXUNUSED(pinfo))
{ {
return _T("val"); return _T("val");
} }
virtual bool HasClearButton() { return FALSE; } virtual bool HasClearButton() { return false; }
virtual bool IsPresent(const PropertyInfo& WXUNUSED(pinfo)) { return FALSE; } virtual bool IsPresent(const PropertyInfo& WXUNUSED(pinfo)) { return false; }
protected: protected:
wxString m_c; wxString m_c;
}; };
@@ -379,7 +379,7 @@ void PropEditCtrlXRCID::WriteValue()
REAL_NODE->DeleteProperty(_T("name")); REAL_NODE->DeleteProperty(_T("name"));
REAL_NODE->AddProperty(_T("name"), s); REAL_NODE->AddProperty(_T("name"), s);
m_TreeCtrl->SetItemBold(m_TreeItem, TRUE); m_TreeCtrl->SetItemBold(m_TreeItem, true);
EditorFrame::Get()->NotifyChanged(CHANGED_TREE_SELECTED); EditorFrame::Get()->NotifyChanged(CHANGED_TREE_SELECTED);
} }
@@ -389,7 +389,7 @@ void PropEditCtrlXRCID::Clear()
{ {
EndEdit(); EndEdit();
REAL_NODE->DeleteProperty(_T("name")); REAL_NODE->DeleteProperty(_T("name"));
m_TreeCtrl->SetItemBold(m_TreeItem, FALSE); m_TreeCtrl->SetItemBold(m_TreeItem, false);
EditorFrame::Get()->NotifyChanged(CHANGED_TREE_SELECTED); EditorFrame::Get()->NotifyChanged(CHANGED_TREE_SELECTED);
} }
@@ -401,7 +401,7 @@ void PropEditCtrlXRCID::OnDetails()
#define stdID(id) , wxString(_T(#id)) #define stdID(id) , wxString(_T(#id))
stdID(wxID_OK) stdID(wxID_CANCEL) stdID(wxID_OK) stdID(wxID_CANCEL)
stdID(wxID_YES) stdID(wxID_NO) stdID(wxID_YES) stdID(wxID_NO)
stdID(wxID_APPLY) stdID(wxID_HELP) stdID(wxID_APPLY) stdID(wxID_HELP)
stdID(wxID_HELP_CONTEXT) stdID(wxID_HELP_CONTEXT)
stdID(wxID_OPEN) stdID(wxID_CLOSE) stdID(wxID_NEW) stdID(wxID_OPEN) stdID(wxID_CLOSE) stdID(wxID_NEW)
@@ -412,20 +412,20 @@ void PropEditCtrlXRCID::OnDetails()
stdID(wxID_HELP_COMMANDS) stdID(wxID_HELP_PROCEDURES) stdID(wxID_HELP_COMMANDS) stdID(wxID_HELP_PROCEDURES)
stdID(wxID_CUT) stdID(wxID_COPY) stdID(wxID_PASTE) stdID(wxID_CUT) stdID(wxID_COPY) stdID(wxID_PASTE)
stdID(wxID_CLEAR) stdID(wxID_FIND) stdID(wxID_DUPLICATE) stdID(wxID_CLEAR) stdID(wxID_FIND) stdID(wxID_DUPLICATE)
stdID(wxID_SELECTALL) stdID(wxID_SELECTALL)
stdID(wxID_STATIC) stdID(wxID_FORWARD) stdID(wxID_BACKWARD) stdID(wxID_STATIC) stdID(wxID_FORWARD) stdID(wxID_BACKWARD)
stdID(wxID_DEFAULT) stdID(wxID_MORE) stdID(wxID_SETUP) stdID(wxID_DEFAULT) stdID(wxID_MORE) stdID(wxID_SETUP)
stdID(wxID_RESET) stdID(wxID_RESET)
#undef stdID #undef stdID
}; };
wxString s = wxString s =
wxGetSingleChoice(_("Choose from predefined IDs:"), _("XRCID"), wxGetSingleChoice(_("Choose from predefined IDs:"), _("XRCID"),
38/*sizeof choices*/, choices); 38/*sizeof choices*/, choices);
if (!s) return; if (!s) return;
m_TextCtrl->SetValue(s); m_TextCtrl->SetValue(s);
WriteValue(); WriteValue();
EditorFrame::Get()->NotifyChanged(CHANGED_PROPS); EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);
} }

View File

@@ -25,12 +25,12 @@ class PropEditCtrlNull : public PropEditCtrl
public: public:
PropEditCtrlNull(PropertiesFrame *propFrame) PropEditCtrlNull(PropertiesFrame *propFrame)
: PropEditCtrl(propFrame) {} : PropEditCtrl(propFrame) {}
virtual void BeginEdit(const wxRect& WXUNUSED(rect), wxTreeItemId WXUNUSED(ti)) {} virtual void BeginEdit(const wxRect& WXUNUSED(rect), wxTreeItemId WXUNUSED(ti)) {}
virtual void EndEdit() {} virtual void EndEdit() {}
virtual wxWindow* CreateEditCtrl() {return NULL;} virtual wxWindow* CreateEditCtrl() {return NULL;}
virtual void ReadValue() {} virtual void ReadValue() {}
virtual void WriteValue() {} virtual void WriteValue() {}
}; };
@@ -42,12 +42,12 @@ class PropEditCtrlTxt : public PropEditCtrl
public: public:
PropEditCtrlTxt(PropertiesFrame *propFrame) PropEditCtrlTxt(PropertiesFrame *propFrame)
: PropEditCtrl(propFrame) {} : PropEditCtrl(propFrame) {}
virtual wxWindow* CreateEditCtrl(); virtual wxWindow* CreateEditCtrl();
virtual void ReadValue(); virtual void ReadValue();
virtual void WriteValue(); virtual void WriteValue();
protected: protected:
wxTextCtrl *m_TextCtrl; wxTextCtrl *m_TextCtrl;
@@ -63,7 +63,7 @@ class PropEditCtrlInt : public PropEditCtrlTxt
public: public:
PropEditCtrlInt(PropertiesFrame *propFrame) PropEditCtrlInt(PropertiesFrame *propFrame)
: PropEditCtrlTxt(propFrame) {} : PropEditCtrlTxt(propFrame) {}
virtual wxWindow* CreateEditCtrl(); virtual wxWindow* CreateEditCtrl();
}; };
@@ -74,13 +74,13 @@ class PropEditCtrlBool : public PropEditCtrl
public: public:
PropEditCtrlBool(PropertiesFrame *propFrame) PropEditCtrlBool(PropertiesFrame *propFrame)
: PropEditCtrl(propFrame) {} : PropEditCtrl(propFrame) {}
virtual wxWindow* CreateEditCtrl(); virtual wxWindow* CreateEditCtrl();
virtual void ReadValue(); virtual void ReadValue();
virtual void WriteValue(); virtual void WriteValue();
virtual wxString GetValueAsText(wxTreeItemId ti); virtual wxString GetValueAsText(wxTreeItemId ti);
protected: protected:
wxChoice *m_Choice; wxChoice *m_Choice;
@@ -94,9 +94,9 @@ class PropEditCtrlCoord : public PropEditCtrlTxt
public: public:
PropEditCtrlCoord(PropertiesFrame *propFrame); PropEditCtrlCoord(PropertiesFrame *propFrame);
~PropEditCtrlCoord(); ~PropEditCtrlCoord();
virtual wxTreeItemId CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo); virtual wxTreeItemId CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo);
private: private:
PropEditCtrl *m_CtrlX, *m_CtrlY, *m_CtrlDlg; PropEditCtrl *m_CtrlX, *m_CtrlY, *m_CtrlDlg;
}; };
@@ -107,9 +107,9 @@ class PropEditCtrlDim : public PropEditCtrlTxt
public: public:
PropEditCtrlDim(PropertiesFrame *propFrame); PropEditCtrlDim(PropertiesFrame *propFrame);
~PropEditCtrlDim(); ~PropEditCtrlDim();
virtual wxTreeItemId CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo); virtual wxTreeItemId CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo);
private: private:
PropEditCtrl *m_CtrlX, *m_CtrlDlg; PropEditCtrl *m_CtrlX, *m_CtrlDlg;
}; };
@@ -121,11 +121,11 @@ class PropEditCtrlXRCID : public PropEditCtrlTxt
public: public:
PropEditCtrlXRCID(PropertiesFrame *propFrame) PropEditCtrlXRCID(PropertiesFrame *propFrame)
: PropEditCtrlTxt(propFrame) {} : PropEditCtrlTxt(propFrame) {}
virtual void ReadValue(); virtual void ReadValue();
virtual void WriteValue(); virtual void WriteValue();
virtual void Clear(); virtual void Clear();
virtual bool HasDetails() { return TRUE; } virtual bool HasDetails() { return true; }
virtual void OnDetails(); virtual void OnDetails();
virtual wxString GetValueAsText(wxTreeItemId ti); virtual wxString GetValueAsText(wxTreeItemId ti);
virtual bool IsPresent(const PropertyInfo& pinfo); virtual bool IsPresent(const PropertyInfo& pinfo);

View File

@@ -36,11 +36,11 @@ class MyMenubarHandler : public wxMenuBarXmlHandler
wxObject *DoCreateResource() wxObject *DoCreateResource()
{ {
//wxMenuBar *menubar = new wxMenuBar(GetStyle()); //wxMenuBar *menubar = new wxMenuBar(GetStyle());
CreateChildren(m_MenuBar); CreateChildren(m_MenuBar);
return m_MenuBar; return m_MenuBar;
} }
private: private:
wxMenuBar *m_MenuBar; wxMenuBar *m_MenuBar;
}; };
@@ -52,41 +52,41 @@ PreviewFrame* PreviewFrame::ms_Instance = NULL;
PreviewFrame *PreviewFrame::Get() PreviewFrame *PreviewFrame::Get()
{ {
if (ms_Instance == NULL) if (ms_Instance == NULL)
{ {
(void)new PreviewFrame; (void)new PreviewFrame;
ms_Instance->Show(TRUE); ms_Instance->Show(true);
} }
return ms_Instance; return ms_Instance;
} }
PreviewFrame::PreviewFrame() PreviewFrame::PreviewFrame()
: wxFrame(EditorFrame::Get(), -1, _("Preview"), : wxFrame(EditorFrame::Get(), wxID_ANY, _("Preview"),
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR
#ifdef __WXMSW__ #ifdef __WXMSW__
| wxFRAME_TOOL_WINDOW | wxFRAME_TOOL_WINDOW
#endif #endif
) )
{ {
m_Dirty = FALSE; m_Dirty = false;
ms_Instance = this; ms_Instance = this;
m_Node = NULL; m_Node = NULL;
SetMenuBar(new wxMenuBar()); SetMenuBar(new wxMenuBar());
m_RC = NULL; m_RC = NULL;
m_TmpFile = wxGetTempFileName(_T("wxrcedit")); m_TmpFile = wxGetTempFileName(_T("wxrcedit"));
ResetResource(); ResetResource();
wxConfigBase *cfg = wxConfigBase::Get(); wxConfigBase *cfg = wxConfigBase::Get();
SetSize(wxRect(wxPoint(cfg->Read(_T("previewframe_x"), -1), cfg->Read(_T("previewframe_y"), -1)), SetSize(wxRect(wxPoint(cfg->Read(_T("previewframe_x"), wxDefaultPosition.x), cfg->Read(_T("previewframe_y"), wxDefaultPosition.y)),
wxSize(cfg->Read(_T("previewframe_w"), 400), cfg->Read(_T("previewframe_h"), 400)))); wxSize(cfg->Read(_T("previewframe_w"), 400), cfg->Read(_T("previewframe_h"), 400))));
m_Splitter = new wxSplitterWindow(this, -1); m_Splitter = new wxSplitterWindow(this, wxID_ANY);
m_LogCtrl = new wxTextCtrl(m_Splitter, -1, wxEmptyString, wxDefaultPosition, m_LogCtrl = new wxTextCtrl(m_Splitter, wxID_ANY, wxEmptyString, wxDefaultPosition,
wxDefaultSize, wxTE_MULTILINE); wxDefaultSize, wxTE_MULTILINE);
m_ScrollWin = new wxScrolledWindow(m_Splitter, -1); m_ScrollWin = new wxScrolledWindow(m_Splitter, wxID_ANY);
m_ScrollWin->SetBackgroundColour(_T("light steel blue")); m_ScrollWin->SetBackgroundColour(_T("light steel blue"));
m_Splitter->SplitHorizontally(m_ScrollWin, m_LogCtrl, cfg->Read(_T("previewframe_sash"), 300)); m_Splitter->SplitHorizontally(m_ScrollWin, m_LogCtrl, cfg->Read(_T("previewframe_sash"), 300));
@@ -113,26 +113,26 @@ void PreviewFrame::ResetResource()
PreviewFrame::~PreviewFrame() PreviewFrame::~PreviewFrame()
{ {
wxConfigBase *cfg = wxConfigBase::Get(); wxConfigBase *cfg = wxConfigBase::Get();
cfg->Write(_T("previewframe_x"), (long)GetPosition().x); cfg->Write(_T("previewframe_x"), (long)GetPosition().x);
cfg->Write(_T("previewframe_y"), (long)GetPosition().y); cfg->Write(_T("previewframe_y"), (long)GetPosition().y);
cfg->Write(_T("previewframe_w"), (long)GetSize().x); cfg->Write(_T("previewframe_w"), (long)GetSize().x);
cfg->Write(_T("previewframe_h"), (long)GetSize().y); cfg->Write(_T("previewframe_h"), (long)GetSize().y);
cfg->Write(_T("previewframe_sash"), (long)m_Splitter->GetSashPosition()); cfg->Write(_T("previewframe_sash"), (long)m_Splitter->GetSashPosition());
ms_Instance = NULL; ms_Instance = NULL;
delete m_RC; delete m_RC;
wxRemoveFile(m_TmpFile); wxRemoveFile(m_TmpFile);
} }
void PreviewFrame::MakeDirty() void PreviewFrame::MakeDirty()
{ {
if (m_Node == NULL) return; if (m_Node == NULL) return;
if (m_Dirty) return; if (m_Dirty) return;
m_Dirty = TRUE; m_Dirty = true;
m_LogCtrl->Clear(); m_LogCtrl->Clear();
m_LogCtrl->SetValue(_("Resource modified.\nMove mouse cursor over the preview window to refresh it.")); m_LogCtrl->SetValue(_("Resource modified.\nMove mouse cursor over the preview window to refresh it."));
} }
@@ -153,11 +153,11 @@ void PreviewFrame::Preview(wxXmlNode *node, wxXmlDocument *orig_doc)
doc.GetRoot()->AddChild(new wxXmlNode(*node)); doc.GetRoot()->AddChild(new wxXmlNode(*node));
doc.SetFileEncoding(orig_doc->GetFileEncoding()); doc.SetFileEncoding(orig_doc->GetFileEncoding());
if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxDialog")) if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxDialog"))
XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel")); XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel"));
if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxFrame")) if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxFrame"))
XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel")); XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel"));
doc.Save(m_TmpFile); doc.Save(m_TmpFile);
// wxXmlResource will detect change automatically // wxXmlResource will detect change automatically
@@ -178,10 +178,10 @@ void PreviewFrame::Preview(wxXmlNode *node, wxXmlDocument *orig_doc)
m_LogCtrl->Clear(); m_LogCtrl->Clear();
wxLogTextCtrl mylog(m_LogCtrl); wxLogTextCtrl mylog(m_LogCtrl);
wxLog *oldlog = wxLog::SetActiveTarget(&mylog); wxLog *oldlog = wxLog::SetActiveTarget(&mylog);
wxString oldcwd = wxGetCwd(); wxString oldcwd = wxGetCwd();
wxSetWorkingDirectory(wxPathOnly(EditorFrame::Get()->GetFileName())); wxSetWorkingDirectory(wxPathOnly(EditorFrame::Get()->GetFileName()));
if (XmlGetClass(node) == _T("wxMenuBar") || XmlGetClass(node) == _T("wxMenu")) if (XmlGetClass(node) == _T("wxMenuBar") || XmlGetClass(node) == _T("wxMenu"))
PreviewMenu(); PreviewMenu();
else if (XmlGetClass(node) == _T("wxToolBar")) else if (XmlGetClass(node) == _T("wxToolBar"))
@@ -189,12 +189,12 @@ void PreviewFrame::Preview(wxXmlNode *node, wxXmlDocument *orig_doc)
else if (XmlGetClass(node) == _T("wxPanel") || XmlGetClass(node) == _T("wxDialog")) else if (XmlGetClass(node) == _T("wxPanel") || XmlGetClass(node) == _T("wxDialog"))
PreviewPanel(); PreviewPanel();
else if (XmlGetClass(node) == _T("wxFrame")) else if (XmlGetClass(node) == _T("wxFrame"))
PreviewWXFrame(); PreviewWXFrame();
wxSetWorkingDirectory(oldcwd); wxSetWorkingDirectory(oldcwd);
wxLog::SetActiveTarget(oldlog); wxLog::SetActiveTarget(oldlog);
m_Dirty = FALSE; m_Dirty = false;
} }
@@ -233,38 +233,38 @@ void PreviewFrame::PreviewPanel()
else else
{ {
m_ScrollWin->SetScrollbars(1, 1, panel->GetSize().x, panel->GetSize().y, m_ScrollWin->SetScrollbars(1, 1, panel->GetSize().x, panel->GetSize().y,
0, 0, TRUE); 0, 0, true);
} }
} }
void PreviewFrame::PreviewWXFrame() void PreviewFrame::PreviewWXFrame()
{ {
//for this to work the frame MUST have a child panel! //for this to work the frame MUST have a child panel!
wxXmlNode* child = m_Node; wxXmlNode* child = m_Node;
wxString name; wxString name;
while( child != NULL) while( child != NULL)
{ {
name = child->GetPropVal(_T("name"), _T("-1")); name = child->GetPropVal(_T("name"), _T("-1"));
if(name != _T("-1")) if(name != _T("-1"))
{ {
wxXmlNode* parent = child->GetParent(); wxXmlNode* parent = child->GetParent();
if(parent->GetPropVal(_T("class"),_T("-1")) == _T("wxPanel")) if(parent->GetPropVal(_T("class"),_T("-1")) == _T("wxPanel"))
break; break;
} }
child = child->GetNext(); child = child->GetNext();
} }
wxPanel *panel = m_RC->LoadPanel(m_ScrollWin, name); wxPanel *panel = m_RC->LoadPanel(m_ScrollWin, name);
if (panel == NULL) if (panel == NULL)
wxLogError(_("Cannot preview the panel -- XML resource corrupted.")); wxLogError(_("Cannot preview the panel -- XML resource corrupted."));
else else
{ {
m_ScrollWin->SetScrollbars(1, 1, panel->GetSize().x, panel->GetSize().y, m_ScrollWin->SetScrollbars(1, 1, panel->GetSize().x, panel->GetSize().y,
0, 0, TRUE); 0, 0, true);
} }
} }

View File

@@ -30,21 +30,21 @@ class PreviewFrame : public wxFrame
public: public:
PreviewFrame(); PreviewFrame();
~PreviewFrame(); ~PreviewFrame();
void Preview(wxXmlNode *node,wxXmlDocument *doc); void Preview(wxXmlNode *node,wxXmlDocument *doc);
void MakeDirty(); void MakeDirty();
// current node updated, needs preview refresh // current node updated, needs preview refresh
// (will be done once mouse enters preview win) // (will be done once mouse enters preview win)
static PreviewFrame *Get(); static PreviewFrame *Get();
void ResetResource(); void ResetResource();
private: private:
void PreviewMenu(); void PreviewMenu();
void PreviewToolbar(); void PreviewToolbar();
void PreviewPanel(); void PreviewPanel();
void PreviewWXFrame(); void PreviewWXFrame();
private: private:
static PreviewFrame *ms_Instance; static PreviewFrame *ms_Instance;
wxXmlNode *m_Node; wxXmlNode *m_Node;
@@ -52,12 +52,12 @@ class PreviewFrame : public wxFrame
wxScrolledWindow *m_ScrollWin; wxScrolledWindow *m_ScrollWin;
wxTextCtrl *m_LogCtrl; wxTextCtrl *m_LogCtrl;
wxSplitterWindow *m_Splitter; wxSplitterWindow *m_Splitter;
wxXmlResource *m_RC; wxXmlResource *m_RC;
wxString m_TmpFile; wxString m_TmpFile;
bool m_Dirty; bool m_Dirty;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
void OnMouseEnter(wxMouseEvent& event); void OnMouseEnter(wxMouseEvent& event);
}; };

View File

@@ -45,7 +45,7 @@ void PropEditCtrl::OnButtonDetails(wxCommandEvent& WXUNUSED(event))
void PropEditCtrl::OnButtonClear(wxCommandEvent& WXUNUSED(event)) void PropEditCtrl::OnButtonClear(wxCommandEvent& WXUNUSED(event))
{ {
Clear(); Clear();
EditorFrame::Get()->NotifyChanged(CHANGED_PROPS); EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);
} }
@@ -54,7 +54,7 @@ void PropEditCtrl::BeginEdit(const wxRect& rect, wxTreeItemId ti)
m_PropInfo = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo); m_PropInfo = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo);
m_TreeItem = ti; m_TreeItem = ti;
m_CanSave = FALSE; m_CanSave = false;
if (!m_Created) if (!m_Created)
{ {
wxSizer *sz = new wxBoxSizer(wxHORIZONTAL); wxSizer *sz = new wxBoxSizer(wxHORIZONTAL);
@@ -62,28 +62,28 @@ void PropEditCtrl::BeginEdit(const wxRect& rect, wxTreeItemId ti)
sz->Add(m_TheCtrl, 1); sz->Add(m_TheCtrl, 1);
if (HasDetails()) if (HasDetails())
sz->Add(new wxButton(this, ID_DETAILS, _T("..."), wxDefaultPosition, sz->Add(new wxButton(this, ID_DETAILS, _T("..."), wxDefaultPosition,
wxSize(16,-1))); wxSize(16,wxDefaultSize.y)));
if (HasClearButton()) if (HasClearButton())
sz->Add(new wxButton(this, ID_CLEAR, _T("X"), wxDefaultPosition, sz->Add(new wxButton(this, ID_CLEAR, _T("X"), wxDefaultPosition,
wxSize(16,-1))); wxSize(16,wxDefaultSize.y)));
SetAutoLayout(TRUE); SetAutoLayout(true);
SetSizer(sz); SetSizer(sz);
m_Created = TRUE; m_Created = true;
} }
m_TheCtrl->SetFocus(); m_TheCtrl->SetFocus();
SetSize(rect.x, rect.y, rect.width, rect.height); SetSize(rect.x, rect.y, rect.width, rect.height);
Show(TRUE); Show(true);
ReadValue(); ReadValue();
m_CanSave = TRUE; m_CanSave = true;
} }
void PropEditCtrl::EndEdit() void PropEditCtrl::EndEdit()
{ {
Show(FALSE); Show(false);
} }
@@ -93,7 +93,7 @@ wxTreeItemId PropEditCtrl::CreateTreeEntry(wxTreeItemId parent, const PropertyIn
wxTreeItemId t = m_TreeCtrl->AppendItem(parent, GetPropName(pinfo)); wxTreeItemId t = m_TreeCtrl->AppendItem(parent, GetPropName(pinfo));
m_TreeCtrl->SetItemData(t, new PETreeData(this, pinfo)); m_TreeCtrl->SetItemData(t, new PETreeData(this, pinfo));
if (IsPresent(pinfo)) if (IsPresent(pinfo))
m_TreeCtrl->SetItemBold(t, TRUE); m_TreeCtrl->SetItemBold(t, true);
return t; return t;
} }
@@ -113,7 +113,7 @@ void PropEditCtrl::Clear()
{ {
n->GetParent()->RemoveChild(n); n->GetParent()->RemoveChild(n);
delete n; delete n;
m_TreeCtrl->SetItemBold(m_TreeItem, FALSE); m_TreeCtrl->SetItemBold(m_TreeItem, false);
} }
} }

View File

@@ -29,45 +29,45 @@ class PropEditCtrl : public wxPanel
{ {
public: public:
PropEditCtrl(PropertiesFrame *propFrame) PropEditCtrl(PropertiesFrame *propFrame)
: wxPanel(propFrame->m_valueWindow, -1), : wxPanel(propFrame->m_valueWindow, wxID_ANY),
m_PropFrame(propFrame), m_Created(FALSE), m_TreeCtrl(propFrame->m_tree) m_PropFrame(propFrame), m_Created(false), m_TreeCtrl(propFrame->m_tree)
{Show(FALSE);} {Show(false);}
virtual void BeginEdit(const wxRect& rect, wxTreeItemId ti); virtual void BeginEdit(const wxRect& rect, wxTreeItemId ti);
virtual void EndEdit(); virtual void EndEdit();
virtual wxTreeItemId CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo); virtual wxTreeItemId CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo);
virtual wxWindow* CreateEditCtrl() = 0; virtual wxWindow* CreateEditCtrl() = 0;
virtual bool IsPresent(const PropertyInfo& pinfo); virtual bool IsPresent(const PropertyInfo& pinfo);
virtual void Clear(); virtual void Clear();
virtual void ReadValue() = 0; virtual void ReadValue() = 0;
virtual void WriteValue() = 0; virtual void WriteValue() = 0;
virtual wxString GetValueAsText(wxTreeItemId ti); virtual wxString GetValueAsText(wxTreeItemId ti);
virtual wxString GetPropName(const PropertyInfo& pinfo) virtual wxString GetPropName(const PropertyInfo& pinfo)
{ return pinfo.Name.AfterLast(_T('/')); } { return pinfo.Name.AfterLast(_T('/')); }
virtual bool HasDetails() { return FALSE; } virtual bool HasDetails() { return false; }
virtual void OnDetails() {} virtual void OnDetails() {}
virtual bool HasClearButton() { return TRUE; } virtual bool HasClearButton() { return true; }
void OnButtonDetails(wxCommandEvent& event); void OnButtonDetails(wxCommandEvent& event);
void OnButtonClear(wxCommandEvent& event); void OnButtonClear(wxCommandEvent& event);
protected: protected:
wxXmlNode *GetNode() { return m_PropFrame->m_Node; } wxXmlNode *GetNode() { return m_PropFrame->m_Node; }
bool CanSave() { return m_CanSave; } bool CanSave() { return m_CanSave; }
PropertiesFrame *m_PropFrame; PropertiesFrame *m_PropFrame;
bool m_Created; bool m_Created;
wxTreeCtrl *m_TreeCtrl; wxTreeCtrl *m_TreeCtrl;
wxTreeItemId m_TreeItem; wxTreeItemId m_TreeItem;
wxWindow *m_TheCtrl; wxWindow *m_TheCtrl;
PropertyInfo *m_PropInfo; PropertyInfo *m_PropInfo;
bool m_CanSave; bool m_CanSave;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
@@ -76,7 +76,7 @@ class PropEditCtrl : public wxPanel
class PETreeData : public wxTreeItemData class PETreeData : public wxTreeItemData
{ {
public: public:
PETreeData(PropEditCtrl *p, const PropertyInfo& pi) : PETreeData(PropEditCtrl *p, const PropertyInfo& pi) :
wxTreeItemData(), wxTreeItemData(),
EditCtrl(p), PropInfo(pi) {} EditCtrl(p), PropInfo(pi) {}
PropEditCtrl *EditCtrl; PropEditCtrl *EditCtrl;

View File

@@ -38,52 +38,52 @@ class PropsTree: public wxRemotelyScrolledTreeCtrl
PropsTree(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition, PropsTree(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition,
const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS) const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS)
: wxRemotelyScrolledTreeCtrl(parent, id, pt, sz, style), : wxRemotelyScrolledTreeCtrl(parent, id, pt, sz, style),
m_EditCtrl(NULL) m_EditCtrl(NULL)
{ {
#if 0 #if 0
// VS: Don't do it, it is *extremely* ugly. // VS: Don't do it, it is *extremely* ugly.
// FIXME: find a better solution. // FIXME: find a better solution.
//make text larger so controls will fit properly //make text larger so controls will fit properly
wxFont font = GetFont(); wxFont font = GetFont();
font.SetPointSize(font.GetPointSize()*1.5); font.SetPointSize(font.GetPointSize()*1.5);
SetFont(font); SetFont(font);
#endif #endif
} }
void OnPaint(wxPaintEvent& event) void OnPaint(wxPaintEvent& event)
{ {
wxPaintDC dc(this); wxPaintDC dc(this);
wxTreeCtrl::OnPaint(event); wxTreeCtrl::OnPaint(event);
// Reset the device origin since it may have been set // Reset the device origin since it may have been set
dc.SetDeviceOrigin(0, 0); dc.SetDeviceOrigin(0, 0);
wxPen pen(wxColour(_T("BLACK")), 1, wxSOLID); wxPen pen(wxColour(_T("BLACK")), 1, wxSOLID);
dc.SetPen(pen); dc.SetPen(pen);
dc.SetBrush(* wxTRANSPARENT_BRUSH); dc.SetBrush(* wxTRANSPARENT_BRUSH);
wxSize clientSize = GetClientSize(); wxSize clientSize = GetClientSize();
wxRect itemRect; wxRect itemRect;
int cy=0; int cy=0;
wxTreeItemId h, lastH; wxTreeItemId h, lastH;
for(h=GetFirstVisibleItem();h;h=GetNextVisible(h)) for(h=GetFirstVisibleItem();h;h=GetNextVisible(h))
{ {
if (h.IsOk() && GetBoundingRect(h, itemRect)) if (h.IsOk() && GetBoundingRect(h, itemRect))
{ {
cy = itemRect.GetTop(); cy = itemRect.GetTop();
dc.DrawLine(0, cy, clientSize.x, cy); dc.DrawLine(0, cy, clientSize.x, cy);
lastH = h; lastH = h;
} }
} }
if (lastH.IsOk() && GetBoundingRect(lastH, itemRect)) if (lastH.IsOk() && GetBoundingRect(lastH, itemRect))
{ {
cy = itemRect.GetBottom(); cy = itemRect.GetBottom();
dc.DrawLine(0, cy, clientSize.x, cy); dc.DrawLine(0, cy, clientSize.x, cy);
} }
} }
void OnSelChange(wxTreeEvent& event) void OnSelChange(wxTreeEvent& event)
@@ -93,7 +93,7 @@ class PropsTree: public wxRemotelyScrolledTreeCtrl
m_EditCtrl->EndEdit(); m_EditCtrl->EndEdit();
m_EditCtrl = NULL; m_EditCtrl = NULL;
} }
wxTreeItemId item = event.GetItem(); wxTreeItemId item = event.GetItem();
PETreeData *dt = (PETreeData*)GetItemData(item); PETreeData *dt = (PETreeData*)GetItemData(item);
if (dt != NULL) if (dt != NULL)
@@ -102,7 +102,7 @@ class PropsTree: public wxRemotelyScrolledTreeCtrl
GetBoundingRect(item, bounding); GetBoundingRect(item, bounding);
bounding.SetX(0); bounding.SetX(0);
bounding.SetWidth(GetCompanionWindow()->GetSize().x); bounding.SetWidth(GetCompanionWindow()->GetSize().x);
dt->EditCtrl->BeginEdit(bounding, item); dt->EditCtrl->BeginEdit(bounding, item);
m_EditCtrl = dt->EditCtrl; m_EditCtrl = dt->EditCtrl;
} }
@@ -124,22 +124,22 @@ class PropsTree: public wxRemotelyScrolledTreeCtrl
event.Skip(); event.Skip();
if (event.GetOrientation() == wxHORIZONTAL) return; if (event.GetOrientation() == wxHORIZONTAL) return;
if (!m_EditCtrl) return; if (!m_EditCtrl) return;
wxTreeItemId id = GetSelection(); wxTreeItemId id = GetSelection();
wxRect bounding; wxRect bounding;
GetBoundingRect(id, bounding); GetBoundingRect(id, bounding);
m_EditCtrl->Move(-1, bounding.y); m_EditCtrl->Move(wxDefaultPosition.x, bounding.y);
} }
PropEditCtrl *m_EditCtrl; PropEditCtrl *m_EditCtrl;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
BEGIN_EVENT_TABLE(PropsTree, wxRemotelyScrolledTreeCtrl) BEGIN_EVENT_TABLE(PropsTree, wxRemotelyScrolledTreeCtrl)
EVT_PAINT(PropsTree::OnPaint) EVT_PAINT(PropsTree::OnPaint)
EVT_TREE_SEL_CHANGED(-1, PropsTree::OnSelChange) EVT_TREE_SEL_CHANGED(wxID_ANY, PropsTree::OnSelChange)
EVT_SCROLLWIN(PropsTree::OnScroll) EVT_SCROLLWIN(PropsTree::OnScroll)
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -147,34 +147,34 @@ END_EVENT_TABLE()
class PropsValueWindow: public wxTreeCompanionWindow class PropsValueWindow: public wxTreeCompanionWindow
{ {
public: public:
PropsValueWindow(wxWindow* parent, wxWindowID id = -1, PropsValueWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize, const wxSize& sz = wxDefaultSize,
long style = 0) long style = 0)
: wxTreeCompanionWindow(parent, id, pos, sz, style) {} : wxTreeCompanionWindow(parent, id, pos, sz, style) {}
virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect)
{ {
if (m_treeCtrl) if (m_treeCtrl)
{ {
PETreeData *data = (PETreeData*)m_treeCtrl->GetItemData(id); PETreeData *data = (PETreeData*)m_treeCtrl->GetItemData(id);
wxString text; wxString text;
if (data != NULL) text = data->EditCtrl->GetValueAsText(id); if (data != NULL) text = data->EditCtrl->GetValueAsText(id);
dc.SetBrush(wxBrush(GetBackgroundColour(), wxSOLID)); dc.SetBrush(wxBrush(GetBackgroundColour(), wxSOLID));
dc.DrawRectangle(rect); dc.DrawRectangle(rect);
dc.SetTextForeground(* wxBLACK); dc.SetTextForeground(* wxBLACK);
dc.SetBackgroundMode(wxTRANSPARENT); dc.SetBackgroundMode(wxTRANSPARENT);
int textW, textH; int textW, textH;
dc.GetTextExtent(text, & textW, & textH); dc.GetTextExtent(text, & textW, & textH);
int x = 5; int x = 5;
int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2); int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2);
dc.DrawText(text, x, y); dc.DrawText(text, x, y);
} }
} }
void OnClick(wxMouseEvent& event) void OnClick(wxMouseEvent& event)
{ {
int flags; int flags;
@@ -189,7 +189,7 @@ class PropsValueWindow: public wxTreeCompanionWindow
}; };
BEGIN_EVENT_TABLE(PropsValueWindow, wxTreeCompanionWindow) BEGIN_EVENT_TABLE(PropsValueWindow, wxTreeCompanionWindow)
EVT_LEFT_DOWN(PropsValueWindow::OnClick) EVT_LEFT_DOWN(PropsValueWindow::OnClick)
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -202,18 +202,18 @@ PropertiesFrame* PropertiesFrame::ms_Instance = NULL;
PropertiesFrame *PropertiesFrame::Get() PropertiesFrame *PropertiesFrame::Get()
{ {
if (ms_Instance == NULL) if (ms_Instance == NULL)
{ {
(void)new PropertiesFrame; (void)new PropertiesFrame;
ms_Instance->Show(TRUE); ms_Instance->Show(true);
} }
return ms_Instance; return ms_Instance;
} }
PropertiesFrame::PropertiesFrame() PropertiesFrame::PropertiesFrame()
: wxFrame(EditorFrame::Get(), -1, _("Properties"), : wxFrame(EditorFrame::Get(), wxID_ANY, _("Properties"),
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR
#ifdef __WXMSW__ #ifdef __WXMSW__
| wxFRAME_TOOL_WINDOW | wxFRAME_TOOL_WINDOW
#endif #endif
@@ -222,34 +222,34 @@ PropertiesFrame::PropertiesFrame()
ms_Instance = this; ms_Instance = this;
m_Node = NULL; m_Node = NULL;
m_scrolledWindow = new wxSplitterScrolledWindow(this, -1, wxDefaultPosition, m_scrolledWindow = new wxSplitterScrolledWindow(this, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxNO_BORDER | wxCLIP_CHILDREN | wxVSCROLL); wxDefaultSize, wxNO_BORDER | wxCLIP_CHILDREN | wxVSCROLL);
m_splitter = new wxThinSplitterWindow(m_scrolledWindow, -1, wxDefaultPosition, m_splitter = new wxThinSplitterWindow(m_scrolledWindow, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxSP_3DBORDER | wxCLIP_CHILDREN /* | wxSP_LIVE_UPDATE */); wxDefaultSize, wxSP_3DBORDER | wxCLIP_CHILDREN /* | wxSP_LIVE_UPDATE */);
m_splitter->SetSashSize(2); m_splitter->SetSashSize(2);
m_tree = new PropsTree(m_splitter, -1, wxDefaultPosition, m_tree = new PropsTree(m_splitter, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxNO_BORDER ); wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxNO_BORDER );
m_tree->SetIndent(2); m_tree->SetIndent(2);
m_valueWindow = new PropsValueWindow(m_splitter, -1, wxDefaultPosition, m_valueWindow = new PropsValueWindow(m_splitter, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxNO_BORDER); wxDefaultSize, wxNO_BORDER);
m_valueWindow->SetBackgroundColour(m_tree->GetBackgroundColour()); m_valueWindow->SetBackgroundColour(m_tree->GetBackgroundColour());
m_splitter->SplitVertically(m_tree, m_valueWindow, wxConfig::Get()->Read(_T("propertiesframe_sash"), 100)); m_splitter->SplitVertically(m_tree, m_valueWindow, wxConfig::Get()->Read(_T("propertiesframe_sash"), 100));
//m_splitter->AdjustScrollbars(); //m_splitter->AdjustScrollbars();
m_scrolledWindow->SetTargetWindow(m_tree); m_scrolledWindow->SetTargetWindow(m_tree);
m_scrolledWindow->EnableScrolling(FALSE, FALSE); m_scrolledWindow->EnableScrolling(false, false);
// Let the two controls know about each other // Let the two controls know about each other
m_valueWindow->SetTreeCtrl(m_tree); m_valueWindow->SetTreeCtrl(m_tree);
m_tree->SetCompanionWindow(m_valueWindow); m_tree->SetCompanionWindow(m_valueWindow);
wxConfigBase *cfg = wxConfigBase::Get(); wxConfigBase *cfg = wxConfigBase::Get();
SetSize(wxRect(wxPoint(cfg->Read(_T("propertiesframe_x"), -1), cfg->Read(_T("propertiesframe_y"), -1)), SetSize(wxRect(wxPoint(cfg->Read(_T("propertiesframe_x"), wxDefaultPosition.x), cfg->Read(_T("propertiesframe_y"), wxDefaultPosition.y)),
wxSize(cfg->Read(_T("propertiesframe_w"), 200), cfg->Read(_T("propertiesframe_h"), 200)))); wxSize(cfg->Read(_T("propertiesframe_w"), 200), cfg->Read(_T("propertiesframe_h"), 200))));
m_EditCtrls.DeleteContents(TRUE);
m_EditCtrls.DeleteContents(true);
m_EditCtrls.Put(_T("bool"), new PropEditCtrlBool(this)); m_EditCtrls.Put(_T("bool"), new PropEditCtrlBool(this));
m_EditCtrls.Put(_T("coord"), new PropEditCtrlCoord(this)); m_EditCtrls.Put(_T("coord"), new PropEditCtrlCoord(this));
m_EditCtrls.Put(_T("color"), new PropEditCtrlColor(this)); m_EditCtrls.Put(_T("color"), new PropEditCtrlColor(this));
@@ -264,7 +264,7 @@ PropertiesFrame::PropertiesFrame()
m_EditCtrls.Put(_T("file"), new PropEditCtrlFile(this)); m_EditCtrls.Put(_T("file"), new PropEditCtrlFile(this));
m_EditCtrls.Put(_T("imagefile"), new PropEditCtrlImageFile(this)); m_EditCtrls.Put(_T("imagefile"), new PropEditCtrlImageFile(this));
m_EditCtrls.Put(_T(""), new PropEditCtrlNull(this)); m_EditCtrls.Put(_T(""), new PropEditCtrlNull(this));
ClearProps(); ClearProps();
} }
@@ -272,26 +272,26 @@ PropertiesFrame::PropertiesFrame()
PropertiesFrame::~PropertiesFrame() PropertiesFrame::~PropertiesFrame()
{ {
wxConfigBase *cfg = wxConfigBase::Get(); wxConfigBase *cfg = wxConfigBase::Get();
cfg->Write(_T("propertiesframe_x"), (long)GetPosition().x); cfg->Write(_T("propertiesframe_x"), (long)GetPosition().x);
cfg->Write(_T("propertiesframe_y"), (long)GetPosition().y); cfg->Write(_T("propertiesframe_y"), (long)GetPosition().y);
cfg->Write(_T("propertiesframe_w"), (long)GetSize().x); cfg->Write(_T("propertiesframe_w"), (long)GetSize().x);
cfg->Write(_T("propertiesframe_h"), (long)GetSize().y); cfg->Write(_T("propertiesframe_h"), (long)GetSize().y);
cfg->Write(_T("propertiesframe_sash"), (long)m_splitter->GetSashPosition()); cfg->Write(_T("propertiesframe_sash"), (long)m_splitter->GetSashPosition());
ms_Instance = NULL; ms_Instance = NULL;
} }
void PropertiesFrame::ShowProps(wxXmlNode *node) void PropertiesFrame::ShowProps(wxXmlNode *node)
{ {
m_Node = node; m_Node = node;
ClearProps(); ClearProps();
AddSingleProp(PropertyInfo(_T("xmlid"), _T("XRCID"), wxEmptyString)); AddSingleProp(PropertyInfo(_T("xmlid"), _T("XRCID"), wxEmptyString));
AddProps(NodeHandler::Find(node)->GetPropsList(node)); AddProps(NodeHandler::Find(node)->GetPropsList(node));
m_tree->Expand(m_tree->GetRootItem()); m_tree->Expand(m_tree->GetRootItem());
m_valueWindow->Refresh(); m_valueWindow->Refresh();
} }
@@ -321,7 +321,7 @@ void PropertiesFrame::AddSingleProp(const PropertyInfo& pinfo, wxTreeItemId *roo
wxTreeItemId tid; wxTreeItemId tid;
if (root != NULL) tid = *root; if (root != NULL) tid = *root;
else tid = m_tree->GetRootItem(); else tid = m_tree->GetRootItem();
if (pec == NULL) if (pec == NULL)
wxLogError(_("Unknown property type '%s'!"), pinfo.Type.c_str()); wxLogError(_("Unknown property type '%s'!"), pinfo.Type.c_str());
else else

View File

@@ -27,15 +27,15 @@ class PropertiesFrame : public wxFrame
public: public:
PropertiesFrame(); PropertiesFrame();
~PropertiesFrame(); ~PropertiesFrame();
void ShowProps(wxXmlNode *node); void ShowProps(wxXmlNode *node);
void ClearProps(); void ClearProps();
void AddProps(PropertyInfoArray& plist); void AddProps(PropertyInfoArray& plist);
void AddSingleProp(const PropertyInfo& pinfo, wxTreeItemId *root = NULL); void AddSingleProp(const PropertyInfo& pinfo, wxTreeItemId *root = NULL);
static PropertiesFrame *Get(); static PropertiesFrame *Get();
private: private:
static PropertiesFrame *ms_Instance; static PropertiesFrame *ms_Instance;
@@ -43,11 +43,11 @@ class PropertiesFrame : public wxFrame
wxRemotelyScrolledTreeCtrl *m_tree; wxRemotelyScrolledTreeCtrl *m_tree;
wxThinSplitterWindow *m_splitter; wxThinSplitterWindow *m_splitter;
wxSplitterScrolledWindow *m_scrolledWindow; wxSplitterScrolledWindow *m_scrolledWindow;
wxTreeCompanionWindow *m_valueWindow; wxTreeCompanionWindow *m_valueWindow;
wxHashTable m_EditCtrls; wxHashTable m_EditCtrls;
friend class PropEditCtrl; friend class PropEditCtrl;
}; };

View File

@@ -58,17 +58,17 @@ BEGIN_EVENT_TABLE(wxRemotelyScrolledTreeCtrl, wxGenericTreeCtrl)
#else #else
BEGIN_EVENT_TABLE(wxRemotelyScrolledTreeCtrl, wxTreeCtrl) BEGIN_EVENT_TABLE(wxRemotelyScrolledTreeCtrl, wxTreeCtrl)
#endif #endif
EVT_SIZE(wxRemotelyScrolledTreeCtrl::OnSize) EVT_SIZE(wxRemotelyScrolledTreeCtrl::OnSize)
EVT_TREE_ITEM_EXPANDED(-1, wxRemotelyScrolledTreeCtrl::OnExpand) EVT_TREE_ITEM_EXPANDED(wxID_ANY, wxRemotelyScrolledTreeCtrl::OnExpand)
EVT_TREE_ITEM_COLLAPSED(-1, wxRemotelyScrolledTreeCtrl::OnExpand) EVT_TREE_ITEM_COLLAPSED(wxID_ANY, wxRemotelyScrolledTreeCtrl::OnExpand)
EVT_SCROLLWIN(wxRemotelyScrolledTreeCtrl::OnScroll) EVT_SCROLLWIN(wxRemotelyScrolledTreeCtrl::OnScroll)
END_EVENT_TABLE() END_EVENT_TABLE()
wxRemotelyScrolledTreeCtrl::wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt, wxRemotelyScrolledTreeCtrl::wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt,
const wxSize& sz, long style): const wxSize& sz, long style):
wxTreeCtrl(parent, id, pt, sz, style) wxTreeCtrl(parent, id, pt, sz, style)
{ {
m_companionWindow = NULL; m_companionWindow = NULL;
} }
wxRemotelyScrolledTreeCtrl::~wxRemotelyScrolledTreeCtrl() wxRemotelyScrolledTreeCtrl::~wxRemotelyScrolledTreeCtrl()
@@ -80,7 +80,7 @@ void wxRemotelyScrolledTreeCtrl::HideVScrollbar()
#if defined(__WXMSW__) && USE_GENERIC_TREECTRL #if defined(__WXMSW__) && USE_GENERIC_TREECTRL
if (!IsKindOf(CLASSINFO(wxGenericTreeCtrl))) if (!IsKindOf(CLASSINFO(wxGenericTreeCtrl)))
{ {
::ShowScrollBar((HWND) GetHWND(), SB_VERT, FALSE); ::ShowScrollBar((HWND) GetHWND(), SB_VERT, false);
} }
else else
#endif #endif
@@ -103,9 +103,9 @@ void wxRemotelyScrolledTreeCtrl::SetScrollbars(int pixelsPerUnitX, int pixelsPer
wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this; wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this;
win->wxGenericTreeCtrl::SetScrollbars(pixelsPerUnitX, 0, noUnitsX, 0, xPos, 0, noRefresh); win->wxGenericTreeCtrl::SetScrollbars(pixelsPerUnitX, 0, noUnitsX, 0, xPos, 0, noRefresh);
wxScrolledWindow* scrolledWindow = GetScrolledWindow(); wxScrolledWindow* scrolledWindow = GetScrolledWindow();
if (scrolledWindow) if (scrolledWindow)
{ {
scrolledWindow->SetScrollbars(0, pixelsPerUnitY, 0, noUnitsY, 0, yPos, noRefresh); scrolledWindow->SetScrollbars(0, pixelsPerUnitY, 0, noUnitsY, 0, yPos, noRefresh);
} }
} }
@@ -163,13 +163,13 @@ void wxRemotelyScrolledTreeCtrl::GetViewStart(int *x, int *y) const
scrolledWindow->GetViewStart(& x2, & y2); scrolledWindow->GetViewStart(& x2, & y2);
* y = y2; * y = y2;
} }
else else
#endif #endif
{ {
// x is wrong since the horizontal scrollbar is controlled by the // x is wrong since the horizontal scrollbar is controlled by the
// tree control, but we probably don't need it. // tree control, but we probably don't need it.
scrolledWindow->GetViewStart(x, y); scrolledWindow->GetViewStart(x, y);
} }
} }
// In case we're using the generic tree control. // In case we're using the generic tree control.
@@ -178,7 +178,7 @@ void wxRemotelyScrolledTreeCtrl::PrepareDC(wxDC& dc)
{ {
if (IsKindOf(CLASSINFO(wxGenericTreeCtrl))) if (IsKindOf(CLASSINFO(wxGenericTreeCtrl)))
{ {
wxScrolledWindow* scrolledWindow = GetScrolledWindow(); wxScrolledWindow* scrolledWindow = GetScrolledWindow();
wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this; wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this;
@@ -207,9 +207,9 @@ void wxRemotelyScrolledTreeCtrl::ScrollToLine(int WXUNUSED(posHoriz), int posVer
if (!IsKindOf(CLASSINFO(wxGenericTreeCtrl))) if (!IsKindOf(CLASSINFO(wxGenericTreeCtrl)))
#endif #endif
{ {
UINT sbCode = SB_THUMBPOSITION; UINT sbCode = SB_THUMBPOSITION;
HWND vertScrollBar = 0; HWND vertScrollBar = 0;
MSWDefWindowProc((WXUINT) WM_VSCROLL, MAKELONG(sbCode, posVert), (WXLPARAM) vertScrollBar); MSWDefWindowProc((WXUINT) WM_VSCROLL, MAKELONG(sbCode, posVert), (WXLPARAM) vertScrollBar);
} }
#if USE_GENERIC_TREECTRL #if USE_GENERIC_TREECTRL
else else
@@ -218,39 +218,39 @@ void wxRemotelyScrolledTreeCtrl::ScrollToLine(int WXUNUSED(posHoriz), int posVer
#if USE_GENERIC_TREECTRL || !defined(__WXMSW__) #if USE_GENERIC_TREECTRL || !defined(__WXMSW__)
{ {
wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this; wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this;
win->Refresh(); win->Refresh();
/* Doesn't work yet because scrolling is ignored by Scroll /* Doesn't work yet because scrolling is ignored by Scroll
int xppu, yppu; int xppu, yppu;
wxScrolledWindow* scrolledWindow = GetScrolledWindow(); wxScrolledWindow* scrolledWindow = GetScrolledWindow();
if (scrolledWindow) if (scrolledWindow)
{ {
scrolledWindow->GetScrollPixelsPerUnit(& xppu, & yppu); scrolledWindow->GetScrollPixelsPerUnit(& xppu, & yppu);
win->Scroll(-1, posVert*yppu); win->Scroll(-1, posVert*yppu);
} }
*/ */
} }
#endif #endif
} }
void wxRemotelyScrolledTreeCtrl::OnSize(wxSizeEvent& event) void wxRemotelyScrolledTreeCtrl::OnSize(wxSizeEvent& event)
{ {
HideVScrollbar(); HideVScrollbar();
AdjustRemoteScrollbars(); AdjustRemoteScrollbars();
event.Skip(); event.Skip();
} }
void wxRemotelyScrolledTreeCtrl::OnExpand(wxTreeEvent& event) void wxRemotelyScrolledTreeCtrl::OnExpand(wxTreeEvent& event)
{ {
AdjustRemoteScrollbars(); AdjustRemoteScrollbars();
event.Skip(); event.Skip();
// If we don't have this, we get some bits of lines still remaining // If we don't have this, we get some bits of lines still remaining
if (event.GetEventType() == wxEVT_COMMAND_TREE_ITEM_COLLAPSED) if (event.GetEventType() == wxEVT_COMMAND_TREE_ITEM_COLLAPSED)
Refresh(); Refresh();
// Pass on the event // Pass on the event
if (m_companionWindow) if (m_companionWindow)
m_companionWindow->GetEventHandler()->ProcessEvent(event); m_companionWindow->GetEventHandler()->ProcessEvent(event);
} }
// Adjust the containing wxScrolledWindow's scrollbars appropriately // Adjust the containing wxScrolledWindow's scrollbars appropriately
@@ -258,50 +258,50 @@ void wxRemotelyScrolledTreeCtrl::AdjustRemoteScrollbars()
{ {
#if USE_GENERIC_TREECTRL || !defined(__WXMSW__) #if USE_GENERIC_TREECTRL || !defined(__WXMSW__)
if (IsKindOf(CLASSINFO(wxGenericTreeCtrl))) if (IsKindOf(CLASSINFO(wxGenericTreeCtrl)))
{ {
// This is for the generic tree control. // This is for the generic tree control.
// It calls SetScrollbars which has been overridden // It calls SetScrollbars which has been overridden
// to adjust the parent scrolled window vertical // to adjust the parent scrolled window vertical
// scrollbar. // scrollbar.
((wxGenericTreeCtrl*) this)->AdjustMyScrollbars(); ((wxGenericTreeCtrl*) this)->AdjustMyScrollbars();
return; return;
} }
else else
#endif #endif
{ {
// This is for the wxMSW tree control // This is for the wxMSW tree control
wxScrolledWindow* scrolledWindow = GetScrolledWindow(); wxScrolledWindow* scrolledWindow = GetScrolledWindow();
if (scrolledWindow) if (scrolledWindow)
{ {
wxRect itemRect; wxRect itemRect;
if (GetBoundingRect(GetRootItem(), itemRect)) if (GetBoundingRect(GetRootItem(), itemRect))
{ {
// Actually, the real height seems to be 1 less than reported // Actually, the real height seems to be 1 less than reported
// (e.g. 16 instead of 16) // (e.g. 16 instead of 16)
int itemHeight = itemRect.GetHeight() - 1; int itemHeight = itemRect.GetHeight() - 1;
int w, h; int w, h;
GetClientSize(&w, &h); GetClientSize(&w, &h);
wxRect rect(0, 0, 0, 0); wxRect rect(0, 0, 0, 0);
CalcTreeSize(rect); CalcTreeSize(rect);
double f = ((double) (rect.GetHeight()) / (double) itemHeight) ; double f = ((double) (rect.GetHeight()) / (double) itemHeight) ;
int treeViewHeight = (int) ceil(f); int treeViewHeight = (int) ceil(f);
int scrollPixelsPerLine = itemHeight; int scrollPixelsPerLine = itemHeight;
int scrollPos = - (itemRect.y / itemHeight); int scrollPos = - (itemRect.y / itemHeight);
scrolledWindow->SetScrollbars(0, scrollPixelsPerLine, 0, treeViewHeight, 0, scrollPos); scrolledWindow->SetScrollbars(0, scrollPixelsPerLine, 0, treeViewHeight, 0, scrollPos);
// Ensure that when a scrollbar becomes hidden or visible, // Ensure that when a scrollbar becomes hidden or visible,
// the contained window sizes are right. // the contained window sizes are right.
// Problem: this is called too early (?) // Problem: this is called too early (?)
wxSizeEvent event(scrolledWindow->GetSize(), scrolledWindow->GetId()); wxSizeEvent event(scrolledWindow->GetSize(), scrolledWindow->GetId());
scrolledWindow->GetEventHandler()->ProcessEvent(event); scrolledWindow->GetEventHandler()->ProcessEvent(event);
} }
} }
} }
} }
@@ -314,10 +314,10 @@ static wxRect CombineRectangles(const wxRect& rect1, const wxRect& rect2)
int bottom1 = rect1.GetBottom(); int bottom1 = rect1.GetBottom();
int right2 = rect2.GetRight(); int right2 = rect2.GetRight();
int bottom2 = rect2.GetBottom(); int bottom2 = rect2.GetBottom();
wxPoint topLeft = wxPoint(wxMin(rect1.x, rect2.x), wxMin(rect1.y, rect2.y)); wxPoint topLeft = wxPoint(wxMin(rect1.x, rect2.x), wxMin(rect1.y, rect2.y));
wxPoint bottomRight = wxPoint(wxMax(right1, right2), wxMax(bottom1, bottom2)); wxPoint bottomRight = wxPoint(wxMax(right1, right2), wxMax(bottom1, bottom2));
rect.x = topLeft.x; rect.y = topLeft.y; rect.x = topLeft.x; rect.y = topLeft.y;
rect.SetRight(bottomRight.x); rect.SetRight(bottomRight.x);
rect.SetBottom(bottomRight.y); rect.SetBottom(bottomRight.y);
@@ -330,40 +330,40 @@ static wxRect CombineRectangles(const wxRect& rect1, const wxRect& rect2)
// correctly // correctly
void wxRemotelyScrolledTreeCtrl::CalcTreeSize(wxRect& rect) void wxRemotelyScrolledTreeCtrl::CalcTreeSize(wxRect& rect)
{ {
CalcTreeSize(GetRootItem(), rect); CalcTreeSize(GetRootItem(), rect);
} }
void wxRemotelyScrolledTreeCtrl::CalcTreeSize(const wxTreeItemId& id, wxRect& rect) void wxRemotelyScrolledTreeCtrl::CalcTreeSize(const wxTreeItemId& id, wxRect& rect)
{ {
// More efficient implementation would be to find the last item (but how?) // More efficient implementation would be to find the last item (but how?)
// Q: is the bounding rect relative to the top of the virtual tree workspace // Q: is the bounding rect relative to the top of the virtual tree workspace
// or the top of the window? How would we convert? // or the top of the window? How would we convert?
wxRect itemSize; wxRect itemSize;
if (GetBoundingRect(id, itemSize)) if (GetBoundingRect(id, itemSize))
{ {
rect = CombineRectangles(rect, itemSize); rect = CombineRectangles(rect, itemSize);
} }
void* cookie; void* cookie;
wxTreeItemId childId = GetFirstChild(id, cookie); wxTreeItemId childId = GetFirstChild(id, cookie);
while (childId) while (childId)
{ {
CalcTreeSize(childId, rect); CalcTreeSize(childId, rect);
childId = GetNextChild(childId, cookie); childId = GetNextChild(childId, cookie);
} }
} }
// Find the scrolled window that contains this control // Find the scrolled window that contains this control
wxScrolledWindow* wxRemotelyScrolledTreeCtrl::GetScrolledWindow() const wxScrolledWindow* wxRemotelyScrolledTreeCtrl::GetScrolledWindow() const
{ {
wxWindow* parent = wxWindow::GetParent(); wxWindow* parent = wxWindow::GetParent();
while (parent) while (parent)
{ {
if (parent->IsKindOf(CLASSINFO(wxScrolledWindow))) if (parent->IsKindOf(CLASSINFO(wxScrolledWindow)))
return (wxScrolledWindow*) parent; return (wxScrolledWindow*) parent;
parent = parent->GetParent(); parent = parent->GetParent();
} }
return NULL; return NULL;
} }
void wxRemotelyScrolledTreeCtrl::OnScroll(wxScrollWinEvent& event) void wxRemotelyScrolledTreeCtrl::OnScroll(wxScrollWinEvent& event)
@@ -393,77 +393,77 @@ void wxRemotelyScrolledTreeCtrl::OnScroll(wxScrollWinEvent& event)
IMPLEMENT_CLASS(wxTreeCompanionWindow, wxWindow) IMPLEMENT_CLASS(wxTreeCompanionWindow, wxWindow)
BEGIN_EVENT_TABLE(wxTreeCompanionWindow, wxWindow) BEGIN_EVENT_TABLE(wxTreeCompanionWindow, wxWindow)
EVT_PAINT(wxTreeCompanionWindow::OnPaint) EVT_PAINT(wxTreeCompanionWindow::OnPaint)
EVT_SCROLLWIN(wxTreeCompanionWindow::OnScroll) EVT_SCROLLWIN(wxTreeCompanionWindow::OnScroll)
EVT_TREE_ITEM_EXPANDED(-1, wxTreeCompanionWindow::OnExpand) EVT_TREE_ITEM_EXPANDED(wxID_ANY, wxTreeCompanionWindow::OnExpand)
EVT_TREE_ITEM_COLLAPSED(-1, wxTreeCompanionWindow::OnExpand) EVT_TREE_ITEM_COLLAPSED(wxID_ANY, wxTreeCompanionWindow::OnExpand)
END_EVENT_TABLE() END_EVENT_TABLE()
wxTreeCompanionWindow::wxTreeCompanionWindow(wxWindow* parent, wxWindowID id, wxTreeCompanionWindow::wxTreeCompanionWindow(wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxPoint& pos,
const wxSize& sz, const wxSize& sz,
long style): long style):
wxWindow(parent, id, pos, sz, style) wxWindow(parent, id, pos, sz, style)
{ {
m_treeCtrl = NULL; m_treeCtrl = NULL;
} }
void wxTreeCompanionWindow::DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) void wxTreeCompanionWindow::DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect)
{ {
// TEST CODE // TEST CODE
#if 1 #if 1
if (m_treeCtrl) if (m_treeCtrl)
{ {
wxString text = m_treeCtrl->GetItemText(id); wxString text = m_treeCtrl->GetItemText(id);
dc.SetTextForeground(* wxBLACK); dc.SetTextForeground(* wxBLACK);
dc.SetBackgroundMode(wxTRANSPARENT); dc.SetBackgroundMode(wxTRANSPARENT);
int textW, textH; int textW, textH;
dc.GetTextExtent(text, & textW, & textH); dc.GetTextExtent(text, & textW, & textH);
int x = 5; int x = 5;
int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2); int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2);
dc.DrawText(text, x, y); dc.DrawText(text, x, y);
} }
#endif #endif
} }
void wxTreeCompanionWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) void wxTreeCompanionWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
{ {
wxPaintDC dc(this); wxPaintDC dc(this);
if (!m_treeCtrl) if (!m_treeCtrl)
return; return;
wxPen pen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID); wxPen pen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID);
dc.SetPen(pen); dc.SetPen(pen);
dc.SetBrush(* wxTRANSPARENT_BRUSH); dc.SetBrush(* wxTRANSPARENT_BRUSH);
wxFont font(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); wxFont font(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
dc.SetFont(font); dc.SetFont(font);
wxSize clientSize = GetClientSize(); wxSize clientSize = GetClientSize();
wxRect itemRect; wxRect itemRect;
wxTreeItemId h, lastH; wxTreeItemId h, lastH;
for(h=m_treeCtrl->GetFirstVisibleItem();h;h=m_treeCtrl->GetNextVisible(h)) for(h=m_treeCtrl->GetFirstVisibleItem();h;h=m_treeCtrl->GetNextVisible(h))
{ {
if (m_treeCtrl->GetBoundingRect(h, itemRect)) if (m_treeCtrl->GetBoundingRect(h, itemRect))
{ {
int cy = itemRect.GetTop(); int cy = itemRect.GetTop();
wxRect drawItemRect(0, cy, clientSize.x, itemRect.GetHeight()); wxRect drawItemRect(0, cy, clientSize.x, itemRect.GetHeight());
lastH = h; lastH = h;
// Draw the actual item // Draw the actual item
DrawItem(dc, h, drawItemRect); DrawItem(dc, h, drawItemRect);
dc.DrawLine(0, cy, clientSize.x, cy); dc.DrawLine(0, cy, clientSize.x, cy);
} }
} }
if (lastH.IsOk() && m_treeCtrl->GetBoundingRect(lastH, itemRect)) if (lastH.IsOk() && m_treeCtrl->GetBoundingRect(lastH, itemRect))
{ {
int cy = itemRect.GetBottom(); int cy = itemRect.GetBottom();
dc.DrawLine(0, cy, clientSize.x, cy); dc.DrawLine(0, cy, clientSize.x, cy);
} }
} }
void wxTreeCompanionWindow::OnScroll(wxScrollWinEvent& event) void wxTreeCompanionWindow::OnScroll(wxScrollWinEvent& event)
@@ -477,15 +477,15 @@ void wxTreeCompanionWindow::OnScroll(wxScrollWinEvent& event)
if (!m_treeCtrl) if (!m_treeCtrl)
return; return;
// TODO: scroll the window physically instead of just refreshing. // TODO: scroll the window physically instead of just refreshing.
Refresh(TRUE); Refresh(true);
} }
void wxTreeCompanionWindow::OnExpand(wxTreeEvent& WXUNUSED(event)) void wxTreeCompanionWindow::OnExpand(wxTreeEvent& WXUNUSED(event))
{ {
// TODO: something more optimized than simply refresh the whole // TODO: something more optimized than simply refresh the whole
// window when the tree is expanded/collapsed. Tricky. // window when the tree is expanded/collapsed. Tricky.
Refresh(); Refresh();
} }
/* /*
@@ -495,7 +495,7 @@ void wxTreeCompanionWindow::OnExpand(wxTreeEvent& WXUNUSED(event))
IMPLEMENT_CLASS(wxThinSplitterWindow, wxSplitterWindow) IMPLEMENT_CLASS(wxThinSplitterWindow, wxSplitterWindow)
BEGIN_EVENT_TABLE(wxThinSplitterWindow, wxSplitterWindow) BEGIN_EVENT_TABLE(wxThinSplitterWindow, wxSplitterWindow)
EVT_SIZE(wxThinSplitterWindow::OnSize) EVT_SIZE(wxThinSplitterWindow::OnSize)
END_EVENT_TABLE() END_EVENT_TABLE()
wxThinSplitterWindow::wxThinSplitterWindow(wxWindow* parent, wxWindowID id, wxThinSplitterWindow::wxThinSplitterWindow(wxWindow* parent, wxWindowID id,
@@ -512,9 +512,9 @@ wxThinSplitterWindow::~wxThinSplitterWindow()
void wxThinSplitterWindow::SizeWindows() void wxThinSplitterWindow::SizeWindows()
{ {
// The client size may have changed inbetween // The client size may have changed inbetween
// the sizing of the first window and the sizing of // the sizing of the first window and the sizing of
// the second. So repeat SizeWindows. // the second. So repeat SizeWindows.
wxSplitterWindow::SizeWindows(); wxSplitterWindow::SizeWindows();
wxSplitterWindow::SizeWindows(); wxSplitterWindow::SizeWindows();
} }
@@ -522,7 +522,7 @@ void wxThinSplitterWindow::SizeWindows()
// Tests for x, y over sash // Tests for x, y over sash
bool wxThinSplitterWindow::SashHitTest(int x, int y, int WXUNUSED(tolerance)) bool wxThinSplitterWindow::SashHitTest(int x, int y, int WXUNUSED(tolerance))
{ {
return wxSplitterWindow::SashHitTest(x, y, 4); return wxSplitterWindow::SashHitTest(x, y, 4);
} }
void wxThinSplitterWindow::DrawSash(wxDC& dc) void wxThinSplitterWindow::DrawSash(wxDC& dc)
@@ -535,42 +535,42 @@ void wxThinSplitterWindow::DrawSash(wxDC& dc)
int w, h; int w, h;
GetClientSize(&w, &h); GetClientSize(&w, &h);
if ( m_splitMode == wxSPLIT_VERTICAL ) if ( m_splitMode == wxSPLIT_VERTICAL )
{ {
dc.SetPen(* m_facePen); dc.SetPen(* m_facePen);
dc.SetBrush(* m_faceBrush); dc.SetBrush(* m_faceBrush);
int h1 = h-1; int h1 = h-1;
int y1 = 0; int y1 = 0;
if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER && (GetWindowStyleFlag() & wxSP_3DBORDER) != wxSP_3DBORDER ) if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER && (GetWindowStyleFlag() & wxSP_3DBORDER) != wxSP_3DBORDER )
h1 += 1; // Not sure why this is necessary... h1 += 1; // Not sure why this is necessary...
if ( (GetWindowStyleFlag() & wxSP_3DBORDER) == wxSP_3DBORDER) if ( (GetWindowStyleFlag() & wxSP_3DBORDER) == wxSP_3DBORDER)
{ {
y1 = 2; h1 -= 3; y1 = 2; h1 -= 3;
} }
dc.DrawRectangle(GetSashPosition(), y1, GetSashSize(), h1); dc.DrawRectangle(GetSashPosition(), y1, GetSashSize(), h1);
} }
else else
{ {
dc.SetPen(* m_facePen); dc.SetPen(* m_facePen);
dc.SetBrush(* m_faceBrush); dc.SetBrush(* m_faceBrush);
int w1 = w-1; int w1 = w-1;
int x1 = 0; int x1 = 0;
if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER && (GetWindowStyleFlag() & wxSP_3DBORDER) != wxSP_3DBORDER ) if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER && (GetWindowStyleFlag() & wxSP_3DBORDER) != wxSP_3DBORDER )
w1 ++; w1 ++;
if ( (GetWindowStyleFlag() & wxSP_3DBORDER) == wxSP_3DBORDER) if ( (GetWindowStyleFlag() & wxSP_3DBORDER) == wxSP_3DBORDER)
{ {
x1 = 2; w1 -= 3; x1 = 2; w1 -= 3;
} }
dc.DrawRectangle(x1, GetSashPosition(), w1, GetSashSize()); dc.DrawRectangle(x1, GetSashPosition(), w1, GetSashSize());
} }
dc.SetPen(wxNullPen); dc.SetPen(wxNullPen);
dc.SetBrush(wxNullBrush); dc.SetBrush(wxNullBrush);
} }
void wxThinSplitterWindow::OnSize(wxSizeEvent& event) void wxThinSplitterWindow::OnSize(wxSizeEvent& event)
{ {
wxSplitterWindow::OnSize(event); wxSplitterWindow::OnSize(event);
} }
/* /*
@@ -580,8 +580,8 @@ void wxThinSplitterWindow::OnSize(wxSizeEvent& event)
IMPLEMENT_CLASS(wxSplitterScrolledWindow, wxScrolledWindow) IMPLEMENT_CLASS(wxSplitterScrolledWindow, wxScrolledWindow)
BEGIN_EVENT_TABLE(wxSplitterScrolledWindow, wxScrolledWindow) BEGIN_EVENT_TABLE(wxSplitterScrolledWindow, wxScrolledWindow)
EVT_SCROLLWIN(wxSplitterScrolledWindow::OnScroll) EVT_SCROLLWIN(wxSplitterScrolledWindow::OnScroll)
EVT_SIZE(wxSplitterScrolledWindow::OnSize) EVT_SIZE(wxSplitterScrolledWindow::OnSize)
END_EVENT_TABLE() END_EVENT_TABLE()
wxSplitterScrolledWindow::wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id, wxSplitterScrolledWindow::wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id,
@@ -594,48 +594,48 @@ wxSplitterScrolledWindow::wxSplitterScrolledWindow(wxWindow* parent, wxWindowID
void wxSplitterScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event)) void wxSplitterScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event))
{ {
wxSize sz = GetClientSize(); wxSize sz = GetClientSize();
if (GetChildren().GetFirst()) if (GetChildren().GetFirst())
{ {
((wxWindow*) GetChildren().GetFirst()->GetData())->SetSize(0, 0, sz.x, sz.y); ((wxWindow*) GetChildren().GetFirst()->GetData())->SetSize(0, 0, sz.x, sz.y);
} }
} }
void wxSplitterScrolledWindow::OnScroll(wxScrollWinEvent& event) void wxSplitterScrolledWindow::OnScroll(wxScrollWinEvent& event)
{ {
// Ensure that events being propagated back up the window hierarchy // Ensure that events being propagated back up the window hierarchy
// don't cause an infinite loop // don't cause an infinite loop
static bool inOnScroll = FALSE; static bool inOnScroll = false;
if (inOnScroll) if (inOnScroll)
{ {
event.Skip(); event.Skip();
return; return;
} }
inOnScroll = TRUE; inOnScroll = true;
int orient = event.GetOrientation(); int orient = event.GetOrientation();
int nScrollInc = CalcScrollInc(event); int nScrollInc = CalcScrollInc(event);
if (nScrollInc == 0) if (nScrollInc == 0)
{ {
inOnScroll = FALSE; inOnScroll = false;
return; return;
} }
if (orient == wxHORIZONTAL) if (orient == wxHORIZONTAL)
{ {
inOnScroll = FALSE; inOnScroll = false;
event.Skip(); event.Skip();
return; return;
#if 0 #if 0
int newPos = m_xScrollPosition + nScrollInc; int newPos = m_xScrollPosition + nScrollInc;
SetScrollPos(wxHORIZONTAL, newPos, TRUE ); SetScrollPos(wxHORIZONTAL, newPos, true );
#endif #endif
} }
else else
{ {
int newPos = m_yScrollPosition + nScrollInc; int newPos = m_yScrollPosition + nScrollInc;
SetScrollPos(wxVERTICAL, newPos, TRUE ); SetScrollPos(wxVERTICAL, newPos, true );
} }
if (orient == wxHORIZONTAL) if (orient == wxHORIZONTAL)
@@ -668,6 +668,6 @@ void wxSplitterScrolledWindow::OnScroll(wxScrollWinEvent& event)
m_targetWindow->MacUpdateImmediately() ; m_targetWindow->MacUpdateImmediately() ;
#endif #endif
inOnScroll = FALSE; inOnScroll = false;
} }

View File

@@ -15,7 +15,7 @@
#define _WX_SPLITTREE_H_ #define _WX_SPLITTREE_H_
#if defined(__GNUG__) && !defined(__APPLE__) #if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "splittree.h" #pragma interface "splittree.h"
#endif #endif
// Set this to 1 to use generic tree control (doesn't yet work properly) // Set this to 1 to use generic tree control (doesn't yet work properly)
@@ -48,15 +48,15 @@ class wxSplitterScrolledWindow;
class wxRemotelyScrolledTreeCtrl: public wxTreeCtrl class wxRemotelyScrolledTreeCtrl: public wxTreeCtrl
{ {
DECLARE_CLASS(wxRemotelyScrolledTreeCtrl) DECLARE_CLASS(wxRemotelyScrolledTreeCtrl)
public: public:
wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition, wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition,
const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS); const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS);
~wxRemotelyScrolledTreeCtrl(); ~wxRemotelyScrolledTreeCtrl();
//// Events //// Events
void OnSize(wxSizeEvent& event); void OnSize(wxSizeEvent& event);
void OnExpand(wxTreeEvent& event); void OnExpand(wxTreeEvent& event);
void OnScroll(wxScrollWinEvent& event); void OnScroll(wxScrollWinEvent& event);
//// Overrides //// Overrides
@@ -69,7 +69,7 @@ public:
virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
int noUnitsX, int noUnitsY, int noUnitsX, int noUnitsY,
int xPos = 0, int yPos = 0, int xPos = 0, int yPos = 0,
bool noRefresh = FALSE ); bool noRefresh = false );
// In case we're using the generic tree control. // In case we're using the generic tree control.
// Get the view start // Get the view start
@@ -82,18 +82,18 @@ public:
virtual int GetScrollPos(int orient) const; virtual int GetScrollPos(int orient) const;
//// Helpers //// Helpers
void HideVScrollbar(); void HideVScrollbar();
// Calculate the tree overall size so we can set the scrollbar // Calculate the tree overall size so we can set the scrollbar
// correctly // correctly
void CalcTreeSize(wxRect& rect); void CalcTreeSize(wxRect& rect);
void CalcTreeSize(const wxTreeItemId& id, wxRect& rect); void CalcTreeSize(const wxTreeItemId& id, wxRect& rect);
// Adjust the containing wxScrolledWindow's scrollbars appropriately // Adjust the containing wxScrolledWindow's scrollbars appropriately
void AdjustRemoteScrollbars(); void AdjustRemoteScrollbars();
// Find the scrolled window that contains this control // Find the scrolled window that contains this control
wxScrolledWindow* GetScrolledWindow() const; wxScrolledWindow* GetScrolledWindow() const;
// Scroll to the given line (in scroll units where each unit is // Scroll to the given line (in scroll units where each unit is
// the height of an item) // the height of an item)
@@ -101,15 +101,15 @@ public:
//// Accessors //// Accessors
// The companion window is one which will get notified when certain // The companion window is one which will get notified when certain
// events happen such as node expansion // events happen such as node expansion
void SetCompanionWindow(wxWindow* companion) { m_companionWindow = companion; } void SetCompanionWindow(wxWindow* companion) { m_companionWindow = companion; }
wxWindow* GetCompanionWindow() const { return m_companionWindow; } wxWindow* GetCompanionWindow() const { return m_companionWindow; }
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
protected: protected:
wxWindow* m_companionWindow; wxWindow* m_companionWindow;
}; };
/* /*
@@ -123,28 +123,28 @@ class wxTreeCompanionWindow: public wxWindow
public: public:
DECLARE_CLASS(wxTreeCompanionWindow) DECLARE_CLASS(wxTreeCompanionWindow)
wxTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1, wxTreeCompanionWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize, const wxSize& sz = wxDefaultSize,
long style = 0); long style = 0);
//// Overrides //// Overrides
virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect); virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect);
//// Events //// Events
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
void OnScroll(wxScrollWinEvent& event); void OnScroll(wxScrollWinEvent& event);
void OnExpand(wxTreeEvent& event); void OnExpand(wxTreeEvent& event);
//// Operations //// Operations
//// Accessors //// Accessors
wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const { return m_treeCtrl; }; wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const { return m_treeCtrl; };
void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl) { m_treeCtrl = treeCtrl; } void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl) { m_treeCtrl = treeCtrl; }
//// Data members //// Data members
protected: protected:
wxRemotelyScrolledTreeCtrl* m_treeCtrl; wxRemotelyScrolledTreeCtrl* m_treeCtrl;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
@@ -162,7 +162,7 @@ class wxThinSplitterWindow: public wxSplitterWindow
public: public:
DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow) DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow)
wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1, wxThinSplitterWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize, const wxSize& sz = wxDefaultSize,
long style = wxSP_3D | wxCLIP_CHILDREN); long style = wxSP_3D | wxCLIP_CHILDREN);
@@ -174,10 +174,10 @@ public:
// Tests for x, y over sash. Overriding this allows us to increase // Tests for x, y over sash. Overriding this allows us to increase
// the tolerance. // the tolerance.
bool SashHitTest(int x, int y, int tolerance = 2); bool SashHitTest(int x, int y, int tolerance = 2);
void DrawSash(wxDC& dc); void DrawSash(wxDC& dc);
//// Events //// Events
void OnSize(wxSizeEvent& event); void OnSize(wxSizeEvent& event);
//// Operations //// Operations
@@ -203,7 +203,7 @@ class wxSplitterScrolledWindow: public wxScrolledWindow
public: public:
DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow) DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow)
wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1, wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize, const wxSize& sz = wxDefaultSize,
long style = 0); long style = 0);
@@ -211,7 +211,7 @@ public:
//// Overrides //// Overrides
//// Events //// Events
void OnScroll(wxScrollWinEvent& event); void OnScroll(wxScrollWinEvent& event);
void OnSize(wxSizeEvent& event); void OnSize(wxSizeEvent& event);

View File

@@ -22,7 +22,7 @@ class WXDLLEXPORT wxXmlNode;
class XmlTreeData : public wxTreeItemData class XmlTreeData : public wxTreeItemData
{ {
public: public:
XmlTreeData(wxXmlNode *n) : Node(n) {} XmlTreeData(wxXmlNode *n) : Node(n) {}
wxXmlNode *Node; wxXmlNode *Node;
}; };

View File

@@ -29,7 +29,7 @@ wxXmlNode *XmlFindNodeSimple(wxXmlNode *parent, const wxString& param)
if (param.IsEmpty()) return parent; if (param.IsEmpty()) return parent;
wxXmlNode *n = parent->GetChildren(); wxXmlNode *n = parent->GetChildren();
while (n) while (n)
{ {
if (n->GetType() == wxXML_ELEMENT_NODE && n->GetName() == param) if (n->GetType() == wxXML_ELEMENT_NODE && n->GetName() == param)
@@ -68,13 +68,13 @@ wxXmlNode *XmlCreateNode(wxXmlNode *parent, const wxString& name)
nm = tkn.GetNextToken(); nm = tkn.GetNextToken();
n = XmlFindNodeSimple(parent, nm); n = XmlFindNodeSimple(parent, nm);
if (n) continue; if (n) continue;
// n == NULL: // n == NULL:
n = new wxXmlNode(wxXML_ELEMENT_NODE, nm); n = new wxXmlNode(wxXML_ELEMENT_NODE, nm);
parent->AddChild(n); parent->AddChild(n);
} }
n->AddChild(new wxXmlNode(wxXML_TEXT_NODE, wxEmptyString)); n->AddChild(new wxXmlNode(wxXML_TEXT_NODE, wxEmptyString));
return n; return n;
} }
@@ -85,12 +85,12 @@ void XmlWriteValue(wxXmlNode *parent, const wxString& name, const wxString& valu
wxXmlNode *n = XmlFindNode(parent, name); wxXmlNode *n = XmlFindNode(parent, name);
if (n == NULL) if (n == NULL)
n = XmlCreateNode(parent, name); n = XmlCreateNode(parent, name);
n = n->GetChildren(); n = n->GetChildren();
while (n) while (n)
{ {
if (n->GetType() == wxXML_TEXT_NODE || if (n->GetType() == wxXML_TEXT_NODE ||
n->GetType() == wxXML_CDATA_SECTION_NODE) n->GetType() == wxXML_CDATA_SECTION_NODE)
{ {
n->SetContent(value); n->SetContent(value);
@@ -107,10 +107,10 @@ wxString XmlReadValue(wxXmlNode *parent, const wxString& name)
wxXmlNode *n = XmlFindNode(parent, name); wxXmlNode *n = XmlFindNode(parent, name);
if (n == NULL) return wxEmptyString; if (n == NULL) return wxEmptyString;
n = n->GetChildren(); n = n->GetChildren();
while (n) while (n)
{ {
if (n->GetType() == wxXML_TEXT_NODE || if (n->GetType() == wxXML_TEXT_NODE ||
n->GetType() == wxXML_CDATA_SECTION_NODE) n->GetType() == wxXML_CDATA_SECTION_NODE)
return n->GetContent(); return n->GetContent();
n = n->GetNext(); n = n->GetNext();

View File

@@ -28,4 +28,4 @@ wxXmlNode *XmlFindNodeSimple(wxXmlNode *parent, const wxString& path);
wxString XmlGetClass(wxXmlNode *parent); wxString XmlGetClass(wxXmlNode *parent);
void XmlSetClass(wxXmlNode *parent, const wxString& classname); void XmlSetClass(wxXmlNode *parent, const wxString& classname);
#endif #endif

View File

@@ -24,7 +24,7 @@
class WXDLLIMPEXP_XRC wxGaugeXmlHandler : public wxXmlResourceHandler class WXDLLIMPEXP_XRC wxGaugeXmlHandler : public wxXmlResourceHandler
{ {
DECLARE_DYNAMIC_CLASS(wxGaugeXmlHandler) DECLARE_DYNAMIC_CLASS(wxGaugeXmlHandler)
enum enum
{ {
wxGAUGE_DEFAULT_RANGE = 100 wxGAUGE_DEFAULT_RANGE = 100

View File

@@ -31,7 +31,7 @@ private:
class WXDLLIMPEXP_XRC wxMenuBarXmlHandler : public wxXmlResourceHandler class WXDLLIMPEXP_XRC wxMenuBarXmlHandler : public wxXmlResourceHandler
{ {
DECLARE_DYNAMIC_CLASS(wxMenuBarXmlHandler) DECLARE_DYNAMIC_CLASS(wxMenuBarXmlHandler)
public: public:
wxMenuBarXmlHandler(); wxMenuBarXmlHandler();
virtual wxObject *DoCreateResource(); virtual wxObject *DoCreateResource();

View File

@@ -22,7 +22,7 @@
class WXDLLIMPEXP_XRC wxScrollBarXmlHandler : public wxXmlResourceHandler class WXDLLIMPEXP_XRC wxScrollBarXmlHandler : public wxXmlResourceHandler
{ {
DECLARE_DYNAMIC_CLASS(wxScrollBarXmlHandler) DECLARE_DYNAMIC_CLASS(wxScrollBarXmlHandler)
enum enum
{ {
wxSL_DEFAULT_VALUE = 0, wxSL_DEFAULT_VALUE = 0,

View File

@@ -33,7 +33,7 @@ public:
private: private:
bool m_isInside; bool m_isInside;
bool m_isGBS; bool m_isGBS;
wxSizer *m_parentSizer; wxSizer *m_parentSizer;
bool IsSizerNode(wxXmlNode *node); bool IsSizerNode(wxXmlNode *node);
@@ -52,7 +52,7 @@ private:
wxGBSpan GetGBSpan(const wxString& param); wxGBSpan GetGBSpan(const wxString& param);
wxSizerItem* MakeSizerItem(); wxSizerItem* MakeSizerItem();
void SetSizerItemAttributes(wxSizerItem* sitem); void SetSizerItemAttributes(wxSizerItem* sitem);
void AddSizerItem(wxSizerItem* sitem); void AddSizerItem(wxSizerItem* sitem);
}; };

View File

@@ -22,7 +22,7 @@
class WXDLLIMPEXP_XRC wxSliderXmlHandler : public wxXmlResourceHandler class WXDLLIMPEXP_XRC wxSliderXmlHandler : public wxXmlResourceHandler
{ {
DECLARE_DYNAMIC_CLASS(wxSliderXmlHandler) DECLARE_DYNAMIC_CLASS(wxSliderXmlHandler)
enum enum
{ {
wxSL_DEFAULT_VALUE = 0, wxSL_DEFAULT_VALUE = 0,

View File

@@ -21,7 +21,7 @@
#if wxUSE_SPINBTN #if wxUSE_SPINBTN
class WXDLLIMPEXP_XRC wxSpinButtonXmlHandler : public wxXmlResourceHandler class WXDLLIMPEXP_XRC wxSpinButtonXmlHandler : public wxXmlResourceHandler
{ {
DECLARE_DYNAMIC_CLASS(wxSpinButtonXmlHandler) DECLARE_DYNAMIC_CLASS(wxSpinButtonXmlHandler)
enum enum
{ {
wxSP_DEFAULT_VALUE = 0, wxSP_DEFAULT_VALUE = 0,
@@ -39,7 +39,7 @@ public:
#if wxUSE_SPINCTRL #if wxUSE_SPINCTRL
class WXDLLIMPEXP_XRC wxSpinCtrlXmlHandler : public wxXmlResourceHandler class WXDLLIMPEXP_XRC wxSpinCtrlXmlHandler : public wxXmlResourceHandler
{ {
DECLARE_DYNAMIC_CLASS(wxSpinCtrlXmlHandler) DECLARE_DYNAMIC_CLASS(wxSpinCtrlXmlHandler)
enum enum
{ {
wxSP_DEFAULT_VALUE = 0, wxSP_DEFAULT_VALUE = 0,

View File

@@ -240,7 +240,7 @@ protected:
bool UpdateResources(); bool UpdateResources();
// Finds a resource (calls UpdateResources) and returns a node containing it. // Finds a resource (calls UpdateResources) and returns a node containing it.
wxXmlNode *FindResource(const wxString& name, const wxString& classname, bool recursive = FALSE); wxXmlNode *FindResource(const wxString& name, const wxString& classname, bool recursive = false);
// Helper function: finds a resource (calls UpdateResources) and returns a node containing it. // Helper function: finds a resource (calls UpdateResources) and returns a node containing it.
wxXmlNode *DoFindResource(wxXmlNode *parent, const wxString& name, const wxString& classname, bool recursive); wxXmlNode *DoFindResource(wxXmlNode *parent, const wxString& name, const wxString& classname, bool recursive);
@@ -329,8 +329,8 @@ public:
// were filled. // were filled.
virtual wxObject *DoCreateResource() = 0; virtual wxObject *DoCreateResource() = 0;
// Returns TRUE if it understands this node and can create // Returns true if it understands this node and can create
// a resource from it, FALSE otherwise. // a resource from it, false otherwise.
virtual bool CanHandle(wxXmlNode *node) = 0; virtual bool CanHandle(wxXmlNode *node) = 0;
// Sets the parent resource. // Sets the parent resource.
@@ -385,7 +385,7 @@ protected:
// - replaces \n, \r, \t by respective chars (according to C syntax) // - replaces \n, \r, \t by respective chars (according to C syntax)
// - replaces _ by & and __ by _ (needed for _File => &File because of XML) // - replaces _ by & and __ by _ (needed for _File => &File because of XML)
// - calls wxGetTranslations (unless disabled in wxXmlResource) // - calls wxGetTranslations (unless disabled in wxXmlResource)
wxString GetText(const wxString& param, bool translate = TRUE); wxString GetText(const wxString& param, bool translate = true);
// Returns the XRCID. // Returns the XRCID.
int GetID(); int GetID();
@@ -393,8 +393,8 @@ protected:
// Returns the resource name. // Returns the resource name.
wxString GetName(); wxString GetName();
// Gets a bool flag (1, t, yes, on, true are TRUE, everything else is FALSE). // Gets a bool flag (1, t, yes, on, true are true, everything else is false).
bool GetBool(const wxString& param, bool defaultv = FALSE); bool GetBool(const wxString& param, bool defaultv = false);
// Gets the integer value from the parameter. // Gets the integer value from the parameter.
long GetLong( const wxString& param, long defaultv = 0 ); long GetLong( const wxString& param, long defaultv = 0 );
@@ -428,7 +428,7 @@ protected:
void SetupWindow(wxWindow *wnd); void SetupWindow(wxWindow *wnd);
// Creates children. // Creates children.
void CreateChildren(wxObject *parent, bool this_hnd_only = FALSE); void CreateChildren(wxObject *parent, bool this_hnd_only = false);
// Helper function. // Helper function.
void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL); void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL);

View File

@@ -42,18 +42,18 @@
// Internal constants // Internal constants
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Popup menu (PU) item control IDs. In this example, they aren't hooked up // Popup menu (PU) item control IDs. In this example, they aren't hooked up
// to any functions. Normally you would use these IDs in your event table, so // to any functions. Normally you would use these IDs in your event table, so
// that if one of these menu items is clicked, then a certain function is // that if one of these menu items is clicked, then a certain function is
// called. // called.
enum { enum {
PU_ADD_RECORD = wxID_HIGHEST + 1, PU_ADD_RECORD = wxID_HIGHEST + 1,
PU_EDIT_RECORD, PU_EDIT_RECORD,
PU_DELETE_RECORD PU_DELETE_RECORD
}; };
// Columns of the listctrl (the leftmost one starts at 0, and so on). // Columns of the listctrl (the leftmost one starts at 0, and so on).
// Allows easier code maintenance if want to add/rearrangement of listctrl's // Allows easier code maintenance if want to add/rearrangement of listctrl's
// columns. // columns.
enum { enum {
RECORD_COLUMN = 0, RECORD_COLUMN = 0,
@@ -71,9 +71,9 @@ IMPLEMENT_DYNAMIC_CLASS( MyResizableListCtrl, wxListCtrl )
// Event table: connect the events to the handler functions to process them // Event table: connect the events to the handler functions to process them
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
BEGIN_EVENT_TABLE( MyResizableListCtrl, wxListCtrl ) BEGIN_EVENT_TABLE( MyResizableListCtrl, wxListCtrl )
// Something to do when right mouse down // Something to do when right mouse down
EVT_RIGHT_DOWN( MyResizableListCtrl::ContextSensitiveMenu ) EVT_RIGHT_DOWN( MyResizableListCtrl::ContextSensitiveMenu )
// Something to do when resized // Something to do when resized
EVT_SIZE( MyResizableListCtrl::OnSize ) EVT_SIZE( MyResizableListCtrl::OnSize )
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -90,15 +90,15 @@ MyResizableListCtrl::MyResizableListCtrl( wxWindow *parent, wxWindowID id,
const wxString& name ) const wxString& name )
: wxListCtrl( parent, id, pos, size, style, validator, name ) : wxListCtrl( parent, id, pos, size, style, validator, name )
{ {
// This listctrl needs to insert its columns in the constructor, since // This listctrl needs to insert its columns in the constructor, since
// as soon as the listctrl is built, it is resized and grafted onto an // as soon as the listctrl is built, it is resized and grafted onto an
// "unknown" XRC placeholder. This induces an OnSize() event, calling the // "unknown" XRC placeholder. This induces an OnSize() event, calling the
// overrriden OnSize function for this class, which needs to have 3 // overrriden OnSize function for this class, which needs to have 3
// columns to resize (else an assert on WXGTK debug build). // columns to resize (else an assert on WXGTK debug build).
InsertColumn( RECORD_COLUMN, _("Record"), wxLIST_FORMAT_LEFT, 140); InsertColumn( RECORD_COLUMN, _("Record"), wxLIST_FORMAT_LEFT, 140);
InsertColumn( ACTION_COLUMN, _("Action"), wxLIST_FORMAT_LEFT, 70); InsertColumn( ACTION_COLUMN, _("Action"), wxLIST_FORMAT_LEFT, 70);
InsertColumn( PRIORITY_COLUMN, _("Priority"), wxLIST_FORMAT_LEFT, 70 ); InsertColumn( PRIORITY_COLUMN, _("Priority"), wxLIST_FORMAT_LEFT, 70 );
} }
@@ -115,16 +115,16 @@ void MyResizableListCtrl::ContextSensitiveMenu( wxMouseEvent& event )
a_menu.Append( PU_ADD_RECORD, _( "Add a new record...") ); a_menu.Append( PU_ADD_RECORD, _( "Add a new record...") );
a_menu.Append( PU_EDIT_RECORD, _( "Edit selected record..." ) ); a_menu.Append( PU_EDIT_RECORD, _( "Edit selected record..." ) );
a_menu.Append( PU_DELETE_RECORD, _( "Delete selected record" ) ); a_menu.Append( PU_DELETE_RECORD, _( "Delete selected record" ) );
// If no listctrl rows selected, then disable the menu items that // If no listctrl rows selected, then disable the menu items that
// require selection // require selection
if ( GetSelectedItemCount() == 0 ) { if ( GetSelectedItemCount() == 0 ) {
a_menu.Enable( PU_EDIT_RECORD, FALSE ); a_menu.Enable( PU_EDIT_RECORD, false );
a_menu.Enable( PU_DELETE_RECORD, FALSE ); a_menu.Enable( PU_DELETE_RECORD, false );
} }
// Show the popup menu (wxWindow::PopupMenu ), at the x,y position // Show the popup menu (wxWindow::PopupMenu ), at the x,y position
// of the click event // of the click event
PopupMenu( &a_menu, event.GetPosition() ); PopupMenu( &a_menu, event.GetPosition() );
} }
@@ -133,28 +133,28 @@ void MyResizableListCtrl::OnSize( wxSizeEvent &event )
{ {
// Call our custom width setting function. // Call our custom width setting function.
SetColumnWidths(); SetColumnWidths();
// REQURED event.Skip() call to allow this event to propagate // REQURED event.Skip() call to allow this event to propagate
// upwards so others can do what they need to do in response to // upwards so others can do what they need to do in response to
// this size event. // this size event.
event.Skip(); event.Skip();
} }
void MyResizableListCtrl::SetColumnWidths() void MyResizableListCtrl::SetColumnWidths()
{ {
// Get width of entire listctrl // Get width of entire listctrl
int leftmostColumnWidth = GetSize().x; int leftmostColumnWidth = GetSize().x;
// Subtract width of other columns, scrollbar, and some padding // Subtract width of other columns, scrollbar, and some padding
leftmostColumnWidth -= GetColumnWidth( ACTION_COLUMN ); leftmostColumnWidth -= GetColumnWidth( ACTION_COLUMN );
leftmostColumnWidth -= GetColumnWidth( PRIORITY_COLUMN ); leftmostColumnWidth -= GetColumnWidth( PRIORITY_COLUMN );
leftmostColumnWidth -= wxSystemSettings::GetSystemMetric( wxSYS_VSCROLL_X ); leftmostColumnWidth -= wxSystemSettings::GetSystemMetric( wxSYS_VSCROLL_X );
leftmostColumnWidth -= 5; leftmostColumnWidth -= 5;
// Set the column width to the new value. // Set the column width to the new value.
SetColumnWidth( RECORD_COLUMN, leftmostColumnWidth ); SetColumnWidth( RECORD_COLUMN, leftmostColumnWidth );
// This is just a debug message in case you want to watch the // This is just a debug message in case you want to watch the
// events scroll by as you resize. // events scroll by as you resize.
wxLogDebug( wxT("Successfully set column widths") ); wxLogDebug( wxT("Successfully set column widths") );
} }

View File

@@ -38,14 +38,14 @@ class MyResizableListCtrl : public wxListCtrl
// Very helpful wxWidgets macro required for wxWidgets-RTTI tracing: By using this // Very helpful wxWidgets macro required for wxWidgets-RTTI tracing: By using this
// you will see "Leaked one object of type myResizeableListCtrl" in the debug log, // you will see "Leaked one object of type myResizeableListCtrl" in the debug log,
// along with which line you if was created, but you forget to free the memory. // along with which line you if was created, but you forget to free the memory.
// NOTE: Using this REQUIRES a default constructor: that means either: giving a // NOTE: Using this REQUIRES a default constructor: that means either: giving a
// default value for all parameters in your constructor, or else having a dummy // default value for all parameters in your constructor, or else having a dummy
// MyResizableListCtrl(){} constructor in addition to your regular one. // MyResizableListCtrl(){} constructor in addition to your regular one.
DECLARE_DYNAMIC_CLASS( MyResizableListCtrl ) DECLARE_DYNAMIC_CLASS( MyResizableListCtrl )
public: public:
// Constructor. // Constructor.
/* /*
These parameters are the same as a wxWidgets constructor. These parameters are the same as a wxWidgets constructor.
\param parent The parent window. \param parent The parent window.
@@ -60,33 +60,33 @@ public:
column. column.
*/ */
MyResizableListCtrl( wxWindow *parent = NULL, MyResizableListCtrl( wxWindow *parent = NULL,
wxWindowID id = -1, wxWindowID id = wxID_ANY,
const wxPoint &pos = wxDefaultPosition, const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize, const wxSize &size = wxDefaultSize,
long style = wxLC_REPORT, long style = wxLC_REPORT,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString &name = wxT("myResizableListCtrl") const wxString &name = wxT("myResizableListCtrl")
); );
// Destuctor. // Destuctor.
~MyResizableListCtrl(); ~MyResizableListCtrl();
protected: protected:
// A custom function for a context sensitive menu.
void ContextSensitiveMenu( wxMouseEvent& event );
// A custom function for a context sensitive menu.
void ContextSensitiveMenu( wxMouseEvent& event );
// This is a wxWidgets function that we are going to override with our own behaviour. // This is a wxWidgets function that we are going to override with our own behaviour.
void OnSize( wxSizeEvent &event ); void OnSize( wxSizeEvent &event );
// A custom function. What is called in the constructor, and in an OnSize() // A custom function. What is called in the constructor, and in an OnSize()
void SetColumnWidths(); void SetColumnWidths();
private: private:
// wxWidgets macro, required to be able to use Event tables in the .cpp file. // wxWidgets macro, required to be able to use Event tables in the .cpp file.
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------

View File

@@ -49,7 +49,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(PreferencesDialog, wxDialog) BEGIN_EVENT_TABLE(PreferencesDialog, wxDialog)
EVT_BUTTON( XRCID( "my_button" ), PreferencesDialog::OnMyButtonClicked ) EVT_BUTTON( XRCID( "my_button" ), PreferencesDialog::OnMyButtonClicked )
EVT_UPDATE_UI(XRCID( "my_checkbox" ), PreferencesDialog::OuUpdateUIMyCheckbox ) EVT_UPDATE_UI(XRCID( "my_checkbox" ), PreferencesDialog::OuUpdateUIMyCheckbox )
// Note that the ID here isn't a XRCID, it is one of the standard wx ID's. // Note that the ID here isn't a XRCID, it is one of the standard wx ID's.
EVT_BUTTON( wxID_OK, PreferencesDialog::OnOK ) EVT_BUTTON( wxID_OK, PreferencesDialog::OnOK )
@@ -60,7 +60,7 @@ END_EVENT_TABLE()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Constructor (Notice how small and easy it is) // Constructor (Notice how small and easy it is)
PreferencesDialog::PreferencesDialog(wxWindow* parent) PreferencesDialog::PreferencesDialog(wxWindow* parent)
{ {
wxXmlResource::Get()->LoadDialog(this, parent, wxT("derived_dialog")); wxXmlResource::Get()->LoadDialog(this, parent, wxT("derived_dialog"));
} }
@@ -76,29 +76,29 @@ PreferencesDialog::~PreferencesDialog()
void PreferencesDialog::OnMyButtonClicked( wxCommandEvent &WXUNUSED(event) ) void PreferencesDialog::OnMyButtonClicked( wxCommandEvent &WXUNUSED(event) )
{ {
// Construct a message dialog. // Construct a message dialog.
wxMessageDialog msgDlg(this, _("You clicked on My Button")); wxMessageDialog msgDlg(this, _("You clicked on My Button"));
// Show it modally. // Show it modally.
msgDlg.ShowModal(); msgDlg.ShowModal();
} }
// Update the enabled/disabled state of the edit/delete buttons depending on // Update the enabled/disabled state of the edit/delete buttons depending on
// whether a row (item) is selected in the listctrl // whether a row (item) is selected in the listctrl
void PreferencesDialog::OuUpdateUIMyCheckbox( wxUpdateUIEvent &WXUNUSED(event) ) void PreferencesDialog::OuUpdateUIMyCheckbox( wxUpdateUIEvent &WXUNUSED(event) )
{ {
// Get a boolean value of whether the checkbox is checked // Get a boolean value of whether the checkbox is checked
bool myCheckBoxIsChecked; bool myCheckBoxIsChecked;
// You could just write: // You could just write:
// myCheckBoxIsChecked = event.IsChecked(); // myCheckBoxIsChecked = event.IsChecked();
// since the event that was passed into this function already has the // since the event that was passed into this function already has the
// is a pointer to the right control. However, // is a pointer to the right control. However,
// this is the XRCCTRL way (which is more obvious as to what is going on). // this is the XRCCTRL way (which is more obvious as to what is going on).
myCheckBoxIsChecked = XRCCTRL(*this, "my_checkbox", wxCheckBox)->IsChecked(); myCheckBoxIsChecked = XRCCTRL(*this, "my_checkbox", wxCheckBox)->IsChecked();
// Now call either Enable(TRUE) or Enable(FALSE) on the textctrl, depending // Now call either Enable(true) or Enable(false) on the textctrl, depending
// on the value of that boolean. // on the value of that boolean.
XRCCTRL(*this, "my_textctrl", wxTextCtrl)->Enable(myCheckBoxIsChecked); XRCCTRL(*this, "my_textctrl", wxTextCtrl)->Enable(myCheckBoxIsChecked);
} }
@@ -108,16 +108,16 @@ void PreferencesDialog::OnOK( wxCommandEvent& WXUNUSED(event) )
wxMessageDialog msgDlg2(this, _("Press OK to close Derived dialog, or Cancel to abort"), wxMessageDialog msgDlg2(this, _("Press OK to close Derived dialog, or Cancel to abort"),
_("Overriding base class OK button handler"), _("Overriding base class OK button handler"),
wxOK | wxCANCEL | wxCENTER ); wxOK | wxCANCEL | wxCENTER );
// Show the message dialog, and if it returns wxID_OK (ie they clicked on OK button)... // Show the message dialog, and if it returns wxID_OK (ie they clicked on OK button)...
if (msgDlg2.ShowModal() == wxID_OK) if (msgDlg2.ShowModal() == wxID_OK)
{ {
// ...then end this Preferences dialog. // ...then end this Preferences dialog.
EndModal( wxID_OK ); EndModal( wxID_OK );
// You could also have used event.Skip() which would then skip up // You could also have used event.Skip() which would then skip up
// to the wxDialog's event table and see if there was a EVT_BUTTON // to the wxDialog's event table and see if there was a EVT_BUTTON
// handler for wxID_OK and if there was, then execute that code. // handler for wxID_OK and if there was, then execute that code.
} }
// Otherwise do nothing. // Otherwise do nothing.
} }

View File

@@ -36,26 +36,26 @@
class PreferencesDialog : public wxDialog class PreferencesDialog : public wxDialog
{ {
public: public:
// Constructor. // Constructor.
/* /*
\param parent The parent window. Simple constructor. \param parent The parent window. Simple constructor.
*/ */
PreferencesDialog( wxWindow* parent ); PreferencesDialog( wxWindow* parent );
// Destructor. // Destructor.
~PreferencesDialog(); ~PreferencesDialog();
private: private:
// Stuff to do when "My Button" gets clicked // Stuff to do when "My Button" gets clicked
void OnMyButtonClicked( wxCommandEvent &event ); void OnMyButtonClicked( wxCommandEvent &event );
// Stuff to do when a "My Checkbox" gets updated // Stuff to do when a "My Checkbox" gets updated
// (drawn, or it changes its value) // (drawn, or it changes its value)
void OuUpdateUIMyCheckbox( wxUpdateUIEvent &event ); void OuUpdateUIMyCheckbox( wxUpdateUIEvent &event );
// Override base class functions of a wxDialog. // Override base class functions of a wxDialog.
void OnOK( wxCommandEvent &event ); void OnOK( wxCommandEvent &event );

View File

@@ -76,18 +76,18 @@
// The event tables connect the wxWidgets events with the functions (event // The event tables connect the wxWidgets events with the functions (event
// handlers) which process them. It can be also done at run-time, but for the // handlers) which process them. It can be also done at run-time, but for the
// simple menu events like this the static method is much simpler. // simple menu events like this the static method is much simpler.
// The reason why the menuitems and tools are given the same name in the // The reason why the menuitems and tools are given the same name in the
// XRC file, is that both a tool (a toolbar item) and a menuitem are designed // XRC file, is that both a tool (a toolbar item) and a menuitem are designed
// to fire the same kind of event (an EVT_MENU) and thus I give them the same // to fire the same kind of event (an EVT_MENU) and thus I give them the same
// ID name to help new users emphasize this point which is often overlooked // ID name to help new users emphasize this point which is often overlooked
// when starting out with wxWidgets. // when starting out with wxWidgets.
BEGIN_EVENT_TABLE(MyFrame, wxFrame) BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(XRCID("exit_tool_or_menuitem"), MyFrame::OnExitToolOrMenuCommand) EVT_MENU(XRCID("exit_tool_or_menuitem"), MyFrame::OnExitToolOrMenuCommand)
EVT_MENU(XRCID("non_derived_dialog_tool_or_menuitem"), MyFrame::OnNonDerivedDialogToolOrMenuCommand) EVT_MENU(XRCID("non_derived_dialog_tool_or_menuitem"), MyFrame::OnNonDerivedDialogToolOrMenuCommand)
EVT_MENU(XRCID("derived_tool_or_menuitem"), MyFrame::OnDerivedDialogToolOrMenuCommand) EVT_MENU(XRCID("derived_tool_or_menuitem"), MyFrame::OnDerivedDialogToolOrMenuCommand)
EVT_MENU(XRCID("controls_tool_or_menuitem"), MyFrame::OnControlsToolOrMenuCommand) EVT_MENU(XRCID("controls_tool_or_menuitem"), MyFrame::OnControlsToolOrMenuCommand)
EVT_MENU(XRCID("uncentered_tool_or_menuitem"), MyFrame::OnUncenteredToolOrMenuCommand) EVT_MENU(XRCID("uncentered_tool_or_menuitem"), MyFrame::OnUncenteredToolOrMenuCommand)
EVT_MENU(XRCID("custom_class_tool_or_menuitem"), MyFrame::OnCustomClassToolOrMenuCommand) EVT_MENU(XRCID("custom_class_tool_or_menuitem"), MyFrame::OnCustomClassToolOrMenuCommand)
EVT_MENU(XRCID("platform_property_tool_or_menuitem"), MyFrame::OnPlatformPropertyToolOrMenuCommand) EVT_MENU(XRCID("platform_property_tool_or_menuitem"), MyFrame::OnPlatformPropertyToolOrMenuCommand)
EVT_MENU(XRCID("art_provider_tool_or_menuitem"), MyFrame::OnArtProviderToolOrMenuCommand) EVT_MENU(XRCID("art_provider_tool_or_menuitem"), MyFrame::OnArtProviderToolOrMenuCommand)
EVT_MENU(XRCID("variable_expansion_tool_or_menuitem"), MyFrame::OnVariableExpansionToolOrMenuCommand) EVT_MENU(XRCID("variable_expansion_tool_or_menuitem"), MyFrame::OnVariableExpansionToolOrMenuCommand)
@@ -102,12 +102,12 @@ END_EVENT_TABLE()
MyFrame::MyFrame(wxWindow* parent) MyFrame::MyFrame(wxWindow* parent)
{ {
// Load up this frame from XRC. [Note, instead of making a class's // Load up this frame from XRC. [Note, instead of making a class's
// constructor take a wxWindow* parent with a default value of NULL, // constructor take a wxWindow* parent with a default value of NULL,
// we could have just had designed MyFrame class with an empty // we could have just had designed MyFrame class with an empty
// constructor and then written here: // constructor and then written here:
// wxXmlResource::Get()->LoadFrame(this, (wxWindow* )NULL, "main_frame"); // wxXmlResource::Get()->LoadFrame(this, (wxWindow* )NULL, "main_frame");
// since this frame will always be the top window, and thus parentless. // since this frame will always be the top window, and thus parentless.
// However, the current approach has source code that can be recycled // However, the current approach has source code that can be recycled
// for other frames that aren't the top level window.] // for other frames that aren't the top level window.]
wxXmlResource::Get()->LoadFrame(this, parent, wxT("main_frame")); wxXmlResource::Get()->LoadFrame(this, parent, wxT("main_frame"));
@@ -121,9 +121,9 @@ MyFrame::MyFrame(wxWindow* parent)
// With toolbars, you currently can't create one, and set it later. It // With toolbars, you currently can't create one, and set it later. It
// needs to be all in one step. // needs to be all in one step.
SetToolBar(wxXmlResource::Get()->LoadToolBar(this, wxT("main_toolbar"))); SetToolBar(wxXmlResource::Get()->LoadToolBar(this, wxT("main_toolbar")));
// Give the frame a optional statusbar. The '1' just means one field. // Give the frame a optional statusbar. The '1' just means one field.
// A gripsizer will automatically get put on into the corner, if that // A gripsizer will automatically get put on into the corner, if that
// is the normal OS behaviour for frames on that platform. Helptext // is the normal OS behaviour for frames on that platform. Helptext
// for menu items and toolbar tools will automatically get displayed // for menu items and toolbar tools will automatically get displayed
// here. // here.
@@ -136,8 +136,8 @@ MyFrame::MyFrame(wxWindow* parent)
void MyFrame::OnExitToolOrMenuCommand(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnExitToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{ {
// TRUE is to force the frame to close. // true is to force the frame to close.
Close(TRUE); Close(true);
} }
@@ -152,10 +152,10 @@ void MyFrame::OnNonDerivedDialogToolOrMenuCommand(wxCommandEvent& WXUNUSED(event
} }
void MyFrame::OnDerivedDialogToolOrMenuCommand(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnDerivedDialogToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{ {
// Make an instance of our derived dialog, passing it "this" window // Make an instance of our derived dialog, passing it "this" window
// (the main frame) as the parent of the dialog. This allows the dialog // (the main frame) as the parent of the dialog. This allows the dialog
// to be destructed automatically when the parent is destroyed. // to be destructed automatically when the parent is destroyed.
PreferencesDialog preferencesDialog(this); PreferencesDialog preferencesDialog(this);
// Show the instance of the dialog, modally. // Show the instance of the dialog, modally.
@@ -163,19 +163,19 @@ void MyFrame::OnDerivedDialogToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
} }
void MyFrame::OnControlsToolOrMenuCommand(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnControlsToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{ {
wxDialog dlg; wxDialog dlg;
wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("controls_dialog")); wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("controls_dialog"));
#if wxUSE_LISTCTRL #if wxUSE_LISTCTRL
// There is no data in the listctrl. This will add some columns // There is no data in the listctrl. This will add some columns
// and some data. You don't need use any pointers // and some data. You don't need use any pointers
// at all to manipulate the controls, just simply use the XRCCTL(...) macros. // at all to manipulate the controls, just simply use the XRCCTL(...) macros.
// "controls_treectrl" is the name of this control in the XRC. // "controls_treectrl" is the name of this control in the XRC.
// (1) Insert a column, with the column header of "Name" // (1) Insert a column, with the column header of "Name"
// (The '_' function around "Name" marks this string as one to translate). // (The '_' function around "Name" marks this string as one to translate).
XRCCTRL(dlg, "controls_listctrl", wxListCtrl)->InsertColumn( 0, XRCCTRL(dlg, "controls_listctrl", wxListCtrl)->InsertColumn( 0,
_("Name"), _("Name"),
wxLIST_FORMAT_LEFT, wxLIST_FORMAT_LEFT,
( 200 ) ( 200 )
@@ -186,12 +186,12 @@ void MyFrame::OnControlsToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
XRCCTRL(dlg, "controls_listctrl", wxListCtrl)->InsertItem(2,wxT("Leon Li")); XRCCTRL(dlg, "controls_listctrl", wxListCtrl)->InsertItem(2,wxT("Leon Li"));
#endif #endif
#if wxUSE_TREECTRL #if wxUSE_TREECTRL
// There is no data in the tree ctrl. These lines will add some. // There is no data in the tree ctrl. These lines will add some.
// (1) Instead of having to write out // (1) Instead of having to write out
// XRCCTRL(dlg, "controls_treectrl", wxTreeCtrl)->SomeFunction() // XRCCTRL(dlg, "controls_treectrl", wxTreeCtrl)->SomeFunction()
// each time (which is also OK), this example code will shown how // each time (which is also OK), this example code will shown how
// to make a pointer to the XRC control, so we can use // to make a pointer to the XRC control, so we can use
// treectrl->SomeFunction() as a short cut. This is useful if you // treectrl->SomeFunction() as a short cut. This is useful if you
// will be referring to this control often in the code. // will be referring to this control often in the code.
wxTreeCtrl* treectrl = XRCCTRL(dlg, "controls_treectrl", wxTreeCtrl); wxTreeCtrl* treectrl = XRCCTRL(dlg, "controls_treectrl", wxTreeCtrl);
@@ -200,15 +200,15 @@ void MyFrame::OnControlsToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
// (3)Append some items to the root node. // (3)Append some items to the root node.
treectrl->AppendItem(treectrl->GetRootItem(), _("Evil henchman 1")); treectrl->AppendItem(treectrl->GetRootItem(), _("Evil henchman 1"));
treectrl->AppendItem(treectrl->GetRootItem(), _("Evil henchman 2")); treectrl->AppendItem(treectrl->GetRootItem(), _("Evil henchman 2"));
treectrl->AppendItem(treectrl->GetRootItem(), _("Evil accountant")); treectrl->AppendItem(treectrl->GetRootItem(), _("Evil accountant"));
#endif #endif
// All done. Show the dialog. // All done. Show the dialog.
dlg.ShowModal(); dlg.ShowModal();
} }
void MyFrame::OnUncenteredToolOrMenuCommand(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnUncenteredToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{ {
wxDialog dlg; wxDialog dlg;
wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("uncentered_dialog")); wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("uncentered_dialog"));
@@ -220,16 +220,16 @@ void MyFrame::OnCustomClassToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{ {
wxDialog dlg; wxDialog dlg;
wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("custom_class_dialog")); wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("custom_class_dialog"));
// Make an instance of our new custom class. // Make an instance of our new custom class.
MyResizableListCtrl* a_myResizableListCtrl = new MyResizableListCtrl(&dlg, MyResizableListCtrl* a_myResizableListCtrl = new MyResizableListCtrl(&dlg,
-1, wxID_ANY,
wxDefaultPosition, wxDefaultPosition,
wxDefaultSize, wxDefaultSize,
wxLC_REPORT, wxLC_REPORT,
wxDefaultValidator); wxDefaultValidator);
// "custom_control_placeholder" is the name of the "unknown" tag in the // "custom_control_placeholder" is the name of the "unknown" tag in the
// custctrl.xrc XRC file. // custctrl.xrc XRC file.
wxXmlResource::Get()->AttachUnknownControl(wxT("custom_control_placeholder"), wxXmlResource::Get()->AttachUnknownControl(wxT("custom_control_placeholder"),
a_myResizableListCtrl); a_myResizableListCtrl);

View File

@@ -41,7 +41,7 @@ public:
// Constructor. // Constructor.
MyFrame( wxWindow* parent=(wxWindow *)NULL); MyFrame( wxWindow* parent=(wxWindow *)NULL);
private: private:
// Event handlers (these functions should _not_ be virtual) // Event handlers (these functions should _not_ be virtual)
void OnExitToolOrMenuCommand(wxCommandEvent& event); void OnExitToolOrMenuCommand(wxCommandEvent& event);
@@ -49,7 +49,7 @@ private:
void OnNonDerivedDialogToolOrMenuCommand(wxCommandEvent& event); void OnNonDerivedDialogToolOrMenuCommand(wxCommandEvent& event);
void OnDerivedDialogToolOrMenuCommand(wxCommandEvent& event); void OnDerivedDialogToolOrMenuCommand(wxCommandEvent& event);
void OnControlsToolOrMenuCommand(wxCommandEvent& event); void OnControlsToolOrMenuCommand(wxCommandEvent& event);
void OnUncenteredToolOrMenuCommand(wxCommandEvent& event); void OnUncenteredToolOrMenuCommand(wxCommandEvent& event);
void OnCustomClassToolOrMenuCommand(wxCommandEvent& event); void OnCustomClassToolOrMenuCommand(wxCommandEvent& event);
void OnPlatformPropertyToolOrMenuCommand(wxCommandEvent& event); void OnPlatformPropertyToolOrMenuCommand(wxCommandEvent& event);
void OnArtProviderToolOrMenuCommand(wxCommandEvent& event); void OnArtProviderToolOrMenuCommand(wxCommandEvent& event);

View File

@@ -75,18 +75,18 @@ bool MyApp::OnInit()
// you want PNGs, then add a PNG handler, etc. See wxImage::AddHandler() // you want PNGs, then add a PNG handler, etc. See wxImage::AddHandler()
// documentation for the types of image handlers available. // documentation for the types of image handlers available.
wxImage::AddHandler(new wxXPMHandler); wxImage::AddHandler(new wxXPMHandler);
// Initialize all the XRC handlers. Always required (unless you feel like // Initialize all the XRC handlers. Always required (unless you feel like
// going through and initializing a handler of each control type you will // going through and initializing a handler of each control type you will
// be using (ie initialize the spinctrl handler, initialize the textctrl // be using (ie initialize the spinctrl handler, initialize the textctrl
// handler). However, if you are only using a few control types, it will // handler). However, if you are only using a few control types, it will
// save some space to only initialize the ones you will be using. See // save some space to only initialize the ones you will be using. See
// wxXRC docs for details. // wxXRC docs for details.
wxXmlResource::Get()->InitAllHandlers(); wxXmlResource::Get()->InitAllHandlers();
// Load all of the XRC files that will be used. You can put everything // Load all of the XRC files that will be used. You can put everything
// into one giant XRC file if you wanted, but then they become more // into one giant XRC file if you wanted, but then they become more
// diffcult to manage, and harder to reuse in later projects. // diffcult to manage, and harder to reuse in later projects.
// The menubar // The menubar
wxXmlResource::Get()->Load(wxT("rc/menu.xrc")); wxXmlResource::Get()->Load(wxT("rc/menu.xrc"));
// The toolbar // The toolbar
@@ -100,7 +100,7 @@ bool MyApp::OnInit()
// Frame example // Frame example
wxXmlResource::Get()->Load(wxT("rc/frame.xrc")); wxXmlResource::Get()->Load(wxT("rc/frame.xrc"));
// Uncentered example // Uncentered example
wxXmlResource::Get()->Load(wxT("rc/uncenter.xrc")); wxXmlResource::Get()->Load(wxT("rc/uncenter.xrc"));
// Custom class example // Custom class example
wxXmlResource::Get()->Load(wxT("rc/custclas.xrc")); wxXmlResource::Get()->Load(wxT("rc/custclas.xrc"));
// wxArtProvider example // wxArtProvider example
@@ -110,15 +110,15 @@ bool MyApp::OnInit()
// Variable expansion example // Variable expansion example
wxXmlResource::Get()->Load(wxT("rc/variable.xrc")); wxXmlResource::Get()->Load(wxT("rc/variable.xrc"));
// Make an instance of your derived frame. Passing NULL (the default value // Make an instance of your derived frame. Passing NULL (the default value
// of MyFrame's constructor is NULL) as the frame doesn't have a frame // of MyFrame's constructor is NULL) as the frame doesn't have a frame
// since it is the first window. // since it is the first window.
MyFrame *frame = new MyFrame(); MyFrame *frame = new MyFrame();
// Show the frame. // Show the frame.
frame->Show(TRUE); frame->Show(true);
// Return TRUE to tell program to continue (FALSE would terminate). // Return true to tell program to continue (false would terminate).
return TRUE; return true;
} }

View File

@@ -39,12 +39,12 @@ class MyApp : public wxApp
public: public:
// Override base class virtuals: // Override base class virtuals:
// wxApp::OnInit() is called on application startup and is a good place // wxApp::OnInit() is called on application startup and is a good place
// for the app initialization (doing it here and not in the ctor // for the app initialization (doing it here and not in the ctor
// allows to have an error return: if OnInit() returns false, the // allows to have an error return: if OnInit() returns false, the
// application terminates) // application terminates)
virtual bool OnInit(); virtual bool OnInit();
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Vaclav Slavik // Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_bmp.h" #pragma implementation "xh_bmp.h"
#endif #endif
@@ -24,13 +24,13 @@
IMPLEMENT_DYNAMIC_CLASS(wxBitmapXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxBitmapXmlHandler, wxXmlResourceHandler)
wxBitmapXmlHandler::wxBitmapXmlHandler() wxBitmapXmlHandler::wxBitmapXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
} }
wxObject *wxBitmapXmlHandler::DoCreateResource() wxObject *wxBitmapXmlHandler::DoCreateResource()
{ {
return new wxBitmap(GetBitmap(wxT(""))); return new wxBitmap(GetBitmap(wxT("")));
} }
@@ -41,13 +41,13 @@ bool wxBitmapXmlHandler::CanHandle(wxXmlNode *node)
IMPLEMENT_DYNAMIC_CLASS(wxIconXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxIconXmlHandler, wxXmlResourceHandler)
wxIconXmlHandler::wxIconXmlHandler() wxIconXmlHandler::wxIconXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
} }
wxObject *wxIconXmlHandler::DoCreateResource() wxObject *wxIconXmlHandler::DoCreateResource()
{ {
return new wxIcon(GetIcon(wxT(""))); return new wxIcon(GetIcon(wxT("")));
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Brian Gavin // Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_bmpbt.h" #pragma implementation "xh_bmpbt.h"
#endif #endif
@@ -24,8 +24,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButtonXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxBitmapButtonXmlHandler, wxXmlResourceHandler)
wxBitmapButtonXmlHandler::wxBitmapButtonXmlHandler() wxBitmapButtonXmlHandler::wxBitmapButtonXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxBU_AUTODRAW); XRC_ADD_STYLE(wxBU_AUTODRAW);
XRC_ADD_STYLE(wxBU_LEFT); XRC_ADD_STYLE(wxBU_LEFT);
@@ -37,7 +37,7 @@ wxBitmapButtonXmlHandler::wxBitmapButtonXmlHandler()
} }
wxObject *wxBitmapButtonXmlHandler::DoCreateResource() wxObject *wxBitmapButtonXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(button, wxBitmapButton) XRC_MAKE_INSTANCE(button, wxBitmapButton)
button->Create(m_parentAsWindow, button->Create(m_parentAsWindow,
@@ -50,14 +50,14 @@ wxObject *wxBitmapButtonXmlHandler::DoCreateResource()
if (GetBool(wxT("default"), 0)) if (GetBool(wxT("default"), 0))
button->SetDefault(); button->SetDefault();
SetupWindow(button); SetupWindow(button);
if (!GetParamValue(wxT("selected")).IsEmpty()) if (!GetParamValue(wxT("selected")).IsEmpty())
button->SetBitmapSelected(GetBitmap(wxT("selected"))); button->SetBitmapSelected(GetBitmap(wxT("selected")));
if (!GetParamValue(wxT("focus")).IsEmpty()) if (!GetParamValue(wxT("focus")).IsEmpty())
button->SetBitmapFocus(GetBitmap(wxT("focus"))); button->SetBitmapFocus(GetBitmap(wxT("focus")));
if (!GetParamValue(wxT("disabled")).IsEmpty()) if (!GetParamValue(wxT("disabled")).IsEmpty())
button->SetBitmapDisabled(GetBitmap(wxT("disabled"))); button->SetBitmapDisabled(GetBitmap(wxT("disabled")));
return button; return button;
} }

View File

@@ -7,7 +7,7 @@
// Copyright: (c) 2000 Vaclav Slavik // Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "xh_bttn.h" #pragma implementation "xh_bttn.h"
#endif #endif
@@ -24,8 +24,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxButtonXmlHandler, wxXmlResourceHandler) IMPLEMENT_DYNAMIC_CLASS(wxButtonXmlHandler, wxXmlResourceHandler)
wxButtonXmlHandler::wxButtonXmlHandler() wxButtonXmlHandler::wxButtonXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxBU_LEFT); XRC_ADD_STYLE(wxBU_LEFT);
XRC_ADD_STYLE(wxBU_RIGHT); XRC_ADD_STYLE(wxBU_RIGHT);
@@ -36,7 +36,7 @@ wxButtonXmlHandler::wxButtonXmlHandler()
} }
wxObject *wxButtonXmlHandler::DoCreateResource() wxObject *wxButtonXmlHandler::DoCreateResource()
{ {
XRC_MAKE_INSTANCE(button, wxButton) XRC_MAKE_INSTANCE(button, wxButton)
button->Create(m_parentAsWindow, button->Create(m_parentAsWindow,
@@ -50,7 +50,7 @@ wxObject *wxButtonXmlHandler::DoCreateResource()
if (GetBool(wxT("default"), 0)) if (GetBool(wxT("default"), 0))
button->SetDefault(); button->SetDefault();
SetupWindow(button); SetupWindow(button);
return button; return button;
} }

Some files were not shown because too many files have changed in this diff Show More