]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/propgrid/propgrid.cpp
removed not doing anything and not compiling code from DoAssociation()
[wxWidgets.git] / samples / propgrid / propgrid.cpp
index 6387831ea1669ff98dc461f8a8f5cef6a1a9b866..8cc2d539dac2d23b0923aa153a191081ecdb63e3 100644 (file)
@@ -651,7 +651,8 @@ enum
     ID_COLOURSCHEME2,
     ID_COLOURSCHEME3,
     ID_CATCOLOURS,
-    ID_SETCOLOUR,
+    ID_SETBGCOLOUR,
+    ID_SETBGCOLOURRECUR,
     ID_STATICLAYOUT,
     ID_POPULATE1,
     ID_POPULATE2,
@@ -726,11 +727,13 @@ BEGIN_EVENT_TABLE(FormMain, wxFrame)
     EVT_MENU( ID_DELETEALL, FormMain::OnClearClick )
     EVT_MENU( ID_ENABLE, FormMain::OnEnableDisable )
     EVT_MENU( ID_HIDE, FormMain::OnHideShow )
+
     EVT_MENU( ID_ITERATE1, FormMain::OnIterate1Click )
     EVT_MENU( ID_ITERATE2, FormMain::OnIterate2Click )
     EVT_MENU( ID_ITERATE3, FormMain::OnIterate3Click )
     EVT_MENU( ID_ITERATE4, FormMain::OnIterate4Click )
-    EVT_MENU( ID_SETCOLOUR, FormMain::OnMisc )
+    EVT_MENU( ID_SETBGCOLOUR, FormMain::OnSetBackgroundColour )
+    EVT_MENU( ID_SETBGCOLOURRECUR, FormMain::OnSetBackgroundColour )
     EVT_MENU( ID_CLEARMODIF, FormMain::OnClearModifyStatusClick )
     EVT_MENU( ID_FREEZE, FormMain::OnFreezeClick )
     EVT_MENU( ID_DUMPLIST, FormMain::OnDumpList )
@@ -1366,8 +1369,9 @@ void FormMain::PopulateWithExamples ()
 
     pg->SetPropertyEditor( wxT("SpinCtrl"), wxPGEditor_SpinCtrl );
     pg->SetPropertyAttribute( wxT("SpinCtrl"), wxPG_ATTR_MIN, (long)-10 );  // Use constants instead of string
-    pg->SetPropertyAttribute( wxT("SpinCtrl"), wxPG_ATTR_MAX, (long)10 );   // for reduced binary size.
+    pg->SetPropertyAttribute( wxT("SpinCtrl"), wxPG_ATTR_MAX, (long)16384 );   // for reduced binary size.
     pg->SetPropertyAttribute( wxT("SpinCtrl"), wxT("Step"), (long)2 );
+    pg->SetPropertyAttribute( wxT("SpinCtrl"), wxT("MotionSpin"), true );
     //pg->SetPropertyAttribute( wxT("SpinCtrl"), wxT("Wrap"), true );
 
     pg->SetPropertyHelpString( wxT("SpinCtrl"),
@@ -1929,7 +1933,9 @@ void FormMain::InitPanel()
     if ( m_panel )
         m_panel->Destroy();
 
-    wxWindow* panel = new wxPanel(this,-1,wxPoint(0,0),wxSize(400,400));
+    wxWindow* panel = new wxPanel(this, wxID_ANY,
+                                  wxPoint(0, 0), wxSize(400, 400),
+                                  wxTAB_TRAVERSAL);
     m_panel = panel;
 
     // Column
@@ -1940,11 +1946,17 @@ void FormMain::InitPanel()
 
 void FormMain::FinalizePanel( bool wasCreated )
 {
+    // Button for tab traversal testing
+    m_topSizer->Add( new wxButton(m_panel, wxID_ANY,
+                     wxS("Should be able to move here with Tab")),
+                     0, wxEXPAND );
+
     m_panel->SetSizer( m_topSizer );
     m_topSizer->SetSizeHints( m_panel );
 
     wxBoxSizer* panelSizer = new wxBoxSizer( wxHORIZONTAL );
     panelSizer->Add( m_panel, 1, wxEXPAND|wxFIXED_MINSIZE );
+
     SetSizer( panelSizer );
     panelSizer->SetSizeHints( this );
 
@@ -1988,7 +2000,6 @@ void FormMain::CreateGrid( int style, int extraStyle )
                 //wxPG_TOOLTIPS |
                 //wxPG_HIDE_CATEGORIES |
                 //wxPG_LIMITED_EDITING |
-                wxTAB_TRAVERSAL |
                 wxPG_TOOLBAR |
                 wxPG_DESCRIPTION;
 
@@ -2084,7 +2095,6 @@ FormMain::FormMain(const wxString& title, const wxPoint& pos, const wxSize& size
                 //wxPG_TOOLTIPS |
                 //wxPG_HIDE_CATEGORIES |
                 //wxPG_LIMITED_EDITING |
-                wxTAB_TRAVERSAL |
                 wxPG_TOOLBAR |
                 wxPG_DESCRIPTION,
                 // extra style
@@ -2115,7 +2125,8 @@ FormMain::FormMain(const wxString& title, const wxPoint& pos, const wxSize& size
     menuTools1->Append(ID_DELETER, wxT("Delete Random") );
     menuTools1->Append(ID_DELETEALL, wxT("Delete All") );
     menuTools1->AppendSeparator();
-    menuTools1->Append(ID_SETCOLOUR, wxT("Set Bg Colour") );
+    menuTools1->Append(ID_SETBGCOLOUR, wxT("Set Bg Colour") );
+    menuTools1->Append(ID_SETBGCOLOURRECUR, wxT("Set Bg Colour (Recursively)") );
     menuTools1->Append(ID_UNSPECIFY, wxT("Set to Unspecified") );
     menuTools1->AppendSeparator();
     m_itemEnable = menuTools1->Append(ID_ENABLE, wxT("Enable"),
@@ -2585,6 +2596,30 @@ void FormMain::OnHideShow( wxCommandEvent& WXUNUSED(event) )
 
 // -----------------------------------------------------------------------
 
+#include "wx/colordlg.h"
+
+void
+FormMain::OnSetBackgroundColour( wxCommandEvent& event )
+{
+    wxPropertyGrid* pg = m_pPropGridManager->GetGrid();
+    wxPGProperty* prop = pg->GetSelection();
+    if ( !prop )
+    {
+        wxMessageBox(wxT("First select a property."));
+        return;
+    }
+
+    wxColour col = ::wxGetColourFromUser(this, *wxWHITE, "Choose colour");
+
+    if ( col.IsOk() )
+    {
+        bool recursively = (event.GetId()==ID_SETBGCOLOURRECUR) ? true : false;
+        pg->SetPropertyBackgroundColour(prop, col, recursively);
+    }
+}
+
+// -----------------------------------------------------------------------
+
 void FormMain::OnInsertPage( wxCommandEvent& WXUNUSED(event) )
 {
     m_pPropGridManager->AddPage(wxT("New Page"));
@@ -3014,28 +3049,6 @@ void FormMain::OnMisc ( wxCommandEvent& event )
             m_pPropGridManager->SetPropertyValueUnspecified(prop);
         }
     }
-    else if ( id == ID_SETCOLOUR )
-    {
-        wxPGProperty* prop = m_pPropGridManager->GetSelection();
-        if ( prop )
-        {
-            wxColourData data;
-            data.SetChooseFull(true);
-            int i;
-            for ( i = 0; i < 16; i++)
-            {
-                wxColour colour(i*16, i*16, i*16);
-                data.SetCustomColour(i, colour);
-            }
-
-            wxColourDialog dialog(this, &data);
-            if ( dialog.ShowModal() == wxID_OK )
-            {
-                wxColourData retData = dialog.GetColourData();
-                m_pPropGridManager->GetGrid()->SetPropertyBackgroundColour(prop,retData.GetColour());
-            }
-        }
-    }
 }
 
 // -----------------------------------------------------------------------