]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/wxprop/src/proplist.cpp
Added wxPropList library
[wxWidgets.git] / utils / wxprop / src / proplist.cpp
index 2b8ba2555bf06ab2df7530f14f3f8d803c217e53..9e9b60f0534dda2cfdaa32490e4d792ea2c51d7c 100644 (file)
@@ -373,13 +373,13 @@ bool wxPropertyListView::RetrieveProperty(wxProperty *property)
 }
 
 
-bool wxPropertyListView::EditProperty(wxProperty *property)
+bool wxPropertyListView::EditProperty(wxProperty *WXUNUSED(property))
 {
   return TRUE;
 }
 
 // Called by the listbox callback
-void wxPropertyListView::OnPropertySelect(wxCommandEvent& event)
+void wxPropertyListView::OnPropertySelect(wxCommandEvent& WXUNUSED(event))
 {
   int sel = propertyScrollingList->GetSelection();
   if (sel > -1)
@@ -396,7 +396,7 @@ bool wxPropertyListView::CreateControls(void)
 {
   wxPanel *panel = (wxPanel *)propertyWindow;
 
-  int largeButtonWidth = 50;
+  int largeButtonWidth = 60;
   int largeButtonHeight = 25;
 
   int smallButtonWidth = 25;
@@ -424,11 +424,17 @@ bool wxPropertyListView::CreateControls(void)
   wxSystemSettings settings;
   wxFont guiFont = settings.GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
 
+#ifdef __WXMSW__
+  wxFont *boringFont = wxTheFontList->FindOrCreateFont(guiFont.GetPointSize(), wxDEFAULT, wxNORMAL, wxNORMAL, FALSE, "Courier New");
+#else
   wxFont *boringFont = wxTheFontList->FindOrCreateFont(guiFont.GetPointSize(), wxMODERN, wxNORMAL, wxNORMAL);
+#endif
 
   // May need to be changed in future to eliminate clashes with app.
   panel->SetClientData((char *)this);
 
+  // These buttons are at the bottom of the window, but create them now
+  // so the constraints are evaluated in the correct order
   if (buttonFlags & wxPROP_BUTTON_OK)
   {
     windowCloseButton = new wxButton(panel, wxID_OK, "OK",
@@ -436,7 +442,7 @@ bool wxPropertyListView::CreateControls(void)
     windowCloseButton->SetDefault();
     windowCloseButton->SetFocus();
   }
-  if (buttonFlags & wxPROP_BUTTON_CLOSE)
+  else if (buttonFlags & wxPROP_BUTTON_CLOSE)
   {
     windowCloseButton = new wxButton(panel, wxID_OK, "Close",
      wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight));
@@ -455,8 +461,9 @@ bool wxPropertyListView::CreateControls(void)
   if (windowCloseButton)
   {
     wxLayoutConstraints *c1 = new wxLayoutConstraints;
+
     c1->left.SameAs       (panel, wxLeft, 2);
-    c1->top.SameAs        (panel, wxTop, 2);
+    c1->bottom.SameAs        (panel, wxBottom, 2);
     c1->width.AsIs();
     c1->height.AsIs();
     windowCloseButton->SetConstraints(c1);
@@ -465,12 +472,9 @@ bool wxPropertyListView::CreateControls(void)
   if (windowCancelButton)
   {
     wxLayoutConstraints *c2 = new wxLayoutConstraints;
-    if (leftMostWindow == panel)
-      c2->left.SameAs       (panel, wxLeft, 2);
-    else
-      c2->left.RightOf      (leftMostWindow, 2);
-      
-    c2->top.SameAs          (panel, wxTop, 2);
+
+    c2->right.SameAs       (panel, wxRight, 2);
+    c2->bottom.SameAs          (panel, wxBottom, 2);
     c2->width.AsIs();
     c2->height.AsIs();
     windowCancelButton->SetConstraints(c2);
@@ -484,7 +488,7 @@ bool wxPropertyListView::CreateControls(void)
     else
       c2->left.RightOf      (leftMostWindow, 2);
       
-    c2->top.SameAs          (panel, wxTop, 2);
+    c2->bottom.SameAs          (panel, wxBottom, 2);
     c2->width.AsIs();
     c2->height.AsIs();
     windowHelpButton->SetConstraints(c2);
@@ -530,9 +534,11 @@ bool wxPropertyListView::CreateControls(void)
 
     wxLayoutConstraints *c = new wxLayoutConstraints;
     c->left.SameAs         (panel, wxLeft, 2);
+/*
     if (windowCloseButton)
       c->top.Below         (windowCloseButton, 2);
     else
+*/
       c->top.SameAs        (panel, wxTop, 2);
 
     c->width.AsIs();
@@ -559,9 +565,11 @@ bool wxPropertyListView::CreateControls(void)
     editButton->Enable(FALSE);
     wxLayoutConstraints *c = new wxLayoutConstraints;
 
+/*
     if (windowCloseButton)
       c->top.Below           (windowCloseButton, 2);
     else
+*/
       c->top.SameAs          (panel, wxTop, 2);
 
     c->right.SameAs          (panel, wxRight, 2);
@@ -579,10 +587,11 @@ bool wxPropertyListView::CreateControls(void)
     c->left.RightOf        (confirmButton, 2);
   else
     c->left.SameAs         (panel, wxLeft, 2);
-
+/*
   if (windowCloseButton)
     c->top.Below           (windowCloseButton, 2);
   else
+*/
     c->top.SameAs          (panel, wxTop, 2);
 
   if (editButton)
@@ -619,10 +628,15 @@ bool wxPropertyListView::CreateControls(void)
     c->top.Below         (valueList, 2);
 
   c->right.SameAs        (panel, wxRight, 2);
-  c->bottom.SameAs       (panel, wxBottom, 2);
+
+  if (windowCloseButton)
+    c->bottom.Above       (windowCloseButton, -2);
+  else
+    c->bottom.SameAs       (panel, wxBottom, 2);
 
   propertyScrollingList->SetConstraints(c);
 
+
   // Note: if this is called now, it causes a GPF.
   // Why?
 //  panel->Layout();
@@ -678,7 +692,7 @@ bool wxPropertyListView::OnClose(void)
   return TRUE;
 }
 
-void wxPropertyListView::OnValueListSelect(wxCommandEvent& event)
+void wxPropertyListView::OnValueListSelect(wxCommandEvent& WXUNUSED(event))
 {
   if (currentProperty && currentValidator)
   {
@@ -699,18 +713,18 @@ void wxPropertyListView::OnOk(wxCommandEvent& event)
   managedWindow->Close(TRUE);
 }
 
-void wxPropertyListView::OnCancel(wxCommandEvent& event)
+void wxPropertyListView::OnCancel(wxCommandEvent& WXUNUSED(event))
 {
 //  SetReturnCode(wxID_CANCEL);
   managedWindow->Close(TRUE);
   dialogCancelled = TRUE;
 }
 
-void wxPropertyListView::OnHelp(wxCommandEvent& event)
+void wxPropertyListView::OnHelp(wxCommandEvent& WXUNUSED(event))
 {
 }
 
-void wxPropertyListView::OnCheck(wxCommandEvent& event)
+void wxPropertyListView::OnCheck(wxCommandEvent& WXUNUSED(event))
 {
   if (currentProperty)
   {
@@ -718,7 +732,7 @@ void wxPropertyListView::OnCheck(wxCommandEvent& event)
   }
 }
 
-void wxPropertyListView::OnCross(wxCommandEvent& event)
+void wxPropertyListView::OnCross(wxCommandEvent& WXUNUSED(event))
 {
   if (currentProperty && currentValidator)
   {
@@ -732,7 +746,7 @@ void wxPropertyListView::OnCross(wxCommandEvent& event)
   }
 }
 
-void wxPropertyListView::OnPropertyDoubleClick(wxCommandEvent& event)
+void wxPropertyListView::OnPropertyDoubleClick(wxCommandEvent& WXUNUSED(event))
 {
   if (currentProperty && currentValidator)
   {
@@ -746,7 +760,7 @@ void wxPropertyListView::OnPropertyDoubleClick(wxCommandEvent& event)
   }
 }
 
-void wxPropertyListView::OnEdit(wxCommandEvent& event)
+void wxPropertyListView::OnEdit(wxCommandEvent& WXUNUSED(event))
 {
   if (currentProperty && currentValidator)
   {
@@ -783,7 +797,7 @@ wxPropertyListDialog::wxPropertyListDialog(wxPropertyListView *v, wxWindow *pare
      wxDialog(parent, -1, title, pos, size, style, name)
 {
   view = v;
-  view->AssociatePanel(this);
+  view->AssociatePanel( ((wxPanel*)this) );
   view->SetManagedWindow(this);
   SetAutoLayout(TRUE);
 }
@@ -801,7 +815,7 @@ bool wxPropertyListDialog::OnClose(void)
     return FALSE;
 }
 
-void wxPropertyListDialog::OnCancel(wxCommandEvent& event)
+void wxPropertyListDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
 {
        SetReturnCode(wxID_CANCEL);
     this->Close();
@@ -830,6 +844,10 @@ bool wxPropertyListDialog::ProcessEvent(wxEvent& event)
  
 IMPLEMENT_CLASS(wxPropertyListPanel, wxPanel)
 
+BEGIN_EVENT_TABLE(wxPropertyListPanel, wxPanel)
+    EVT_SIZE(wxPropertyListPanel::OnSize)
+END_EVENT_TABLE()
+
 void wxPropertyListPanel::OnDefaultAction(wxControl *item)
 {
 /*
@@ -847,6 +865,11 @@ bool wxPropertyListPanel::ProcessEvent(wxEvent& event)
                return TRUE;
 }
 
+void wxPropertyListPanel::OnSize(wxSizeEvent& WXUNUSED(event))
+{
+    Layout();
+}
+
 /*
  * Property frame
  */
@@ -856,12 +879,18 @@ IMPLEMENT_CLASS(wxPropertyListFrame, wxFrame)
 bool wxPropertyListFrame::OnClose(void)
 {
   if (view)
-    return view->OnClose();
+  {
+    if (propertyPanel)
+        propertyPanel->SetView(NULL);
+    view->OnClose();
+    view = NULL;
+    return TRUE;
+  }
   else
     return FALSE;
 }
 
-wxPanel *wxPropertyListFrame::OnCreatePanel(wxFrame *parent, wxPropertyListView *v)
+wxPropertyListPanel *wxPropertyListFrame::OnCreatePanel(wxFrame *parent, wxPropertyListView *v)
 {
   return new wxPropertyListPanel(v, parent);
 }
@@ -1749,7 +1778,7 @@ bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList
  *
  */
 
-void wxPropertyStringListEditorDialog::OnStrings(wxCommandEvent& event)
+void wxPropertyStringListEditorDialog::OnStrings(wxCommandEvent& WXUNUSED(event))
 {
   int sel = listBox->GetSelection();
   if (sel > -1)
@@ -1760,7 +1789,7 @@ void wxPropertyStringListEditorDialog::OnStrings(wxCommandEvent& event)
   }
 }
 
-void wxPropertyStringListEditorDialog::OnDelete(wxCommandEvent& event)
+void wxPropertyStringListEditorDialog::OnDelete(wxCommandEvent& WXUNUSED(event))
 {
   int sel = listBox->GetSelection();
   if (sel == -1)
@@ -1777,7 +1806,7 @@ void wxPropertyStringListEditorDialog::OnDelete(wxCommandEvent& event)
   stringText->SetValue("");
 }
 
-void wxPropertyStringListEditorDialog::OnAdd(wxCommandEvent& event)
+void wxPropertyStringListEditorDialog::OnAdd(wxCommandEvent& WXUNUSED(event))
 {
   SaveCurrentSelection();
   
@@ -1790,14 +1819,14 @@ void wxPropertyStringListEditorDialog::OnAdd(wxCommandEvent& event)
   stringText->SetFocus();
 }
 
-void wxPropertyStringListEditorDialog::OnOK(wxCommandEvent& event)
+void wxPropertyStringListEditorDialog::OnOK(wxCommandEvent& WXUNUSED(event))
 {
   SaveCurrentSelection();
   EndModal(wxID_OK);
   Close(TRUE);
 }
 
-void wxPropertyStringListEditorDialog::OnCancel(wxCommandEvent& event)
+void wxPropertyStringListEditorDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
 {
   dialogCancelled = TRUE;
   EndModal(wxID_CANCEL);