class WXDLLIMPEXP_XRC wxGaugeXmlHandler : public wxXmlResourceHandler
{
- DECLARE_DYNAMIC_CLASS(wxGaugeXmlHandler)
+ DECLARE_DYNAMIC_CLASS(wxGaugeXmlHandler)
enum
{
wxGAUGE_DEFAULT_RANGE = 100
class WXDLLIMPEXP_XRC wxMenuBarXmlHandler : public wxXmlResourceHandler
{
- DECLARE_DYNAMIC_CLASS(wxMenuBarXmlHandler)
+ DECLARE_DYNAMIC_CLASS(wxMenuBarXmlHandler)
public:
wxMenuBarXmlHandler();
virtual wxObject *DoCreateResource();
class WXDLLIMPEXP_XRC wxScrollBarXmlHandler : public wxXmlResourceHandler
{
- DECLARE_DYNAMIC_CLASS(wxScrollBarXmlHandler)
+ DECLARE_DYNAMIC_CLASS(wxScrollBarXmlHandler)
enum
{
wxSL_DEFAULT_VALUE = 0,
private:
bool m_isInside;
bool m_isGBS;
-
+
wxSizer *m_parentSizer;
bool IsSizerNode(wxXmlNode *node);
wxGBSpan GetGBSpan(const wxString& param);
wxSizerItem* MakeSizerItem();
void SetSizerItemAttributes(wxSizerItem* sitem);
- void AddSizerItem(wxSizerItem* sitem);
+ void AddSizerItem(wxSizerItem* sitem);
};
class WXDLLIMPEXP_XRC wxSliderXmlHandler : public wxXmlResourceHandler
{
- DECLARE_DYNAMIC_CLASS(wxSliderXmlHandler)
+ DECLARE_DYNAMIC_CLASS(wxSliderXmlHandler)
enum
{
wxSL_DEFAULT_VALUE = 0,
#if wxUSE_SPINBTN
class WXDLLIMPEXP_XRC wxSpinButtonXmlHandler : public wxXmlResourceHandler
{
- DECLARE_DYNAMIC_CLASS(wxSpinButtonXmlHandler)
+ DECLARE_DYNAMIC_CLASS(wxSpinButtonXmlHandler)
enum
{
wxSP_DEFAULT_VALUE = 0,
#if wxUSE_SPINCTRL
class WXDLLIMPEXP_XRC wxSpinCtrlXmlHandler : public wxXmlResourceHandler
{
- DECLARE_DYNAMIC_CLASS(wxSpinCtrlXmlHandler)
+ DECLARE_DYNAMIC_CLASS(wxSpinCtrlXmlHandler)
enum
{
wxSP_DEFAULT_VALUE = 0,
bool UpdateResources();
// 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.
wxXmlNode *DoFindResource(wxXmlNode *parent, const wxString& name, const wxString& classname, bool recursive);
// were filled.
virtual wxObject *DoCreateResource() = 0;
- // Returns TRUE if it understands this node and can create
- // a resource from it, FALSE otherwise.
+ // Returns true if it understands this node and can create
+ // a resource from it, false otherwise.
virtual bool CanHandle(wxXmlNode *node) = 0;
// Sets the parent resource.
// - replaces \n, \r, \t by respective chars (according to C syntax)
// - replaces _ by & and __ by _ (needed for _File => &File because of XML)
// - 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.
int GetID();
// Returns the resource name.
wxString GetName();
- // Gets a bool flag (1, t, yes, on, true are TRUE, everything else is FALSE).
- bool GetBool(const wxString& param, bool defaultv = FALSE);
+ // Gets a bool flag (1, t, yes, on, true are true, everything else is false).
+ bool GetBool(const wxString& param, bool defaultv = false);
// Gets the integer value from the parameter.
long GetLong( const wxString& param, long defaultv = 0 );
void SetupWindow(wxWindow *wnd);
// Creates children.
- void CreateChildren(wxObject *parent, bool this_hnd_only = FALSE);
+ void CreateChildren(wxObject *parent, bool this_hnd_only = false);
// Helper function.
void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL);
// 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
-// 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.
enum {
- PU_ADD_RECORD = wxID_HIGHEST + 1,
+ PU_ADD_RECORD = wxID_HIGHEST + 1,
PU_EDIT_RECORD,
- PU_DELETE_RECORD
+ PU_DELETE_RECORD
};
// 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.
enum {
RECORD_COLUMN = 0,
// Event table: connect the events to the handler functions to process them
//-----------------------------------------------------------------------------
-BEGIN_EVENT_TABLE( MyResizableListCtrl, wxListCtrl )
- // Something to do when right mouse down
- EVT_RIGHT_DOWN( MyResizableListCtrl::ContextSensitiveMenu )
+BEGIN_EVENT_TABLE( MyResizableListCtrl, wxListCtrl )
+ // Something to do when right mouse down
+ EVT_RIGHT_DOWN( MyResizableListCtrl::ContextSensitiveMenu )
// Something to do when resized
EVT_SIZE( MyResizableListCtrl::OnSize )
END_EVENT_TABLE()
const wxString& name )
: wxListCtrl( parent, id, pos, size, style, validator, name )
{
-
- // 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
- // "unknown" XRC placeholder. This induces an OnSize() event, calling the
- // overrriden OnSize function for this class, which needs to have 3
+
+ // 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
+ // "unknown" XRC placeholder. This induces an OnSize() event, calling the
+ // overrriden OnSize function for this class, which needs to have 3
// columns to resize (else an assert on WXGTK debug build).
InsertColumn( RECORD_COLUMN, _("Record"), wxLIST_FORMAT_LEFT, 140);
InsertColumn( ACTION_COLUMN, _("Action"), wxLIST_FORMAT_LEFT, 70);
- InsertColumn( PRIORITY_COLUMN, _("Priority"), wxLIST_FORMAT_LEFT, 70 );
+ InsertColumn( PRIORITY_COLUMN, _("Priority"), wxLIST_FORMAT_LEFT, 70 );
}
a_menu.Append( PU_ADD_RECORD, _( "Add a new record...") );
a_menu.Append( PU_EDIT_RECORD, _( "Edit 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
if ( GetSelectedItemCount() == 0 ) {
- a_menu.Enable( PU_EDIT_RECORD, FALSE );
- a_menu.Enable( PU_DELETE_RECORD, FALSE );
+ a_menu.Enable( PU_EDIT_RECORD, false );
+ a_menu.Enable( PU_DELETE_RECORD, false );
}
- // Show the popup menu (wxWindow::PopupMenu ), at the x,y position
- // of the click event
+ // Show the popup menu (wxWindow::PopupMenu ), at the x,y position
+ // of the click event
PopupMenu( &a_menu, event.GetPosition() );
}
{
// Call our custom width setting function.
SetColumnWidths();
- // REQURED event.Skip() call to allow this event to propagate
- // upwards so others can do what they need to do in response to
+ // REQURED event.Skip() call to allow this event to propagate
+ // upwards so others can do what they need to do in response to
// this size event.
event.Skip();
}
void MyResizableListCtrl::SetColumnWidths()
-{
+{
// Get width of entire listctrl
- int leftmostColumnWidth = GetSize().x;
-
- // Subtract width of other columns, scrollbar, and some padding
+ int leftmostColumnWidth = GetSize().x;
+
+ // Subtract width of other columns, scrollbar, and some padding
leftmostColumnWidth -= GetColumnWidth( ACTION_COLUMN );
leftmostColumnWidth -= GetColumnWidth( PRIORITY_COLUMN );
- leftmostColumnWidth -= wxSystemSettings::GetSystemMetric( wxSYS_VSCROLL_X );
+ leftmostColumnWidth -= wxSystemSettings::GetSystemMetric( wxSYS_VSCROLL_X );
leftmostColumnWidth -= 5;
-
+
// Set the column width to the new value.
- SetColumnWidth( RECORD_COLUMN, leftmostColumnWidth );
-
- // This is just a debug message in case you want to watch the
+ SetColumnWidth( RECORD_COLUMN, leftmostColumnWidth );
+
+ // This is just a debug message in case you want to watch the
// events scroll by as you resize.
wxLogDebug( wxT("Successfully set column widths") );
}
// 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,
// 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
// MyResizableListCtrl(){} constructor in addition to your regular one.
DECLARE_DYNAMIC_CLASS( MyResizableListCtrl )
public:
- // Constructor.
+ // Constructor.
/*
These parameters are the same as a wxWidgets constructor.
\param parent The parent window.
column.
*/
MyResizableListCtrl( wxWindow *parent = NULL,
- wxWindowID id = -1,
+ wxWindowID id = wxID_ANY,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = wxLC_REPORT,
const wxValidator& validator = wxDefaultValidator,
const wxString &name = wxT("myResizableListCtrl")
- );
+ );
// 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.
void OnSize( wxSizeEvent &event );
-
+
// A custom function. What is called in the constructor, and in an OnSize()
- void SetColumnWidths();
-
+ void SetColumnWidths();
+
private:
// wxWidgets macro, required to be able to use Event tables in the .cpp file.
DECLARE_EVENT_TABLE()
-
+
};
//----------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------
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 )
// Note that the ID here isn't a XRCID, it is one of the standard wx ID's.
EVT_BUTTON( wxID_OK, PreferencesDialog::OnOK )
//-----------------------------------------------------------------------------
// Constructor (Notice how small and easy it is)
PreferencesDialog::PreferencesDialog(wxWindow* parent)
-{
+{
wxXmlResource::Get()->LoadDialog(this, parent, wxT("derived_dialog"));
}
void PreferencesDialog::OnMyButtonClicked( wxCommandEvent &WXUNUSED(event) )
{
// Construct a message dialog.
- wxMessageDialog msgDlg(this, _("You clicked on My Button"));
-
+ wxMessageDialog msgDlg(this, _("You clicked on My Button"));
+
// Show it modally.
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
void PreferencesDialog::OuUpdateUIMyCheckbox( wxUpdateUIEvent &WXUNUSED(event) )
{
// Get a boolean value of whether the checkbox is checked
- bool myCheckBoxIsChecked;
+ bool myCheckBoxIsChecked;
// You could just write:
// myCheckBoxIsChecked = event.IsChecked();
- // since the event that was passed into this function already has the
- // is a pointer to the right control. However,
+ // since the event that was passed into this function already has the
+ // is a pointer to the right control. However,
// this is the XRCCTRL way (which is more obvious as to what is going on).
myCheckBoxIsChecked = XRCCTRL(*this, "my_checkbox", wxCheckBox)->IsChecked();
- // Now call either Enable(TRUE) or Enable(FALSE) on the textctrl, depending
- // on the value of that boolean.
- XRCCTRL(*this, "my_textctrl", wxTextCtrl)->Enable(myCheckBoxIsChecked);
+ // Now call either Enable(true) or Enable(false) on the textctrl, depending
+ // on the value of that boolean.
+ XRCCTRL(*this, "my_textctrl", wxTextCtrl)->Enable(myCheckBoxIsChecked);
}
wxMessageDialog msgDlg2(this, _("Press OK to close Derived dialog, or Cancel to abort"),
_("Overriding base class OK button handler"),
wxOK | wxCANCEL | wxCENTER );
-
+
// Show the message dialog, and if it returns wxID_OK (ie they clicked on OK button)...
if (msgDlg2.ShowModal() == wxID_OK)
{
- // ...then end this Preferences dialog.
+ // ...then end this Preferences dialog.
EndModal( wxID_OK );
// 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
- // 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.
}
class PreferencesDialog : public wxDialog
{
-public:
-
+public:
+
// Constructor.
/*
\param parent The parent window. Simple constructor.
- */
+ */
PreferencesDialog( wxWindow* parent );
-
- // Destructor.
+
+ // Destructor.
~PreferencesDialog();
private:
-
+
// Stuff to do when "My Button" gets clicked
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)
void OuUpdateUIMyCheckbox( wxUpdateUIEvent &event );
-
+
// Override base class functions of a wxDialog.
void OnOK( wxCommandEvent &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
// 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
-// 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
+// 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
// when starting out with wxWidgets.
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(XRCID("exit_tool_or_menuitem"), MyFrame::OnExitToolOrMenuCommand)
- EVT_MENU(XRCID("non_derived_dialog_tool_or_menuitem"), MyFrame::OnNonDerivedDialogToolOrMenuCommand)
- EVT_MENU(XRCID("derived_tool_or_menuitem"), MyFrame::OnDerivedDialogToolOrMenuCommand)
- EVT_MENU(XRCID("controls_tool_or_menuitem"), MyFrame::OnControlsToolOrMenuCommand)
- EVT_MENU(XRCID("uncentered_tool_or_menuitem"), MyFrame::OnUncenteredToolOrMenuCommand)
- EVT_MENU(XRCID("custom_class_tool_or_menuitem"), MyFrame::OnCustomClassToolOrMenuCommand)
+ EVT_MENU(XRCID("non_derived_dialog_tool_or_menuitem"), MyFrame::OnNonDerivedDialogToolOrMenuCommand)
+ EVT_MENU(XRCID("derived_tool_or_menuitem"), MyFrame::OnDerivedDialogToolOrMenuCommand)
+ EVT_MENU(XRCID("controls_tool_or_menuitem"), MyFrame::OnControlsToolOrMenuCommand)
+ EVT_MENU(XRCID("uncentered_tool_or_menuitem"), MyFrame::OnUncenteredToolOrMenuCommand)
+ EVT_MENU(XRCID("custom_class_tool_or_menuitem"), MyFrame::OnCustomClassToolOrMenuCommand)
EVT_MENU(XRCID("platform_property_tool_or_menuitem"), MyFrame::OnPlatformPropertyToolOrMenuCommand)
EVT_MENU(XRCID("art_provider_tool_or_menuitem"), MyFrame::OnArtProviderToolOrMenuCommand)
EVT_MENU(XRCID("variable_expansion_tool_or_menuitem"), MyFrame::OnVariableExpansionToolOrMenuCommand)
MyFrame::MyFrame(wxWindow* parent)
{
// Load up this frame from XRC. [Note, instead of making a class's
- // constructor take a wxWindow* parent with a default value of NULL,
- // we could have just had designed MyFrame class with an empty
+ // constructor take a wxWindow* parent with a default value of NULL,
+ // we could have just had designed MyFrame class with an empty
// constructor and then written here:
// wxXmlResource::Get()->LoadFrame(this, (wxWindow* )NULL, "main_frame");
- // since this frame will always be the top window, and thus parentless.
- // However, the current approach has source code that can be recycled
+ // since this frame will always be the top window, and thus parentless.
+ // However, the current approach has source code that can be recycled
// for other frames that aren't the top level window.]
wxXmlResource::Get()->LoadFrame(this, parent, wxT("main_frame"));
// With toolbars, you currently can't create one, and set it later. It
// needs to be all in one step.
SetToolBar(wxXmlResource::Get()->LoadToolBar(this, wxT("main_toolbar")));
-
- // Give the frame a optional statusbar. The '1' just means one field.
- // A gripsizer will automatically get put on into the corner, if that
+
+ // Give the frame a optional statusbar. The '1' just means one field.
+ // A gripsizer will automatically get put on into the corner, if that
// is the normal OS behaviour for frames on that platform. Helptext
// for menu items and toolbar tools will automatically get displayed
// here.
void MyFrame::OnExitToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{
- // TRUE is to force the frame to close.
- Close(TRUE);
+ // true is to force the frame to close.
+ Close(true);
}
}
-void MyFrame::OnDerivedDialogToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
+void MyFrame::OnDerivedDialogToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{
// 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.
PreferencesDialog preferencesDialog(this);
// Show the instance of the dialog, modally.
}
-void MyFrame::OnControlsToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
+void MyFrame::OnControlsToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{
wxDialog dlg;
wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("controls_dialog"));
#if wxUSE_LISTCTRL
// 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.
// "controls_treectrl" is the name of this control in the XRC.
// (1) Insert a column, with the column header of "Name"
// (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"),
wxLIST_FORMAT_LEFT,
( 200 )
XRCCTRL(dlg, "controls_listctrl", wxListCtrl)->InsertItem(2,wxT("Leon Li"));
#endif
-#if wxUSE_TREECTRL
+#if wxUSE_TREECTRL
// There is no data in the tree ctrl. These lines will add some.
- // (1) Instead of having to write out
- // XRCCTRL(dlg, "controls_treectrl", wxTreeCtrl)->SomeFunction()
+ // (1) Instead of having to write out
+ // XRCCTRL(dlg, "controls_treectrl", wxTreeCtrl)->SomeFunction()
// 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
// will be referring to this control often in the code.
wxTreeCtrl* treectrl = XRCCTRL(dlg, "controls_treectrl", wxTreeCtrl);
// (3)Append some items to the root node.
treectrl->AppendItem(treectrl->GetRootItem(), _("Evil henchman 1"));
treectrl->AppendItem(treectrl->GetRootItem(), _("Evil henchman 2"));
- treectrl->AppendItem(treectrl->GetRootItem(), _("Evil accountant"));
+ treectrl->AppendItem(treectrl->GetRootItem(), _("Evil accountant"));
#endif
-
+
// All done. Show the dialog.
dlg.ShowModal();
}
-void MyFrame::OnUncenteredToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
+void MyFrame::OnUncenteredToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{
wxDialog dlg;
wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("uncentered_dialog"));
{
wxDialog dlg;
wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("custom_class_dialog"));
-
- // Make an instance of our new custom class.
- MyResizableListCtrl* a_myResizableListCtrl = new MyResizableListCtrl(&dlg,
- -1,
+
+ // Make an instance of our new custom class.
+ MyResizableListCtrl* a_myResizableListCtrl = new MyResizableListCtrl(&dlg,
+ wxID_ANY,
wxDefaultPosition,
wxDefaultSize,
wxLC_REPORT,
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.
wxXmlResource::Get()->AttachUnknownControl(wxT("custom_control_placeholder"),
a_myResizableListCtrl);
// Constructor.
MyFrame( wxWindow* parent=(wxWindow *)NULL);
-private:
+private:
// Event handlers (these functions should _not_ be virtual)
void OnExitToolOrMenuCommand(wxCommandEvent& event);
void OnNonDerivedDialogToolOrMenuCommand(wxCommandEvent& event);
void OnDerivedDialogToolOrMenuCommand(wxCommandEvent& event);
void OnControlsToolOrMenuCommand(wxCommandEvent& event);
- void OnUncenteredToolOrMenuCommand(wxCommandEvent& event);
+ void OnUncenteredToolOrMenuCommand(wxCommandEvent& event);
void OnCustomClassToolOrMenuCommand(wxCommandEvent& event);
void OnPlatformPropertyToolOrMenuCommand(wxCommandEvent& event);
void OnArtProviderToolOrMenuCommand(wxCommandEvent& event);
// you want PNGs, then add a PNG handler, etc. See wxImage::AddHandler()
// documentation for the types of image handlers available.
wxImage::AddHandler(new wxXPMHandler);
-
+
// Initialize all the XRC handlers. Always required (unless you feel like
// going through and initializing a handler of each control type you will
// be using (ie initialize the spinctrl handler, initialize the textctrl
// 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
// wxXRC docs for details.
- wxXmlResource::Get()->InitAllHandlers();
-
+ wxXmlResource::Get()->InitAllHandlers();
+
// 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
- // diffcult to manage, and harder to reuse in later projects.
+ // into one giant XRC file if you wanted, but then they become more
+ // diffcult to manage, and harder to reuse in later projects.
// The menubar
wxXmlResource::Get()->Load(wxT("rc/menu.xrc"));
// The toolbar
// Frame example
wxXmlResource::Get()->Load(wxT("rc/frame.xrc"));
// Uncentered example
- wxXmlResource::Get()->Load(wxT("rc/uncenter.xrc"));
+ wxXmlResource::Get()->Load(wxT("rc/uncenter.xrc"));
// Custom class example
wxXmlResource::Get()->Load(wxT("rc/custclas.xrc"));
// wxArtProvider example
// Variable expansion example
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
- // since it is the first window.
+ // since it is the first window.
MyFrame *frame = new MyFrame();
-
+
// Show the frame.
- frame->Show(TRUE);
-
- // Return TRUE to tell program to continue (FALSE would terminate).
- return TRUE;
+ frame->Show(true);
+
+ // Return true to tell program to continue (false would terminate).
+ return true;
}
public:
// Override base class virtuals:
- // wxApp::OnInit() is called on application startup and is a good place
- // for the app initialization (doing it here and not in the ctor
- // allows to have an error return: if OnInit() returns false, the
+ // wxApp::OnInit() is called on application startup and is a good place
+ // for the app initialization (doing it here and not in the ctor
+ // allows to have an error return: if OnInit() returns false, the
// application terminates)
virtual bool OnInit();
-
+
};
//-----------------------------------------------------------------------------
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_bmp.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxBitmapXmlHandler, wxXmlResourceHandler)
-wxBitmapXmlHandler::wxBitmapXmlHandler()
-: wxXmlResourceHandler()
+wxBitmapXmlHandler::wxBitmapXmlHandler()
+: wxXmlResourceHandler()
{
}
wxObject *wxBitmapXmlHandler::DoCreateResource()
-{
+{
return new wxBitmap(GetBitmap(wxT("")));
}
IMPLEMENT_DYNAMIC_CLASS(wxIconXmlHandler, wxXmlResourceHandler)
-wxIconXmlHandler::wxIconXmlHandler()
-: wxXmlResourceHandler()
+wxIconXmlHandler::wxIconXmlHandler()
+: wxXmlResourceHandler()
{
}
wxObject *wxIconXmlHandler::DoCreateResource()
-{
+{
return new wxIcon(GetIcon(wxT("")));
}
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_bmpbt.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButtonXmlHandler, wxXmlResourceHandler)
-wxBitmapButtonXmlHandler::wxBitmapButtonXmlHandler()
-: wxXmlResourceHandler()
+wxBitmapButtonXmlHandler::wxBitmapButtonXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxBU_AUTODRAW);
XRC_ADD_STYLE(wxBU_LEFT);
}
wxObject *wxBitmapButtonXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(button, wxBitmapButton)
button->Create(m_parentAsWindow,
if (GetBool(wxT("default"), 0))
button->SetDefault();
SetupWindow(button);
-
+
if (!GetParamValue(wxT("selected")).IsEmpty())
button->SetBitmapSelected(GetBitmap(wxT("selected")));
if (!GetParamValue(wxT("focus")).IsEmpty())
button->SetBitmapFocus(GetBitmap(wxT("focus")));
if (!GetParamValue(wxT("disabled")).IsEmpty())
button->SetBitmapDisabled(GetBitmap(wxT("disabled")));
-
+
return button;
}
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_bttn.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxButtonXmlHandler, wxXmlResourceHandler)
-wxButtonXmlHandler::wxButtonXmlHandler()
-: wxXmlResourceHandler()
+wxButtonXmlHandler::wxButtonXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxBU_LEFT);
XRC_ADD_STYLE(wxBU_RIGHT);
}
wxObject *wxButtonXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(button, wxButton)
button->Create(m_parentAsWindow,
if (GetBool(wxT("default"), 0))
button->SetDefault();
SetupWindow(button);
-
+
return button;
}
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_cald.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxCalendarCtrlXmlHandler, wxXmlResourceHandler)
-wxCalendarCtrlXmlHandler::wxCalendarCtrlXmlHandler()
-: wxXmlResourceHandler()
+wxCalendarCtrlXmlHandler::wxCalendarCtrlXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxCAL_SUNDAY_FIRST);
XRC_ADD_STYLE(wxCAL_MONDAY_FIRST);
wxObject *wxCalendarCtrlXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(calendar, wxCalendarCtrl);
calendar->Create(m_parentAsWindow,
GetPosition(), GetSize(),
GetStyle(),
GetName());
-
+
SetupWindow(calendar);
-
+
return calendar;
}
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_chckb.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxCheckBoxXmlHandler, wxXmlResourceHandler)
-wxCheckBoxXmlHandler::wxCheckBoxXmlHandler()
-: wxXmlResourceHandler()
+wxCheckBoxXmlHandler::wxCheckBoxXmlHandler()
+: wxXmlResourceHandler()
{
AddWindowStyles();
}
wxObject *wxCheckBoxXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(control, wxCheckBox)
control->Create(m_parentAsWindow,
control->SetValue(GetBool( wxT("checked")));
SetupWindow(control);
-
+
return control;
}
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_chckl.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxCheckListBoxXmlHandler, wxXmlResourceHandler)
-wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler()
-: wxXmlResourceHandler(), m_insideBox(FALSE)
+wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler()
+: wxXmlResourceHandler(), m_insideBox(false)
{
// no styles
AddWindowStyles();
}
wxObject *wxCheckListBoxXmlHandler::DoCreateResource()
-{
+{
if (m_class == wxT("wxCheckListBox")
#if WXWIN_COMPATIBILITY_2_4
|| m_class == wxT("wxCheckList")
wxLogDebug(wxT("'wxCheckList' name is deprecated, use 'wxCheckListBox' instead."));
#endif
// need to build the list of strings from children
- m_insideBox = TRUE;
+ m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
wxString *strings = (wxString *) NULL;
if (strList.GetCount() > 0)
wxString v = n->GetPropVal(wxT("checked"), wxEmptyString);
v.MakeLower();
if (v && v == wxT("1"))
- control->Check( i, TRUE );
+ control->Check( i, true );
- i++;
+ i++;
n = n->GetNext();
}
-
+
SetupWindow(control);
if (strings != NULL)
delete[] strings;
- strList.Clear(); // dump the strings
+ strList.Clear(); // dump the strings
return control;
}
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_choic.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxChoiceXmlHandler, wxXmlResourceHandler)
-wxChoiceXmlHandler::wxChoiceXmlHandler()
-: wxXmlResourceHandler() , m_insideBox(FALSE)
+wxChoiceXmlHandler::wxChoiceXmlHandler()
+: wxXmlResourceHandler() , m_insideBox(false)
{
XRC_ADD_STYLE(wxCB_SORT);
AddWindowStyles();
}
wxObject *wxChoiceXmlHandler::DoCreateResource()
-{
+{
if( m_class == wxT("wxChoice"))
{
// find the selection
long selection = GetLong(wxT("selection"), -1);
// need to build the list of strings from children
- m_insideBox = TRUE;
+ m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
wxString *strings = (wxString *) NULL;
if (strList.GetCount() > 0)
if (strings != NULL)
delete[] strings;
- strList.Clear(); // dump the strings
+ strList.Clear(); // dump the strings
return control;
}
{
// on the inside now.
// handle <item>Label</item>
-
+
// add to the list
wxString str = GetNodeContent(m_node);
if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_combo.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxComboBoxXmlHandler, wxXmlResourceHandler)
-wxComboBoxXmlHandler::wxComboBoxXmlHandler()
-: wxXmlResourceHandler() , m_insideBox(FALSE)
+wxComboBoxXmlHandler::wxComboBoxXmlHandler()
+: wxXmlResourceHandler() , m_insideBox(false)
{
XRC_ADD_STYLE(wxCB_SIMPLE);
XRC_ADD_STYLE(wxCB_SORT);
}
wxObject *wxComboBoxXmlHandler::DoCreateResource()
-{
+{
if( m_class == wxT("wxComboBox"))
{
// find the selection
long selection = GetLong( wxT("selection"), -1 );
// need to build the list of strings from children
- m_insideBox = TRUE;
+ m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
wxString *strings = (wxString *) NULL;
if (strList.GetCount() > 0)
if (strings != NULL)
delete[] strings;
- strList.Clear(); // dump the strings
+ strList.Clear(); // dump the strings
return control;
}
CreateChildren(dlg);
- if (GetBool(wxT("centered"), FALSE))
+ if (GetBool(wxT("centered"), false))
dlg->Centre();
return dlg;
CreateChildren(frame);
- if (GetBool(wxT("centered"), FALSE))
+ if (GetBool(wxT("centered"), false))
frame->Centre();
return frame;
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_gauge.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxGaugeXmlHandler, wxXmlResourceHandler)
-wxGaugeXmlHandler::wxGaugeXmlHandler()
-: wxXmlResourceHandler()
+wxGaugeXmlHandler::wxGaugeXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxGA_HORIZONTAL);
XRC_ADD_STYLE(wxGA_VERTICAL);
}
wxObject *wxGaugeXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(control, wxGauge)
control->Create(m_parentAsWindow,
GetID(),
- GetLong(wxT("range"), wxGAUGE_DEFAULT_RANGE),
+ GetLong(wxT("range"), wxGAUGE_DEFAULT_RANGE),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
wxObject *wxGenericDirCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(ctrl, wxGenericDirCtrl)
-
+
ctrl->Create(m_parentAsWindow,
GetID(),
GetText(wxT("defaultfolder")),
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_html.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindowXmlHandler, wxXmlResourceHandler)
-wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler()
-: wxXmlResourceHandler()
+wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxHW_SCROLLBAR_NEVER);
XRC_ADD_STYLE(wxHW_SCROLLBAR_AUTO);
{
wxString url = GetParamValue(wxT("url"));
wxFileSystem& fsys = GetCurFileSystem();
-
+
wxFSFile *f = fsys.OpenFile(url);
if (f)
{
else
control->LoadPage(url);
}
-
+
else if (HasParam(wxT("htmlcode")))
{
control->SetPage(GetText(wxT("htmlcode")));
}
SetupWindow(control);
-
+
return control;
}
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_listb.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxListBoxXmlHandler, wxXmlResourceHandler)
-wxListBoxXmlHandler::wxListBoxXmlHandler()
-: wxXmlResourceHandler() , m_insideBox(FALSE)
+wxListBoxXmlHandler::wxListBoxXmlHandler()
+: wxXmlResourceHandler() , m_insideBox(false)
{
XRC_ADD_STYLE(wxLB_SINGLE);
XRC_ADD_STYLE(wxLB_MULTIPLE);
}
wxObject *wxListBoxXmlHandler::DoCreateResource()
-{
+{
if( m_class == wxT("wxListBox"))
{
// find the selection
long selection = GetLong(wxT("selection"), -1);
// need to build the list of strings from children
- m_insideBox = TRUE;
+ m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
wxString *strings = (wxString *) NULL;
if (strList.GetCount() > 0)
if (strings != NULL)
delete[] strings;
- strList.Clear(); // dump the strings
+ strList.Clear(); // dump the strings
return control;
}
{
// on the inside now.
// handle <item>Label</item>
-
+
// add to the list
wxString str = GetNodeContent(m_node);
if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_listc.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxListCtrlXmlHandler, wxXmlResourceHandler)
-wxListCtrlXmlHandler::wxListCtrlXmlHandler()
-: wxXmlResourceHandler()
+wxListCtrlXmlHandler::wxListCtrlXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxLC_LIST);
XRC_ADD_STYLE(wxLC_REPORT);
}
wxObject *wxListCtrlXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(list, wxListCtrl)
list->Create(m_parentAsWindow,
GetName());
// FIXME: add columns definition
-
+
SetupWindow(list);
-
+
return list;
}
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_menu.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxMenuXmlHandler, wxXmlResourceHandler)
-wxMenuXmlHandler::wxMenuXmlHandler() :
- wxXmlResourceHandler(), m_insideMenu(FALSE)
+wxMenuXmlHandler::wxMenuXmlHandler() :
+ wxXmlResourceHandler(), m_insideMenu(false)
{
XRC_ADD_STYLE(wxMENU_TEAROFF);
}
wxMenu *menu = new wxMenu(GetStyle());
wxString title = GetText(wxT("label"));
wxString help = GetText(wxT("help"));
-
+
bool oldins = m_insideMenu;
- m_insideMenu = TRUE;
- CreateChildren(menu, TRUE/*only this handler*/);
+ m_insideMenu = true;
+ CreateChildren(menu, true/*only this handler*/);
m_insideMenu = oldins;
wxMenuBar *p_bar = wxDynamicCast(m_parent, wxMenuBar);
else
{
wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu);
-
+
if (m_class == wxT("separator"))
p_menu->AppendSeparator();
else if (m_class == wxT("break"))
p_menu->Break();
else /*wxMenuItem*/
- {
+ {
int id = GetID();
wxString label = GetText(wxT("label"));
- wxString accel = GetText(wxT("accel"), FALSE);
+ wxString accel = GetText(wxT("accel"), false);
wxString fullLabel = label;
if (!accel.IsEmpty())
fullLabel << wxT("\t") << accel;
wxMenuItem *mitem = new wxMenuItem(p_menu, id, fullLabel,
GetText(wxT("help")), kind);
-
+
#if wxCHECK_VERSION(2,3,0) || (defined(__WXMSW__) && wxUSE_OWNER_DRAWN)
if (HasParam(wxT("bitmap")))
mitem->SetBitmap(GetBitmap(wxT("bitmap"), wxART_MENU));
#endif
p_menu->Append(mitem);
- mitem->Enable(GetBool(wxT("enabled"), TRUE));
+ mitem->Enable(GetBool(wxT("enabled"), true));
if (kind == wxITEM_CHECK)
mitem->Check(GetBool(wxT("checked")));
}
bool wxMenuXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxMenu")) ||
- (m_insideMenu &&
+ (m_insideMenu &&
(IsOfClass(node, wxT("wxMenuItem")) ||
IsOfClass(node, wxT("break")) ||
IsOfClass(node, wxT("separator")))
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_notbk.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxNotebookXmlHandler, wxXmlResourceHandler)
-wxNotebookXmlHandler::wxNotebookXmlHandler()
-: wxXmlResourceHandler(), m_isInside(FALSE), m_notebook(NULL)
+wxNotebookXmlHandler::wxNotebookXmlHandler()
+: wxXmlResourceHandler(), m_isInside(false), m_notebook(NULL)
{
XRC_ADD_STYLE(wxNB_FIXEDWIDTH);
XRC_ADD_STYLE(wxNB_LEFT);
}
wxObject *wxNotebookXmlHandler::DoCreateResource()
-{
+{
if (m_class == wxT("notebookpage"))
{
wxXmlNode *n = GetParamNode(wxT("object"));
if (n)
{
bool old_ins = m_isInside;
- m_isInside = FALSE;
+ m_isInside = false;
wxObject *item = CreateResFromNode(n, m_notebook, NULL);
m_isInside = old_ins;
wxWindow *wnd = wxDynamicCast(item, wxWindow);
if (wnd)
m_notebook->AddPage(wnd, GetText(wxT("label")),
GetBool(wxT("selected"), 0));
- else
- wxLogError(wxT("Error in resource."));
+ else
+ wxLogError(wxT("Error in resource."));
return wnd;
}
else
return NULL;
}
}
-
- else
+
+ else
{
XRC_MAKE_INSTANCE(nb, wxNotebook)
- nb->Create(m_parentAsWindow,
+ nb->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style")),
wxNotebook *old_par = m_notebook;
m_notebook = nb;
bool old_ins = m_isInside;
- m_isInside = TRUE;
- CreateChildren(m_notebook, TRUE/*only this handler*/);
+ m_isInside = true;
+ CreateChildren(m_notebook, true/*only this handler*/);
m_isInside = old_ins;
m_notebook = old_par;
- if (GetBool(wxT("usenotebooksizer"), FALSE))
+ if (GetBool(wxT("usenotebooksizer"), false))
return new wxNotebookSizer(nb);
else
return nb;
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_panel.h"
#endif
}
wxObject *wxPanelXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(panel, wxPanel)
panel->Create(m_parentAsWindow,
SetupWindow(panel);
CreateChildren(panel);
-
+
return panel;
}
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_radbt.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxRadioButtonXmlHandler, wxXmlResourceHandler)
-wxRadioButtonXmlHandler::wxRadioButtonXmlHandler()
-: wxXmlResourceHandler()
+wxRadioButtonXmlHandler::wxRadioButtonXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxRB_GROUP);
AddWindowStyles();
}
wxObject *wxRadioButtonXmlHandler::DoCreateResource()
-{
+{
/* BOBM - implementation note.
* once the wxBitmapRadioButton is implemented.
- * look for a bitmap property. If not null,
- * make it a wxBitmapRadioButton instead of the
+ * look for a bitmap property. If not null,
+ * make it a wxBitmapRadioButton instead of the
* normal radio button.
- */
+ */
XRC_MAKE_INSTANCE(control, wxRadioButton)
control->SetValue(GetBool(wxT("value"), 0));
SetupWindow(control);
-
+
return control;
}
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_radbx.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxRadioBoxXmlHandler, wxXmlResourceHandler)
-wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
-: wxXmlResourceHandler(), m_insideBox(FALSE)
+wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
+: wxXmlResourceHandler(), m_insideBox(false)
{
XRC_ADD_STYLE(wxRA_SPECIFY_COLS);
XRC_ADD_STYLE(wxRA_HORIZONTAL);
}
wxObject *wxRadioBoxXmlHandler::DoCreateResource()
-{
+{
if( m_class == wxT("wxRadioBox"))
{
// find the selection
long selection = GetLong( wxT("selection"), -1 );
// need to build the list of strings from children
- m_insideBox = TRUE;
+ m_insideBox = true;
CreateChildrenPrivately( NULL, GetParamNode(wxT("content")));
wxString *strings = (wxString *) NULL;
if( strList.GetCount() > 0 )
if (strings != NULL)
delete[] strings;
- strList.Clear(); // dump the strings
+ strList.Clear(); // dump the strings
return control;
}
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_scrol.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxScrollBarXmlHandler, wxXmlResourceHandler)
-wxScrollBarXmlHandler::wxScrollBarXmlHandler()
-: wxXmlResourceHandler()
+wxScrollBarXmlHandler::wxScrollBarXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxSB_HORIZONTAL);
XRC_ADD_STYLE(wxSB_VERTICAL);
}
wxObject *wxScrollBarXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(control, wxScrollBar)
control->Create(m_parentAsWindow,
wxDefaultValidator,
GetName());
- control->SetScrollbar(GetLong( wxT("value"), 0),
+ control->SetScrollbar(GetLong( wxT("value"), 0),
GetLong( wxT("thumbsize"),1),
GetLong( wxT("range"), 10),
GetLong( wxT("pagesize"),1));
SetupWindow(control);
CreateChildren(control);
-
+
return control;
}
// Copyright: (c) 2002 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_scwin.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindowXmlHandler, wxXmlResourceHandler)
-wxScrolledWindowXmlHandler::wxScrolledWindowXmlHandler()
-: wxXmlResourceHandler()
+wxScrolledWindowXmlHandler::wxScrolledWindowXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxHSCROLL);
XRC_ADD_STYLE(wxVSCROLL);
}
wxObject *wxScrolledWindowXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(control, wxScrolledWindow)
control->Create(m_parentAsWindow,
SetupWindow(control);
CreateChildren(control);
-
+
return control;
}
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_sizer.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxSizerXmlHandler, wxXmlResourceHandler)
-
-
-wxSizerXmlHandler::wxSizerXmlHandler()
+
+
+wxSizerXmlHandler::wxSizerXmlHandler()
: wxXmlResourceHandler(),
- m_isInside(FALSE),
- m_isGBS(FALSE),
+ m_isInside(false),
+ m_isGBS(false),
m_parentSizer(NULL)
{
XRC_ADD_STYLE(wxHORIZONTAL);
XRC_ADD_STYLE(wxALIGN_CENTRE_HORIZONTAL);
XRC_ADD_STYLE(wxALIGN_CENTER_VERTICAL);
XRC_ADD_STYLE(wxALIGN_CENTRE_VERTICAL);
-
+
XRC_ADD_STYLE(wxADJUST_MINSIZE);
XRC_ADD_STYLE(wxFIXED_MINSIZE);
}
{
return ( (!m_isInside && IsSizerNode(node)) ||
(m_isInside && IsOfClass(node, wxT("sizeritem"))) ||
- (m_isInside && IsOfClass(node, wxT("spacer")))
+ (m_isInside && IsOfClass(node, wxT("spacer")))
);
}
-
+
wxObject* wxSizerXmlHandler::DoCreateResource()
-{
+{
if (m_class == wxT("sizeritem"))
return Handle_sizeritem();
-
+
else if (m_class == wxT("spacer"))
return Handle_spacer();
{
// create a sizer item for it
wxSizerItem* sitem = MakeSizerItem();
-
+
// now fetch the item to be managed
bool old_gbs = m_isGBS;
bool old_ins = m_isInside;
wxSizer *old_par = m_parentSizer;
- m_isInside = FALSE;
- if (!IsSizerNode(n)) m_parentSizer = NULL;
+ m_isInside = false;
+ if (!IsSizerNode(n)) m_parentSizer = NULL;
wxObject *item = CreateResFromNode(n, m_parent, NULL);
m_isInside = old_ins;
m_parentSizer = old_par;
// and figure out what type it is
wxSizer *sizer = wxDynamicCast(item, wxSizer);
wxWindow *wnd = wxDynamicCast(item, wxWindow);
-
+
if (sizer)
sitem->SetSizer(sizer);
else if (wnd)
sitem->SetWindow(wnd);
- else
+ else
wxLogError(wxT("Error in resource."));
// finally, set other wxSizerItem attributes
wxSizerItem* sitem = MakeSizerItem();
SetSizerItemAttributes(sitem);
sitem->SetSpacer(GetSize());
- AddSizerItem(sitem);
+ AddSizerItem(sitem);
return NULL;
}
wxObject* wxSizerXmlHandler::Handle_sizer()
{
wxSizer *sizer = NULL;
-
+
wxXmlNode *parentNode = m_node->GetParent();
wxCHECK_MSG(m_parentSizer != NULL ||
else if (m_class == wxT("wxStaticBoxSizer"))
sizer = Handle_wxStaticBoxSizer();
-
+
else if (m_class == wxT("wxGridSizer"))
sizer = Handle_wxGridSizer();
-
+
else if (m_class == wxT("wxFlexGridSizer"))
sizer = Handle_wxFlexGridSizer();
else if (m_class == wxT("wxGridBagSizer"))
sizer = Handle_wxGridBagSizer();
-
+
wxSize minsize = GetSize(wxT("minsize"));
if (!(minsize == wxDefaultSize))
sizer->SetMinSize(minsize);
// set new state
m_parentSizer = sizer;
- m_isInside = TRUE;
+ m_isInside = true;
m_isGBS = (m_class == wxT("wxGridBagSizer"));
-
- CreateChildren(m_parent, TRUE/*only this handler*/);
+
+ CreateChildren(m_parent, true/*only this handler*/);
// restore state
m_isInside = old_ins;
if (m_parentSizer == NULL) // setup window:
{
- m_parentAsWindow->SetAutoLayout(TRUE);
+ m_parentAsWindow->SetAutoLayout(true);
m_parentAsWindow->SetSizer(sizer);
wxXmlNode *nd = m_node;
if (m_parentAsWindow->GetWindowStyle() & (wxRESIZE_BOX | wxRESIZE_BORDER))
sizer->SetSizeHints(m_parentAsWindow);
}
-
+
return sizer;
}
wxSizer* wxSizerXmlHandler::Handle_wxBoxSizer()
{
return new wxBoxSizer(GetStyle(wxT("orient"), wxHORIZONTAL));
-}
-
+}
+
wxSizer* wxSizerXmlHandler::Handle_wxStaticBoxSizer()
{
return new wxStaticBoxSizer(
GetName()),
GetStyle(wxT("orient"), wxHORIZONTAL));
}
-
+
wxSizer* wxSizerXmlHandler::Handle_wxGridSizer()
{
return new wxGridSizer(GetLong(wxT("rows")), GetLong(wxT("cols")),
wxSizer* wxSizerXmlHandler::Handle_wxFlexGridSizer()
{
- wxFlexGridSizer *sizer =
+ wxFlexGridSizer *sizer =
new wxFlexGridSizer(GetLong(wxT("rows")), GetLong(wxT("cols")),
GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
SetGrowables(sizer, wxT("growablerows"), true);
wxSizer* wxSizerXmlHandler::Handle_wxGridBagSizer()
{
- wxGridBagSizer *sizer =
+ wxGridBagSizer *sizer =
new wxGridBagSizer(GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
SetGrowables(sizer, wxT("growablerows"), true);
SetGrowables(sizer, wxT("growablecols"), false);
sz = GetSize(wxT("ratio"));
if (!(sz == wxDefaultSize))
sitem->SetRatio(sz);
-
+
if (m_isGBS)
{
wxGBSizerItem* gbsitem = (wxGBSizerItem*)sitem;
gbsitem->SetPos(GetGBPos(wxT("cellpos")));
gbsitem->SetSpan(GetGBSpan(wxT("cellspan")));
- }
+ }
}
void wxSizerXmlHandler::AddSizerItem(wxSizerItem* sitem)
else
m_parentSizer->Add(sitem);
}
-
+
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_slidr.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxSliderXmlHandler, wxXmlResourceHandler)
-wxSliderXmlHandler::wxSliderXmlHandler()
-: wxXmlResourceHandler()
+wxSliderXmlHandler::wxSliderXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxSL_HORIZONTAL);
XRC_ADD_STYLE(wxSL_VERTICAL);
}
wxObject *wxSliderXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(control, wxSlider)
control->Create(m_parentAsWindow,
GetID(),
- GetLong(wxT("value"), wxSL_DEFAULT_VALUE),
+ GetLong(wxT("value"), wxSL_DEFAULT_VALUE),
GetLong(wxT("min"), wxSL_DEFAULT_MIN),
GetLong(wxT("max"), wxSL_DEFAULT_MAX),
GetPosition(), GetSize(),
}
SetupWindow(control);
-
+
return control;
}
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_spin.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxSpinButtonXmlHandler, wxXmlResourceHandler)
-wxSpinButtonXmlHandler::wxSpinButtonXmlHandler()
-: wxXmlResourceHandler()
+wxSpinButtonXmlHandler::wxSpinButtonXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxSP_HORIZONTAL);
XRC_ADD_STYLE(wxSP_VERTICAL);
}
wxObject *wxSpinButtonXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(control, wxSpinButton)
control->Create(m_parentAsWindow,
control->SetRange(GetLong( wxT("min"), wxSP_DEFAULT_MIN),
GetLong(wxT("max"), wxSP_DEFAULT_MAX));
SetupWindow(control);
-
+
return control;
}
IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrlXmlHandler, wxXmlResourceHandler)
-wxSpinCtrlXmlHandler::wxSpinCtrlXmlHandler()
-: wxXmlResourceHandler()
+wxSpinCtrlXmlHandler::wxSpinCtrlXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxSP_HORIZONTAL);
XRC_ADD_STYLE(wxSP_VERTICAL);
}
wxObject *wxSpinCtrlXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(control, wxSpinCtrl)
-
+
control->Create(m_parentAsWindow,
GetID(),
GetText(wxT("value")),
GetName());
SetupWindow(control);
-
+
return control;
}
// Copyright: (c) 2003 panga@freemail.hu, Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_split.h"
#endif
wxXmlNode *n = m_node->GetChildren();
while (n)
{
- if ((n->GetType() == wxXML_ELEMENT_NODE) &&
+ if ((n->GetType() == wxXML_ELEMENT_NODE) &&
(n->GetName() == wxT("object") ||
n->GetName() == wxT("object_ref")))
{
{
win2 = win;
break;
- }
+ }
}
n = n->GetNext();
}
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_stbmp.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmapXmlHandler, wxXmlResourceHandler)
-wxStaticBitmapXmlHandler::wxStaticBitmapXmlHandler()
-: wxXmlResourceHandler()
+wxStaticBitmapXmlHandler::wxStaticBitmapXmlHandler()
+: wxXmlResourceHandler()
{
AddWindowStyles();
}
wxObject *wxStaticBitmapXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(bmp, wxStaticBitmap)
bmp->Create(m_parentAsWindow,
GetName());
SetupWindow(bmp);
-
+
return bmp;
}
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_stbox.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxStaticBoxXmlHandler, wxXmlResourceHandler)
-wxStaticBoxXmlHandler::wxStaticBoxXmlHandler()
-: wxXmlResourceHandler()
+wxStaticBoxXmlHandler::wxStaticBoxXmlHandler()
+: wxXmlResourceHandler()
{
AddWindowStyles();
}
wxObject *wxStaticBoxXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(box, wxStaticBox)
box->Create(m_parentAsWindow,
GetName());
SetupWindow(box);
-
+
return box;
}
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_stlin.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxStaticLineXmlHandler, wxXmlResourceHandler)
-wxStaticLineXmlHandler::wxStaticLineXmlHandler()
-: wxXmlResourceHandler()
+wxStaticLineXmlHandler::wxStaticLineXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxLI_HORIZONTAL);
XRC_ADD_STYLE(wxLI_VERTICAL);
}
wxObject *wxStaticLineXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(line, wxStaticLine)
line->Create(m_parentAsWindow,
GetName());
SetupWindow(line);
-
+
return line;
}
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_sttxt.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxStaticTextXmlHandler, wxXmlResourceHandler)
-wxStaticTextXmlHandler::wxStaticTextXmlHandler()
-: wxXmlResourceHandler()
+wxStaticTextXmlHandler::wxStaticTextXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxST_NO_AUTORESIZE);
XRC_ADD_STYLE(wxALIGN_LEFT);
}
wxObject *wxStaticTextXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(text, wxStaticText)
text->Create(m_parentAsWindow,
GetName());
SetupWindow(text);
-
+
return text;
}
// Copyright: (c) 2000 Aleksandras Gluchovas
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_text.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrlXmlHandler, wxXmlResourceHandler)
-wxTextCtrlXmlHandler::wxTextCtrlXmlHandler() : wxXmlResourceHandler()
+wxTextCtrlXmlHandler::wxTextCtrlXmlHandler() : wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxTE_NO_VSCROLL);
XRC_ADD_STYLE(wxTE_AUTO_SCROLL);
}
wxObject *wxTextCtrlXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(text, wxTextCtrl)
text->Create(m_parentAsWindow,
GetName());
SetupWindow(text);
-
+
return text;
}
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_toolb.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxToolBarXmlHandler, wxXmlResourceHandler)
-wxToolBarXmlHandler::wxToolBarXmlHandler()
-: wxXmlResourceHandler(), m_isInside(FALSE), m_toolbar(NULL)
+wxToolBarXmlHandler::wxToolBarXmlHandler()
+: wxXmlResourceHandler(), m_isInside(false), m_toolbar(NULL)
{
XRC_ADD_STYLE(wxTB_FLAT);
XRC_ADD_STYLE(wxTB_DOCKABLE);
}
wxObject *wxToolBarXmlHandler::DoCreateResource()
-{
+{
if (m_class == wxT("tool"))
{
wxCHECK_MSG(m_toolbar, NULL, wxT("Incorrect syntax of XRC resource: tool not within a toolbar!"));
-
+
if (GetPosition() != wxDefaultPosition)
{
m_toolbar->AddTool(GetID(),
GetText(wxT("longhelp")));
}
else
- {
+ {
wxItemKind kind = wxITEM_NORMAL;
if (GetBool(wxT("radio")))
kind = wxITEM_RADIO;
wxASSERT_MSG( kind == wxITEM_NORMAL,
_T("can't have both toggleable and radion button at once") );
kind = wxITEM_CHECK;
- }
+ }
m_toolbar->AddTool(GetID(),
GetText(wxT("label")),
GetBitmap(wxT("bitmap"), wxART_TOOLBAR),
}
return m_toolbar; // must return non-NULL
}
-
+
else if (m_class == wxT("separator"))
{
wxCHECK_MSG(m_toolbar, NULL, wxT("Incorrect syntax of XRC resource: separator not within a toolbar!"));
m_toolbar->AddSeparator();
return m_toolbar; // must return non-NULL
}
-
+
else /*<object class="wxToolBar">*/
{
int style = GetStyle(wxT("style"), wxNO_BORDER | wxTB_HORIZONTAL);
#endif
XRC_MAKE_INSTANCE(toolbar, wxToolBar)
-
+
toolbar->Create(m_parentAsWindow,
GetID(),
GetPosition(),
if (children_node == NULL) return toolbar;
- m_isInside = TRUE;
+ m_isInside = true;
m_toolbar = toolbar;
wxXmlNode *n = children_node;
while (n)
{
- if ((n->GetType() == wxXML_ELEMENT_NODE) &&
+ if ((n->GetType() == wxXML_ELEMENT_NODE) &&
(n->GetName() == wxT("object") || n->GetName() == wxT("object_ref")))
{
wxObject *created = CreateResFromNode(n, toolbar, NULL);
n = n->GetNext();
}
- m_isInside = FALSE;
+ m_isInside = false;
m_toolbar = NULL;
toolbar->Realize();
bool wxToolBarXmlHandler::CanHandle(wxXmlNode *node)
{
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"))));
}
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_tree.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrlXmlHandler, wxXmlResourceHandler)
-wxTreeCtrlXmlHandler::wxTreeCtrlXmlHandler()
-: wxXmlResourceHandler()
+wxTreeCtrlXmlHandler::wxTreeCtrlXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxTR_EDIT_LABELS);
XRC_ADD_STYLE(wxTR_NO_BUTTONS);
}
wxObject *wxTreeCtrlXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(tree, wxTreeCtrl)
tree->Create(m_parentAsWindow,
GetName());
SetupWindow(tree);
-
+
return tree;
}
public:
wxUnknownControlContainer(wxWindow *parent,
const wxString& controlName,
- wxWindowID id = -1,
+ wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0)
wxPanel *panel =
new wxUnknownControlContainer(m_parentAsWindow,
- GetName(), -1,
+ GetName(), wxID_ANY,
GetPosition(), GetSize(),
GetStyle(wxT("style")));
SetupWindow(panel);
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_wizrd.h"
#endif
}
wxObject *wxWizardXmlHandler::DoCreateResource()
-{
+{
if (m_class == wxT("wxWizard"))
{
XRC_MAKE_INSTANCE(wiz, wxWizard)
bool wxWizardXmlHandler::CanHandle(wxXmlNode *node)
{
- return IsOfClass(node, wxT("wxWizard")) ||
+ return IsOfClass(node, wxT("wxWizard")) ||
(m_wizard != NULL &&
(IsOfClass(node, wxT("wxWizardPage")) ||
IsOfClass(node, wxT("wxWizardPageSimple")))
wxString fnd;
wxXmlResourceDataRecord *drec;
bool iswild = wxIsWild(filemask);
- bool rt = TRUE;
+ bool rt = true;
#if wxUSE_FILESYSTEM
wxFileSystem fsys;
if (!container)
{
wxLogError(_("Cannot find container for unknown control '%s'."), name.c_str());
- return FALSE;
+ return false;
}
return control->Reparent(container);
}
wxXmlNode *c = node->GetChildren();
while (c)
{
- isok = FALSE;
+ isok = false;
if (!c->GetPropVal(wxT("platform"), &s))
- isok = TRUE;
+ isok = true;
else
{
wxStringTokenizer tkn(s, wxT(" |"));
# if wxUSE_FILESYSTEM
file = fsys.OpenFile(m_data[i].File);
- if (file)
- stream = file->GetStream();
+ if (file)
+ stream = file->GetStream();
# else
stream = new wxFileInputStream(m_data[i].File);
# endif
rt = false;
}
else
- {
+ {
long version;
int v1, v2, v3, v4;
wxString verstr = m_data[i].Doc->GetRoot()->GetPropVal(
ProcessPlatformProperty(m_data[i].Doc->GetRoot());
#if wxUSE_FILESYSTEM
- m_data[i].Time = file->GetModificationTime();
+ m_data[i].Time = file->GetModificationTime();
#else
m_data[i].Time = wxDateTime(wxFileModificationTime(m_data[i].File));
#endif
- }
+ }
# if wxUSE_FILESYSTEM
- wxDELETE(file);
- wxUnusedVar(file);
+ wxDELETE(file);
+ wxUnusedVar(file);
# else
- wxDELETE(stream);
+ wxDELETE(stream);
# endif
}
}
wxString refName = node->GetPropVal(wxT("ref"), wxEmptyString);
if (refName.empty())
continue;
- wxXmlNode* refNode = FindResource(refName, wxEmptyString, TRUE);
+ wxXmlNode* refNode = FindResource(refName, wxEmptyString, true);
if (refNode &&
refNode->GetPropVal(wxT("class"), wxEmptyString) == classname)
{
(node->GetName() == wxT("object") ||
node->GetName() == wxT("object_ref")) )
{
- wxXmlNode* found = DoFindResource(node, name, classname, TRUE);
+ wxXmlNode* found = DoFindResource(node, name, classname, true);
if ( found )
return found;
}
if ( node->GetName() == wxT("object_ref") )
{
wxString refName = node->GetPropVal(wxT("ref"), wxEmptyString);
- wxXmlNode* refNode = FindResource(refName, wxEmptyString, TRUE);
+ wxXmlNode* refNode = FindResource(refName, wxEmptyString, true);
if ( !refNode )
{
else if (family == wxT("swiss")) ifamily = wxSWISS;
else if (family == wxT("modern")) ifamily = wxMODERN;
- bool underlined = GetBool(wxT("underlined"), FALSE);
+ bool underlined = GetBool(wxT("underlined"), false);
wxString encoding = GetParamValue(wxT("encoding"));
wxFontMapper mapper;
wxStringTokenizer tk(faces, wxT(","));
while (tk.HasMoreTokens())
{
- int index = enu.GetFacenames()->Index(tk.GetNextToken(), FALSE);
+ int index = enu.GetFacenames()->Index(tk.GetNextToken(), false);
if (index != wxNOT_FOUND)
{
facename = (*enu.GetFacenames())[index];
if (HasParam(wxT("fg")))
wnd->SetForegroundColour(GetColour(wxT("fg")));
if (GetBool(wxT("enabled"), 1) == 0)
- wnd->Enable(FALSE);
+ wnd->Enable(false);
if (GetBool(wxT("focused"), 0) == 1)
wnd->SetFocus();
if (GetBool(wxT("hidden"), 0) == 1)
- wnd->Show(FALSE);
+ wnd->Show(false);
#if wxUSE_TOOLTIPS
if (HasParam(wxT("tooltip")))
wnd->SetToolTip(GetText(wxT("tooltip")));
{
AddStdXRCID_Records();
wxXmlResource::AddSubclassFactory(new wxXmlSubclassFactoryCXX);
- return TRUE;
+ return true;
}
void OnExit()
{
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
// -- Already done in xmlres.cpp
//#ifdef __GNUG__
//#pragma implementation "xmlres.h"
#endif
#if wxUSE_CHECKBOX
AddHandler(new wxCheckBoxXmlHandler);
-#endif
+#endif
#if wxUSE_HTML
AddHandler(new wxHtmlWindowXmlHandler);
-#endif
+#endif
#if wxUSE_SPINBTN
AddHandler(new wxSpinButtonXmlHandler);
-#endif
+#endif
#if wxUSE_SPINCTRL
AddHandler(new wxSpinCtrlXmlHandler);
-#endif
+#endif
#if wxUSE_SCROLLBAR
AddHandler(new wxScrollBarXmlHandler);
#endif
SetAppName(_T("wxConvertApp"));
if (HandleCommandLine())
- return TRUE;
+ return true;
// 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);
InitMenu();
- m_pFrame->Show(TRUE);
+ m_pFrame->Show(true);
SetTopWindow(m_pFrame);
- return TRUE;
+ return true;
}
void wxConvertApp::InitMenu()
void wxMainFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
- Close(TRUE);
+ Close(true);
}
{
if (argc != 2)
- return FALSE;
+ return false;
//Figure out kind of conversion
wxString source,target;
if ((source.Find(_T(".wxr"))>0)&&(target.Find(_T(".xml"))>0))
{
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);
- 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);
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
void OnWXR2XML(wxCommandEvent& event);
void OnRc2Wxr(wxCommandEvent& event);
void OnQuit(wxCommandEvent& event);
- wxMainFrame(wxWindow* parent, wxWindowID id,
+ wxMainFrame(wxWindow* parent, wxWindowID id,
const wxString& title, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = _T("frame"));
virtual ~wxMainFrame();
-
+
protected:
DECLARE_EVENT_TABLE()
};
-class wxConvertApp : public wxApp
+class wxConvertApp : public wxApp
{
public:
bool HandleCommandLine();
{
-m_done=FALSE;
+m_done=false;
m_controlid=6000;
if ((ch==' ')|(ch==',')|(ch==13)|(ch==10)|(ch=='|'))
- return TRUE;
+ return true;
{
-m_done=TRUE;
+m_done=true;
-return TRUE;
+return true;
}
-return FALSE;
+return false;
}
{
-m_done=TRUE;
+m_done=true;
return tok;
{
-m_done=TRUE;
+m_done=true;
return tok;
{
-m_done=TRUE;
+m_done=true;
if (ch==EOF)
- m_done=TRUE;
+ m_done=true;
{
- int result;
+ int result;
result=m_rc.Tell();
if((result>=m_filesize))
- m_done=TRUE;
+ m_done=true;
if((result==-1))
- m_done=TRUE;
+ m_done=true;
if(ch==EOF)
- m_done=TRUE;
+ m_done=true;
}
if (tok==_T("POPUP"))
- {
+ {
ParsePopupMenu();
- wxFprintf(m_wxr,_T(" ],\\\n"));
+ wxFprintf(m_wxr,_T(" ],\\\n"));
- }
+ }
}
w=GetToken();
-return TRUE;
+return true;
}
#include "wx/file.h"
#include "stdio.h"
-class rc2wxr : public wxObject
+class rc2wxr : public wxObject
{
public:
rc2wxr();
rc2xml::rc2xml()
{
- m_done=FALSE;
+ m_done=false;
m_bitmaplist=new wxList(wxKEY_STRING);
m_stringtable=new wxList(wxKEY_STRING);
m_iconlist = new wxList(wxKEY_STRING);
result=m_xmlfile.Open(xmlfile.c_str(),_T("w+t"));
wxASSERT_MSG(result,_T("Couldn't create XML file"));
if (!result)
- return FALSE;
+ return false;
/* Write Basic header for XML file */
ParseResourceHeader();
//Gather all the resource we need for toolbars,menus, and etc
FirstPass();
- m_done=FALSE;
+ m_done=false;
m_rc.Seek(0);
//Read in dialogs, toolbars,menus
SecondPass();
wxMessageBox(_("Conversion complete."), _("Done"),
wxOK | wxICON_INFORMATION);
-return TRUE;
+return true;
}
bool GotOrs;
GotOrs = ReadOrs(token);
if (ReadRect(x,y,width,height))
- if (GotOrs==FALSE)
+ if (GotOrs==false)
ReadOrs(token);
- if (token.Find(_T("WS_GROUP")) != -1)
+ if (token.Find(_T("WS_GROUP")) != wxNOT_FOUND)
style += _T("wxRB_GROUP");
m_xmlfile.Write(_T("\t\t<object class=\"wxRadioButton\""));
{
//if ((ch==' ')|(ch==',')|(ch==13)|(ch==10)|(ch=='|')|(ch=='\t'))
if ((ch==' ')|(ch==',')|(ch==13)|(ch==10)|(ch=='\t'))
- return TRUE;
+ return true;
if (ch==EOF)
{
- m_done=TRUE;
- return TRUE;
+ m_done=true;
+ return true;
}
- return FALSE;
+ return false;
}
void rc2xml::ParseGroupBox(wxString phrase, wxString varname)
if (m_rc.Eof())
{
- m_done=TRUE;
+ m_done=true;
return token;
}
ReadChar(ch);
if (ch==EOF)
{
- m_done=TRUE;
+ m_done=true;
return token;
}
if (ch==EOF)
{
- m_done=TRUE;
+ m_done=true;
}
}
if (ch == EOF)
- m_done = TRUE;
+ m_done = true;
if (listseperator)
*listseperator = (ch == ',');
{
wxString phrase;
//ASCII code 34 "
- bool done=FALSE;
+ bool done=false;
int p,ch=0,lastch=0;
ReadChar(ch);
while (ch!=34)
ReadChar(ch);
ReadChar(ch);
- while (done==FALSE)
+ while (done==false)
{
if ((ch==34)&&(lastch!='\\'))
{
else
{
m_rc.Seek(p);
- done = TRUE;
+ done = true;
}
}
- if (done==TRUE)
+ if (done==true)
break;
if (ch=='\r')
ReadChar(ch); // skip
result=m_rc.Tell();
if((result>=m_filesize))
- m_done=TRUE;
+ m_done=true;
result=m_rc.Read(&ch,1);
if((result==-1))
- m_done=TRUE;
+ m_done=true;
if(ch==EOF)
- m_done=TRUE;
+ m_done=true;
}
void rc2xml::ParseComboBox(wxString varname)
bool GotOrs;
GotOrs = ReadOrs(token);
if (ReadRect(x,y,width,height))
- if (GotOrs==FALSE)
+ if (GotOrs==false)
ReadOrs(token);
m_xmlfile.Write(_T("\t\t<object class=\"wxComboBox\""));
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"));
- if (token.Find(_T("CBS_SORT")) != -1)
+ if (token.Find(_T("CBS_SORT")) != wxNOT_FOUND)
WriteStyle(_T("wxCB_SORT"));
- if (token.Find(_T("CBS_DISABLENOSCROLL")) != -1)
+ if (token.Find(_T("CBS_DISABLENOSCROLL")) != wxNOT_FOUND)
WriteStyle(_T("wxLB_ALWAYS_SB"));
m_xmlfile.Write(_T("\n\t\t</object>\n"));
{
wxString token,style;
ReadOrs(token);
- if (token.Find(_T("TBS_VERT"))!=-1)
+ if (token.Find(_T("TBS_VERT"))!=wxNOT_FOUND)
style+=_T("wxSL_VERTICAL");
//MFC RC Default is horizontal
else
token=PeekToken();
if (token.IsNumber())
- return FALSE;
+ return false;
orstring=GetToken();
while(PeekToken()==_T("|"))
//Grab next token
orstring+=GetToken();
}
- return TRUE;
+ return true;
}
//Is it a checkbutton or a radiobutton or a pushbutton or a groupbox
ReadOrs(token);
m_rc.Seek(p);
- if (token.Find(_T("BS_AUTOCHECKBOX"))!=-1)
+ if (token.Find(_T("BS_AUTOCHECKBOX"))!=wxNOT_FOUND)
ParseCheckBox(label, varname);
- else if ((token.Find(_T("BS_AUTORADIOBUTTON"))!=-1)||
- (token.Find(_T("BS_RADIOBUTTON"))!=-1))
+ else if ((token.Find(_T("BS_AUTORADIOBUTTON"))!=wxNOT_FOUND)||
+ (token.Find(_T("BS_RADIOBUTTON"))!=wxNOT_FOUND))
ParseRadioButton(label, varname);
- else if (token.Find(_T("BS_GROUPBOX"))!=-1)
+ else if (token.Find(_T("BS_GROUPBOX"))!=wxNOT_FOUND)
ParseGroupBox(label, varname);
- else // if ((token.Find("BS_PUSHBUTTON")!=-1)||
-// (token.Find("BS_DEFPUSHBUTTON")!=-1))
+ else // if ((token.Find("BS_PUSHBUTTON")!=wxNOT_FOUND)||
+// (token.Find("BS_DEFPUSHBUTTON")!=wxNOT_FOUND))
ParsePushButton(label, varname); // make default case
}
wxString token,style;
ReadOrs(token);
- if (token.Find(_T("UDS_HORZ"))!=-1)
+ if (token.Find(_T("UDS_HORZ"))!=wxNOT_FOUND)
style=_T("wxSP_HORIZONTAL");
//MFC default
else
wxLogError(_T("Unable to load bitmap:")+*bitmappath);
//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
varname.Replace(_T("IDR_"),_T("TB_"));
WriteName(varname);
{
SplitHelp(msg,tip,longhelp);
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
buttonname=CleanName(buttonname);
wxNode *node=m_stringtable->Find(strid);
wxString *s;
if (node==NULL)
- return FALSE;
+ return false;
s=(wxString *)node->GetData();
st=*s;
- return TRUE;
+ return true;
}
bool rc2xml::SplitHelp(wxString msg, wxString &shorthelp, wxString &longhelp)
{
int spot;
spot=msg.Find(_T("\\n"));
- if (spot==-1)
+ if (spot==wxNOT_FOUND)
{
shorthelp=msg;
longhelp=msg;
longhelp=msg.Left(spot);
spot=msg.Length()-spot-2;
shorthelp=msg.Right(spot);
- return TRUE;
+ return true;
}
void rc2xml::ParseMenuItem()
int p=m_rc.Tell();
ReadOrs(token);
m_rc.Seek(p);
- if (token.Find(_T("SS_BITMAP"))!=-1)
+ if (token.Find(_T("SS_BITMAP"))!=wxNOT_FOUND)
ParseStaticBitmap(label,varname);
else
ParseStaticText(label,varname);
ReadOrs(token);
-if (token.Find(_T("SBS_VERT"))!=-1)
+if (token.Find(_T("SBS_VERT"))!=wxNOT_FOUND)
style=_T("wxSB_VERTICAL");
//Default MFC style is horizontal
else
//Read through entire file
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);
//Just ignore #define token
#include <wx/list.h>
-class rc2xml : public wxObject
+class rc2xml : public wxObject
{
public:
wxString m_workingpath;
~rc2xml();
protected:
- wxString LookUpId(wxString id);
-
+ wxString LookUpId(wxString id);
+
void ParseResourceHeader();
void WriteBitmap(wxString bitmapname);
void ParseListCtrl(wxString label,wxString varname);
wxList * m_iconlist;
void ParseIconStatic();
void ParseMenuItem();
-
+
//Functions
bool SplitHelp(wxString msg, wxString &shorthelp, wxString &longhelp);
bool LookUpString(wxString strid,wxString & st);
result = m_xmlfile.Open(xmlfile.c_str(), _T("w+t"));
wxASSERT_MSG(result, _T("Couldn't create XML file"));
if (!result)
- return FALSE;
+ return false;
result = m_table.ParseResourceFile(wxrfile);
wxASSERT_MSG(result, _T("Couldn't Load WXR file"));
if (!result)
- return FALSE;
+ return false;
// Write basic xml header
m_xmlfile.Write(_T("<?xml version=\"1.0\" ?>\n"));
m_xmlfile.Write(_T("<resource>\n"));
wxHashTable::Node *node;
node = m_table.Next();
- while (node)
+ while (node)
{
wxItemResource *res = (wxItemResource *) node->GetData();
wxString resType(res->GetType());
wxLogError(_T("Found unsupported resource ") + resType);
node = m_table.Next();
}
- return TRUE;
+ return true;
}
void wxr2xml::ParsePanel(wxItemResource * res)
void wxr2xml::ParseControls(wxItemResource * res)
{
wxNode *node = res->GetChildren().GetFirst();
- while (node)
+ while (node)
{
wxItemResource *res = (wxItemResource *) node->GetData();
wxString resType(res->GetType());
if (style & wxNO_FULL_REPAINT_ON_RESIZE)
s += _T("wxNO_FULL_REPAINT_ON_RESIZE|");
- if (restype == _T("wxDialog"))
+ if (restype == _T("wxDialog"))
{
if (style & wxDIALOG_MODAL)
s += _T("wxDIALOG_MODAL|");
s += _T("wxCLIP_CHILDREN|");
}
- if (restype == _T("wxPanel"))
+ if (restype == _T("wxPanel"))
{
if (style & wxCLIP_CHILDREN)
s += _T("wxCLIP_CHILDREN|");
s += _T("wxWS_EX_VALIDATE_RECURSIVELY|");
}
- if (restype == _T("wxComboBox"))
+ if (restype == _T("wxComboBox"))
{
if (style & wxCB_SORT)
s += _T("wxCB_SORT|");
s += _T("wxCB_DROPDOWN|");
}
- if (restype == _T("wxGauge"))
+ if (restype == _T("wxGauge"))
{
if (style & wxGA_HORIZONTAL)
s += _T("wxGA_HORIZONTAL|");
s += _T("wxGA_SMOOTH|");
}
- if (restype == _T("wxRadioButton"))
+ if (restype == _T("wxRadioButton"))
{
if (style & wxRB_GROUP)
s += _T("wxRB_GROUP|");
}
- if (restype == _T("wxStaticText"))
+ if (restype == _T("wxStaticText"))
{
if (style & wxST_NO_AUTORESIZE)
s += _T("wxST_NO_AUTORESIZEL|");
}
- if (restype == _T("wxRadioBox"))
+ if (restype == _T("wxRadioBox"))
{
if (style & wxRA_HORIZONTAL)
s += _T("wxRA_HORIZONTAL|");
s += _T("wxRA_VERTICAL|");
}
- if (restype == _T("wxListBox"))
+ if (restype == _T("wxListBox"))
{
if (style & wxLB_SINGLE)
s += _T("wxLB_SINGLE|");
s += _T("wxLB_SORT|");
}
- if (restype == _T("wxTextCtrl"))
+ if (restype == _T("wxTextCtrl"))
{
if (style & wxTE_PROCESS_ENTER)
s += _T("wxTE_PROCESS_ENTER|");
{
if (style & wxSB_HORIZONTAL)
s += _T("wxSB_HORIZONTAL|");
- if (style & wxSB_VERTICAL)
+ if (style & wxSB_VERTICAL)
s += _T("wxSB_VERTICAL|");
}
{
wxItemResource *child;
wxNode *node = res->GetChildren().GetFirst();
- // Get Menu
+ // Get Menu
m_xmlfile.Write(_T("\t\t\t<object class=\"wxMenu\" "));
wxString menuname;
menuname << _T("name = \"menu_") << res->GetValue1() << _T("\"");
menuname << _T("name = \"menuitem_") << res->GetValue1() << _T("\"");
m_xmlfile.Write(menuname);
m_xmlfile.Write(_T(">\n"));
- m_xmlfile.Write(_T(" <label>")
+ m_xmlfile.Write(_T("\t\t\t<label>")
+ FixMenuString(res->GetTitle()) + _T("</label>\n"));
if (res->GetValue4() != _T(""))
- m_xmlfile.Write(_T(" <help>") +
+ m_xmlfile.Write(_T("\t\t\t<help>") +
res->GetValue4() + _T("</help>\n"));
if (res->GetValue2())
m_xmlfile.Write(_T("\t\t\t\t<checkable>1</checkable>\n"));
void wxr2xml::PanelStuff(wxItemResource * res)
{
if ((res->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0)
- m_dlgunits = TRUE;
+ m_dlgunits = true;
else
- m_dlgunits = FALSE;
+ m_dlgunits = false;
// If this is true ignore fonts, background color and use system
// defaults instead
if ((res->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0)
- m_systemdefaults = TRUE;
+ m_systemdefaults = true;
else
- m_systemdefaults = FALSE;
+ m_systemdefaults = false;
}
void wxr2xml::ParseBitmapButton(wxItemResource *res)
{
-
+
m_xmlfile.Write(_T("\t\t\t<object class=\"wxBitmapButton\""));
WriteControlInfo(res);
// value4 holds bitmap name
bitmapname += _T(".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</object>\n"));
}
GetFontFace(font);
GetFontStyle(font);
GetFontWeight(font);
-
+
if (font.GetUnderlined())
m_xmlfile.Write(_T("\t\t\t\t<underlined>1</underlined>\n"));
-
+
m_xmlfile.Write(_T("\t\t\t</font>\n"));
}
void wxr2xml::GetFontFace(wxFont font)
{
int family=font.GetFamily();
-
+
switch (family)
{
case wxDEFAULT:
class XRCWidgetData
{
public:
- XRCWidgetData(const wxString& vname,const wxString& vclass)
+ XRCWidgetData(const wxString& vname,const wxString& vclass)
: m_class(vclass), m_name(vname) {}
const wxString& GetName() const { return m_name; }
const wxString& GetClass() const { return m_class; }
class XRCWndClassData
{
-private:
+private:
wxString m_className;
wxString m_parentClassName;
ArrayOfXRCWidgetData m_wdata;
-
+
void BrowseXmlNode(wxXmlNode* node)
{
wxString classValue;
wxString nameValue;
- wxXmlNode* children;
+ wxXmlNode* children;
while (node)
{
if (node->GetName() == _T("object")
}
children = node->GetChildren();
if (children)
- BrowseXmlNode(children);
+ BrowseXmlNode(children);
node = node->GetNext();
}
}
-
+
public:
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());
-
+
}
-
+
const ArrayOfXRCWidgetData& GetWidgetData(){
return m_wdata;
}
}
file.Write(_T("\nprivate:\n void InitWidgetsFromXRC(){\n")
_T(" wxXmlResource::Get()->LoadObject(this,NULL,\"")
- + m_className
+ + m_className
+ _T("\",\"")
- + m_parentClassName
- + _T("\");\n"));
+ + m_parentClassName
+ + _T("\");\n"));
for(i=0;i<m_wdata.Count();++i){
const XRCWidgetData& w = m_wdata.Item(i);
- file.Write( _T(" ")
- + w.GetName()
+ file.Write( _T(" ")
+ + w.GetName()
+ _T(" = XRCCTRL(*this,\"")
- + w.GetName()
+ + w.GetName()
+ _T("\",")
+ w.GetClass()
+ _T(");\n")
);
}
file.Write(_T(" }\n"));
-
+
file.Write(
_T("public:\n")
- + m_className
+ + m_className
+ _T("::")
+ m_className
+ _T("(){\n")
{
public:
// don't use builtin cmd line parsing:
- virtual bool OnInit() { return true; }
+ virtual bool OnInit() { return true; }
virtual int OnRun();
-
-private:
+
+private:
void ParseParams(const wxCmdLineParser& cmdline);
void CompileRes();
wxArrayString PrepareTempFiles();
void OutputGettext();
wxArrayString FindStrings();
wxArrayString FindStrings(wxXmlNode *node);
-
+
bool flagVerbose, flagCPP, flagPython, flagGettext;
wxString parOutput, parFuncname, parOutputPath;
wxArrayString parFiles;
{
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_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_OPTION, _T("l"), _T("list-of-handlers", _T("output list of neccessary handlers to this file" },
#endif
{ 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_NONE }
flagH = flagCPP && cmdline.Found(_T("e"));
- if (!cmdline.Found(_T("o"), &parOutput))
+ if (!cmdline.Found(_T("o"), &parOutput))
{
if (flagGettext)
parOutput = wxEmptyString;
}
if (!parOutputPath) parOutputPath = _T(".");
- if (!cmdline.Found(_T("n"), &parFuncname))
+ if (!cmdline.Found(_T("n"), &parFuncname))
parFuncname = _T("InitXmlResource");
for (size_t i = 0; i < cmdline.GetParamCount(); i++)
wxRemoveFile(parOutput);
if (!retCode)
- {
+ {
if (flagCPP){
MakePackageCPP(files);
if (flagH)
else
MakePackageZIP(files);
}
-
+
DeleteTempFiles(files);
}
name2.Replace(_T("\\"), _T("_"));
name2.Replace(_T("*"), _T("_"));
name2.Replace(_T("?"), _T("_"));
-
+
wxString s = wxFileNameFromPath(parOutput) + _T("$") + name2;
if (wxFileExists(s) && flist.Index(s) == wxNOT_FOUND)
- {
+ {
for (int i = 0;; i++)
{
s.Printf(wxFileNameFromPath(parOutput) + _T("$%03i-") + name2, i);
wxArrayString XmlResApp::PrepareTempFiles()
{
wxArrayString flist;
-
+
for (size_t i = 0; i < parFiles.Count(); i++)
{
- if (flagVerbose)
+ if (flagVerbose)
wxPrintf(_T("processing ") + parFiles[i] + _T("...\n"));
wxXmlDocument doc;
-
+
if (!doc.Load(parFiles[i]))
{
wxLogError(_T("Error parsing file ") + parFiles[i]);
retCode = 1;
continue;
}
-
+
wxString name, ext, path;
wxSplitPath(parFiles[i], &path, &name, &ext);
}
}
wxString internalName = GetInternalFileName(parFiles[i], flist);
-
+
doc.Save(parOutputPath + wxFILE_SEP_PATH + internalName);
flist.Add(internalName);
}
-
+
return flist;
}
{
// Any bitmaps:
if (node->GetName() == _T("bitmap"))
- return TRUE;
+ return true;
// URLs in wxHtmlWindow:
if (node->GetName() == _T("url"))
- return TRUE;
-
+ return true;
+
// wxBitmapButton:
wxXmlNode *parent = node->GetParent();
- if (parent != NULL &&
+ if (parent != NULL &&
parent->GetPropVal(_T("class"), _T("")) == _T("wxBitmapButton") &&
- (node->GetName() == _T("focus") ||
+ (node->GetName() == _T("focus") ||
node->GetName() == _T("disabled") ||
node->GetName() == _T("selected")))
- return TRUE;
-
+ return true;
+
// wxBitmap or wxIcon toplevel resources:
if (node->GetName() == _T("object"))
{
wxString klass = node->GetPropVal(_T("class"), wxEmptyString);
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>
while (n)
{
if (containsFilename &&
- (n->GetType() == wxXML_TEXT_NODE ||
+ (n->GetType() == wxXML_TEXT_NODE ||
n->GetType() == wxXML_CDATA_SECTION_NODE))
{
wxString fullname;
else
fullname = inputPath + wxFILE_SEP_PATH + n->GetContent();
- if (flagVerbose)
+ if (flagVerbose)
wxPrintf(_T("adding ") + fullname + _T("...\n"));
wxString filename = GetInternalFileName(n->GetContent(), flist);
void XmlResApp::MakePackageZIP(const wxArrayString& flist)
{
wxString files;
-
+
for (size_t i = 0; i < flist.Count(); i++)
files += flist[i] + _T(" ");
files.RemoveLast();
-
- if (flagVerbose)
+
+ if (flagVerbose)
wxPrintf(_T("compressing ") + parOutput + _T("...\n"));
-
+
wxString cwd = wxGetCwd();
wxSetWorkingDirectory(parOutputPath);
- int execres = wxExecute(_T("zip -9 -j ") +
- wxString(flagVerbose ? _T("") : _T("-q ")) +
- parOutput + _T(" ") + files, TRUE);
+ int execres = wxExecute(_T("zip -9 -j ") +
+ wxString(flagVerbose ? _T("") : _T("-q ")) +
+ parOutput + _T(" ") + files, true);
wxSetWorkingDirectory(cwd);
if (execres == -1)
{
wxString snum;
wxFFile file(filename, wxT("rb"));
size_t lng = file.Length();
-
+
snum.Printf(_T("%i"), num);
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");
// we cannot use string literals because MSVC is dumb wannabe compiler
// with arbitrary limitation to 2048 strings :(
-
+
unsigned char *buffer = new unsigned char[lng];
file.Read(buffer, lng);
-
+
for (size_t i = 0, linelng = 0; i < lng; i++)
{
tmp.Printf(_T("%i"), buffer[i]);
output << tmp;
linelng += tmp.Length()+1;
}
-
+
delete[] buffer;
-
+
output += _T("};\n\n");
-
+
return output;
}
wxFFile file(parOutput, wxT("wt"));
size_t i;
- if (flagVerbose)
+ if (flagVerbose)
wxPrintf(_T("creating C++ source file ") + parOutput + _T("...\n"));
-
+
file.Write(_T("")
_T("//\n")
_T("// This file was automatically generated by wxrc, do not edit by hand.\n")
for (i = 0; i < flist.Count(); i++)
file.Write(
FileToCppArray(parOutputPath + wxFILE_SEP_PATH + flist[i], i));
-
+
file.Write(_T("")
_T("void ") + parFuncname + wxT("()\n")
_T("{\n")
file.Write(_T(" wxXmlResource::Get()->Load(wxT(\"memory:XRC_resource/") +
GetInternalFileName(parFiles[i], flist) + _T("\"));\n"));
}
-
+
file.Write(_T("}\n"));
{
wxString fileSpec = (parOutput.BeforeLast('.')).AfterLast('/');
wxString heaFileName = fileSpec + _T(".h");
-
+
wxFFile file(heaFileName, wxT("wt"));
file.Write(
_T("//\n")
_T("//\n\n")
_T("#ifndef __") + fileSpec + _T("_h__\n")
_T("#define __") + fileSpec + _T("_h__\n")
-);
+);
for(size_t i=0;i<aXRCWndClassData.Count();++i){
- aXRCWndClassData.Item(i).GenerateHeaderCode(file);
- }
+ aXRCWndClassData.Item(i).GenerateHeaderCode(file);
+ }
file.Write(
_T("\nvoid \n")
+ parFuncname
wxString snum;
wxFFile file(filename, wxT("rb"));
size_t lng = file.Length();
-
+
snum.Printf(_T("%i"), num);
output = _T(" xml_res_file_") + snum + _T(" = \"\"\"\\\n");
-
+
unsigned char *buffer = new unsigned char[lng];
file.Read(buffer, lng);
-
+
for (size_t i = 0, linelng = 0; i < lng; i++)
{
unsigned char c = buffer[i];
output << tmp;
linelng += tmp.Length();
}
-
+
delete[] buffer;
-
+
output += _T("\"\"\"\n\n");
-
+
return output;
}
wxFFile file(parOutput, wxT("wt"));
size_t i;
- if (flagVerbose)
+ if (flagVerbose)
wxPrintf(_T("creating Python source file ") + parOutput + _T("...\n"));
-
+
file.Write(
_T("#\n")
_T("# This file was automatically generated by wxrc, do not edit by hand.\n")
_T("from wxPython.xrc import *\n\n")
);
-
+
file.Write(_T("def ") + parFuncname + _T("():\n"));
for (i = 0; i < flist.Count(); i++)
void XmlResApp::OutputGettext()
{
wxArrayString str = FindStrings();
-
+
wxFFile fout;
if (parOutput.empty())
fout.Attach(stdout);
else
fout.Open(parOutput, wxT("wt"));
-
+
for (size_t i = 0; i < str.GetCount(); i++)
fout.Write(_T("_(\"") + str[i] + _T("\");\n"));
-
+
if (!parOutput) fout.Detach();
}
for (size_t i = 0; i < parFiles.Count(); i++)
{
- if (flagVerbose)
+ if (flagVerbose)
wxPrintf(_T("processing ") + parFiles[i] + _T("...\n"));
- wxXmlDocument doc;
+ wxXmlDocument doc;
if (!doc.Load(parFiles[i]))
{
wxLogError(_T("Error parsing file ") + parFiles[i]);
a2 = FindStrings(doc.GetRoot());
WX_APPEND_ARRAY(arr, a2);
}
-
+
return arr;
}
else
str2 << wxT('&') << *dt;
}
- else
+ else
{
switch (*dt)
{
(*(dt+1) != 'r'))
str2 << wxT("\\\\");
else
- str2 << wxT("\\");
+ str2 << wxT("\\");
break;
case wxT('"') : str2 << wxT("\\\""); break;
default : str2 << *dt; break;
wxXmlNode *n = node;
if (n == NULL) return arr;
n = n->GetChildren();
-
+
while (n)
{
if ((node->GetType() == wxXML_ELEMENT_NODE) &&
// parent is an element, i.e. has subnodes...
- (n->GetType() == wxXML_TEXT_NODE ||
+ (n->GetType() == wxXML_TEXT_NODE ||
n->GetType() == wxXML_CDATA_SECTION_NODE) &&
// ...it is textnode...
(
{
arr.Add(ConvertText(n->GetContent()));
}
-
+
// subnodes:
if (n->GetType() == wxXML_ELEMENT_NODE)
{
wxArrayString a2 = FindStrings(n);
WX_APPEND_ARRAY(arr, a2);
}
-
+
n = n->GetNext();
}
return arr;
wxInitAllImageHandlers();
wxFrame *frame = new EditorFrame(NULL, arg);
SetTopWindow(frame);
- frame->Show(TRUE);
- PreviewFrame::Get()->Show(TRUE);
- PropertiesFrame::Get()->Show(TRUE);
- return TRUE;
+ frame->Show(true);
+ PreviewFrame::Get()->Show(true);
+ PropertiesFrame::Get()->Show(true);
+ return true;
}
public:
EditorTreeCtrl(wxWindow *parent, int id, EditorFrame *frame)
: wxTreeCtrl(parent, id), m_EdFrame(frame) {}
-
+
private:
EditorFrame *m_EdFrame;
-
+
void OnRightClick(wxMouseEvent &event)
{
- wxTreeItemId item =
+ wxTreeItemId item =
m_EdFrame->m_TreeCtrl->HitTest(event.GetPosition());
if (item.IsOk())
{
END_EVENT_TABLE()
-enum
+enum
{
ID_PREVIEW = wxID_HIGHEST + 100,
ID_NEW,
ID_SAVEAS,
ID_DELETE_NODE,
ID_EXIT,
- ID_TREE,
-
+ ID_TREE,
+
ID_CUT,
ID_PASTE_SYBLING,
ID_PASTE_CHILD,
ID_COPY,
ID_NEWDIALOG,
- ID_NEWFRAME,
+ ID_NEWFRAME,
ID_NEWPANEL,
ID_NEWMENU,
ID_NEWMENUBAR,
- ID_NEWTOOLBAR,
+ ID_NEWTOOLBAR,
ID_NEWNODE = wxID_HIGHEST + 10000, // safely out of XRCID range :)
ID_NEWSYBNODE = ID_NEWNODE + 20000
};
EditorFrame *EditorFrame::ms_Instance = NULL;
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;
m_Clipboard = NULL;
- m_Modified = FALSE;
-
+ m_Modified = false;
+
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))));
m_SelectedNode = NULL;
menuEdit->AppendSeparator();
menuEdit->Append(ID_DELETE_NODE, _T("Delete"));
- menuEdit->Enable(ID_PASTE_SYBLING, FALSE);
- menuEdit->Enable(ID_PASTE_CHILD, FALSE);
-
+ menuEdit->Enable(ID_PASTE_SYBLING, false);
+ menuEdit->Enable(ID_PASTE_CHILD, false);
+
wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(menuFile, _T("&File"));
menuBar->Append(menuEdit, _T("&Edit"));
SetMenuBar(menuBar);
-
+
// Create toolbar:
wxToolBar *toolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT);
toolBar->SetMargins(2, 2);
toolBar->SetToolBitmapSize(wxSize(24, 24));
toolBar -> AddTool(ID_EXIT, wxBITMAP(close), wxNullBitmap,
- FALSE, -1, -1, (wxObject *) NULL,
+ false, wxDefaultPosition.x, wxDefaultPosition.y, (wxObject *) NULL,
_("Quit the editor"));
toolBar -> AddTool(ID_OPEN, wxBITMAP(open), wxNullBitmap,
- FALSE, -1, -1, (wxObject *) NULL,
- _("Open XML resource file"));
+ false, wxDefaultPosition.x, wxDefaultPosition.y, (wxObject *) NULL,
+ _("Open XML resource file"));
toolBar -> AddTool(ID_SAVE, wxBITMAP(save), wxNullBitmap,
- FALSE, -1, -1, (wxObject *) NULL,
+ false, wxDefaultPosition.x, wxDefaultPosition.y, (wxObject *) NULL,
_("Save XML file"));
toolBar -> AddTool(ID_PREVIEW, wxBITMAP(preview), wxNullBitmap,
- FALSE, -1, -1, (wxObject *) NULL,
- _("Preview"));
+ false, wxDefaultPosition.x, wxDefaultPosition.y, (wxObject *) NULL,
+ _("Preview"));
toolBar -> Realize();
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
-
+
// Create tree control:
m_TreeCtrl = new EditorTreeCtrl(this, ID_TREE, this);
wxImageList *imgList = new wxImageList(16, 16);
m_TreeCtrl->AssignImageList(imgList);
sizer->Add(m_TreeCtrl, 1, wxEXPAND);
- SetAutoLayout(TRUE);
+ SetAutoLayout(true);
SetSizer(sizer);
// Load file:
PropertiesFrame::Get()->Close();
wxConfigBase *cfg = wxConfigBase::Get();
-
+
cfg->Write(_T("editor_x"), (long)GetPosition().x);
cfg->Write(_T("editor_y"), (long)GetPosition().y);
cfg->Write(_T("editor_w"), (long)GetSize().x);
if (!AskToSave()) return;
delete m_Resource;
-
+
// create new resource in order to handle version differences properly
PreviewFrame::Get()->ResetResource();
-
+
m_FileName = wxEmptyString;
m_Resource = new wxXmlRcEditDocument;
- m_Modified = FALSE;
-
+ m_Modified = false;
+
if (!m_Resource->Load(filename, wxLocale::GetSystemEncodingName()))
{
delete m_Resource;
void EditorFrame::SaveFile(const wxString& filename)
{
m_FileName = filename;
-
+
// save it:
if (!m_Resource->Save(filename))
wxLogError(_("Error saving ") + filename);
else
- m_Modified = FALSE;
+ m_Modified = false;
RefreshTitle();
}
void EditorFrame::NewFile()
-{
+{
if (!AskToSave()) return;
delete m_Resource;
-
+
m_FileName = wxEmptyString;
m_Resource = new wxXmlRcEditDocument;
m_Resource->SetRoot(new wxXmlNode(wxXML_ELEMENT_NODE, _("resource")));
-
- m_Resource->SetFileEncoding(_T("utf-8"));
+
+ m_Resource->SetFileEncoding(_T("utf-8"));
#if !wxUSE_UNICODE
m_Resource->SetEncoding(wxLocale::GetSystemEncodingName());
#endif
-
- m_Resource->GetRoot()->AddProperty(_T("version"),
+
+ m_Resource->GetRoot()->AddProperty(_T("version"),
WX_XMLRES_CURRENT_VERSION_STRING);
- m_Modified = FALSE;
+ m_Modified = false;
RefreshTree();
RefreshTitle();
}
void EditorFrame::RefreshTree()
{
wxXmlNode *sel = m_SelectedNode;
-
- m_TreeCtrl->DeleteAllItems();
+
+ m_TreeCtrl->DeleteAllItems();
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)
{
if (n->GetType() == wxXML_ELEMENT_NODE)
XmlTreeData *dt;
wxXmlNode *nd;
void* cookie;
-
+
item = m_TreeCtrl->GetFirstChild(*root, cookie);
while (item.IsOk())
{
dt = (XmlTreeData*)(m_TreeCtrl->GetItemData(item));
nd = (dt) ? dt->Node : NULL;
- if (nd == node)
+ if (nd == node)
{
RecursivelyExpand(m_TreeCtrl, *root);
m_TreeCtrl->SelectItem(item);
m_TreeCtrl->EnsureVisible(item);
- return TRUE;
+ return true;
}
- if (m_TreeCtrl->ItemHasChildren(item) && SelectNode(node, &item))
- return TRUE;
+ if (m_TreeCtrl->ItemHasChildren(item) && SelectNode(node, &item))
+ return true;
item = m_TreeCtrl->GetNextChild(*root, cookie);
}
- return FALSE;
+ return false;
}
wxTreeItemId EditorFrame::CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent, wxXmlNode *node)
{
- if (!node)
+ if (!node)
{
wxTreeItemId invalid;
return invalid;
if (change_type & CHANGED_TREE_SELECTED)
{
wxTreeItemId sel = m_TreeCtrl->GetSelection();
- m_TreeCtrl->SetItemText(sel,
+ m_TreeCtrl->SetItemText(sel,
NodeHandler::Find(m_SelectedNode)->GetTreeString(m_SelectedNode));
}
int icon = NodeHandler::Find(m_SelectedNode)->GetTreeIcon(m_SelectedNode);
m_TreeCtrl->SetItemImage(sel, icon);
}
-
+
if (!m_Modified)
{
- m_Modified = TRUE;
+ m_Modified = true;
RefreshTitle();
}
-
+
PreviewFrame::Get()->MakeDirty();
}
void EditorFrame::OnTreeSel(wxTreeEvent& event)
{
XmlTreeData *dt = (XmlTreeData*)(m_TreeCtrl->GetItemData(event.GetItem()));
- wxXmlNode *node = (dt) ? dt->Node : NULL;
-
+ wxXmlNode *node = (dt) ? dt->Node : NULL;
+
m_SelectedNode = node;
if (node)
PropertiesFrame::Get()->ShowProps(node);
void EditorFrame::OnToolbar(wxCommandEvent& event)
{
- switch (event.GetId())
+ switch (event.GetId())
{
case ID_PREVIEW :
{
}
case ID_EXIT :
- Close(TRUE);
+ Close(true);
break;
case ID_NEW :
{
if (event.GetId() >= ID_NEWSYBNODE)
{
- XmlTreeData *pardt =
+ XmlTreeData *pardt =
(XmlTreeData*)(m_TreeCtrl->GetItemData(
m_TreeCtrl->GetItemParent(m_TreeCtrl->GetSelection())));
wxTreeItemId root = m_TreeCtrl->GetSelection();
SelectNode(node, &root);
}
-
+
else
{
wxString name;
switch (event.GetId())
{
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_NEWMENU : name = _T("wxMenu"); break;
case ID_NEWMENUBAR : name = _T("wxMenuBar"); break;
case ID_NEWTOOLBAR : name = _T("wxToolBar"); break;
default : return; // never occurs
}
-
+
wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, _T("object"));
node->AddProperty(_T("class"), name);
m_Resource->GetRoot()->AddChild(node);
void EditorFrame::OnRightClickTree(wxPoint pos)
{
wxMenu *popup = new wxMenu;
-
+
if (m_SelectedNode == NULL || m_SelectedNode == m_Resource->GetRoot())
{
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_NEWMENU, _("New wxMenu"));
popup->Append(ID_NEWMENUBAR, _("New wxMenuBar"));
popup->Append(ID_NEWTOOLBAR, _("New wxToolBar"));
}
-
+
else
- {
+ {
bool has_children;
{
- wxArrayString& arr =
+ wxArrayString& arr =
NodeHandler::Find(NodeHandler::Find(m_SelectedNode)->GetRealNode(m_SelectedNode))->
GetChildTypes();
{
news2->Append(i + ID_NEWNODE, arr[i]);
#ifdef __WXGTK__ // doesn't support Break
- if (i % 20 == 19)
+ if (i % 20 == 19)
{
wxMenu *m = new wxMenu;
news2->Append(ID_NEWNODE+arr.GetCount(), _("More..."), m);
}
- XmlTreeData *pardt =
+ XmlTreeData *pardt =
(XmlTreeData*)(m_TreeCtrl->GetItemData(
m_TreeCtrl->GetItemParent(m_TreeCtrl->GetSelection())));
if (pardt && pardt->Node && pardt->Node != m_Resource->GetRoot())
{
wxXmlNode *nd = pardt->Node;
- wxArrayString& arr =
+ wxArrayString& arr =
NodeHandler::Find(NodeHandler::Find(nd)->GetRealNode(nd))->
GetChildTypes();
{
news2->Append(i + ID_NEWSYBNODE, arr[i]);
#ifdef __WXGTK__ // doesn't support Break
- if (i % 20 == 19)
+ if (i % 20 == 19)
{
wxMenu *m = new wxMenu;
news2->Append(ID_NEWSYBNODE+arr.GetCount(), _("More..."), m);
popup->Enable(ID_PASTE_SYBLING, m_Clipboard != NULL);
popup->Enable(ID_PASTE_CHILD, has_children && m_Clipboard != NULL);
}
-
+
m_TreeCtrl->PopupMenu(popup, pos);
delete popup;
}
case ID_CUT:
delete m_Clipboard;
m_Clipboard = new wxXmlNode(*m_SelectedNode);
- GetMenuBar()->Enable(ID_PASTE_SYBLING, TRUE);
- GetMenuBar()->Enable(ID_PASTE_CHILD, TRUE);
+ GetMenuBar()->Enable(ID_PASTE_SYBLING, true);
+ GetMenuBar()->Enable(ID_PASTE_CHILD, true);
if (event.GetId() == ID_CUT) DeleteSelectedNode();
break;
-
+
case ID_PASTE_SYBLING:
{
- XmlTreeData *pardt =
+ XmlTreeData *pardt =
(XmlTreeData*)(m_TreeCtrl->GetItemData(
m_TreeCtrl->GetItemParent(m_TreeCtrl->GetSelection())));
}
}
break;
-
+
case ID_PASTE_CHILD:
wxXmlNode *realnode = NodeHandler::Find(m_SelectedNode)->GetRealNode(m_SelectedNode);
NodeHandler *hnd = NodeHandler::Find(realnode);
bool EditorFrame::AskToSave()
// 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'
{
- if (!m_Modified) return TRUE;
-
- int res = wxMessageBox(_("File modified. Do you want to save changes?"), _("Save changes"),
+ if (!m_Modified) return true;
+
+ int res = wxMessageBox(_("File modified. Do you want to save changes?"), _("Save changes"),
wxYES_NO | wxCANCEL | wxCENTRE | wxICON_QUESTION);
if (res == wxYES)
SaveFile(m_FileName);
{
public:
friend class EditorTreeCtrl;
-
+
EditorFrame(wxFrame *parent, const wxString& filename);
~EditorFrame();
void NewFile();
void SaveFile(const wxString& filename);
wxString GetFileName() { return m_FileName; }
-
+
void RefreshTree();
void RefreshTitle();
bool SelectNode(wxXmlNode *node, wxTreeItemId *root = NULL);
-
+
wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent, wxXmlNode *node);
-
+
void NotifyChanged(int change_type);
-
+
static EditorFrame *Get() { return ms_Instance; }
-
+
private:
static EditorFrame *ms_Instance;
-
+
wxTreeCtrl *m_TreeCtrl;
-
+
wxXmlNode *m_SelectedNode;
-
+
wxXmlNode *m_Clipboard;
wxString m_FileName;
wxXmlRcEditDocument *m_Resource;
-
+
bool m_Modified;
-
+
bool AskToSave();
void DeleteSelectedNode();
wxList NodeHandler::ms_Handlers;
-bool NodeHandler::ms_HandlersLoaded = FALSE;
+bool NodeHandler::ms_HandlersLoaded = false;
NodeHandler *NodeHandler::Find(wxXmlNode *node)
{
if (!ms_HandlersLoaded)
{
- ms_HandlersLoaded = TRUE;
- ms_Handlers.DeleteContents(TRUE);
-
+ ms_HandlersLoaded = true;
+ ms_Handlers.DeleteContents(true);
+
NodeInfoArray& arr = NodesDb::Get()->GetNodesInfo();
NodeHandler *hnd;
for (size_t i = 0; i < arr.GetCount(); i++)
hnd = new NodeHandler(&(arr[i]));
if (hnd) ms_Handlers.Append(hnd);
}
- ms_Handlers.Append(new NodeHandlerUnknown);
+ ms_Handlers.Append(new NodeHandlerUnknown);
}
wxNode *n = ms_Handlers.GetFirst();
-NodeHandler::NodeHandler(NodeInfo *ni) :
+NodeHandler::NodeHandler(NodeInfo *ni) :
m_NodeInfo(ni)
{
}
-wxTreeItemId NodeHandler::CreateTreeNode(wxTreeCtrl *treectrl,
+wxTreeItemId NodeHandler::CreateTreeNode(wxTreeCtrl *treectrl,
wxTreeItemId parent,
wxXmlNode *node)
{
int icon = GetTreeIcon(node);
- wxTreeItemId item =
+ wxTreeItemId item =
treectrl->AppendItem(parent, GetTreeString(node),
icon, icon, new XmlTreeData(node));
if (parent == treectrl->GetRootItem())
{
wxString basetype = m_NodeInfo->ChildType;
NodeInfoArray& arr = NodesDb::Get()->GetNodesInfo();
-
+
for (size_t i = 0; i < arr.GetCount(); i++)
{
NodeInfo &ni = arr[i];
-
- if (ni.NodeClass == basetype && !ni.Abstract)
+
+ if (ni.NodeClass == basetype && !ni.Abstract)
m_ChildTypes.Add(ni.NodeClass);
-
+
if (ni.DerivedFrom.Index(basetype) != wxNOT_FOUND && !ni.Abstract)
m_ChildTypes.Add(ni.NodeClass);
}
-wxTreeItemId NodeHandlerPanel::CreateTreeNode(wxTreeCtrl *treectrl,
+wxTreeItemId NodeHandlerPanel::CreateTreeNode(wxTreeCtrl *treectrl,
wxTreeItemId parent,
wxXmlNode *node)
{
wxTreeItemId root = NodeHandler::CreateTreeNode(treectrl, parent, node);
-
+
wxXmlNode *n = XmlFindNode(node, _T("object"));
while (n)
void NodeHandlerSizer::InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before)
-{
+{
if (XmlGetClass(node) == _T("spacer") || XmlGetClass(node) == _T("sizeritem"))
{
if (insert_before)
-wxTreeItemId NodeHandlerSizerItem::CreateTreeNode(wxTreeCtrl *treectrl,
+wxTreeItemId NodeHandlerSizerItem::CreateTreeNode(wxTreeCtrl *treectrl,
wxTreeItemId parent,
wxXmlNode *node)
{
wxXmlNode *nd = GetRealNode(node);
m_dummy.Add(PropertyInfo(wxEmptyString, wxEmptyString, wxEmptyString));
size_t pos = m_dummy.GetCount();
- WX_APPEND_ARRAY(m_dummy,
+ WX_APPEND_ARRAY(m_dummy,
Find(nd)->GetPropsList(nd));
for (size_t i = pos; i < m_dummy.GetCount(); i++)
m_dummy[i].Name = _T("object/") + m_dummy[i].Name;
-
+
return m_dummy;
}
void NodeHandlerNotebook::InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before)
-{
+{
{
wxXmlNode *itemnode;
-
+
if (XmlGetClass(node) == _T("notebookpage"))
itemnode = node;
else
{
public:
static NodeHandler *Find(wxXmlNode *node);
-
+
NodeHandler(NodeInfo *ni);
virtual ~NodeHandler();
-
+
virtual bool CanHandle(wxXmlNode *node);
virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent,
wxXmlNode *node);
wxArrayString& GetChildTypes();
virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL);
virtual wxXmlNode *GetRealNode(wxXmlNode *node) { return node; }
-
+
protected:
NodeInfo *m_NodeInfo;
wxArrayString m_ChildTypes;
-
+
static wxList ms_Handlers;
static bool ms_HandlersLoaded;
};
{
public:
NodeHandlerPanel(NodeInfo *ni) : NodeHandler(ni) {}
-
+
virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent,
wxXmlNode *node);
virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL);
{
public:
NodeHandlerSizer(NodeInfo *ni) : NodeHandlerPanel(ni) {}
-
+
virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL);
virtual int GetTreeIcon(wxXmlNode *node);
};
{
public:
NodeHandlerNotebook(NodeInfo *ni) : NodeHandlerPanel(ni) {}
-
+
virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL);
};
class NodeHandlerNotebookPage : public NodeHandlerSizerItem
{
public:
- NodeHandlerNotebookPage(NodeInfo *ni) :
+ NodeHandlerNotebookPage(NodeInfo *ni) :
NodeHandlerSizerItem(ni) {}
};
{
public:
NodeHandlerUnknown() : NodeHandler(new NodeInfo) {}
-
- virtual bool CanHandle(wxXmlNode *WXUNUSED(node)) { return TRUE; }
+
+ virtual bool CanHandle(wxXmlNode *WXUNUSED(node)) { return true; }
};
-#endif
+#endif
{
wxString tp;
wxString nd, cht;
- bool ab = FALSE;
+ bool ab = false;
long icn = -1;
NodeClass.Empty();
wxString path = list.FindValidPath(filename);
if (path.IsEmpty()) return;
-
+
wxTextFile tf;
tf.Open(path);
-
+
if (!tf.IsOpened()) return;
for (size_t i = 0; i < tf.GetLineCount(); i++)
tkn.GetNextToken();
pi.Type = tkn.GetNextToken();
if (tkn.HasMoreTokens()) pi.MoreInfo = tkn.GetNextToken();
-
- bool fnd = FALSE;
+
+ bool fnd = false;
for (size_t j = 0; j < Props.GetCount(); j++)
{
if (Props[j].Name == pi.Name)
Props[j].MoreInfo << _T(',') << pi.MoreInfo;
else
Props[j] = pi;
- fnd = TRUE;
+ fnd = true;
}
}
-
+
if (!fnd) Props.Add(pi);
}
}
-
+
if (!nd.IsEmpty()) NodeClass = nd;
if (!cht.IsEmpty()) ChildType = cht;
if (!!tp) Type = tp;
NodesDb *NodesDb::Get()
{
- if (ms_Instance == NULL)
+ if (ms_Instance == NULL)
{
(void)new NodesDb;
}
m_Paths.Add(_T("."));
m_Paths.Add(_T("./df"));
-#ifdef __UNIX__
+#ifdef __UNIX__
m_Paths.Add(wxGetHomeDir() + _T("/.wxrcedit"));
#ifdef wxINSTALL_PREFIX
m_Paths.Add(wxINSTALL_PREFIX _T("/share/wx/wxrcedit"));
void NodesDb::LoadDir(const wxString& path)
{
if (!wxDirExists(path)) return;
-
+
wxDir dir(path);
wxString filename;
bool cont;
void NodesDb::LoadFile(const wxString& file)
{
- NodeInfo *ni = new NodeInfo;
+ NodeInfo *ni = new NodeInfo;
ni->Type = wxEmptyString;
ni->Icon = 0;
wxPathList paths;
size_t i;
-
+
for (i = 0; i < m_Paths.GetCount(); i++)
paths.Add(m_Paths[i]);
-
+
ni->Read(file, paths);
-
+
// maybe we already parsed it?
for (i = 0; i < m_Infos.GetCount(); i++)
if (m_Infos[i].NodeClass == ni->NodeClass) return;
-
+
m_Infos.Add(ni);
}
PropertyInfo() {}
PropertyInfo(const wxString& atype, const wxString& aname, const wxString& amoreinfo)
: Type(atype), Name(aname), MoreInfo(amoreinfo) {}
-
+
PropertyInfo& operator=(const PropertyInfo& p)
{
Type = p.Type; Name = p.Name; MoreInfo = p.MoreInfo;
return *this;
}
-
+
wxString Type;
wxString Name;
wxString MoreInfo;
{
public:
wxString NodeClass;
- wxString Type;
+ wxString Type;
PropertyInfoArray Props;
wxArrayString DerivedFrom;
bool Abstract;
wxString ChildType;
int Icon;
-
+
void Read(const wxString& filename, wxPathList& list);
};
{
public:
NodesDb();
-
+
void Load();
void LoadDir(const wxString& path);
void LoadFile(const wxString& file);
-
+
NodeInfoArray& GetNodesInfo() { return m_Infos; }
-
+
static NodesDb *Get();
-
+
private:
static NodesDb *ms_Instance;
NodeInfoArray m_Infos;
-#endif
+#endif
wxWindow* PropEditCtrlFont::CreateEditCtrl()
{
PropEditCtrlTxt::CreateEditCtrl();
- m_TextCtrl->Enable(FALSE);
+ m_TextCtrl->Enable(false);
return m_TextCtrl;
}
BEGIN_EVENT_TABLE(PropEditCtrlChoice, PropEditCtrl)
- EVT_CHOICE(-1, PropEditCtrlChoice::OnChoice)
+ EVT_CHOICE(wxID_ANY, PropEditCtrlChoice::OnChoice)
END_EVENT_TABLE()
wxWindow* PropEditCtrlChoice::CreateEditCtrl()
{
- m_Choice = new wxChoice(this, -1);
-
+ m_Choice = new wxChoice(this, wxID_ANY);
+
return m_Choice;
}
-
+
void PropEditCtrlChoice::ReadValue()
{
wxStringTokenizer tkn(m_PropInfo->MoreInfo, _T(","));
void PropEditCtrlChoice::OnChoice(wxCommandEvent& WXUNUSED(event))
{
- if (CanSave())
+ if (CanSave())
{
WriteValue();
- EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);
+ EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);
}
}
wxColour clr;
wxString txt = m_TextCtrl->GetValue();
long unsigned tmp;
-
+
if (txt.Length() == 7 && txt[0u] == _T('#') &&
wxSscanf(txt.c_str(), _T("#%lX"), &tmp) == 1)
- clr = wxColour((tmp & 0xFF0000) >> 16,
- (tmp & 0x00FF00) >> 8,
+ clr = wxColour((tmp & 0xFF0000) >> 16,
+ (tmp & 0x00FF00) >> 8,
(tmp & 0x0000FF));
clr = wxGetColourFromUser(NULL, clr);
wxArrayString arr;
size_t i;
int j;
-
+
wxStringTokenizer tkn(m_PropInfo->MoreInfo, _T(","));
while (tkn.HasMoreTokens())
arr.Add(tkn.GetNextToken());
wxConfigBase *cfg = wxConfigBase::Get();
-
- wxDialog dlg(m_PropFrame, -1, _("Flags"),
- wxPoint(cfg->Read(_T("flagsdlg_x"), -1), cfg->Read(_T("flagsdlg_y"), -1)),
+
+ wxDialog dlg(m_PropFrame, wxID_ANY, _("Flags"),
+ 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)),
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
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);
wxSizer *sz2 = new wxBoxSizer(wxHORIZONTAL);
wxButton *btnok = new wxButton(&dlg, wxID_OK, _("OK"));
sz->Add(sz2, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 10);
dlg.SetSizer(sz);
- dlg.SetAutoLayout(TRUE);
+ dlg.SetAutoLayout(true);
dlg.Layout();
-
+
for (i = 0; i < arr.GetCount(); i++)
lbox->Append(arr[i]);
-
+
tkn.SetString(txt, _T("| "));
while (tkn.HasMoreTokens())
{
j = arr.Index(t);
if (j != wxNOT_FOUND) lbox->Check(j);
}
-
-
+
+
if (dlg.ShowModal() != wxID_OK) return;
-
+
txt.Empty();
-
+
for (i = 0; i < arr.GetCount(); i++)
if (lbox->IsChecked(i))
txt << arr[i] << _T('|');
{
wxString txt = m_TextCtrl->GetValue();
txt = wxPathOnly(EditorFrame::Get()->GetFileName()) + _T("/") + txt;
- wxString name = wxFileSelector(_("Choose file"),
+ wxString name = wxFileSelector(_("Choose file"),
wxPathOnly(txt),
wxFileNameFromPath(txt),
_T(""),
GetFileTypes(),
wxOPEN | wxFILE_MUST_EXIST);
if (!name) return;
-
+
// compute relative path:
wxArrayString axrc, afile;
wxStringTokenizer tkn;
while (tkn.HasMoreTokens()) afile.Add(tkn.GetNextToken());
tkn.SetString(EditorFrame::Get()->GetFileName(), _T("/\\"));
while (tkn.HasMoreTokens()) axrc.Add(tkn.GetNextToken());
-
+
if (afile.GetCount() == 0 || axrc.GetCount() == 0)
txt = name;
else
public:
PropEditCtrlFont(PropertiesFrame *propFrame)
: PropEditCtrlTxt(propFrame) {}
-
+
virtual wxWindow* CreateEditCtrl();
virtual wxTreeItemId CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo);
};
public:
PropEditCtrlChoice(PropertiesFrame *propFrame)
: PropEditCtrl(propFrame) {}
-
+
virtual wxWindow* CreateEditCtrl();
-
+
virtual void ReadValue();
virtual void WriteValue();
-
+
protected:
wxChoice *m_Choice;
PropEditCtrlColor(PropertiesFrame *propFrame)
: PropEditCtrlTxt(propFrame) {}
- virtual bool HasDetails() { return TRUE; }
+ virtual bool HasDetails() { return true; }
virtual void OnDetails();
};
PropEditCtrlFlags(PropertiesFrame *propFrame)
: PropEditCtrlTxt(propFrame) {}
- virtual bool HasDetails() { return TRUE; }
+ virtual bool HasDetails() { return true; }
virtual void OnDetails();
};
PropEditCtrlFile(PropertiesFrame *propFrame)
: PropEditCtrlTxt(propFrame) {}
- virtual bool HasDetails() { return TRUE; }
+ virtual bool HasDetails() { return true; }
virtual void OnDetails();
-
+
virtual wxString GetFileTypes();
};
BEGIN_EVENT_TABLE(PropEditCtrlTxt, PropEditCtrl)
- EVT_TEXT(-1, PropEditCtrlTxt::OnText)
+ EVT_TEXT(wxID_ANY, PropEditCtrlTxt::OnText)
END_EVENT_TABLE()
wxWindow *PropEditCtrlTxt::CreateEditCtrl()
{
- return (m_TextCtrl = new wxTextCtrl(this, -1));
+ return (m_TextCtrl = new wxTextCtrl(this, wxID_ANY));
}
void PropEditCtrlTxt::OnText(wxCommandEvent& WXUNUSED(event))
{
- if (CanSave())
+ if (CanSave())
{
WriteValue();
EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);
{
wxString newv = m_TextCtrl->GetValue();
XmlWriteValue(GetNode(), m_PropInfo->Name, newv);
- m_TreeCtrl->SetItemBold(m_TreeItem, TRUE);
+ m_TreeCtrl->SetItemBold(m_TreeItem, true);
}
BEGIN_EVENT_TABLE(PropEditCtrlBool, PropEditCtrl)
- EVT_CHOICE(-1, PropEditCtrlBool::OnChoice)
+ EVT_CHOICE(wxID_ANY, PropEditCtrlBool::OnChoice)
END_EVENT_TABLE()
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("true"));
return m_Choice;
wxString newv = m_Choice->GetSelection() == 0 ? _T("0") : _T("1");
XmlWriteValue(GetNode(), m_PropInfo->Name, newv);
- m_TreeCtrl->SetItemBold(m_TreeItem, TRUE);
+ m_TreeCtrl->SetItemBold(m_TreeItem, true);
}
void PropEditCtrlBool::OnChoice(wxCommandEvent& WXUNUSED(event))
{
- if (CanSave())
+ if (CanSave())
{
WriteValue();
EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);
public:
PropEditCtrlCoordXY(PropertiesFrame *propFrame, int which)
: PropEditCtrlInt(propFrame), m_which(which) {}
-
+
virtual void ReadValue()
{
wxString s = XmlReadValue(GetNode(), m_PropInfo->Name);
}
m_TextCtrl->SetValue(m_c[m_which]);
}
-
+
virtual void WriteValue()
{
m_c[m_which] = m_TextCtrl->GetValue();
wxString prev = XmlReadValue(GetNode(), m_PropInfo->Name);
if (prev[prev.Len()-1] == _T('d')) s << _T('d');
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)
{
PropertyInfo *pi = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo);
}
return m_c[m_which];
}
-
+
virtual wxString GetPropName(const PropertyInfo& WXUNUSED(pinfo))
{
if (m_which == 0) return _T("x"); else return _T("y");
}
- virtual bool HasClearButton() { return FALSE; }
- virtual bool IsPresent(const PropertyInfo& WXUNUSED(pinfo)) { return FALSE; }
+ virtual bool HasClearButton() { return false; }
+ virtual bool IsPresent(const PropertyInfo& WXUNUSED(pinfo)) { return false; }
+
-
protected:
wxString m_c[2];
int m_which;
public:
PropEditCtrlCoordDlg(PropertiesFrame *propFrame)
: PropEditCtrlBool(propFrame) {}
-
+
virtual void ReadValue()
{
wxString s = XmlReadValue(GetNode(), m_PropInfo->Name);
else
m_Choice->SetSelection(0);
}
-
+
virtual void WriteValue()
{
wxString s = XmlReadValue(GetNode(), m_PropInfo->Name).BeforeFirst(_T('d'));
if (m_Choice->GetSelection() == 1) s << _T('d');
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)
{
PropertyInfo *pi = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo);
else
return _("true");
}
-
+
virtual wxString GetPropName(const PropertyInfo& WXUNUSED(pinfo))
{
return _T("dlg");
}
- virtual bool HasClearButton() { return FALSE; }
- virtual bool IsPresent(const PropertyInfo& WXUNUSED(pinfo)) { return FALSE; }
+ virtual bool HasClearButton() { return false; }
+ virtual bool IsPresent(const PropertyInfo& WXUNUSED(pinfo)) { return false; }
};
public:
PropEditCtrlDimX(PropertiesFrame *propFrame)
: PropEditCtrlInt(propFrame){}
-
+
virtual void ReadValue()
{
wxString s = XmlReadValue(GetNode(), m_PropInfo->Name);
m_c = s.BeforeFirst(_T('d'));
m_TextCtrl->SetValue(m_c);
}
-
+
virtual void WriteValue()
{
wxString s = XmlReadValue(GetNode(), m_PropInfo->Name);
s = m_c;
if (dlg) s << _T('d');
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)
{
PropertyInfo *pi = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo);
return XmlReadValue(GetNode(), pi->Name).BeforeFirst(_T('d'));
}
-
+
virtual wxString GetPropName(const PropertyInfo& WXUNUSED(pinfo))
{
return _T("val");
}
- virtual bool HasClearButton() { return FALSE; }
- virtual bool IsPresent(const PropertyInfo& WXUNUSED(pinfo)) { return FALSE; }
+ virtual bool HasClearButton() { return false; }
+ virtual bool IsPresent(const PropertyInfo& WXUNUSED(pinfo)) { return false; }
+
-
protected:
wxString m_c;
};
REAL_NODE->DeleteProperty(_T("name"));
REAL_NODE->AddProperty(_T("name"), s);
- m_TreeCtrl->SetItemBold(m_TreeItem, TRUE);
+ m_TreeCtrl->SetItemBold(m_TreeItem, true);
EditorFrame::Get()->NotifyChanged(CHANGED_TREE_SELECTED);
}
{
EndEdit();
REAL_NODE->DeleteProperty(_T("name"));
- m_TreeCtrl->SetItemBold(m_TreeItem, FALSE);
+ m_TreeCtrl->SetItemBold(m_TreeItem, false);
EditorFrame::Get()->NotifyChanged(CHANGED_TREE_SELECTED);
}
#define stdID(id) , wxString(_T(#id))
stdID(wxID_OK) stdID(wxID_CANCEL)
stdID(wxID_YES) stdID(wxID_NO)
- stdID(wxID_APPLY) stdID(wxID_HELP)
+ stdID(wxID_APPLY) stdID(wxID_HELP)
stdID(wxID_HELP_CONTEXT)
stdID(wxID_OPEN) stdID(wxID_CLOSE) stdID(wxID_NEW)
stdID(wxID_HELP_COMMANDS) stdID(wxID_HELP_PROCEDURES)
stdID(wxID_CUT) stdID(wxID_COPY) stdID(wxID_PASTE)
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_DEFAULT) stdID(wxID_MORE) stdID(wxID_SETUP)
- stdID(wxID_RESET)
+ stdID(wxID_RESET)
#undef stdID
};
- wxString s =
- wxGetSingleChoice(_("Choose from predefined IDs:"), _("XRCID"),
+ wxString s =
+ wxGetSingleChoice(_("Choose from predefined IDs:"), _("XRCID"),
38/*sizeof choices*/, choices);
if (!s) return;
m_TextCtrl->SetValue(s);
WriteValue();
- EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);
+ EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);
}
public:
PropEditCtrlNull(PropertiesFrame *propFrame)
: PropEditCtrl(propFrame) {}
-
+
virtual void BeginEdit(const wxRect& WXUNUSED(rect), wxTreeItemId WXUNUSED(ti)) {}
virtual void EndEdit() {}
-
+
virtual wxWindow* CreateEditCtrl() {return NULL;}
-
+
virtual void ReadValue() {}
virtual void WriteValue() {}
};
public:
PropEditCtrlTxt(PropertiesFrame *propFrame)
: PropEditCtrl(propFrame) {}
-
+
virtual wxWindow* CreateEditCtrl();
-
+
virtual void ReadValue();
virtual void WriteValue();
-
+
protected:
wxTextCtrl *m_TextCtrl;
public:
PropEditCtrlInt(PropertiesFrame *propFrame)
: PropEditCtrlTxt(propFrame) {}
-
+
virtual wxWindow* CreateEditCtrl();
};
public:
PropEditCtrlBool(PropertiesFrame *propFrame)
: PropEditCtrl(propFrame) {}
-
+
virtual wxWindow* CreateEditCtrl();
-
+
virtual void ReadValue();
virtual void WriteValue();
virtual wxString GetValueAsText(wxTreeItemId ti);
-
+
protected:
wxChoice *m_Choice;
public:
PropEditCtrlCoord(PropertiesFrame *propFrame);
~PropEditCtrlCoord();
-
+
virtual wxTreeItemId CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo);
-
+
private:
PropEditCtrl *m_CtrlX, *m_CtrlY, *m_CtrlDlg;
};
public:
PropEditCtrlDim(PropertiesFrame *propFrame);
~PropEditCtrlDim();
-
+
virtual wxTreeItemId CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo);
-
+
private:
PropEditCtrl *m_CtrlX, *m_CtrlDlg;
};
public:
PropEditCtrlXRCID(PropertiesFrame *propFrame)
: PropEditCtrlTxt(propFrame) {}
-
+
virtual void ReadValue();
virtual void WriteValue();
virtual void Clear();
- virtual bool HasDetails() { return TRUE; }
+ virtual bool HasDetails() { return true; }
virtual void OnDetails();
virtual wxString GetValueAsText(wxTreeItemId ti);
virtual bool IsPresent(const PropertyInfo& pinfo);
wxObject *DoCreateResource()
{
- //wxMenuBar *menubar = new wxMenuBar(GetStyle());
+ //wxMenuBar *menubar = new wxMenuBar(GetStyle());
CreateChildren(m_MenuBar);
return m_MenuBar;
}
-
+
private:
wxMenuBar *m_MenuBar;
};
PreviewFrame *PreviewFrame::Get()
{
- if (ms_Instance == NULL)
+ if (ms_Instance == NULL)
{
(void)new PreviewFrame;
- ms_Instance->Show(TRUE);
+ ms_Instance->Show(true);
}
return ms_Instance;
}
PreviewFrame::PreviewFrame()
- : wxFrame(EditorFrame::Get(), -1, _("Preview"),
- wxDefaultPosition, wxDefaultSize,
+ : wxFrame(EditorFrame::Get(), wxID_ANY, _("Preview"),
+ wxDefaultPosition, wxDefaultSize,
wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR
#ifdef __WXMSW__
| wxFRAME_TOOL_WINDOW
#endif
)
{
- m_Dirty = FALSE;
+ m_Dirty = false;
ms_Instance = this;
m_Node = NULL;
-
+
SetMenuBar(new wxMenuBar());
-
+
m_RC = NULL;
m_TmpFile = wxGetTempFileName(_T("wxrcedit"));
ResetResource();
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))));
- m_Splitter = new wxSplitterWindow(this, -1);
- m_LogCtrl = new wxTextCtrl(m_Splitter, -1, wxEmptyString, wxDefaultPosition,
+ m_Splitter = new wxSplitterWindow(this, wxID_ANY);
+ m_LogCtrl = new wxTextCtrl(m_Splitter, wxID_ANY, wxEmptyString, wxDefaultPosition,
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_Splitter->SplitHorizontally(m_ScrollWin, m_LogCtrl, cfg->Read(_T("previewframe_sash"), 300));
PreviewFrame::~PreviewFrame()
{
- wxConfigBase *cfg = wxConfigBase::Get();
+ wxConfigBase *cfg = wxConfigBase::Get();
cfg->Write(_T("previewframe_x"), (long)GetPosition().x);
cfg->Write(_T("previewframe_y"), (long)GetPosition().y);
cfg->Write(_T("previewframe_w"), (long)GetSize().x);
cfg->Write(_T("previewframe_h"), (long)GetSize().y);
cfg->Write(_T("previewframe_sash"), (long)m_Splitter->GetSashPosition());
-
+
ms_Instance = NULL;
-
+
delete m_RC;
wxRemoveFile(m_TmpFile);
}
-
+
void PreviewFrame::MakeDirty()
{
if (m_Node == NULL) return;
if (m_Dirty) return;
- m_Dirty = TRUE;
+ m_Dirty = true;
m_LogCtrl->Clear();
m_LogCtrl->SetValue(_("Resource modified.\nMove mouse cursor over the preview window to refresh it."));
}
doc.GetRoot()->AddChild(new wxXmlNode(*node));
doc.SetFileEncoding(orig_doc->GetFileEncoding());
- if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxDialog"))
- XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel"));
+ if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxDialog"))
+ XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel"));
- if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxFrame"))
- XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel"));
+ if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxFrame"))
+ XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel"));
doc.Save(m_TmpFile);
// wxXmlResource will detect change automatically
m_LogCtrl->Clear();
wxLogTextCtrl mylog(m_LogCtrl);
wxLog *oldlog = wxLog::SetActiveTarget(&mylog);
-
+
wxString oldcwd = wxGetCwd();
wxSetWorkingDirectory(wxPathOnly(EditorFrame::Get()->GetFileName()));
-
+
if (XmlGetClass(node) == _T("wxMenuBar") || XmlGetClass(node) == _T("wxMenu"))
PreviewMenu();
else if (XmlGetClass(node) == _T("wxToolBar"))
else if (XmlGetClass(node) == _T("wxPanel") || XmlGetClass(node) == _T("wxDialog"))
PreviewPanel();
else if (XmlGetClass(node) == _T("wxFrame"))
- PreviewWXFrame();
+ PreviewWXFrame();
wxSetWorkingDirectory(oldcwd);
wxLog::SetActiveTarget(oldlog);
-
- m_Dirty = FALSE;
+
+ m_Dirty = false;
}
else
{
m_ScrollWin->SetScrollbars(1, 1, panel->GetSize().x, panel->GetSize().y,
- 0, 0, TRUE);
+ 0, 0, true);
}
}
void PreviewFrame::PreviewWXFrame()
{
- //for this to work the frame MUST have a child panel!
-
- wxXmlNode* child = m_Node;
- wxString name;
-
- while( child != NULL)
- {
- name = child->GetPropVal(_T("name"), _T("-1"));
-
- if(name != _T("-1"))
- {
- wxXmlNode* parent = child->GetParent();
- if(parent->GetPropVal(_T("class"),_T("-1")) == _T("wxPanel"))
- break;
- }
- child = child->GetNext();
- }
+ //for this to work the frame MUST have a child panel!
+
+ wxXmlNode* child = m_Node;
+ wxString name;
+
+ while( child != NULL)
+ {
+ name = child->GetPropVal(_T("name"), _T("-1"));
+
+ if(name != _T("-1"))
+ {
+ wxXmlNode* parent = child->GetParent();
+ if(parent->GetPropVal(_T("class"),_T("-1")) == _T("wxPanel"))
+ break;
+ }
+ child = child->GetNext();
+ }
wxPanel *panel = m_RC->LoadPanel(m_ScrollWin, name);
-
+
if (panel == NULL)
wxLogError(_("Cannot preview the panel -- XML resource corrupted."));
else
{
m_ScrollWin->SetScrollbars(1, 1, panel->GetSize().x, panel->GetSize().y,
- 0, 0, TRUE);
+ 0, 0, true);
}
}
public:
PreviewFrame();
~PreviewFrame();
-
+
void Preview(wxXmlNode *node,wxXmlDocument *doc);
void MakeDirty();
// current node updated, needs preview refresh
// (will be done once mouse enters preview win)
-
+
static PreviewFrame *Get();
void ResetResource();
-
+
private:
void PreviewMenu();
void PreviewToolbar();
void PreviewPanel();
- void PreviewWXFrame();
-
+ void PreviewWXFrame();
+
private:
static PreviewFrame *ms_Instance;
wxXmlNode *m_Node;
wxScrolledWindow *m_ScrollWin;
wxTextCtrl *m_LogCtrl;
wxSplitterWindow *m_Splitter;
-
+
wxXmlResource *m_RC;
wxString m_TmpFile;
-
+
bool m_Dirty;
-
+
DECLARE_EVENT_TABLE()
void OnMouseEnter(wxMouseEvent& event);
};
void PropEditCtrl::OnButtonClear(wxCommandEvent& WXUNUSED(event))
{
Clear();
- EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);
+ EditorFrame::Get()->NotifyChanged(CHANGED_PROPS);
}
m_PropInfo = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo);
m_TreeItem = ti;
- m_CanSave = FALSE;
+ m_CanSave = false;
if (!m_Created)
{
wxSizer *sz = new wxBoxSizer(wxHORIZONTAL);
sz->Add(m_TheCtrl, 1);
if (HasDetails())
sz->Add(new wxButton(this, ID_DETAILS, _T("..."), wxDefaultPosition,
- wxSize(16,-1)));
+ wxSize(16,wxDefaultSize.y)));
if (HasClearButton())
sz->Add(new wxButton(this, ID_CLEAR, _T("X"), wxDefaultPosition,
- wxSize(16,-1)));
- SetAutoLayout(TRUE);
+ wxSize(16,wxDefaultSize.y)));
+ SetAutoLayout(true);
SetSizer(sz);
- m_Created = TRUE;
+ m_Created = true;
}
m_TheCtrl->SetFocus();
SetSize(rect.x, rect.y, rect.width, rect.height);
- Show(TRUE);
+ Show(true);
ReadValue();
- m_CanSave = TRUE;
+ m_CanSave = true;
}
void PropEditCtrl::EndEdit()
{
- Show(FALSE);
+ Show(false);
}
wxTreeItemId t = m_TreeCtrl->AppendItem(parent, GetPropName(pinfo));
m_TreeCtrl->SetItemData(t, new PETreeData(this, pinfo));
if (IsPresent(pinfo))
- m_TreeCtrl->SetItemBold(t, TRUE);
+ m_TreeCtrl->SetItemBold(t, true);
return t;
}
{
n->GetParent()->RemoveChild(n);
delete n;
- m_TreeCtrl->SetItemBold(m_TreeItem, FALSE);
+ m_TreeCtrl->SetItemBold(m_TreeItem, false);
}
}
{
public:
PropEditCtrl(PropertiesFrame *propFrame)
- : wxPanel(propFrame->m_valueWindow, -1),
- m_PropFrame(propFrame), m_Created(FALSE), m_TreeCtrl(propFrame->m_tree)
- {Show(FALSE);}
-
+ : wxPanel(propFrame->m_valueWindow, wxID_ANY),
+ m_PropFrame(propFrame), m_Created(false), m_TreeCtrl(propFrame->m_tree)
+ {Show(false);}
+
virtual void BeginEdit(const wxRect& rect, wxTreeItemId ti);
virtual void EndEdit();
-
+
virtual wxTreeItemId CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo);
virtual wxWindow* CreateEditCtrl() = 0;
-
+
virtual bool IsPresent(const PropertyInfo& pinfo);
-
+
virtual void Clear();
virtual void ReadValue() = 0;
virtual void WriteValue() = 0;
virtual wxString GetValueAsText(wxTreeItemId ti);
virtual wxString GetPropName(const PropertyInfo& pinfo)
{ return pinfo.Name.AfterLast(_T('/')); }
-
- virtual bool HasDetails() { return FALSE; }
+
+ virtual bool HasDetails() { return false; }
virtual void OnDetails() {}
- virtual bool HasClearButton() { return TRUE; }
-
+ virtual bool HasClearButton() { return true; }
+
void OnButtonDetails(wxCommandEvent& event);
void OnButtonClear(wxCommandEvent& event);
-
+
protected:
wxXmlNode *GetNode() { return m_PropFrame->m_Node; }
bool CanSave() { return m_CanSave; }
-
+
PropertiesFrame *m_PropFrame;
bool m_Created;
wxTreeCtrl *m_TreeCtrl;
wxTreeItemId m_TreeItem;
wxWindow *m_TheCtrl;
PropertyInfo *m_PropInfo;
-
+
bool m_CanSave;
-
+
DECLARE_EVENT_TABLE()
};
class PETreeData : public wxTreeItemData
{
public:
- PETreeData(PropEditCtrl *p, const PropertyInfo& pi) :
+ PETreeData(PropEditCtrl *p, const PropertyInfo& pi) :
wxTreeItemData(),
EditCtrl(p), PropInfo(pi) {}
PropEditCtrl *EditCtrl;
PropsTree(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition,
const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS)
: wxRemotelyScrolledTreeCtrl(parent, id, pt, sz, style),
- m_EditCtrl(NULL)
- {
+ m_EditCtrl(NULL)
+ {
#if 0
// VS: Don't do it, it is *extremely* ugly.
// FIXME: find a better solution.
- //make text larger so controls will fit properly
- wxFont font = GetFont();
- font.SetPointSize(font.GetPointSize()*1.5);
- SetFont(font);
+ //make text larger so controls will fit properly
+ wxFont font = GetFont();
+ font.SetPointSize(font.GetPointSize()*1.5);
+ SetFont(font);
#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
dc.SetDeviceOrigin(0, 0);
- wxPen pen(wxColour(_T("BLACK")), 1, wxSOLID);
- dc.SetPen(pen);
+ wxPen pen(wxColour(_T("BLACK")), 1, wxSOLID);
+ dc.SetPen(pen);
- dc.SetBrush(* wxTRANSPARENT_BRUSH);
+ dc.SetBrush(* wxTRANSPARENT_BRUSH);
wxSize clientSize = GetClientSize();
- wxRect itemRect;
- int cy=0;
- wxTreeItemId h, lastH;
- for(h=GetFirstVisibleItem();h;h=GetNextVisible(h))
- {
- if (h.IsOk() && GetBoundingRect(h, itemRect))
- {
- cy = itemRect.GetTop();
-
- dc.DrawLine(0, cy, clientSize.x, cy);
- lastH = h;
- }
- }
- if (lastH.IsOk() && GetBoundingRect(lastH, itemRect))
- {
- cy = itemRect.GetBottom();
- dc.DrawLine(0, cy, clientSize.x, cy);
- }
+ wxRect itemRect;
+ int cy=0;
+ wxTreeItemId h, lastH;
+ for(h=GetFirstVisibleItem();h;h=GetNextVisible(h))
+ {
+ if (h.IsOk() && GetBoundingRect(h, itemRect))
+ {
+ cy = itemRect.GetTop();
+
+ dc.DrawLine(0, cy, clientSize.x, cy);
+ lastH = h;
+ }
+ }
+ if (lastH.IsOk() && GetBoundingRect(lastH, itemRect))
+ {
+ cy = itemRect.GetBottom();
+ dc.DrawLine(0, cy, clientSize.x, cy);
+ }
}
void OnSelChange(wxTreeEvent& event)
m_EditCtrl->EndEdit();
m_EditCtrl = NULL;
}
-
+
wxTreeItemId item = event.GetItem();
PETreeData *dt = (PETreeData*)GetItemData(item);
if (dt != NULL)
GetBoundingRect(item, bounding);
bounding.SetX(0);
- bounding.SetWidth(GetCompanionWindow()->GetSize().x);
+ bounding.SetWidth(GetCompanionWindow()->GetSize().x);
dt->EditCtrl->BeginEdit(bounding, item);
m_EditCtrl = dt->EditCtrl;
}
event.Skip();
if (event.GetOrientation() == wxHORIZONTAL) return;
if (!m_EditCtrl) return;
-
+
wxTreeItemId id = GetSelection();
wxRect bounding;
GetBoundingRect(id, bounding);
-
- m_EditCtrl->Move(-1, bounding.y);
+
+ m_EditCtrl->Move(wxDefaultPosition.x, bounding.y);
}
-
+
PropEditCtrl *m_EditCtrl;
-
+
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(PropsTree, wxRemotelyScrolledTreeCtrl)
- EVT_PAINT(PropsTree::OnPaint)
- EVT_TREE_SEL_CHANGED(-1, PropsTree::OnSelChange)
+ EVT_PAINT(PropsTree::OnPaint)
+ EVT_TREE_SEL_CHANGED(wxID_ANY, PropsTree::OnSelChange)
EVT_SCROLLWIN(PropsTree::OnScroll)
END_EVENT_TABLE()
class PropsValueWindow: public wxTreeCompanionWindow
{
public:
- PropsValueWindow(wxWindow* parent, wxWindowID id = -1,
+ PropsValueWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize,
long style = 0)
: wxTreeCompanionWindow(parent, id, pos, sz, style) {}
-
+
virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect)
{
- if (m_treeCtrl)
- {
+ if (m_treeCtrl)
+ {
PETreeData *data = (PETreeData*)m_treeCtrl->GetItemData(id);
- wxString text;
+ wxString text;
if (data != NULL) text = data->EditCtrl->GetValueAsText(id);
dc.SetBrush(wxBrush(GetBackgroundColour(), wxSOLID));
dc.DrawRectangle(rect);
- dc.SetTextForeground(* wxBLACK);
- dc.SetBackgroundMode(wxTRANSPARENT);
+ dc.SetTextForeground(* wxBLACK);
+ dc.SetBackgroundMode(wxTRANSPARENT);
- int textW, textH;
- dc.GetTextExtent(text, & textW, & textH);
+ int textW, textH;
+ dc.GetTextExtent(text, & textW, & textH);
- int x = 5;
- int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2);
+ int x = 5;
+ int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2);
- dc.DrawText(text, x, y);
- }
+ dc.DrawText(text, x, y);
+ }
}
-
+
void OnClick(wxMouseEvent& event)
{
int flags;
};
BEGIN_EVENT_TABLE(PropsValueWindow, wxTreeCompanionWindow)
- EVT_LEFT_DOWN(PropsValueWindow::OnClick)
+ EVT_LEFT_DOWN(PropsValueWindow::OnClick)
END_EVENT_TABLE()
PropertiesFrame *PropertiesFrame::Get()
{
- if (ms_Instance == NULL)
+ if (ms_Instance == NULL)
{
(void)new PropertiesFrame;
- ms_Instance->Show(TRUE);
+ ms_Instance->Show(true);
}
return ms_Instance;
}
PropertiesFrame::PropertiesFrame()
- : wxFrame(EditorFrame::Get(), -1, _("Properties"),
+ : wxFrame(EditorFrame::Get(), wxID_ANY, _("Properties"),
wxDefaultPosition, wxDefaultSize,
- wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR
+ wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR
#ifdef __WXMSW__
| wxFRAME_TOOL_WINDOW
#endif
ms_Instance = this;
m_Node = NULL;
- m_scrolledWindow = new wxSplitterScrolledWindow(this, -1, wxDefaultPosition,
- wxDefaultSize, wxNO_BORDER | wxCLIP_CHILDREN | wxVSCROLL);
- m_splitter = new wxThinSplitterWindow(m_scrolledWindow, -1, wxDefaultPosition,
- wxDefaultSize, wxSP_3DBORDER | wxCLIP_CHILDREN /* | wxSP_LIVE_UPDATE */);
- m_splitter->SetSashSize(2);
- m_tree = new PropsTree(m_splitter, -1, wxDefaultPosition,
- wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxNO_BORDER );
+ m_scrolledWindow = new wxSplitterScrolledWindow(this, wxID_ANY, wxDefaultPosition,
+ wxDefaultSize, wxNO_BORDER | wxCLIP_CHILDREN | wxVSCROLL);
+ m_splitter = new wxThinSplitterWindow(m_scrolledWindow, wxID_ANY, wxDefaultPosition,
+ wxDefaultSize, wxSP_3DBORDER | wxCLIP_CHILDREN /* | wxSP_LIVE_UPDATE */);
+ m_splitter->SetSashSize(2);
+ m_tree = new PropsTree(m_splitter, wxID_ANY, wxDefaultPosition,
+ wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxNO_BORDER );
m_tree->SetIndent(2);
- m_valueWindow = new PropsValueWindow(m_splitter, -1, wxDefaultPosition,
- wxDefaultSize, wxNO_BORDER);
+ m_valueWindow = new PropsValueWindow(m_splitter, wxID_ANY, wxDefaultPosition,
+ wxDefaultSize, wxNO_BORDER);
m_valueWindow->SetBackgroundColour(m_tree->GetBackgroundColour());
m_splitter->SplitVertically(m_tree, m_valueWindow, wxConfig::Get()->Read(_T("propertiesframe_sash"), 100));
- //m_splitter->AdjustScrollbars();
- m_scrolledWindow->SetTargetWindow(m_tree);
+ //m_splitter->AdjustScrollbars();
+ m_scrolledWindow->SetTargetWindow(m_tree);
- m_scrolledWindow->EnableScrolling(FALSE, FALSE);
+ m_scrolledWindow->EnableScrolling(false, false);
- // Let the two controls know about each other
- m_valueWindow->SetTreeCtrl(m_tree);
- m_tree->SetCompanionWindow(m_valueWindow);
+ // Let the two controls know about each other
+ m_valueWindow->SetTreeCtrl(m_tree);
+ m_tree->SetCompanionWindow(m_valueWindow);
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))));
-
- m_EditCtrls.DeleteContents(TRUE);
+
+ m_EditCtrls.DeleteContents(true);
m_EditCtrls.Put(_T("bool"), new PropEditCtrlBool(this));
m_EditCtrls.Put(_T("coord"), new PropEditCtrlCoord(this));
m_EditCtrls.Put(_T("color"), new PropEditCtrlColor(this));
m_EditCtrls.Put(_T("file"), new PropEditCtrlFile(this));
m_EditCtrls.Put(_T("imagefile"), new PropEditCtrlImageFile(this));
m_EditCtrls.Put(_T(""), new PropEditCtrlNull(this));
-
+
ClearProps();
}
PropertiesFrame::~PropertiesFrame()
{
- wxConfigBase *cfg = wxConfigBase::Get();
+ wxConfigBase *cfg = wxConfigBase::Get();
cfg->Write(_T("propertiesframe_x"), (long)GetPosition().x);
cfg->Write(_T("propertiesframe_y"), (long)GetPosition().y);
cfg->Write(_T("propertiesframe_w"), (long)GetSize().x);
cfg->Write(_T("propertiesframe_h"), (long)GetSize().y);
cfg->Write(_T("propertiesframe_sash"), (long)m_splitter->GetSashPosition());
-
+
ms_Instance = NULL;
}
-
+
void PropertiesFrame::ShowProps(wxXmlNode *node)
{
m_Node = node;
-
+
ClearProps();
AddSingleProp(PropertyInfo(_T("xmlid"), _T("XRCID"), wxEmptyString));
AddProps(NodeHandler::Find(node)->GetPropsList(node));
-
+
m_tree->Expand(m_tree->GetRootItem());
m_valueWindow->Refresh();
}
wxTreeItemId tid;
if (root != NULL) tid = *root;
else tid = m_tree->GetRootItem();
-
+
if (pec == NULL)
wxLogError(_("Unknown property type '%s'!"), pinfo.Type.c_str());
else
public:
PropertiesFrame();
~PropertiesFrame();
-
+
void ShowProps(wxXmlNode *node);
-
+
void ClearProps();
void AddProps(PropertyInfoArray& plist);
void AddSingleProp(const PropertyInfo& pinfo, wxTreeItemId *root = NULL);
-
+
static PropertiesFrame *Get();
-
+
private:
static PropertiesFrame *ms_Instance;
wxRemotelyScrolledTreeCtrl *m_tree;
wxThinSplitterWindow *m_splitter;
- wxSplitterScrolledWindow *m_scrolledWindow;
+ wxSplitterScrolledWindow *m_scrolledWindow;
wxTreeCompanionWindow *m_valueWindow;
-
+
wxHashTable m_EditCtrls;
-
+
friend class PropEditCtrl;
};
#else
BEGIN_EVENT_TABLE(wxRemotelyScrolledTreeCtrl, wxTreeCtrl)
#endif
- EVT_SIZE(wxRemotelyScrolledTreeCtrl::OnSize)
- EVT_TREE_ITEM_EXPANDED(-1, wxRemotelyScrolledTreeCtrl::OnExpand)
- EVT_TREE_ITEM_COLLAPSED(-1, wxRemotelyScrolledTreeCtrl::OnExpand)
- EVT_SCROLLWIN(wxRemotelyScrolledTreeCtrl::OnScroll)
+ EVT_SIZE(wxRemotelyScrolledTreeCtrl::OnSize)
+ EVT_TREE_ITEM_EXPANDED(wxID_ANY, wxRemotelyScrolledTreeCtrl::OnExpand)
+ EVT_TREE_ITEM_COLLAPSED(wxID_ANY, wxRemotelyScrolledTreeCtrl::OnExpand)
+ EVT_SCROLLWIN(wxRemotelyScrolledTreeCtrl::OnScroll)
END_EVENT_TABLE()
wxRemotelyScrolledTreeCtrl::wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt,
const wxSize& sz, long style):
wxTreeCtrl(parent, id, pt, sz, style)
{
- m_companionWindow = NULL;
+ m_companionWindow = NULL;
}
wxRemotelyScrolledTreeCtrl::~wxRemotelyScrolledTreeCtrl()
#if defined(__WXMSW__) && USE_GENERIC_TREECTRL
if (!IsKindOf(CLASSINFO(wxGenericTreeCtrl)))
{
- ::ShowScrollBar((HWND) GetHWND(), SB_VERT, FALSE);
+ ::ShowScrollBar((HWND) GetHWND(), SB_VERT, false);
}
else
#endif
wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this;
win->wxGenericTreeCtrl::SetScrollbars(pixelsPerUnitX, 0, noUnitsX, 0, xPos, 0, noRefresh);
- wxScrolledWindow* scrolledWindow = GetScrolledWindow();
- if (scrolledWindow)
- {
+ wxScrolledWindow* scrolledWindow = GetScrolledWindow();
+ if (scrolledWindow)
+ {
scrolledWindow->SetScrollbars(0, pixelsPerUnitY, 0, noUnitsY, 0, yPos, noRefresh);
}
}
scrolledWindow->GetViewStart(& x2, & y2);
* y = y2;
}
- else
+ else
#endif
- {
- // x is wrong since the horizontal scrollbar is controlled by the
- // tree control, but we probably don't need it.
+ {
+ // x is wrong since the horizontal scrollbar is controlled by the
+ // tree control, but we probably don't need it.
scrolledWindow->GetViewStart(x, y);
- }
+ }
}
// In case we're using the generic tree control.
{
if (IsKindOf(CLASSINFO(wxGenericTreeCtrl)))
{
- wxScrolledWindow* scrolledWindow = GetScrolledWindow();
+ wxScrolledWindow* scrolledWindow = GetScrolledWindow();
wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this;
if (!IsKindOf(CLASSINFO(wxGenericTreeCtrl)))
#endif
{
- UINT sbCode = SB_THUMBPOSITION;
- HWND vertScrollBar = 0;
- MSWDefWindowProc((WXUINT) WM_VSCROLL, MAKELONG(sbCode, posVert), (WXLPARAM) vertScrollBar);
+ UINT sbCode = SB_THUMBPOSITION;
+ HWND vertScrollBar = 0;
+ MSWDefWindowProc((WXUINT) WM_VSCROLL, MAKELONG(sbCode, posVert), (WXLPARAM) vertScrollBar);
}
#if USE_GENERIC_TREECTRL
else
#if USE_GENERIC_TREECTRL || !defined(__WXMSW__)
{
wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this;
- win->Refresh();
- /* Doesn't work yet because scrolling is ignored by Scroll
+ win->Refresh();
+ /* Doesn't work yet because scrolling is ignored by Scroll
int xppu, yppu;
- wxScrolledWindow* scrolledWindow = GetScrolledWindow();
- if (scrolledWindow)
- {
- scrolledWindow->GetScrollPixelsPerUnit(& xppu, & yppu);
- win->Scroll(-1, posVert*yppu);
- }
- */
+ wxScrolledWindow* scrolledWindow = GetScrolledWindow();
+ if (scrolledWindow)
+ {
+ scrolledWindow->GetScrollPixelsPerUnit(& xppu, & yppu);
+ win->Scroll(-1, posVert*yppu);
+ }
+ */
}
#endif
}
void wxRemotelyScrolledTreeCtrl::OnSize(wxSizeEvent& event)
{
- HideVScrollbar();
- AdjustRemoteScrollbars();
- event.Skip();
+ HideVScrollbar();
+ AdjustRemoteScrollbars();
+ event.Skip();
}
void wxRemotelyScrolledTreeCtrl::OnExpand(wxTreeEvent& event)
{
- AdjustRemoteScrollbars();
- event.Skip();
+ AdjustRemoteScrollbars();
+ event.Skip();
// If we don't have this, we get some bits of lines still remaining
if (event.GetEventType() == wxEVT_COMMAND_TREE_ITEM_COLLAPSED)
Refresh();
- // Pass on the event
- if (m_companionWindow)
- m_companionWindow->GetEventHandler()->ProcessEvent(event);
+ // Pass on the event
+ if (m_companionWindow)
+ m_companionWindow->GetEventHandler()->ProcessEvent(event);
}
// Adjust the containing wxScrolledWindow's scrollbars appropriately
{
#if USE_GENERIC_TREECTRL || !defined(__WXMSW__)
if (IsKindOf(CLASSINFO(wxGenericTreeCtrl)))
- {
- // This is for the generic tree control.
- // It calls SetScrollbars which has been overridden
- // to adjust the parent scrolled window vertical
- // scrollbar.
- ((wxGenericTreeCtrl*) this)->AdjustMyScrollbars();
+ {
+ // This is for the generic tree control.
+ // It calls SetScrollbars which has been overridden
+ // to adjust the parent scrolled window vertical
+ // scrollbar.
+ ((wxGenericTreeCtrl*) this)->AdjustMyScrollbars();
return;
- }
- else
+ }
+ else
#endif
- {
- // This is for the wxMSW tree control
- wxScrolledWindow* scrolledWindow = GetScrolledWindow();
- if (scrolledWindow)
- {
- wxRect itemRect;
- if (GetBoundingRect(GetRootItem(), itemRect))
- {
+ {
+ // This is for the wxMSW tree control
+ wxScrolledWindow* scrolledWindow = GetScrolledWindow();
+ if (scrolledWindow)
+ {
+ wxRect itemRect;
+ if (GetBoundingRect(GetRootItem(), itemRect))
+ {
// Actually, the real height seems to be 1 less than reported
// (e.g. 16 instead of 16)
int itemHeight = itemRect.GetHeight() - 1;
-
- int w, h;
- GetClientSize(&w, &h);
-
- wxRect rect(0, 0, 0, 0);
- CalcTreeSize(rect);
+
+ int w, h;
+ GetClientSize(&w, &h);
+
+ wxRect rect(0, 0, 0, 0);
+ CalcTreeSize(rect);
double f = ((double) (rect.GetHeight()) / (double) itemHeight) ;
int treeViewHeight = (int) ceil(f);
-
- int scrollPixelsPerLine = itemHeight;
- int scrollPos = - (itemRect.y / itemHeight);
-
- scrolledWindow->SetScrollbars(0, scrollPixelsPerLine, 0, treeViewHeight, 0, scrollPos);
-
- // Ensure that when a scrollbar becomes hidden or visible,
- // the contained window sizes are right.
- // Problem: this is called too early (?)
- wxSizeEvent event(scrolledWindow->GetSize(), scrolledWindow->GetId());
- scrolledWindow->GetEventHandler()->ProcessEvent(event);
- }
- }
- }
+
+ int scrollPixelsPerLine = itemHeight;
+ int scrollPos = - (itemRect.y / itemHeight);
+
+ scrolledWindow->SetScrollbars(0, scrollPixelsPerLine, 0, treeViewHeight, 0, scrollPos);
+
+ // Ensure that when a scrollbar becomes hidden or visible,
+ // the contained window sizes are right.
+ // Problem: this is called too early (?)
+ wxSizeEvent event(scrolledWindow->GetSize(), scrolledWindow->GetId());
+ scrolledWindow->GetEventHandler()->ProcessEvent(event);
+ }
+ }
+ }
}
int bottom1 = rect1.GetBottom();
int right2 = rect2.GetRight();
int bottom2 = rect2.GetBottom();
-
+
wxPoint topLeft = wxPoint(wxMin(rect1.x, rect2.x), wxMin(rect1.y, rect2.y));
wxPoint bottomRight = wxPoint(wxMax(right1, right2), wxMax(bottom1, bottom2));
-
+
rect.x = topLeft.x; rect.y = topLeft.y;
rect.SetRight(bottomRight.x);
rect.SetBottom(bottomRight.y);
// correctly
void wxRemotelyScrolledTreeCtrl::CalcTreeSize(wxRect& rect)
{
- CalcTreeSize(GetRootItem(), rect);
+ CalcTreeSize(GetRootItem(), rect);
}
void wxRemotelyScrolledTreeCtrl::CalcTreeSize(const wxTreeItemId& id, wxRect& rect)
{
- // 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
- // or the top of the window? How would we convert?
- wxRect itemSize;
- if (GetBoundingRect(id, itemSize))
- {
- rect = CombineRectangles(rect, itemSize);
- }
-
- void* cookie;
- wxTreeItemId childId = GetFirstChild(id, cookie);
- while (childId)
- {
- CalcTreeSize(childId, rect);
- childId = GetNextChild(childId, cookie);
- }
+ // 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
+ // or the top of the window? How would we convert?
+ wxRect itemSize;
+ if (GetBoundingRect(id, itemSize))
+ {
+ rect = CombineRectangles(rect, itemSize);
+ }
+
+ void* cookie;
+ wxTreeItemId childId = GetFirstChild(id, cookie);
+ while (childId)
+ {
+ CalcTreeSize(childId, rect);
+ childId = GetNextChild(childId, cookie);
+ }
}
// Find the scrolled window that contains this control
wxScrolledWindow* wxRemotelyScrolledTreeCtrl::GetScrolledWindow() const
{
- wxWindow* parent = wxWindow::GetParent();
- while (parent)
- {
- if (parent->IsKindOf(CLASSINFO(wxScrolledWindow)))
- return (wxScrolledWindow*) parent;
- parent = parent->GetParent();
- }
- return NULL;
+ wxWindow* parent = wxWindow::GetParent();
+ while (parent)
+ {
+ if (parent->IsKindOf(CLASSINFO(wxScrolledWindow)))
+ return (wxScrolledWindow*) parent;
+ parent = parent->GetParent();
+ }
+ return NULL;
}
void wxRemotelyScrolledTreeCtrl::OnScroll(wxScrollWinEvent& event)
IMPLEMENT_CLASS(wxTreeCompanionWindow, wxWindow)
BEGIN_EVENT_TABLE(wxTreeCompanionWindow, wxWindow)
- EVT_PAINT(wxTreeCompanionWindow::OnPaint)
- EVT_SCROLLWIN(wxTreeCompanionWindow::OnScroll)
- EVT_TREE_ITEM_EXPANDED(-1, wxTreeCompanionWindow::OnExpand)
- EVT_TREE_ITEM_COLLAPSED(-1, wxTreeCompanionWindow::OnExpand)
+ EVT_PAINT(wxTreeCompanionWindow::OnPaint)
+ EVT_SCROLLWIN(wxTreeCompanionWindow::OnScroll)
+ EVT_TREE_ITEM_EXPANDED(wxID_ANY, wxTreeCompanionWindow::OnExpand)
+ EVT_TREE_ITEM_COLLAPSED(wxID_ANY, wxTreeCompanionWindow::OnExpand)
END_EVENT_TABLE()
wxTreeCompanionWindow::wxTreeCompanionWindow(wxWindow* parent, wxWindowID id,
const wxPoint& pos,
const wxSize& sz,
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)
{
- // TEST CODE
+ // TEST CODE
#if 1
- if (m_treeCtrl)
- {
- wxString text = m_treeCtrl->GetItemText(id);
- dc.SetTextForeground(* wxBLACK);
- dc.SetBackgroundMode(wxTRANSPARENT);
+ if (m_treeCtrl)
+ {
+ wxString text = m_treeCtrl->GetItemText(id);
+ dc.SetTextForeground(* wxBLACK);
+ dc.SetBackgroundMode(wxTRANSPARENT);
- int textW, textH;
- dc.GetTextExtent(text, & textW, & textH);
+ int textW, textH;
+ dc.GetTextExtent(text, & textW, & textH);
- int x = 5;
- int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2);
+ int x = 5;
+ int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2);
- dc.DrawText(text, x, y);
- }
+ dc.DrawText(text, x, y);
+ }
#endif
}
void wxTreeCompanionWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
{
- wxPaintDC dc(this);
+ wxPaintDC dc(this);
if (!m_treeCtrl)
return;
- wxPen pen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID);
- dc.SetPen(pen);
- dc.SetBrush(* wxTRANSPARENT_BRUSH);
- wxFont font(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
- dc.SetFont(font);
+ wxPen pen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID);
+ dc.SetPen(pen);
+ dc.SetBrush(* wxTRANSPARENT_BRUSH);
+ wxFont font(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
+ dc.SetFont(font);
wxSize clientSize = GetClientSize();
- wxRect itemRect;
- wxTreeItemId h, lastH;
- for(h=m_treeCtrl->GetFirstVisibleItem();h;h=m_treeCtrl->GetNextVisible(h))
- {
- if (m_treeCtrl->GetBoundingRect(h, itemRect))
- {
- int cy = itemRect.GetTop();
- wxRect drawItemRect(0, cy, clientSize.x, itemRect.GetHeight());
-
- lastH = h;
-
- // Draw the actual item
- DrawItem(dc, h, drawItemRect);
- dc.DrawLine(0, cy, clientSize.x, cy);
- }
- }
- if (lastH.IsOk() && m_treeCtrl->GetBoundingRect(lastH, itemRect))
- {
- int cy = itemRect.GetBottom();
- dc.DrawLine(0, cy, clientSize.x, cy);
- }
+ wxRect itemRect;
+ wxTreeItemId h, lastH;
+ for(h=m_treeCtrl->GetFirstVisibleItem();h;h=m_treeCtrl->GetNextVisible(h))
+ {
+ if (m_treeCtrl->GetBoundingRect(h, itemRect))
+ {
+ int cy = itemRect.GetTop();
+ wxRect drawItemRect(0, cy, clientSize.x, itemRect.GetHeight());
+
+ lastH = h;
+
+ // Draw the actual item
+ DrawItem(dc, h, drawItemRect);
+ dc.DrawLine(0, cy, clientSize.x, cy);
+ }
+ }
+ if (lastH.IsOk() && m_treeCtrl->GetBoundingRect(lastH, itemRect))
+ {
+ int cy = itemRect.GetBottom();
+ dc.DrawLine(0, cy, clientSize.x, cy);
+ }
}
void wxTreeCompanionWindow::OnScroll(wxScrollWinEvent& event)
if (!m_treeCtrl)
return;
- // TODO: scroll the window physically instead of just refreshing.
- Refresh(TRUE);
+ // TODO: scroll the window physically instead of just refreshing.
+ Refresh(true);
}
void wxTreeCompanionWindow::OnExpand(wxTreeEvent& WXUNUSED(event))
{
- // TODO: something more optimized than simply refresh the whole
- // window when the tree is expanded/collapsed. Tricky.
- Refresh();
+ // TODO: something more optimized than simply refresh the whole
+ // window when the tree is expanded/collapsed. Tricky.
+ Refresh();
}
/*
IMPLEMENT_CLASS(wxThinSplitterWindow, wxSplitterWindow)
BEGIN_EVENT_TABLE(wxThinSplitterWindow, wxSplitterWindow)
- EVT_SIZE(wxThinSplitterWindow::OnSize)
+ EVT_SIZE(wxThinSplitterWindow::OnSize)
END_EVENT_TABLE()
wxThinSplitterWindow::wxThinSplitterWindow(wxWindow* parent, wxWindowID id,
void wxThinSplitterWindow::SizeWindows()
{
- // The client size may have changed inbetween
- // the sizing of the first window and the sizing of
- // the second. So repeat SizeWindows.
+ // The client size may have changed inbetween
+ // the sizing of the first window and the sizing of
+ // the second. So repeat SizeWindows.
wxSplitterWindow::SizeWindows();
wxSplitterWindow::SizeWindows();
}
// Tests for x, y over sash
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)
int w, h;
GetClientSize(&w, &h);
- if ( m_splitMode == wxSPLIT_VERTICAL )
- {
- dc.SetPen(* m_facePen);
- dc.SetBrush(* m_faceBrush);
- int h1 = h-1;
- int y1 = 0;
- if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER && (GetWindowStyleFlag() & wxSP_3DBORDER) != wxSP_3DBORDER )
- h1 += 1; // Not sure why this is necessary...
- if ( (GetWindowStyleFlag() & wxSP_3DBORDER) == wxSP_3DBORDER)
- {
- y1 = 2; h1 -= 3;
- }
- dc.DrawRectangle(GetSashPosition(), y1, GetSashSize(), h1);
- }
- else
- {
- dc.SetPen(* m_facePen);
- dc.SetBrush(* m_faceBrush);
- int w1 = w-1;
- int x1 = 0;
- if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER && (GetWindowStyleFlag() & wxSP_3DBORDER) != wxSP_3DBORDER )
- w1 ++;
- if ( (GetWindowStyleFlag() & wxSP_3DBORDER) == wxSP_3DBORDER)
- {
- x1 = 2; w1 -= 3;
- }
- dc.DrawRectangle(x1, GetSashPosition(), w1, GetSashSize());
- }
-
+ if ( m_splitMode == wxSPLIT_VERTICAL )
+ {
+ dc.SetPen(* m_facePen);
+ dc.SetBrush(* m_faceBrush);
+ int h1 = h-1;
+ int y1 = 0;
+ if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER && (GetWindowStyleFlag() & wxSP_3DBORDER) != wxSP_3DBORDER )
+ h1 += 1; // Not sure why this is necessary...
+ if ( (GetWindowStyleFlag() & wxSP_3DBORDER) == wxSP_3DBORDER)
+ {
+ y1 = 2; h1 -= 3;
+ }
+ dc.DrawRectangle(GetSashPosition(), y1, GetSashSize(), h1);
+ }
+ else
+ {
+ dc.SetPen(* m_facePen);
+ dc.SetBrush(* m_faceBrush);
+ int w1 = w-1;
+ int x1 = 0;
+ if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER && (GetWindowStyleFlag() & wxSP_3DBORDER) != wxSP_3DBORDER )
+ w1 ++;
+ if ( (GetWindowStyleFlag() & wxSP_3DBORDER) == wxSP_3DBORDER)
+ {
+ x1 = 2; w1 -= 3;
+ }
+ dc.DrawRectangle(x1, GetSashPosition(), w1, GetSashSize());
+ }
+
dc.SetPen(wxNullPen);
dc.SetBrush(wxNullBrush);
}
void wxThinSplitterWindow::OnSize(wxSizeEvent& event)
{
- wxSplitterWindow::OnSize(event);
+ wxSplitterWindow::OnSize(event);
}
/*
IMPLEMENT_CLASS(wxSplitterScrolledWindow, wxScrolledWindow)
BEGIN_EVENT_TABLE(wxSplitterScrolledWindow, wxScrolledWindow)
- EVT_SCROLLWIN(wxSplitterScrolledWindow::OnScroll)
- EVT_SIZE(wxSplitterScrolledWindow::OnSize)
+ EVT_SCROLLWIN(wxSplitterScrolledWindow::OnScroll)
+ EVT_SIZE(wxSplitterScrolledWindow::OnSize)
END_EVENT_TABLE()
wxSplitterScrolledWindow::wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id,
void wxSplitterScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event))
{
- wxSize sz = GetClientSize();
- if (GetChildren().GetFirst())
- {
- ((wxWindow*) GetChildren().GetFirst()->GetData())->SetSize(0, 0, sz.x, sz.y);
- }
+ wxSize sz = GetClientSize();
+ if (GetChildren().GetFirst())
+ {
+ ((wxWindow*) GetChildren().GetFirst()->GetData())->SetSize(0, 0, sz.x, sz.y);
+ }
}
void wxSplitterScrolledWindow::OnScroll(wxScrollWinEvent& event)
{
// Ensure that events being propagated back up the window hierarchy
// don't cause an infinite loop
- static bool inOnScroll = FALSE;
+ static bool inOnScroll = false;
if (inOnScroll)
{
event.Skip();
return;
}
- inOnScroll = TRUE;
-
+ inOnScroll = true;
+
int orient = event.GetOrientation();
int nScrollInc = CalcScrollInc(event);
if (nScrollInc == 0)
{
- inOnScroll = FALSE;
+ inOnScroll = false;
return;
}
if (orient == wxHORIZONTAL)
{
- inOnScroll = FALSE;
+ inOnScroll = false;
event.Skip();
return;
#if 0
int newPos = m_xScrollPosition + nScrollInc;
- SetScrollPos(wxHORIZONTAL, newPos, TRUE );
+ SetScrollPos(wxHORIZONTAL, newPos, true );
#endif
}
else
{
int newPos = m_yScrollPosition + nScrollInc;
- SetScrollPos(wxVERTICAL, newPos, TRUE );
+ SetScrollPos(wxVERTICAL, newPos, true );
}
if (orient == wxHORIZONTAL)
m_targetWindow->MacUpdateImmediately() ;
#endif
- inOnScroll = FALSE;
+ inOnScroll = false;
}
#define _WX_SPLITTREE_H_
#if defined(__GNUG__) && !defined(__APPLE__)
- #pragma interface "splittree.h"
+ #pragma interface "splittree.h"
#endif
// Set this to 1 to use generic tree control (doesn't yet work properly)
class wxRemotelyScrolledTreeCtrl: public wxTreeCtrl
{
- DECLARE_CLASS(wxRemotelyScrolledTreeCtrl)
+ DECLARE_CLASS(wxRemotelyScrolledTreeCtrl)
public:
wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition,
const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS);
- ~wxRemotelyScrolledTreeCtrl();
+ ~wxRemotelyScrolledTreeCtrl();
//// Events
- void OnSize(wxSizeEvent& event);
- void OnExpand(wxTreeEvent& event);
+ void OnSize(wxSizeEvent& event);
+ void OnExpand(wxTreeEvent& event);
void OnScroll(wxScrollWinEvent& event);
//// Overrides
virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
int noUnitsX, int noUnitsY,
int xPos = 0, int yPos = 0,
- bool noRefresh = FALSE );
+ bool noRefresh = false );
// In case we're using the generic tree control.
// Get the view start
virtual int GetScrollPos(int orient) const;
//// Helpers
- void HideVScrollbar();
+ void HideVScrollbar();
- // Calculate the tree overall size so we can set the scrollbar
- // correctly
- void CalcTreeSize(wxRect& rect);
- void CalcTreeSize(const wxTreeItemId& id, wxRect& rect);
+ // Calculate the tree overall size so we can set the scrollbar
+ // correctly
+ void CalcTreeSize(wxRect& rect);
+ void CalcTreeSize(const wxTreeItemId& id, wxRect& rect);
- // Adjust the containing wxScrolledWindow's scrollbars appropriately
- void AdjustRemoteScrollbars();
+ // Adjust the containing wxScrolledWindow's scrollbars appropriately
+ void AdjustRemoteScrollbars();
- // Find the scrolled window that contains this control
- wxScrolledWindow* GetScrolledWindow() const;
+ // Find the scrolled window that contains this control
+ wxScrolledWindow* GetScrolledWindow() const;
// Scroll to the given line (in scroll units where each unit is
// the height of an item)
//// Accessors
- // The companion window is one which will get notified when certain
- // events happen such as node expansion
- void SetCompanionWindow(wxWindow* companion) { m_companionWindow = companion; }
- wxWindow* GetCompanionWindow() const { return m_companionWindow; }
+ // The companion window is one which will get notified when certain
+ // events happen such as node expansion
+ void SetCompanionWindow(wxWindow* companion) { m_companionWindow = companion; }
+ wxWindow* GetCompanionWindow() const { return m_companionWindow; }
DECLARE_EVENT_TABLE()
protected:
- wxWindow* m_companionWindow;
+ wxWindow* m_companionWindow;
};
/*
public:
DECLARE_CLASS(wxTreeCompanionWindow)
- wxTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
+ wxTreeCompanionWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize,
long style = 0);
//// Overrides
- virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect);
+ virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect);
//// Events
- void OnPaint(wxPaintEvent& event);
+ void OnPaint(wxPaintEvent& event);
void OnScroll(wxScrollWinEvent& event);
- void OnExpand(wxTreeEvent& event);
+ void OnExpand(wxTreeEvent& event);
//// Operations
//// Accessors
- wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const { return m_treeCtrl; };
- void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl) { m_treeCtrl = treeCtrl; }
+ wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const { return m_treeCtrl; };
+ void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl) { m_treeCtrl = treeCtrl; }
//// Data members
protected:
- wxRemotelyScrolledTreeCtrl* m_treeCtrl;
+ wxRemotelyScrolledTreeCtrl* m_treeCtrl;
DECLARE_EVENT_TABLE()
};
public:
DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow)
- wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
+ wxThinSplitterWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize,
long style = wxSP_3D | wxCLIP_CHILDREN);
// Tests for x, y over sash. Overriding this allows us to increase
// the tolerance.
bool SashHitTest(int x, int y, int tolerance = 2);
- void DrawSash(wxDC& dc);
+ void DrawSash(wxDC& dc);
//// Events
-
+
void OnSize(wxSizeEvent& event);
//// Operations
public:
DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow)
- wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
+ wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize,
long style = 0);
//// Overrides
//// Events
-
+
void OnScroll(wxScrollWinEvent& event);
void OnSize(wxSizeEvent& event);
class XmlTreeData : public wxTreeItemData
{
public:
- XmlTreeData(wxXmlNode *n) : Node(n) {}
+ XmlTreeData(wxXmlNode *n) : Node(n) {}
wxXmlNode *Node;
};
if (param.IsEmpty()) return parent;
wxXmlNode *n = parent->GetChildren();
-
+
while (n)
{
if (n->GetType() == wxXML_ELEMENT_NODE && n->GetName() == param)
nm = tkn.GetNextToken();
n = XmlFindNodeSimple(parent, nm);
if (n) continue;
-
+
// n == NULL:
n = new wxXmlNode(wxXML_ELEMENT_NODE, nm);
- parent->AddChild(n);
+ parent->AddChild(n);
}
n->AddChild(new wxXmlNode(wxXML_TEXT_NODE, wxEmptyString));
-
+
return n;
}
wxXmlNode *n = XmlFindNode(parent, name);
if (n == NULL)
n = XmlCreateNode(parent, name);
-
+
n = n->GetChildren();
-
+
while (n)
{
- if (n->GetType() == wxXML_TEXT_NODE ||
+ if (n->GetType() == wxXML_TEXT_NODE ||
n->GetType() == wxXML_CDATA_SECTION_NODE)
{
n->SetContent(value);
wxXmlNode *n = XmlFindNode(parent, name);
if (n == NULL) return wxEmptyString;
n = n->GetChildren();
-
+
while (n)
{
- if (n->GetType() == wxXML_TEXT_NODE ||
+ if (n->GetType() == wxXML_TEXT_NODE ||
n->GetType() == wxXML_CDATA_SECTION_NODE)
return n->GetContent();
n = n->GetNext();
wxString XmlGetClass(wxXmlNode *parent);
void XmlSetClass(wxXmlNode *parent, const wxString& classname);
-#endif
+#endif
class WXDLLIMPEXP_XRC wxGaugeXmlHandler : public wxXmlResourceHandler
{
- DECLARE_DYNAMIC_CLASS(wxGaugeXmlHandler)
+ DECLARE_DYNAMIC_CLASS(wxGaugeXmlHandler)
enum
{
wxGAUGE_DEFAULT_RANGE = 100
class WXDLLIMPEXP_XRC wxMenuBarXmlHandler : public wxXmlResourceHandler
{
- DECLARE_DYNAMIC_CLASS(wxMenuBarXmlHandler)
+ DECLARE_DYNAMIC_CLASS(wxMenuBarXmlHandler)
public:
wxMenuBarXmlHandler();
virtual wxObject *DoCreateResource();
class WXDLLIMPEXP_XRC wxScrollBarXmlHandler : public wxXmlResourceHandler
{
- DECLARE_DYNAMIC_CLASS(wxScrollBarXmlHandler)
+ DECLARE_DYNAMIC_CLASS(wxScrollBarXmlHandler)
enum
{
wxSL_DEFAULT_VALUE = 0,
private:
bool m_isInside;
bool m_isGBS;
-
+
wxSizer *m_parentSizer;
bool IsSizerNode(wxXmlNode *node);
wxGBSpan GetGBSpan(const wxString& param);
wxSizerItem* MakeSizerItem();
void SetSizerItemAttributes(wxSizerItem* sitem);
- void AddSizerItem(wxSizerItem* sitem);
+ void AddSizerItem(wxSizerItem* sitem);
};
class WXDLLIMPEXP_XRC wxSliderXmlHandler : public wxXmlResourceHandler
{
- DECLARE_DYNAMIC_CLASS(wxSliderXmlHandler)
+ DECLARE_DYNAMIC_CLASS(wxSliderXmlHandler)
enum
{
wxSL_DEFAULT_VALUE = 0,
#if wxUSE_SPINBTN
class WXDLLIMPEXP_XRC wxSpinButtonXmlHandler : public wxXmlResourceHandler
{
- DECLARE_DYNAMIC_CLASS(wxSpinButtonXmlHandler)
+ DECLARE_DYNAMIC_CLASS(wxSpinButtonXmlHandler)
enum
{
wxSP_DEFAULT_VALUE = 0,
#if wxUSE_SPINCTRL
class WXDLLIMPEXP_XRC wxSpinCtrlXmlHandler : public wxXmlResourceHandler
{
- DECLARE_DYNAMIC_CLASS(wxSpinCtrlXmlHandler)
+ DECLARE_DYNAMIC_CLASS(wxSpinCtrlXmlHandler)
enum
{
wxSP_DEFAULT_VALUE = 0,
bool UpdateResources();
// 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.
wxXmlNode *DoFindResource(wxXmlNode *parent, const wxString& name, const wxString& classname, bool recursive);
// were filled.
virtual wxObject *DoCreateResource() = 0;
- // Returns TRUE if it understands this node and can create
- // a resource from it, FALSE otherwise.
+ // Returns true if it understands this node and can create
+ // a resource from it, false otherwise.
virtual bool CanHandle(wxXmlNode *node) = 0;
// Sets the parent resource.
// - replaces \n, \r, \t by respective chars (according to C syntax)
// - replaces _ by & and __ by _ (needed for _File => &File because of XML)
// - 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.
int GetID();
// Returns the resource name.
wxString GetName();
- // Gets a bool flag (1, t, yes, on, true are TRUE, everything else is FALSE).
- bool GetBool(const wxString& param, bool defaultv = FALSE);
+ // Gets a bool flag (1, t, yes, on, true are true, everything else is false).
+ bool GetBool(const wxString& param, bool defaultv = false);
// Gets the integer value from the parameter.
long GetLong( const wxString& param, long defaultv = 0 );
void SetupWindow(wxWindow *wnd);
// Creates children.
- void CreateChildren(wxObject *parent, bool this_hnd_only = FALSE);
+ void CreateChildren(wxObject *parent, bool this_hnd_only = false);
// Helper function.
void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL);
// 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
-// 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.
enum {
- PU_ADD_RECORD = wxID_HIGHEST + 1,
+ PU_ADD_RECORD = wxID_HIGHEST + 1,
PU_EDIT_RECORD,
- PU_DELETE_RECORD
+ PU_DELETE_RECORD
};
// 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.
enum {
RECORD_COLUMN = 0,
// Event table: connect the events to the handler functions to process them
//-----------------------------------------------------------------------------
-BEGIN_EVENT_TABLE( MyResizableListCtrl, wxListCtrl )
- // Something to do when right mouse down
- EVT_RIGHT_DOWN( MyResizableListCtrl::ContextSensitiveMenu )
+BEGIN_EVENT_TABLE( MyResizableListCtrl, wxListCtrl )
+ // Something to do when right mouse down
+ EVT_RIGHT_DOWN( MyResizableListCtrl::ContextSensitiveMenu )
// Something to do when resized
EVT_SIZE( MyResizableListCtrl::OnSize )
END_EVENT_TABLE()
const wxString& name )
: wxListCtrl( parent, id, pos, size, style, validator, name )
{
-
- // 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
- // "unknown" XRC placeholder. This induces an OnSize() event, calling the
- // overrriden OnSize function for this class, which needs to have 3
+
+ // 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
+ // "unknown" XRC placeholder. This induces an OnSize() event, calling the
+ // overrriden OnSize function for this class, which needs to have 3
// columns to resize (else an assert on WXGTK debug build).
InsertColumn( RECORD_COLUMN, _("Record"), wxLIST_FORMAT_LEFT, 140);
InsertColumn( ACTION_COLUMN, _("Action"), wxLIST_FORMAT_LEFT, 70);
- InsertColumn( PRIORITY_COLUMN, _("Priority"), wxLIST_FORMAT_LEFT, 70 );
+ InsertColumn( PRIORITY_COLUMN, _("Priority"), wxLIST_FORMAT_LEFT, 70 );
}
a_menu.Append( PU_ADD_RECORD, _( "Add a new record...") );
a_menu.Append( PU_EDIT_RECORD, _( "Edit 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
if ( GetSelectedItemCount() == 0 ) {
- a_menu.Enable( PU_EDIT_RECORD, FALSE );
- a_menu.Enable( PU_DELETE_RECORD, FALSE );
+ a_menu.Enable( PU_EDIT_RECORD, false );
+ a_menu.Enable( PU_DELETE_RECORD, false );
}
- // Show the popup menu (wxWindow::PopupMenu ), at the x,y position
- // of the click event
+ // Show the popup menu (wxWindow::PopupMenu ), at the x,y position
+ // of the click event
PopupMenu( &a_menu, event.GetPosition() );
}
{
// Call our custom width setting function.
SetColumnWidths();
- // REQURED event.Skip() call to allow this event to propagate
- // upwards so others can do what they need to do in response to
+ // REQURED event.Skip() call to allow this event to propagate
+ // upwards so others can do what they need to do in response to
// this size event.
event.Skip();
}
void MyResizableListCtrl::SetColumnWidths()
-{
+{
// Get width of entire listctrl
- int leftmostColumnWidth = GetSize().x;
-
- // Subtract width of other columns, scrollbar, and some padding
+ int leftmostColumnWidth = GetSize().x;
+
+ // Subtract width of other columns, scrollbar, and some padding
leftmostColumnWidth -= GetColumnWidth( ACTION_COLUMN );
leftmostColumnWidth -= GetColumnWidth( PRIORITY_COLUMN );
- leftmostColumnWidth -= wxSystemSettings::GetSystemMetric( wxSYS_VSCROLL_X );
+ leftmostColumnWidth -= wxSystemSettings::GetSystemMetric( wxSYS_VSCROLL_X );
leftmostColumnWidth -= 5;
-
+
// Set the column width to the new value.
- SetColumnWidth( RECORD_COLUMN, leftmostColumnWidth );
-
- // This is just a debug message in case you want to watch the
+ SetColumnWidth( RECORD_COLUMN, leftmostColumnWidth );
+
+ // This is just a debug message in case you want to watch the
// events scroll by as you resize.
wxLogDebug( wxT("Successfully set column widths") );
}
// 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,
// 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
// MyResizableListCtrl(){} constructor in addition to your regular one.
DECLARE_DYNAMIC_CLASS( MyResizableListCtrl )
public:
- // Constructor.
+ // Constructor.
/*
These parameters are the same as a wxWidgets constructor.
\param parent The parent window.
column.
*/
MyResizableListCtrl( wxWindow *parent = NULL,
- wxWindowID id = -1,
+ wxWindowID id = wxID_ANY,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = wxLC_REPORT,
const wxValidator& validator = wxDefaultValidator,
const wxString &name = wxT("myResizableListCtrl")
- );
+ );
// 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.
void OnSize( wxSizeEvent &event );
-
+
// A custom function. What is called in the constructor, and in an OnSize()
- void SetColumnWidths();
-
+ void SetColumnWidths();
+
private:
// wxWidgets macro, required to be able to use Event tables in the .cpp file.
DECLARE_EVENT_TABLE()
-
+
};
//----------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------
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 )
// Note that the ID here isn't a XRCID, it is one of the standard wx ID's.
EVT_BUTTON( wxID_OK, PreferencesDialog::OnOK )
//-----------------------------------------------------------------------------
// Constructor (Notice how small and easy it is)
PreferencesDialog::PreferencesDialog(wxWindow* parent)
-{
+{
wxXmlResource::Get()->LoadDialog(this, parent, wxT("derived_dialog"));
}
void PreferencesDialog::OnMyButtonClicked( wxCommandEvent &WXUNUSED(event) )
{
// Construct a message dialog.
- wxMessageDialog msgDlg(this, _("You clicked on My Button"));
-
+ wxMessageDialog msgDlg(this, _("You clicked on My Button"));
+
// Show it modally.
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
void PreferencesDialog::OuUpdateUIMyCheckbox( wxUpdateUIEvent &WXUNUSED(event) )
{
// Get a boolean value of whether the checkbox is checked
- bool myCheckBoxIsChecked;
+ bool myCheckBoxIsChecked;
// You could just write:
// myCheckBoxIsChecked = event.IsChecked();
- // since the event that was passed into this function already has the
- // is a pointer to the right control. However,
+ // since the event that was passed into this function already has the
+ // is a pointer to the right control. However,
// this is the XRCCTRL way (which is more obvious as to what is going on).
myCheckBoxIsChecked = XRCCTRL(*this, "my_checkbox", wxCheckBox)->IsChecked();
- // Now call either Enable(TRUE) or Enable(FALSE) on the textctrl, depending
- // on the value of that boolean.
- XRCCTRL(*this, "my_textctrl", wxTextCtrl)->Enable(myCheckBoxIsChecked);
+ // Now call either Enable(true) or Enable(false) on the textctrl, depending
+ // on the value of that boolean.
+ XRCCTRL(*this, "my_textctrl", wxTextCtrl)->Enable(myCheckBoxIsChecked);
}
wxMessageDialog msgDlg2(this, _("Press OK to close Derived dialog, or Cancel to abort"),
_("Overriding base class OK button handler"),
wxOK | wxCANCEL | wxCENTER );
-
+
// Show the message dialog, and if it returns wxID_OK (ie they clicked on OK button)...
if (msgDlg2.ShowModal() == wxID_OK)
{
- // ...then end this Preferences dialog.
+ // ...then end this Preferences dialog.
EndModal( wxID_OK );
// 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
- // 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.
}
class PreferencesDialog : public wxDialog
{
-public:
-
+public:
+
// Constructor.
/*
\param parent The parent window. Simple constructor.
- */
+ */
PreferencesDialog( wxWindow* parent );
-
- // Destructor.
+
+ // Destructor.
~PreferencesDialog();
private:
-
+
// Stuff to do when "My Button" gets clicked
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)
void OuUpdateUIMyCheckbox( wxUpdateUIEvent &event );
-
+
// Override base class functions of a wxDialog.
void OnOK( wxCommandEvent &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
// 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
-// 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
+// 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
// when starting out with wxWidgets.
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(XRCID("exit_tool_or_menuitem"), MyFrame::OnExitToolOrMenuCommand)
- EVT_MENU(XRCID("non_derived_dialog_tool_or_menuitem"), MyFrame::OnNonDerivedDialogToolOrMenuCommand)
- EVT_MENU(XRCID("derived_tool_or_menuitem"), MyFrame::OnDerivedDialogToolOrMenuCommand)
- EVT_MENU(XRCID("controls_tool_or_menuitem"), MyFrame::OnControlsToolOrMenuCommand)
- EVT_MENU(XRCID("uncentered_tool_or_menuitem"), MyFrame::OnUncenteredToolOrMenuCommand)
- EVT_MENU(XRCID("custom_class_tool_or_menuitem"), MyFrame::OnCustomClassToolOrMenuCommand)
+ EVT_MENU(XRCID("non_derived_dialog_tool_or_menuitem"), MyFrame::OnNonDerivedDialogToolOrMenuCommand)
+ EVT_MENU(XRCID("derived_tool_or_menuitem"), MyFrame::OnDerivedDialogToolOrMenuCommand)
+ EVT_MENU(XRCID("controls_tool_or_menuitem"), MyFrame::OnControlsToolOrMenuCommand)
+ EVT_MENU(XRCID("uncentered_tool_or_menuitem"), MyFrame::OnUncenteredToolOrMenuCommand)
+ EVT_MENU(XRCID("custom_class_tool_or_menuitem"), MyFrame::OnCustomClassToolOrMenuCommand)
EVT_MENU(XRCID("platform_property_tool_or_menuitem"), MyFrame::OnPlatformPropertyToolOrMenuCommand)
EVT_MENU(XRCID("art_provider_tool_or_menuitem"), MyFrame::OnArtProviderToolOrMenuCommand)
EVT_MENU(XRCID("variable_expansion_tool_or_menuitem"), MyFrame::OnVariableExpansionToolOrMenuCommand)
MyFrame::MyFrame(wxWindow* parent)
{
// Load up this frame from XRC. [Note, instead of making a class's
- // constructor take a wxWindow* parent with a default value of NULL,
- // we could have just had designed MyFrame class with an empty
+ // constructor take a wxWindow* parent with a default value of NULL,
+ // we could have just had designed MyFrame class with an empty
// constructor and then written here:
// wxXmlResource::Get()->LoadFrame(this, (wxWindow* )NULL, "main_frame");
- // since this frame will always be the top window, and thus parentless.
- // However, the current approach has source code that can be recycled
+ // since this frame will always be the top window, and thus parentless.
+ // However, the current approach has source code that can be recycled
// for other frames that aren't the top level window.]
wxXmlResource::Get()->LoadFrame(this, parent, wxT("main_frame"));
// With toolbars, you currently can't create one, and set it later. It
// needs to be all in one step.
SetToolBar(wxXmlResource::Get()->LoadToolBar(this, wxT("main_toolbar")));
-
- // Give the frame a optional statusbar. The '1' just means one field.
- // A gripsizer will automatically get put on into the corner, if that
+
+ // Give the frame a optional statusbar. The '1' just means one field.
+ // A gripsizer will automatically get put on into the corner, if that
// is the normal OS behaviour for frames on that platform. Helptext
// for menu items and toolbar tools will automatically get displayed
// here.
void MyFrame::OnExitToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{
- // TRUE is to force the frame to close.
- Close(TRUE);
+ // true is to force the frame to close.
+ Close(true);
}
}
-void MyFrame::OnDerivedDialogToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
+void MyFrame::OnDerivedDialogToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{
// 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.
PreferencesDialog preferencesDialog(this);
// Show the instance of the dialog, modally.
}
-void MyFrame::OnControlsToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
+void MyFrame::OnControlsToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{
wxDialog dlg;
wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("controls_dialog"));
#if wxUSE_LISTCTRL
// 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.
// "controls_treectrl" is the name of this control in the XRC.
// (1) Insert a column, with the column header of "Name"
// (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"),
wxLIST_FORMAT_LEFT,
( 200 )
XRCCTRL(dlg, "controls_listctrl", wxListCtrl)->InsertItem(2,wxT("Leon Li"));
#endif
-#if wxUSE_TREECTRL
+#if wxUSE_TREECTRL
// There is no data in the tree ctrl. These lines will add some.
- // (1) Instead of having to write out
- // XRCCTRL(dlg, "controls_treectrl", wxTreeCtrl)->SomeFunction()
+ // (1) Instead of having to write out
+ // XRCCTRL(dlg, "controls_treectrl", wxTreeCtrl)->SomeFunction()
// 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
// will be referring to this control often in the code.
wxTreeCtrl* treectrl = XRCCTRL(dlg, "controls_treectrl", wxTreeCtrl);
// (3)Append some items to the root node.
treectrl->AppendItem(treectrl->GetRootItem(), _("Evil henchman 1"));
treectrl->AppendItem(treectrl->GetRootItem(), _("Evil henchman 2"));
- treectrl->AppendItem(treectrl->GetRootItem(), _("Evil accountant"));
+ treectrl->AppendItem(treectrl->GetRootItem(), _("Evil accountant"));
#endif
-
+
// All done. Show the dialog.
dlg.ShowModal();
}
-void MyFrame::OnUncenteredToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
+void MyFrame::OnUncenteredToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{
wxDialog dlg;
wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("uncentered_dialog"));
{
wxDialog dlg;
wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("custom_class_dialog"));
-
- // Make an instance of our new custom class.
- MyResizableListCtrl* a_myResizableListCtrl = new MyResizableListCtrl(&dlg,
- -1,
+
+ // Make an instance of our new custom class.
+ MyResizableListCtrl* a_myResizableListCtrl = new MyResizableListCtrl(&dlg,
+ wxID_ANY,
wxDefaultPosition,
wxDefaultSize,
wxLC_REPORT,
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.
wxXmlResource::Get()->AttachUnknownControl(wxT("custom_control_placeholder"),
a_myResizableListCtrl);
// Constructor.
MyFrame( wxWindow* parent=(wxWindow *)NULL);
-private:
+private:
// Event handlers (these functions should _not_ be virtual)
void OnExitToolOrMenuCommand(wxCommandEvent& event);
void OnNonDerivedDialogToolOrMenuCommand(wxCommandEvent& event);
void OnDerivedDialogToolOrMenuCommand(wxCommandEvent& event);
void OnControlsToolOrMenuCommand(wxCommandEvent& event);
- void OnUncenteredToolOrMenuCommand(wxCommandEvent& event);
+ void OnUncenteredToolOrMenuCommand(wxCommandEvent& event);
void OnCustomClassToolOrMenuCommand(wxCommandEvent& event);
void OnPlatformPropertyToolOrMenuCommand(wxCommandEvent& event);
void OnArtProviderToolOrMenuCommand(wxCommandEvent& event);
// you want PNGs, then add a PNG handler, etc. See wxImage::AddHandler()
// documentation for the types of image handlers available.
wxImage::AddHandler(new wxXPMHandler);
-
+
// Initialize all the XRC handlers. Always required (unless you feel like
// going through and initializing a handler of each control type you will
// be using (ie initialize the spinctrl handler, initialize the textctrl
// 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
// wxXRC docs for details.
- wxXmlResource::Get()->InitAllHandlers();
-
+ wxXmlResource::Get()->InitAllHandlers();
+
// 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
- // diffcult to manage, and harder to reuse in later projects.
+ // into one giant XRC file if you wanted, but then they become more
+ // diffcult to manage, and harder to reuse in later projects.
// The menubar
wxXmlResource::Get()->Load(wxT("rc/menu.xrc"));
// The toolbar
// Frame example
wxXmlResource::Get()->Load(wxT("rc/frame.xrc"));
// Uncentered example
- wxXmlResource::Get()->Load(wxT("rc/uncenter.xrc"));
+ wxXmlResource::Get()->Load(wxT("rc/uncenter.xrc"));
// Custom class example
wxXmlResource::Get()->Load(wxT("rc/custclas.xrc"));
// wxArtProvider example
// Variable expansion example
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
- // since it is the first window.
+ // since it is the first window.
MyFrame *frame = new MyFrame();
-
+
// Show the frame.
- frame->Show(TRUE);
-
- // Return TRUE to tell program to continue (FALSE would terminate).
- return TRUE;
+ frame->Show(true);
+
+ // Return true to tell program to continue (false would terminate).
+ return true;
}
public:
// Override base class virtuals:
- // wxApp::OnInit() is called on application startup and is a good place
- // for the app initialization (doing it here and not in the ctor
- // allows to have an error return: if OnInit() returns false, the
+ // wxApp::OnInit() is called on application startup and is a good place
+ // for the app initialization (doing it here and not in the ctor
+ // allows to have an error return: if OnInit() returns false, the
// application terminates)
virtual bool OnInit();
-
+
};
//-----------------------------------------------------------------------------
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_bmp.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxBitmapXmlHandler, wxXmlResourceHandler)
-wxBitmapXmlHandler::wxBitmapXmlHandler()
-: wxXmlResourceHandler()
+wxBitmapXmlHandler::wxBitmapXmlHandler()
+: wxXmlResourceHandler()
{
}
wxObject *wxBitmapXmlHandler::DoCreateResource()
-{
+{
return new wxBitmap(GetBitmap(wxT("")));
}
IMPLEMENT_DYNAMIC_CLASS(wxIconXmlHandler, wxXmlResourceHandler)
-wxIconXmlHandler::wxIconXmlHandler()
-: wxXmlResourceHandler()
+wxIconXmlHandler::wxIconXmlHandler()
+: wxXmlResourceHandler()
{
}
wxObject *wxIconXmlHandler::DoCreateResource()
-{
+{
return new wxIcon(GetIcon(wxT("")));
}
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_bmpbt.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButtonXmlHandler, wxXmlResourceHandler)
-wxBitmapButtonXmlHandler::wxBitmapButtonXmlHandler()
-: wxXmlResourceHandler()
+wxBitmapButtonXmlHandler::wxBitmapButtonXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxBU_AUTODRAW);
XRC_ADD_STYLE(wxBU_LEFT);
}
wxObject *wxBitmapButtonXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(button, wxBitmapButton)
button->Create(m_parentAsWindow,
if (GetBool(wxT("default"), 0))
button->SetDefault();
SetupWindow(button);
-
+
if (!GetParamValue(wxT("selected")).IsEmpty())
button->SetBitmapSelected(GetBitmap(wxT("selected")));
if (!GetParamValue(wxT("focus")).IsEmpty())
button->SetBitmapFocus(GetBitmap(wxT("focus")));
if (!GetParamValue(wxT("disabled")).IsEmpty())
button->SetBitmapDisabled(GetBitmap(wxT("disabled")));
-
+
return button;
}
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_bttn.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxButtonXmlHandler, wxXmlResourceHandler)
-wxButtonXmlHandler::wxButtonXmlHandler()
-: wxXmlResourceHandler()
+wxButtonXmlHandler::wxButtonXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxBU_LEFT);
XRC_ADD_STYLE(wxBU_RIGHT);
}
wxObject *wxButtonXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(button, wxButton)
button->Create(m_parentAsWindow,
if (GetBool(wxT("default"), 0))
button->SetDefault();
SetupWindow(button);
-
+
return button;
}
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_cald.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxCalendarCtrlXmlHandler, wxXmlResourceHandler)
-wxCalendarCtrlXmlHandler::wxCalendarCtrlXmlHandler()
-: wxXmlResourceHandler()
+wxCalendarCtrlXmlHandler::wxCalendarCtrlXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxCAL_SUNDAY_FIRST);
XRC_ADD_STYLE(wxCAL_MONDAY_FIRST);
wxObject *wxCalendarCtrlXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(calendar, wxCalendarCtrl);
calendar->Create(m_parentAsWindow,
GetPosition(), GetSize(),
GetStyle(),
GetName());
-
+
SetupWindow(calendar);
-
+
return calendar;
}
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_chckb.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxCheckBoxXmlHandler, wxXmlResourceHandler)
-wxCheckBoxXmlHandler::wxCheckBoxXmlHandler()
-: wxXmlResourceHandler()
+wxCheckBoxXmlHandler::wxCheckBoxXmlHandler()
+: wxXmlResourceHandler()
{
AddWindowStyles();
}
wxObject *wxCheckBoxXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(control, wxCheckBox)
control->Create(m_parentAsWindow,
control->SetValue(GetBool( wxT("checked")));
SetupWindow(control);
-
+
return control;
}
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_chckl.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxCheckListBoxXmlHandler, wxXmlResourceHandler)
-wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler()
-: wxXmlResourceHandler(), m_insideBox(FALSE)
+wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler()
+: wxXmlResourceHandler(), m_insideBox(false)
{
// no styles
AddWindowStyles();
}
wxObject *wxCheckListBoxXmlHandler::DoCreateResource()
-{
+{
if (m_class == wxT("wxCheckListBox")
#if WXWIN_COMPATIBILITY_2_4
|| m_class == wxT("wxCheckList")
wxLogDebug(wxT("'wxCheckList' name is deprecated, use 'wxCheckListBox' instead."));
#endif
// need to build the list of strings from children
- m_insideBox = TRUE;
+ m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
wxString *strings = (wxString *) NULL;
if (strList.GetCount() > 0)
wxString v = n->GetPropVal(wxT("checked"), wxEmptyString);
v.MakeLower();
if (v && v == wxT("1"))
- control->Check( i, TRUE );
+ control->Check( i, true );
- i++;
+ i++;
n = n->GetNext();
}
-
+
SetupWindow(control);
if (strings != NULL)
delete[] strings;
- strList.Clear(); // dump the strings
+ strList.Clear(); // dump the strings
return control;
}
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_choic.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxChoiceXmlHandler, wxXmlResourceHandler)
-wxChoiceXmlHandler::wxChoiceXmlHandler()
-: wxXmlResourceHandler() , m_insideBox(FALSE)
+wxChoiceXmlHandler::wxChoiceXmlHandler()
+: wxXmlResourceHandler() , m_insideBox(false)
{
XRC_ADD_STYLE(wxCB_SORT);
AddWindowStyles();
}
wxObject *wxChoiceXmlHandler::DoCreateResource()
-{
+{
if( m_class == wxT("wxChoice"))
{
// find the selection
long selection = GetLong(wxT("selection"), -1);
// need to build the list of strings from children
- m_insideBox = TRUE;
+ m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
wxString *strings = (wxString *) NULL;
if (strList.GetCount() > 0)
if (strings != NULL)
delete[] strings;
- strList.Clear(); // dump the strings
+ strList.Clear(); // dump the strings
return control;
}
{
// on the inside now.
// handle <item>Label</item>
-
+
// add to the list
wxString str = GetNodeContent(m_node);
if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_combo.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxComboBoxXmlHandler, wxXmlResourceHandler)
-wxComboBoxXmlHandler::wxComboBoxXmlHandler()
-: wxXmlResourceHandler() , m_insideBox(FALSE)
+wxComboBoxXmlHandler::wxComboBoxXmlHandler()
+: wxXmlResourceHandler() , m_insideBox(false)
{
XRC_ADD_STYLE(wxCB_SIMPLE);
XRC_ADD_STYLE(wxCB_SORT);
}
wxObject *wxComboBoxXmlHandler::DoCreateResource()
-{
+{
if( m_class == wxT("wxComboBox"))
{
// find the selection
long selection = GetLong( wxT("selection"), -1 );
// need to build the list of strings from children
- m_insideBox = TRUE;
+ m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
wxString *strings = (wxString *) NULL;
if (strList.GetCount() > 0)
if (strings != NULL)
delete[] strings;
- strList.Clear(); // dump the strings
+ strList.Clear(); // dump the strings
return control;
}
CreateChildren(dlg);
- if (GetBool(wxT("centered"), FALSE))
+ if (GetBool(wxT("centered"), false))
dlg->Centre();
return dlg;
CreateChildren(frame);
- if (GetBool(wxT("centered"), FALSE))
+ if (GetBool(wxT("centered"), false))
frame->Centre();
return frame;
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_gauge.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxGaugeXmlHandler, wxXmlResourceHandler)
-wxGaugeXmlHandler::wxGaugeXmlHandler()
-: wxXmlResourceHandler()
+wxGaugeXmlHandler::wxGaugeXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxGA_HORIZONTAL);
XRC_ADD_STYLE(wxGA_VERTICAL);
}
wxObject *wxGaugeXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(control, wxGauge)
control->Create(m_parentAsWindow,
GetID(),
- GetLong(wxT("range"), wxGAUGE_DEFAULT_RANGE),
+ GetLong(wxT("range"), wxGAUGE_DEFAULT_RANGE),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
wxObject *wxGenericDirCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(ctrl, wxGenericDirCtrl)
-
+
ctrl->Create(m_parentAsWindow,
GetID(),
GetText(wxT("defaultfolder")),
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_html.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindowXmlHandler, wxXmlResourceHandler)
-wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler()
-: wxXmlResourceHandler()
+wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxHW_SCROLLBAR_NEVER);
XRC_ADD_STYLE(wxHW_SCROLLBAR_AUTO);
{
wxString url = GetParamValue(wxT("url"));
wxFileSystem& fsys = GetCurFileSystem();
-
+
wxFSFile *f = fsys.OpenFile(url);
if (f)
{
else
control->LoadPage(url);
}
-
+
else if (HasParam(wxT("htmlcode")))
{
control->SetPage(GetText(wxT("htmlcode")));
}
SetupWindow(control);
-
+
return control;
}
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_listb.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxListBoxXmlHandler, wxXmlResourceHandler)
-wxListBoxXmlHandler::wxListBoxXmlHandler()
-: wxXmlResourceHandler() , m_insideBox(FALSE)
+wxListBoxXmlHandler::wxListBoxXmlHandler()
+: wxXmlResourceHandler() , m_insideBox(false)
{
XRC_ADD_STYLE(wxLB_SINGLE);
XRC_ADD_STYLE(wxLB_MULTIPLE);
}
wxObject *wxListBoxXmlHandler::DoCreateResource()
-{
+{
if( m_class == wxT("wxListBox"))
{
// find the selection
long selection = GetLong(wxT("selection"), -1);
// need to build the list of strings from children
- m_insideBox = TRUE;
+ m_insideBox = true;
CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
wxString *strings = (wxString *) NULL;
if (strList.GetCount() > 0)
if (strings != NULL)
delete[] strings;
- strList.Clear(); // dump the strings
+ strList.Clear(); // dump the strings
return control;
}
{
// on the inside now.
// handle <item>Label</item>
-
+
// add to the list
wxString str = GetNodeContent(m_node);
if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_listc.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxListCtrlXmlHandler, wxXmlResourceHandler)
-wxListCtrlXmlHandler::wxListCtrlXmlHandler()
-: wxXmlResourceHandler()
+wxListCtrlXmlHandler::wxListCtrlXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxLC_LIST);
XRC_ADD_STYLE(wxLC_REPORT);
}
wxObject *wxListCtrlXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(list, wxListCtrl)
list->Create(m_parentAsWindow,
GetName());
// FIXME: add columns definition
-
+
SetupWindow(list);
-
+
return list;
}
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_menu.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxMenuXmlHandler, wxXmlResourceHandler)
-wxMenuXmlHandler::wxMenuXmlHandler() :
- wxXmlResourceHandler(), m_insideMenu(FALSE)
+wxMenuXmlHandler::wxMenuXmlHandler() :
+ wxXmlResourceHandler(), m_insideMenu(false)
{
XRC_ADD_STYLE(wxMENU_TEAROFF);
}
wxMenu *menu = new wxMenu(GetStyle());
wxString title = GetText(wxT("label"));
wxString help = GetText(wxT("help"));
-
+
bool oldins = m_insideMenu;
- m_insideMenu = TRUE;
- CreateChildren(menu, TRUE/*only this handler*/);
+ m_insideMenu = true;
+ CreateChildren(menu, true/*only this handler*/);
m_insideMenu = oldins;
wxMenuBar *p_bar = wxDynamicCast(m_parent, wxMenuBar);
else
{
wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu);
-
+
if (m_class == wxT("separator"))
p_menu->AppendSeparator();
else if (m_class == wxT("break"))
p_menu->Break();
else /*wxMenuItem*/
- {
+ {
int id = GetID();
wxString label = GetText(wxT("label"));
- wxString accel = GetText(wxT("accel"), FALSE);
+ wxString accel = GetText(wxT("accel"), false);
wxString fullLabel = label;
if (!accel.IsEmpty())
fullLabel << wxT("\t") << accel;
wxMenuItem *mitem = new wxMenuItem(p_menu, id, fullLabel,
GetText(wxT("help")), kind);
-
+
#if wxCHECK_VERSION(2,3,0) || (defined(__WXMSW__) && wxUSE_OWNER_DRAWN)
if (HasParam(wxT("bitmap")))
mitem->SetBitmap(GetBitmap(wxT("bitmap"), wxART_MENU));
#endif
p_menu->Append(mitem);
- mitem->Enable(GetBool(wxT("enabled"), TRUE));
+ mitem->Enable(GetBool(wxT("enabled"), true));
if (kind == wxITEM_CHECK)
mitem->Check(GetBool(wxT("checked")));
}
bool wxMenuXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxMenu")) ||
- (m_insideMenu &&
+ (m_insideMenu &&
(IsOfClass(node, wxT("wxMenuItem")) ||
IsOfClass(node, wxT("break")) ||
IsOfClass(node, wxT("separator")))
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_notbk.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxNotebookXmlHandler, wxXmlResourceHandler)
-wxNotebookXmlHandler::wxNotebookXmlHandler()
-: wxXmlResourceHandler(), m_isInside(FALSE), m_notebook(NULL)
+wxNotebookXmlHandler::wxNotebookXmlHandler()
+: wxXmlResourceHandler(), m_isInside(false), m_notebook(NULL)
{
XRC_ADD_STYLE(wxNB_FIXEDWIDTH);
XRC_ADD_STYLE(wxNB_LEFT);
}
wxObject *wxNotebookXmlHandler::DoCreateResource()
-{
+{
if (m_class == wxT("notebookpage"))
{
wxXmlNode *n = GetParamNode(wxT("object"));
if (n)
{
bool old_ins = m_isInside;
- m_isInside = FALSE;
+ m_isInside = false;
wxObject *item = CreateResFromNode(n, m_notebook, NULL);
m_isInside = old_ins;
wxWindow *wnd = wxDynamicCast(item, wxWindow);
if (wnd)
m_notebook->AddPage(wnd, GetText(wxT("label")),
GetBool(wxT("selected"), 0));
- else
- wxLogError(wxT("Error in resource."));
+ else
+ wxLogError(wxT("Error in resource."));
return wnd;
}
else
return NULL;
}
}
-
- else
+
+ else
{
XRC_MAKE_INSTANCE(nb, wxNotebook)
- nb->Create(m_parentAsWindow,
+ nb->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style")),
wxNotebook *old_par = m_notebook;
m_notebook = nb;
bool old_ins = m_isInside;
- m_isInside = TRUE;
- CreateChildren(m_notebook, TRUE/*only this handler*/);
+ m_isInside = true;
+ CreateChildren(m_notebook, true/*only this handler*/);
m_isInside = old_ins;
m_notebook = old_par;
- if (GetBool(wxT("usenotebooksizer"), FALSE))
+ if (GetBool(wxT("usenotebooksizer"), false))
return new wxNotebookSizer(nb);
else
return nb;
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_panel.h"
#endif
}
wxObject *wxPanelXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(panel, wxPanel)
panel->Create(m_parentAsWindow,
SetupWindow(panel);
CreateChildren(panel);
-
+
return panel;
}
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_radbt.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxRadioButtonXmlHandler, wxXmlResourceHandler)
-wxRadioButtonXmlHandler::wxRadioButtonXmlHandler()
-: wxXmlResourceHandler()
+wxRadioButtonXmlHandler::wxRadioButtonXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxRB_GROUP);
AddWindowStyles();
}
wxObject *wxRadioButtonXmlHandler::DoCreateResource()
-{
+{
/* BOBM - implementation note.
* once the wxBitmapRadioButton is implemented.
- * look for a bitmap property. If not null,
- * make it a wxBitmapRadioButton instead of the
+ * look for a bitmap property. If not null,
+ * make it a wxBitmapRadioButton instead of the
* normal radio button.
- */
+ */
XRC_MAKE_INSTANCE(control, wxRadioButton)
control->SetValue(GetBool(wxT("value"), 0));
SetupWindow(control);
-
+
return control;
}
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_radbx.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxRadioBoxXmlHandler, wxXmlResourceHandler)
-wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
-: wxXmlResourceHandler(), m_insideBox(FALSE)
+wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
+: wxXmlResourceHandler(), m_insideBox(false)
{
XRC_ADD_STYLE(wxRA_SPECIFY_COLS);
XRC_ADD_STYLE(wxRA_HORIZONTAL);
}
wxObject *wxRadioBoxXmlHandler::DoCreateResource()
-{
+{
if( m_class == wxT("wxRadioBox"))
{
// find the selection
long selection = GetLong( wxT("selection"), -1 );
// need to build the list of strings from children
- m_insideBox = TRUE;
+ m_insideBox = true;
CreateChildrenPrivately( NULL, GetParamNode(wxT("content")));
wxString *strings = (wxString *) NULL;
if( strList.GetCount() > 0 )
if (strings != NULL)
delete[] strings;
- strList.Clear(); // dump the strings
+ strList.Clear(); // dump the strings
return control;
}
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_scrol.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxScrollBarXmlHandler, wxXmlResourceHandler)
-wxScrollBarXmlHandler::wxScrollBarXmlHandler()
-: wxXmlResourceHandler()
+wxScrollBarXmlHandler::wxScrollBarXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxSB_HORIZONTAL);
XRC_ADD_STYLE(wxSB_VERTICAL);
}
wxObject *wxScrollBarXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(control, wxScrollBar)
control->Create(m_parentAsWindow,
wxDefaultValidator,
GetName());
- control->SetScrollbar(GetLong( wxT("value"), 0),
+ control->SetScrollbar(GetLong( wxT("value"), 0),
GetLong( wxT("thumbsize"),1),
GetLong( wxT("range"), 10),
GetLong( wxT("pagesize"),1));
SetupWindow(control);
CreateChildren(control);
-
+
return control;
}
// Copyright: (c) 2002 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_scwin.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindowXmlHandler, wxXmlResourceHandler)
-wxScrolledWindowXmlHandler::wxScrolledWindowXmlHandler()
-: wxXmlResourceHandler()
+wxScrolledWindowXmlHandler::wxScrolledWindowXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxHSCROLL);
XRC_ADD_STYLE(wxVSCROLL);
}
wxObject *wxScrolledWindowXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(control, wxScrolledWindow)
control->Create(m_parentAsWindow,
SetupWindow(control);
CreateChildren(control);
-
+
return control;
}
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_sizer.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxSizerXmlHandler, wxXmlResourceHandler)
-
-
-wxSizerXmlHandler::wxSizerXmlHandler()
+
+
+wxSizerXmlHandler::wxSizerXmlHandler()
: wxXmlResourceHandler(),
- m_isInside(FALSE),
- m_isGBS(FALSE),
+ m_isInside(false),
+ m_isGBS(false),
m_parentSizer(NULL)
{
XRC_ADD_STYLE(wxHORIZONTAL);
XRC_ADD_STYLE(wxALIGN_CENTRE_HORIZONTAL);
XRC_ADD_STYLE(wxALIGN_CENTER_VERTICAL);
XRC_ADD_STYLE(wxALIGN_CENTRE_VERTICAL);
-
+
XRC_ADD_STYLE(wxADJUST_MINSIZE);
XRC_ADD_STYLE(wxFIXED_MINSIZE);
}
{
return ( (!m_isInside && IsSizerNode(node)) ||
(m_isInside && IsOfClass(node, wxT("sizeritem"))) ||
- (m_isInside && IsOfClass(node, wxT("spacer")))
+ (m_isInside && IsOfClass(node, wxT("spacer")))
);
}
-
+
wxObject* wxSizerXmlHandler::DoCreateResource()
-{
+{
if (m_class == wxT("sizeritem"))
return Handle_sizeritem();
-
+
else if (m_class == wxT("spacer"))
return Handle_spacer();
{
// create a sizer item for it
wxSizerItem* sitem = MakeSizerItem();
-
+
// now fetch the item to be managed
bool old_gbs = m_isGBS;
bool old_ins = m_isInside;
wxSizer *old_par = m_parentSizer;
- m_isInside = FALSE;
- if (!IsSizerNode(n)) m_parentSizer = NULL;
+ m_isInside = false;
+ if (!IsSizerNode(n)) m_parentSizer = NULL;
wxObject *item = CreateResFromNode(n, m_parent, NULL);
m_isInside = old_ins;
m_parentSizer = old_par;
// and figure out what type it is
wxSizer *sizer = wxDynamicCast(item, wxSizer);
wxWindow *wnd = wxDynamicCast(item, wxWindow);
-
+
if (sizer)
sitem->SetSizer(sizer);
else if (wnd)
sitem->SetWindow(wnd);
- else
+ else
wxLogError(wxT("Error in resource."));
// finally, set other wxSizerItem attributes
wxSizerItem* sitem = MakeSizerItem();
SetSizerItemAttributes(sitem);
sitem->SetSpacer(GetSize());
- AddSizerItem(sitem);
+ AddSizerItem(sitem);
return NULL;
}
wxObject* wxSizerXmlHandler::Handle_sizer()
{
wxSizer *sizer = NULL;
-
+
wxXmlNode *parentNode = m_node->GetParent();
wxCHECK_MSG(m_parentSizer != NULL ||
else if (m_class == wxT("wxStaticBoxSizer"))
sizer = Handle_wxStaticBoxSizer();
-
+
else if (m_class == wxT("wxGridSizer"))
sizer = Handle_wxGridSizer();
-
+
else if (m_class == wxT("wxFlexGridSizer"))
sizer = Handle_wxFlexGridSizer();
else if (m_class == wxT("wxGridBagSizer"))
sizer = Handle_wxGridBagSizer();
-
+
wxSize minsize = GetSize(wxT("minsize"));
if (!(minsize == wxDefaultSize))
sizer->SetMinSize(minsize);
// set new state
m_parentSizer = sizer;
- m_isInside = TRUE;
+ m_isInside = true;
m_isGBS = (m_class == wxT("wxGridBagSizer"));
-
- CreateChildren(m_parent, TRUE/*only this handler*/);
+
+ CreateChildren(m_parent, true/*only this handler*/);
// restore state
m_isInside = old_ins;
if (m_parentSizer == NULL) // setup window:
{
- m_parentAsWindow->SetAutoLayout(TRUE);
+ m_parentAsWindow->SetAutoLayout(true);
m_parentAsWindow->SetSizer(sizer);
wxXmlNode *nd = m_node;
if (m_parentAsWindow->GetWindowStyle() & (wxRESIZE_BOX | wxRESIZE_BORDER))
sizer->SetSizeHints(m_parentAsWindow);
}
-
+
return sizer;
}
wxSizer* wxSizerXmlHandler::Handle_wxBoxSizer()
{
return new wxBoxSizer(GetStyle(wxT("orient"), wxHORIZONTAL));
-}
-
+}
+
wxSizer* wxSizerXmlHandler::Handle_wxStaticBoxSizer()
{
return new wxStaticBoxSizer(
GetName()),
GetStyle(wxT("orient"), wxHORIZONTAL));
}
-
+
wxSizer* wxSizerXmlHandler::Handle_wxGridSizer()
{
return new wxGridSizer(GetLong(wxT("rows")), GetLong(wxT("cols")),
wxSizer* wxSizerXmlHandler::Handle_wxFlexGridSizer()
{
- wxFlexGridSizer *sizer =
+ wxFlexGridSizer *sizer =
new wxFlexGridSizer(GetLong(wxT("rows")), GetLong(wxT("cols")),
GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
SetGrowables(sizer, wxT("growablerows"), true);
wxSizer* wxSizerXmlHandler::Handle_wxGridBagSizer()
{
- wxGridBagSizer *sizer =
+ wxGridBagSizer *sizer =
new wxGridBagSizer(GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
SetGrowables(sizer, wxT("growablerows"), true);
SetGrowables(sizer, wxT("growablecols"), false);
sz = GetSize(wxT("ratio"));
if (!(sz == wxDefaultSize))
sitem->SetRatio(sz);
-
+
if (m_isGBS)
{
wxGBSizerItem* gbsitem = (wxGBSizerItem*)sitem;
gbsitem->SetPos(GetGBPos(wxT("cellpos")));
gbsitem->SetSpan(GetGBSpan(wxT("cellspan")));
- }
+ }
}
void wxSizerXmlHandler::AddSizerItem(wxSizerItem* sitem)
else
m_parentSizer->Add(sitem);
}
-
+
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_slidr.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxSliderXmlHandler, wxXmlResourceHandler)
-wxSliderXmlHandler::wxSliderXmlHandler()
-: wxXmlResourceHandler()
+wxSliderXmlHandler::wxSliderXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxSL_HORIZONTAL);
XRC_ADD_STYLE(wxSL_VERTICAL);
}
wxObject *wxSliderXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(control, wxSlider)
control->Create(m_parentAsWindow,
GetID(),
- GetLong(wxT("value"), wxSL_DEFAULT_VALUE),
+ GetLong(wxT("value"), wxSL_DEFAULT_VALUE),
GetLong(wxT("min"), wxSL_DEFAULT_MIN),
GetLong(wxT("max"), wxSL_DEFAULT_MAX),
GetPosition(), GetSize(),
}
SetupWindow(control);
-
+
return control;
}
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_spin.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxSpinButtonXmlHandler, wxXmlResourceHandler)
-wxSpinButtonXmlHandler::wxSpinButtonXmlHandler()
-: wxXmlResourceHandler()
+wxSpinButtonXmlHandler::wxSpinButtonXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxSP_HORIZONTAL);
XRC_ADD_STYLE(wxSP_VERTICAL);
}
wxObject *wxSpinButtonXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(control, wxSpinButton)
control->Create(m_parentAsWindow,
control->SetRange(GetLong( wxT("min"), wxSP_DEFAULT_MIN),
GetLong(wxT("max"), wxSP_DEFAULT_MAX));
SetupWindow(control);
-
+
return control;
}
IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrlXmlHandler, wxXmlResourceHandler)
-wxSpinCtrlXmlHandler::wxSpinCtrlXmlHandler()
-: wxXmlResourceHandler()
+wxSpinCtrlXmlHandler::wxSpinCtrlXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxSP_HORIZONTAL);
XRC_ADD_STYLE(wxSP_VERTICAL);
}
wxObject *wxSpinCtrlXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(control, wxSpinCtrl)
-
+
control->Create(m_parentAsWindow,
GetID(),
GetText(wxT("value")),
GetName());
SetupWindow(control);
-
+
return control;
}
// Copyright: (c) 2003 panga@freemail.hu, Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_split.h"
#endif
wxXmlNode *n = m_node->GetChildren();
while (n)
{
- if ((n->GetType() == wxXML_ELEMENT_NODE) &&
+ if ((n->GetType() == wxXML_ELEMENT_NODE) &&
(n->GetName() == wxT("object") ||
n->GetName() == wxT("object_ref")))
{
{
win2 = win;
break;
- }
+ }
}
n = n->GetNext();
}
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_stbmp.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmapXmlHandler, wxXmlResourceHandler)
-wxStaticBitmapXmlHandler::wxStaticBitmapXmlHandler()
-: wxXmlResourceHandler()
+wxStaticBitmapXmlHandler::wxStaticBitmapXmlHandler()
+: wxXmlResourceHandler()
{
AddWindowStyles();
}
wxObject *wxStaticBitmapXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(bmp, wxStaticBitmap)
bmp->Create(m_parentAsWindow,
GetName());
SetupWindow(bmp);
-
+
return bmp;
}
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_stbox.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxStaticBoxXmlHandler, wxXmlResourceHandler)
-wxStaticBoxXmlHandler::wxStaticBoxXmlHandler()
-: wxXmlResourceHandler()
+wxStaticBoxXmlHandler::wxStaticBoxXmlHandler()
+: wxXmlResourceHandler()
{
AddWindowStyles();
}
wxObject *wxStaticBoxXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(box, wxStaticBox)
box->Create(m_parentAsWindow,
GetName());
SetupWindow(box);
-
+
return box;
}
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_stlin.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxStaticLineXmlHandler, wxXmlResourceHandler)
-wxStaticLineXmlHandler::wxStaticLineXmlHandler()
-: wxXmlResourceHandler()
+wxStaticLineXmlHandler::wxStaticLineXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxLI_HORIZONTAL);
XRC_ADD_STYLE(wxLI_VERTICAL);
}
wxObject *wxStaticLineXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(line, wxStaticLine)
line->Create(m_parentAsWindow,
GetName());
SetupWindow(line);
-
+
return line;
}
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_sttxt.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxStaticTextXmlHandler, wxXmlResourceHandler)
-wxStaticTextXmlHandler::wxStaticTextXmlHandler()
-: wxXmlResourceHandler()
+wxStaticTextXmlHandler::wxStaticTextXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxST_NO_AUTORESIZE);
XRC_ADD_STYLE(wxALIGN_LEFT);
}
wxObject *wxStaticTextXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(text, wxStaticText)
text->Create(m_parentAsWindow,
GetName());
SetupWindow(text);
-
+
return text;
}
// Copyright: (c) 2000 Aleksandras Gluchovas
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_text.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrlXmlHandler, wxXmlResourceHandler)
-wxTextCtrlXmlHandler::wxTextCtrlXmlHandler() : wxXmlResourceHandler()
+wxTextCtrlXmlHandler::wxTextCtrlXmlHandler() : wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxTE_NO_VSCROLL);
XRC_ADD_STYLE(wxTE_AUTO_SCROLL);
}
wxObject *wxTextCtrlXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(text, wxTextCtrl)
text->Create(m_parentAsWindow,
GetName());
SetupWindow(text);
-
+
return text;
}
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_toolb.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxToolBarXmlHandler, wxXmlResourceHandler)
-wxToolBarXmlHandler::wxToolBarXmlHandler()
-: wxXmlResourceHandler(), m_isInside(FALSE), m_toolbar(NULL)
+wxToolBarXmlHandler::wxToolBarXmlHandler()
+: wxXmlResourceHandler(), m_isInside(false), m_toolbar(NULL)
{
XRC_ADD_STYLE(wxTB_FLAT);
XRC_ADD_STYLE(wxTB_DOCKABLE);
}
wxObject *wxToolBarXmlHandler::DoCreateResource()
-{
+{
if (m_class == wxT("tool"))
{
wxCHECK_MSG(m_toolbar, NULL, wxT("Incorrect syntax of XRC resource: tool not within a toolbar!"));
-
+
if (GetPosition() != wxDefaultPosition)
{
m_toolbar->AddTool(GetID(),
GetText(wxT("longhelp")));
}
else
- {
+ {
wxItemKind kind = wxITEM_NORMAL;
if (GetBool(wxT("radio")))
kind = wxITEM_RADIO;
wxASSERT_MSG( kind == wxITEM_NORMAL,
_T("can't have both toggleable and radion button at once") );
kind = wxITEM_CHECK;
- }
+ }
m_toolbar->AddTool(GetID(),
GetText(wxT("label")),
GetBitmap(wxT("bitmap"), wxART_TOOLBAR),
}
return m_toolbar; // must return non-NULL
}
-
+
else if (m_class == wxT("separator"))
{
wxCHECK_MSG(m_toolbar, NULL, wxT("Incorrect syntax of XRC resource: separator not within a toolbar!"));
m_toolbar->AddSeparator();
return m_toolbar; // must return non-NULL
}
-
+
else /*<object class="wxToolBar">*/
{
int style = GetStyle(wxT("style"), wxNO_BORDER | wxTB_HORIZONTAL);
#endif
XRC_MAKE_INSTANCE(toolbar, wxToolBar)
-
+
toolbar->Create(m_parentAsWindow,
GetID(),
GetPosition(),
if (children_node == NULL) return toolbar;
- m_isInside = TRUE;
+ m_isInside = true;
m_toolbar = toolbar;
wxXmlNode *n = children_node;
while (n)
{
- if ((n->GetType() == wxXML_ELEMENT_NODE) &&
+ if ((n->GetType() == wxXML_ELEMENT_NODE) &&
(n->GetName() == wxT("object") || n->GetName() == wxT("object_ref")))
{
wxObject *created = CreateResFromNode(n, toolbar, NULL);
n = n->GetNext();
}
- m_isInside = FALSE;
+ m_isInside = false;
m_toolbar = NULL;
toolbar->Realize();
bool wxToolBarXmlHandler::CanHandle(wxXmlNode *node)
{
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"))));
}
// Copyright: (c) 2000 Brian Gavin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_tree.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrlXmlHandler, wxXmlResourceHandler)
-wxTreeCtrlXmlHandler::wxTreeCtrlXmlHandler()
-: wxXmlResourceHandler()
+wxTreeCtrlXmlHandler::wxTreeCtrlXmlHandler()
+: wxXmlResourceHandler()
{
XRC_ADD_STYLE(wxTR_EDIT_LABELS);
XRC_ADD_STYLE(wxTR_NO_BUTTONS);
}
wxObject *wxTreeCtrlXmlHandler::DoCreateResource()
-{
+{
XRC_MAKE_INSTANCE(tree, wxTreeCtrl)
tree->Create(m_parentAsWindow,
GetName());
SetupWindow(tree);
-
+
return tree;
}
public:
wxUnknownControlContainer(wxWindow *parent,
const wxString& controlName,
- wxWindowID id = -1,
+ wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0)
wxPanel *panel =
new wxUnknownControlContainer(m_parentAsWindow,
- GetName(), -1,
+ GetName(), wxID_ANY,
GetPosition(), GetSize(),
GetStyle(wxT("style")));
SetupWindow(panel);
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_wizrd.h"
#endif
}
wxObject *wxWizardXmlHandler::DoCreateResource()
-{
+{
if (m_class == wxT("wxWizard"))
{
XRC_MAKE_INSTANCE(wiz, wxWizard)
bool wxWizardXmlHandler::CanHandle(wxXmlNode *node)
{
- return IsOfClass(node, wxT("wxWizard")) ||
+ return IsOfClass(node, wxT("wxWizard")) ||
(m_wizard != NULL &&
(IsOfClass(node, wxT("wxWizardPage")) ||
IsOfClass(node, wxT("wxWizardPageSimple")))
wxString fnd;
wxXmlResourceDataRecord *drec;
bool iswild = wxIsWild(filemask);
- bool rt = TRUE;
+ bool rt = true;
#if wxUSE_FILESYSTEM
wxFileSystem fsys;
if (!container)
{
wxLogError(_("Cannot find container for unknown control '%s'."), name.c_str());
- return FALSE;
+ return false;
}
return control->Reparent(container);
}
wxXmlNode *c = node->GetChildren();
while (c)
{
- isok = FALSE;
+ isok = false;
if (!c->GetPropVal(wxT("platform"), &s))
- isok = TRUE;
+ isok = true;
else
{
wxStringTokenizer tkn(s, wxT(" |"));
# if wxUSE_FILESYSTEM
file = fsys.OpenFile(m_data[i].File);
- if (file)
- stream = file->GetStream();
+ if (file)
+ stream = file->GetStream();
# else
stream = new wxFileInputStream(m_data[i].File);
# endif
rt = false;
}
else
- {
+ {
long version;
int v1, v2, v3, v4;
wxString verstr = m_data[i].Doc->GetRoot()->GetPropVal(
ProcessPlatformProperty(m_data[i].Doc->GetRoot());
#if wxUSE_FILESYSTEM
- m_data[i].Time = file->GetModificationTime();
+ m_data[i].Time = file->GetModificationTime();
#else
m_data[i].Time = wxDateTime(wxFileModificationTime(m_data[i].File));
#endif
- }
+ }
# if wxUSE_FILESYSTEM
- wxDELETE(file);
- wxUnusedVar(file);
+ wxDELETE(file);
+ wxUnusedVar(file);
# else
- wxDELETE(stream);
+ wxDELETE(stream);
# endif
}
}
wxString refName = node->GetPropVal(wxT("ref"), wxEmptyString);
if (refName.empty())
continue;
- wxXmlNode* refNode = FindResource(refName, wxEmptyString, TRUE);
+ wxXmlNode* refNode = FindResource(refName, wxEmptyString, true);
if (refNode &&
refNode->GetPropVal(wxT("class"), wxEmptyString) == classname)
{
(node->GetName() == wxT("object") ||
node->GetName() == wxT("object_ref")) )
{
- wxXmlNode* found = DoFindResource(node, name, classname, TRUE);
+ wxXmlNode* found = DoFindResource(node, name, classname, true);
if ( found )
return found;
}
if ( node->GetName() == wxT("object_ref") )
{
wxString refName = node->GetPropVal(wxT("ref"), wxEmptyString);
- wxXmlNode* refNode = FindResource(refName, wxEmptyString, TRUE);
+ wxXmlNode* refNode = FindResource(refName, wxEmptyString, true);
if ( !refNode )
{
else if (family == wxT("swiss")) ifamily = wxSWISS;
else if (family == wxT("modern")) ifamily = wxMODERN;
- bool underlined = GetBool(wxT("underlined"), FALSE);
+ bool underlined = GetBool(wxT("underlined"), false);
wxString encoding = GetParamValue(wxT("encoding"));
wxFontMapper mapper;
wxStringTokenizer tk(faces, wxT(","));
while (tk.HasMoreTokens())
{
- int index = enu.GetFacenames()->Index(tk.GetNextToken(), FALSE);
+ int index = enu.GetFacenames()->Index(tk.GetNextToken(), false);
if (index != wxNOT_FOUND)
{
facename = (*enu.GetFacenames())[index];
if (HasParam(wxT("fg")))
wnd->SetForegroundColour(GetColour(wxT("fg")));
if (GetBool(wxT("enabled"), 1) == 0)
- wnd->Enable(FALSE);
+ wnd->Enable(false);
if (GetBool(wxT("focused"), 0) == 1)
wnd->SetFocus();
if (GetBool(wxT("hidden"), 0) == 1)
- wnd->Show(FALSE);
+ wnd->Show(false);
#if wxUSE_TOOLTIPS
if (HasParam(wxT("tooltip")))
wnd->SetToolTip(GetText(wxT("tooltip")));
{
AddStdXRCID_Records();
wxXmlResource::AddSubclassFactory(new wxXmlSubclassFactoryCXX);
- return TRUE;
+ return true;
}
void OnExit()
{
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
// -- Already done in xmlres.cpp
//#ifdef __GNUG__
//#pragma implementation "xmlres.h"
#endif
#if wxUSE_CHECKBOX
AddHandler(new wxCheckBoxXmlHandler);
-#endif
+#endif
#if wxUSE_HTML
AddHandler(new wxHtmlWindowXmlHandler);
-#endif
+#endif
#if wxUSE_SPINBTN
AddHandler(new wxSpinButtonXmlHandler);
-#endif
+#endif
#if wxUSE_SPINCTRL
AddHandler(new wxSpinCtrlXmlHandler);
-#endif
+#endif
#if wxUSE_SCROLLBAR
AddHandler(new wxScrollBarXmlHandler);
#endif
class XRCWidgetData
{
public:
- XRCWidgetData(const wxString& vname,const wxString& vclass)
+ XRCWidgetData(const wxString& vname,const wxString& vclass)
: m_class(vclass), m_name(vname) {}
const wxString& GetName() const { return m_name; }
const wxString& GetClass() const { return m_class; }
class XRCWndClassData
{
-private:
+private:
wxString m_className;
wxString m_parentClassName;
ArrayOfXRCWidgetData m_wdata;
-
+
void BrowseXmlNode(wxXmlNode* node)
{
wxString classValue;
wxString nameValue;
- wxXmlNode* children;
+ wxXmlNode* children;
while (node)
{
if (node->GetName() == _T("object")
}
children = node->GetChildren();
if (children)
- BrowseXmlNode(children);
+ BrowseXmlNode(children);
node = node->GetNext();
}
}
-
+
public:
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());
-
+
}
-
+
const ArrayOfXRCWidgetData& GetWidgetData(){
return m_wdata;
}
}
file.Write(_T("\nprivate:\n void InitWidgetsFromXRC(){\n")
_T(" wxXmlResource::Get()->LoadObject(this,NULL,\"")
- + m_className
+ + m_className
+ _T("\",\"")
- + m_parentClassName
- + _T("\");\n"));
+ + m_parentClassName
+ + _T("\");\n"));
for(i=0;i<m_wdata.Count();++i){
const XRCWidgetData& w = m_wdata.Item(i);
- file.Write( _T(" ")
- + w.GetName()
+ file.Write( _T(" ")
+ + w.GetName()
+ _T(" = XRCCTRL(*this,\"")
- + w.GetName()
+ + w.GetName()
+ _T("\",")
+ w.GetClass()
+ _T(");\n")
);
}
file.Write(_T(" }\n"));
-
+
file.Write(
_T("public:\n")
- + m_className
+ + m_className
+ _T("::")
+ m_className
+ _T("(){\n")
{
public:
// don't use builtin cmd line parsing:
- virtual bool OnInit() { return true; }
+ virtual bool OnInit() { return true; }
virtual int OnRun();
-
-private:
+
+private:
void ParseParams(const wxCmdLineParser& cmdline);
void CompileRes();
wxArrayString PrepareTempFiles();
void OutputGettext();
wxArrayString FindStrings();
wxArrayString FindStrings(wxXmlNode *node);
-
+
bool flagVerbose, flagCPP, flagPython, flagGettext;
wxString parOutput, parFuncname, parOutputPath;
wxArrayString parFiles;
{
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_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_OPTION, _T("l"), _T("list-of-handlers", _T("output list of neccessary handlers to this file" },
#endif
{ 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_NONE }
flagH = flagCPP && cmdline.Found(_T("e"));
- if (!cmdline.Found(_T("o"), &parOutput))
+ if (!cmdline.Found(_T("o"), &parOutput))
{
if (flagGettext)
parOutput = wxEmptyString;
}
if (!parOutputPath) parOutputPath = _T(".");
- if (!cmdline.Found(_T("n"), &parFuncname))
+ if (!cmdline.Found(_T("n"), &parFuncname))
parFuncname = _T("InitXmlResource");
for (size_t i = 0; i < cmdline.GetParamCount(); i++)
wxRemoveFile(parOutput);
if (!retCode)
- {
+ {
if (flagCPP){
MakePackageCPP(files);
if (flagH)
else
MakePackageZIP(files);
}
-
+
DeleteTempFiles(files);
}
name2.Replace(_T("\\"), _T("_"));
name2.Replace(_T("*"), _T("_"));
name2.Replace(_T("?"), _T("_"));
-
+
wxString s = wxFileNameFromPath(parOutput) + _T("$") + name2;
if (wxFileExists(s) && flist.Index(s) == wxNOT_FOUND)
- {
+ {
for (int i = 0;; i++)
{
s.Printf(wxFileNameFromPath(parOutput) + _T("$%03i-") + name2, i);
wxArrayString XmlResApp::PrepareTempFiles()
{
wxArrayString flist;
-
+
for (size_t i = 0; i < parFiles.Count(); i++)
{
- if (flagVerbose)
+ if (flagVerbose)
wxPrintf(_T("processing ") + parFiles[i] + _T("...\n"));
wxXmlDocument doc;
-
+
if (!doc.Load(parFiles[i]))
{
wxLogError(_T("Error parsing file ") + parFiles[i]);
retCode = 1;
continue;
}
-
+
wxString name, ext, path;
wxSplitPath(parFiles[i], &path, &name, &ext);
}
}
wxString internalName = GetInternalFileName(parFiles[i], flist);
-
+
doc.Save(parOutputPath + wxFILE_SEP_PATH + internalName);
flist.Add(internalName);
}
-
+
return flist;
}
{
// Any bitmaps:
if (node->GetName() == _T("bitmap"))
- return TRUE;
+ return true;
// URLs in wxHtmlWindow:
if (node->GetName() == _T("url"))
- return TRUE;
-
+ return true;
+
// wxBitmapButton:
wxXmlNode *parent = node->GetParent();
- if (parent != NULL &&
+ if (parent != NULL &&
parent->GetPropVal(_T("class"), _T("")) == _T("wxBitmapButton") &&
- (node->GetName() == _T("focus") ||
+ (node->GetName() == _T("focus") ||
node->GetName() == _T("disabled") ||
node->GetName() == _T("selected")))
- return TRUE;
-
+ return true;
+
// wxBitmap or wxIcon toplevel resources:
if (node->GetName() == _T("object"))
{
wxString klass = node->GetPropVal(_T("class"), wxEmptyString);
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>
while (n)
{
if (containsFilename &&
- (n->GetType() == wxXML_TEXT_NODE ||
+ (n->GetType() == wxXML_TEXT_NODE ||
n->GetType() == wxXML_CDATA_SECTION_NODE))
{
wxString fullname;
else
fullname = inputPath + wxFILE_SEP_PATH + n->GetContent();
- if (flagVerbose)
+ if (flagVerbose)
wxPrintf(_T("adding ") + fullname + _T("...\n"));
wxString filename = GetInternalFileName(n->GetContent(), flist);
void XmlResApp::MakePackageZIP(const wxArrayString& flist)
{
wxString files;
-
+
for (size_t i = 0; i < flist.Count(); i++)
files += flist[i] + _T(" ");
files.RemoveLast();
-
- if (flagVerbose)
+
+ if (flagVerbose)
wxPrintf(_T("compressing ") + parOutput + _T("...\n"));
-
+
wxString cwd = wxGetCwd();
wxSetWorkingDirectory(parOutputPath);
- int execres = wxExecute(_T("zip -9 -j ") +
- wxString(flagVerbose ? _T("") : _T("-q ")) +
- parOutput + _T(" ") + files, TRUE);
+ int execres = wxExecute(_T("zip -9 -j ") +
+ wxString(flagVerbose ? _T("") : _T("-q ")) +
+ parOutput + _T(" ") + files, true);
wxSetWorkingDirectory(cwd);
if (execres == -1)
{
wxString snum;
wxFFile file(filename, wxT("rb"));
size_t lng = file.Length();
-
+
snum.Printf(_T("%i"), num);
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");
// we cannot use string literals because MSVC is dumb wannabe compiler
// with arbitrary limitation to 2048 strings :(
-
+
unsigned char *buffer = new unsigned char[lng];
file.Read(buffer, lng);
-
+
for (size_t i = 0, linelng = 0; i < lng; i++)
{
tmp.Printf(_T("%i"), buffer[i]);
output << tmp;
linelng += tmp.Length()+1;
}
-
+
delete[] buffer;
-
+
output += _T("};\n\n");
-
+
return output;
}
wxFFile file(parOutput, wxT("wt"));
size_t i;
- if (flagVerbose)
+ if (flagVerbose)
wxPrintf(_T("creating C++ source file ") + parOutput + _T("...\n"));
-
+
file.Write(_T("")
_T("//\n")
_T("// This file was automatically generated by wxrc, do not edit by hand.\n")
for (i = 0; i < flist.Count(); i++)
file.Write(
FileToCppArray(parOutputPath + wxFILE_SEP_PATH + flist[i], i));
-
+
file.Write(_T("")
_T("void ") + parFuncname + wxT("()\n")
_T("{\n")
file.Write(_T(" wxXmlResource::Get()->Load(wxT(\"memory:XRC_resource/") +
GetInternalFileName(parFiles[i], flist) + _T("\"));\n"));
}
-
+
file.Write(_T("}\n"));
{
wxString fileSpec = (parOutput.BeforeLast('.')).AfterLast('/');
wxString heaFileName = fileSpec + _T(".h");
-
+
wxFFile file(heaFileName, wxT("wt"));
file.Write(
_T("//\n")
_T("//\n\n")
_T("#ifndef __") + fileSpec + _T("_h__\n")
_T("#define __") + fileSpec + _T("_h__\n")
-);
+);
for(size_t i=0;i<aXRCWndClassData.Count();++i){
- aXRCWndClassData.Item(i).GenerateHeaderCode(file);
- }
+ aXRCWndClassData.Item(i).GenerateHeaderCode(file);
+ }
file.Write(
_T("\nvoid \n")
+ parFuncname
wxString snum;
wxFFile file(filename, wxT("rb"));
size_t lng = file.Length();
-
+
snum.Printf(_T("%i"), num);
output = _T(" xml_res_file_") + snum + _T(" = \"\"\"\\\n");
-
+
unsigned char *buffer = new unsigned char[lng];
file.Read(buffer, lng);
-
+
for (size_t i = 0, linelng = 0; i < lng; i++)
{
unsigned char c = buffer[i];
output << tmp;
linelng += tmp.Length();
}
-
+
delete[] buffer;
-
+
output += _T("\"\"\"\n\n");
-
+
return output;
}
wxFFile file(parOutput, wxT("wt"));
size_t i;
- if (flagVerbose)
+ if (flagVerbose)
wxPrintf(_T("creating Python source file ") + parOutput + _T("...\n"));
-
+
file.Write(
_T("#\n")
_T("# This file was automatically generated by wxrc, do not edit by hand.\n")
_T("from wxPython.xrc import *\n\n")
);
-
+
file.Write(_T("def ") + parFuncname + _T("():\n"));
for (i = 0; i < flist.Count(); i++)
void XmlResApp::OutputGettext()
{
wxArrayString str = FindStrings();
-
+
wxFFile fout;
if (parOutput.empty())
fout.Attach(stdout);
else
fout.Open(parOutput, wxT("wt"));
-
+
for (size_t i = 0; i < str.GetCount(); i++)
fout.Write(_T("_(\"") + str[i] + _T("\");\n"));
-
+
if (!parOutput) fout.Detach();
}
for (size_t i = 0; i < parFiles.Count(); i++)
{
- if (flagVerbose)
+ if (flagVerbose)
wxPrintf(_T("processing ") + parFiles[i] + _T("...\n"));
- wxXmlDocument doc;
+ wxXmlDocument doc;
if (!doc.Load(parFiles[i]))
{
wxLogError(_T("Error parsing file ") + parFiles[i]);
a2 = FindStrings(doc.GetRoot());
WX_APPEND_ARRAY(arr, a2);
}
-
+
return arr;
}
else
str2 << wxT('&') << *dt;
}
- else
+ else
{
switch (*dt)
{
(*(dt+1) != 'r'))
str2 << wxT("\\\\");
else
- str2 << wxT("\\");
+ str2 << wxT("\\");
break;
case wxT('"') : str2 << wxT("\\\""); break;
default : str2 << *dt; break;
wxXmlNode *n = node;
if (n == NULL) return arr;
n = n->GetChildren();
-
+
while (n)
{
if ((node->GetType() == wxXML_ELEMENT_NODE) &&
// parent is an element, i.e. has subnodes...
- (n->GetType() == wxXML_TEXT_NODE ||
+ (n->GetType() == wxXML_TEXT_NODE ||
n->GetType() == wxXML_CDATA_SECTION_NODE) &&
// ...it is textnode...
(
{
arr.Add(ConvertText(n->GetContent()));
}
-
+
// subnodes:
if (n->GetType() == wxXML_ELEMENT_NODE)
{
wxArrayString a2 = FindStrings(n);
WX_APPEND_ARRAY(arr, a2);
}
-
+
n = n->GetNext();
}
return arr;