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

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

View File

@@ -42,18 +42,18 @@
// 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,
@@ -71,9 +71,9 @@ IMPLEMENT_DYNAMIC_CLASS( MyResizableListCtrl, wxListCtrl )
// 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()
@@ -90,15 +90,15 @@ MyResizableListCtrl::MyResizableListCtrl( wxWindow *parent, wxWindowID id,
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 );
}
@@ -115,16 +115,16 @@ void MyResizableListCtrl::ContextSensitiveMenu( wxMouseEvent& event )
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() );
}
@@ -133,28 +133,28 @@ void MyResizableListCtrl::OnSize( wxSizeEvent &event )
{
// 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") );
}

View File

@@ -38,14 +38,14 @@ class MyResizableListCtrl : public wxListCtrl
// 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.
@@ -60,33 +60,33 @@ public:
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()
};
//----------------------------------------------------------------------------------------

View File

@@ -49,7 +49,7 @@
//-----------------------------------------------------------------------------
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 )
@@ -60,7 +60,7 @@ END_EVENT_TABLE()
//-----------------------------------------------------------------------------
// Constructor (Notice how small and easy it is)
PreferencesDialog::PreferencesDialog(wxWindow* parent)
{
{
wxXmlResource::Get()->LoadDialog(this, parent, wxT("derived_dialog"));
}
@@ -76,29 +76,29 @@ PreferencesDialog::~PreferencesDialog()
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);
}
@@ -108,16 +108,16 @@ void PreferencesDialog::OnOK( wxCommandEvent& WXUNUSED(event) )
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.
}

View File

@@ -36,26 +36,26 @@
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 );

View File

@@ -76,18 +76,18 @@
// 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)
@@ -102,12 +102,12 @@ END_EVENT_TABLE()
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"));
@@ -121,9 +121,9 @@ MyFrame::MyFrame(wxWindow* parent)
// 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.
@@ -136,8 +136,8 @@ MyFrame::MyFrame(wxWindow* parent)
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);
}
@@ -152,10 +152,10 @@ void MyFrame::OnNonDerivedDialogToolOrMenuCommand(wxCommandEvent& WXUNUSED(event
}
void MyFrame::OnDerivedDialogToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnDerivedDialogToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{
// Make an instance of our derived dialog, passing it "this" window
// (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.
@@ -163,19 +163,19 @@ void MyFrame::OnDerivedDialogToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
}
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 )
@@ -186,12 +186,12 @@ void MyFrame::OnControlsToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
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);
@@ -200,15 +200,15 @@ void MyFrame::OnControlsToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
// (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"));
@@ -220,16 +220,16 @@ void MyFrame::OnCustomClassToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{
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);

View File

@@ -41,7 +41,7 @@ public:
// Constructor.
MyFrame( wxWindow* parent=(wxWindow *)NULL);
private:
private:
// Event handlers (these functions should _not_ be virtual)
void OnExitToolOrMenuCommand(wxCommandEvent& event);
@@ -49,7 +49,7 @@ private:
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);

View File

@@ -75,18 +75,18 @@ bool MyApp::OnInit()
// 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
@@ -100,7 +100,7 @@ bool MyApp::OnInit()
// 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
@@ -110,15 +110,15 @@ bool MyApp::OnInit()
// 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;
}

View File

@@ -39,12 +39,12 @@ class MyApp : public wxApp
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();
};
//-----------------------------------------------------------------------------