]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/propgrid/propgrid.cpp
Document ctors creating a wxString from repeated characters.
[wxWidgets.git] / samples / propgrid / propgrid.cpp
index 861d4dc1c00be6d24682aefa5fc18f2c4c5b5360..74742446d12690bc8d2d26fbdddfc02d0d0801f0 100644 (file)
@@ -687,7 +687,8 @@ enum
     ID_SELECTSTYLE,
     ID_SAVESTATE,
     ID_RESTORESTATE,
-    ID_RUNMINIMAL
+    ID_RUNMINIMAL,
+    ID_ENABLELABELEDITING
 };
 
 // -----------------------------------------------------------------------
@@ -713,6 +714,12 @@ BEGIN_EVENT_TABLE(FormMain, wxFrame)
     EVT_PG_DOUBLE_CLICK( PGID, FormMain::OnPropertyGridItemDoubleClick )
     // This occurs when propgridmanager's page changes.
     EVT_PG_PAGE_CHANGED( PGID, FormMain::OnPropertyGridPageChange )
+    // This occurs when user starts editing a property label
+    EVT_PG_LABEL_EDIT_BEGIN( PGID,
+        FormMain::OnPropertyGridLabelEditBegin )
+    // This occurs when user stops editing a property label
+    EVT_PG_LABEL_EDIT_ENDING( PGID,
+        FormMain::OnPropertyGridLabelEditEnding )
     // This occurs when property's editor button (if any) is clicked.
     EVT_BUTTON( PGID, FormMain::OnPropertyGridButtonClick )
 
@@ -745,6 +752,7 @@ BEGIN_EVENT_TABLE(FormMain, wxFrame)
     EVT_MENU( ID_SETBGCOLOURRECUR, FormMain::OnSetBackgroundColour )
     EVT_MENU( ID_CLEARMODIF, FormMain::OnClearModifyStatusClick )
     EVT_MENU( ID_FREEZE, FormMain::OnFreezeClick )
+    EVT_MENU( ID_ENABLELABELEDITING, FormMain::OnEnableLabelEditing )
     EVT_MENU( ID_DUMPLIST, FormMain::OnDumpList )
 
     EVT_MENU( ID_COLOURSCHEME1, FormMain::OnColourScheme )
@@ -1018,6 +1026,22 @@ void FormMain::OnPropertyGridPageChange( wxPropertyGridEvent& WXUNUSED(event) )
 
 // -----------------------------------------------------------------------
 
+void FormMain::OnPropertyGridLabelEditBegin( wxPropertyGridEvent& event )
+{
+    wxLogDebug("wxPG_EVT_LABEL_EDIT_BEGIN(%s)",
+               event.GetProperty()->GetLabel().c_str());
+}
+
+// -----------------------------------------------------------------------
+
+void FormMain::OnPropertyGridLabelEditEnding( wxPropertyGridEvent& event )
+{
+    wxLogDebug("wxPG_EVT_LABEL_EDIT_ENDING(%s)",
+               event.GetProperty()->GetLabel().c_str());
+}
+
+// -----------------------------------------------------------------------
+
 void FormMain::OnPropertyGridHighlight( wxPropertyGridEvent& WXUNUSED(event) )
 {
 }
@@ -2045,7 +2069,8 @@ void FormMain::CreateGrid( int style, int extraStyle )
 
     if ( extraStyle == -1 )
         // default extra style
-        extraStyle = wxPG_EX_MODE_BUTTONS;
+        extraStyle = wxPG_EX_MODE_BUTTONS |
+                     wxPG_EX_MULTIPLE_SELECTION;
                 //| wxPG_EX_AUTO_UNSPECIFIED_VALUES
                 //| wxPG_EX_GREY_LABEL_WHEN_DISABLED
                 //| wxPG_EX_NATIVE_DOUBLE_BUFFERING
@@ -2066,7 +2091,10 @@ void FormMain::CreateGrid( int style, int extraStyle )
                                   // event handling will obviously be broken.
                                   PGID, /*wxID_ANY*/
                                   wxDefaultPosition,
-                                  wxDefaultSize,
+                                  wxSize(100, 100), // FIXME: wxDefaultSize gives assertion in propgrid.
+                                                    // But calling SetInitialSize in manager changes the code
+                                                    // order to the grid gets created immediately, before SetExtraStyle
+                                                    // is called.
                                   style );
 
     m_propGrid = pgman->GetGrid();
@@ -2140,7 +2168,8 @@ FormMain::FormMain(const wxString& title, const wxPoint& pos, const wxSize& size
                 wxPG_TOOLBAR |
                 wxPG_DESCRIPTION,
                 // extra style
-                wxPG_EX_MODE_BUTTONS
+                wxPG_EX_MODE_BUTTONS |
+                wxPG_EX_MULTIPLE_SELECTION
                 //| wxPG_EX_AUTO_UNSPECIFIED_VALUES
                 //| wxPG_EX_GREY_LABEL_WHEN_DISABLED
                 //| wxPG_EX_NATIVE_DOUBLE_BUFFERING
@@ -2217,6 +2246,8 @@ FormMain::FormMain(const wxString& title, const wxPoint& pos, const wxSize& size
 
     menuTry->Append(ID_SELECTSTYLE, wxT("Set Window Style"),
         wxT("Select window style flags used by the grid."));
+    menuTry->Append(ID_ENABLELABELEDITING, "Enable label editing",
+        "This calls wxPropertyGrid::MakeColumnEditable(0)");
     menuTry->AppendSeparator();
     menuTry->AppendRadioItem( ID_COLOURSCHEME1, wxT("Standard Colour Scheme") );
     menuTry->AppendRadioItem( ID_COLOURSCHEME2, wxT("White Colour Scheme") );
@@ -2433,11 +2464,13 @@ void FormMain::OnDelPropRClick( wxCommandEvent& WXUNUSED(event) )
 
 // -----------------------------------------------------------------------
 
-void FormMain::OnContextMenu( wxContextMenuEvent& WXUNUSED(event) )
+void FormMain::OnContextMenu( wxContextMenuEvent& event )
 {
     wxLogDebug(wxT("FormMain::OnContextMenu(%i,%i)"),
         event.GetPosition().x,event.GetPosition().y);
 
+    wxUnusedVar(event);
+
     //event.Skip();
 }
 
@@ -2758,6 +2791,13 @@ void FormMain::OnFreezeClick( wxCommandEvent& event )
 
 // -----------------------------------------------------------------------
 
+void FormMain::OnEnableLabelEditing( wxCommandEvent& WXUNUSED(event) )
+{
+    m_propGrid->MakeColumnEditable(0);
+}
+
+// -----------------------------------------------------------------------
+
 void FormMain::OnAbout(wxCommandEvent& WXUNUSED(event))
 {
     wxString msg;
@@ -2782,7 +2822,7 @@ void FormMain::OnAbout(wxCommandEvent& WXUNUSED(event))
             wxT("Jaakko Salli"), wxVERSION_STRING
             );
 
-    wxMessageBox(msg, _T("About"), wxOK | wxICON_INFORMATION, this);
+    wxMessageBox(msg, wxT("About"), wxOK | wxICON_INFORMATION, this);
 }
 
 // -----------------------------------------------------------------------
@@ -2899,6 +2939,7 @@ void FormMain::OnSelectStyle( wxCommandEvent& WXUNUSED(event) )
         ADD_FLAG(wxPG_LIMITED_EDITING)
         ADD_FLAG(wxPG_TOOLBAR)
         ADD_FLAG(wxPG_DESCRIPTION)
+        ADD_FLAG(wxPG_NO_INTERNAL_BORDER)
         wxMultiChoiceDialog dlg( this, wxT("Select window styles to use"),
                                  wxT("wxPropertyGrid Window Style"), chs );
         dlg.SetSelections(sel);
@@ -2926,6 +2967,11 @@ void FormMain::OnSelectStyle( wxCommandEvent& WXUNUSED(event) )
         ADD_FLAG(wxPG_EX_NATIVE_DOUBLE_BUFFERING)
         ADD_FLAG(wxPG_EX_AUTO_UNSPECIFIED_VALUES)
         ADD_FLAG(wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES)
+        ADD_FLAG(wxPG_EX_HIDE_PAGE_BUTTONS)
+        ADD_FLAG(wxPG_EX_MULTIPLE_SELECTION)
+        ADD_FLAG(wxPG_EX_ENABLE_TLP_TRACKING)
+        ADD_FLAG(wxPG_EX_NO_TOOLBAR_DIVIDER)
+        ADD_FLAG(wxPG_EX_TOOLBAR_SEPARATOR)
         wxMultiChoiceDialog dlg( this, wxT("Select extra window styles to use"),
                                  wxT("wxPropertyGrid Extra Style"), chs );
         dlg.SetSelections(sel);
@@ -3136,8 +3182,8 @@ bool cxApplication::OnInit()
     //wxLocale Locale;
     //Locale.Init(wxLANGUAGE_FINNISH);
 
-       FormMain* frame = Form1 = new FormMain( wxT("wxPropertyGrid Sample"), wxPoint(0,0), wxSize(300,500) );
-       frame->Show(true);
+    FormMain* frame = Form1 = new FormMain( wxT("wxPropertyGrid Sample"), wxPoint(0,0), wxSize(300,500) );
+    frame->Show(true);
 
     //
     // Parse command-line
@@ -3156,7 +3202,7 @@ bool cxApplication::OnInit()
         }
     }
 
-       return true;
+    return true;
 }
 
 // -----------------------------------------------------------------------