]> git.saurik.com Git - wxWidgets.git/commitdiff
Implemented Mac-style button toggling within wxButtonToolBar, and line
authorJulian Smart <julian@anthemion.co.uk>
Fri, 14 Apr 2006 12:40:34 +0000 (12:40 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Fri, 14 Apr 2006 12:40:34 +0000 (12:40 +0000)
under toolbar.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38710 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/generic/buttonbar.h
include/wx/mac/carbon/chkconf.h
samples/dialogs/dialogs.cpp
src/generic/buttonbar.cpp
src/generic/toolbkg.cpp

index 7d339e6eae4b87a8a33611492d72b556156992bb..96e83491a9c2e38030bf338567326283c18f2a0b 100644 (file)
@@ -90,6 +90,9 @@ protected:
     // receives button commands
     void OnCommand(wxCommandEvent& event);
 
     // receives button commands
     void OnCommand(wxCommandEvent& event);
 
+    // paints a border
+    void OnPaint(wxPaintEvent& event);
+
 private:
     // have we calculated the positions of our tools?
     bool m_needsLayout;
 private:
     // have we calculated the positions of our tools?
     bool m_needsLayout;
index f9c630775e34105c0e0f39d387ce321a00075655..a7759ef6f32a6b6b9b75a2106559bf7ba44534ef 100644 (file)
@@ -39,7 +39,7 @@
  */
 
 #ifndef wxMAC_USE_NATIVE_TOOLBAR
  */
 
 #ifndef wxMAC_USE_NATIVE_TOOLBAR
-    #define wxMAC_USE_NATIVE_TOOLBAR 0
+    #define wxMAC_USE_NATIVE_TOOLBAR 1
 #endif
 
 #endif
 #endif
 
 #endif
index 8a7e4e8b6e297535d70e11cc6e7b7eeda860b22a..14bfa3554976034576acc5e43f2bbf6ca544c65c 100644 (file)
@@ -1420,9 +1420,11 @@ SettingsDialog::SettingsDialog(wxWindow* win, int dialogType)
     int tabImage2 = -1;
     
     bool useToolBook = (dialogType == DIALOGS_PROPERTY_SHEET_TOOLBOOK || dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK);
     int tabImage2 = -1;
     
     bool useToolBook = (dialogType == DIALOGS_PROPERTY_SHEET_TOOLBOOK || dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK);
+    int resizeBorder = wxRESIZE_BORDER;
 
     if (useToolBook)
     {
 
     if (useToolBook)
     {
+        resizeBorder = 0;
         tabImage1 = 0;
         tabImage2 = 1;
         
         tabImage1 = 0;
         tabImage2 = 1;
         
@@ -1433,6 +1435,8 @@ SettingsDialog::SettingsDialog(wxWindow* win, int dialogType)
             sheetStyle |= wxPROPSHEET_TOOLBOOK;
             
         SetSheetStyle(sheetStyle);
             sheetStyle |= wxPROPSHEET_TOOLBOOK;
             
         SetSheetStyle(sheetStyle);
+        SetSheetInnerBorder(0);
+        SetSheetOuterBorder(0);
 
         // create a dummy image list with a few icons
         const wxSize imageSize(32, 32);
 
         // create a dummy image list with a few icons
         const wxSize imageSize(32, 32);
@@ -1453,7 +1457,7 @@ SettingsDialog::SettingsDialog(wxWindow* win, int dialogType)
     Create(win, wxID_ANY, _("Preferences"), wxDefaultPosition, wxDefaultSize,
         wxDEFAULT_DIALOG_STYLE
 #ifndef __WXWINCE__
     Create(win, wxID_ANY, _("Preferences"), wxDefaultPosition, wxDefaultSize,
         wxDEFAULT_DIALOG_STYLE
 #ifndef __WXWINCE__
-        |wxRESIZE_BORDER
+        |resizeBorder
 #endif
     );
 
 #endif
     );
 
index 47308b318940b274144cb7103333085fc8a49801..c632ec8ca3167bbaf84cafcea40145a2c779c603 100644 (file)
@@ -37,6 +37,8 @@
 #include "wx/frame.h"
 #include "wx/image.h"
 #include "wx/log.h"
 #include "wx/frame.h"
 #include "wx/image.h"
 #include "wx/log.h"
+#include "wx/settings.h"
+#include "wx/dcclient.h"
 
 // ----------------------------------------------------------------------------
 // wxButtonToolBarTool: our implementation of wxToolBarToolBase
 
 // ----------------------------------------------------------------------------
 // wxButtonToolBarTool: our implementation of wxToolBarToolBase
@@ -96,6 +98,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxButtonToolBar, wxControl)
 
 BEGIN_EVENT_TABLE(wxButtonToolBar, wxControl)
     EVT_BUTTON(wxID_ANY, wxButtonToolBar::OnCommand)
 
 BEGIN_EVENT_TABLE(wxButtonToolBar, wxControl)
     EVT_BUTTON(wxID_ANY, wxButtonToolBar::OnCommand)
+    EVT_PAINT(wxButtonToolBar::OnPaint)
 END_EVENT_TABLE()
 
 // ----------------------------------------------------------------------------
 END_EVENT_TABLE()
 
 // ----------------------------------------------------------------------------
@@ -111,7 +114,10 @@ void wxButtonToolBar::Init()
     m_widthSeparator = wxDefaultCoord;
 
     m_maxWidth =
     m_widthSeparator = wxDefaultCoord;
 
     m_maxWidth =
-    m_maxHeight = 0;
+        m_maxHeight = 0;
+
+    SetMargins(8, 4);
+    SetToolPacking(5);
 }
 
 bool wxButtonToolBar::Create(wxWindow *parent,
 }
 
 bool wxButtonToolBar::Create(wxWindow *parent,
@@ -127,6 +133,9 @@ bool wxButtonToolBar::Create(wxWindow *parent,
         return false;
     }
 
         return false;
     }
 
+    // TODO: get the correct colour from the system
+    wxColour lightBackground(240, 240, 240);
+    SetBackgroundColour(lightBackground);
     return true;
 }
 
     return true;
 }
 
@@ -362,7 +371,7 @@ void wxButtonToolBar::DoLayout()
             if (!tool->GetButton())
             {
                 wxBitmapButton* bmpButton = new wxBitmapButton(this, tool->GetId(), tool->GetNormalBitmap(), wxPoint(tool->m_x, tool->m_y), wxDefaultSize,
             if (!tool->GetButton())
             {
                 wxBitmapButton* bmpButton = new wxBitmapButton(this, tool->GetId(), tool->GetNormalBitmap(), wxPoint(tool->m_x, tool->m_y), wxDefaultSize,
-                    wxBU_AUTODRAW);
+                    wxBU_AUTODRAW|wxBORDER_NONE);
                 
                 tool->SetButton(bmpButton);
             }
                 
                 tool->SetButton(bmpButton);
             }
@@ -404,6 +413,10 @@ void wxButtonToolBar::DoLayout()
     // calculate the total toolbar size
     m_maxWidth = x + 2*m_xMargin;
     m_maxHeight = maxHeight + 2*m_yMargin;
     // calculate the total toolbar size
     m_maxWidth = x + 2*m_xMargin;
     m_maxHeight = maxHeight + 2*m_yMargin;
+
+    if ((GetWindowStyle() & wxTB_NODIVIDER) == 0)
+        m_maxHeight += 2;
+
 }
 
 wxSize wxButtonToolBar::DoGetBestClientSize() const
 }
 
 wxSize wxButtonToolBar::DoGetBestClientSize() const
@@ -421,8 +434,51 @@ void wxButtonToolBar::OnCommand(wxCommandEvent& event)
         return;
     }
 
         return;
     }
 
+    if (tool->CanBeToggled())
+        tool->Toggle(tool->IsToggled());
+
     // TODO: handle toggle items
     // TODO: handle toggle items
-    OnLeftClick(event.GetId(), false);    
+    OnLeftClick(event.GetId(), false);
+
+    if (tool->GetKind() == wxITEM_RADIO)
+        UnToggleRadioGroup(tool);
+
+    if (tool->CanBeToggled())
+        Refresh();
+}
+
+// paints a border
+void wxButtonToolBar::OnPaint(wxPaintEvent& event)
+{
+    wxPaintDC dc(this);
+
+    for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
+          node;
+          node = node->GetNext() )
+    {
+        wxButtonToolBarTool *tool =  (wxButtonToolBarTool*) node->GetData();
+        if (tool->IsToggled())
+        {
+            wxRect rectTool = GetToolRect(tool);
+            rectTool.y = 0; rectTool.height = GetClientSize().y;
+            wxBrush brush(wxColour(220, 220, 220));
+            wxPen pen(*wxLIGHT_GREY);
+            dc.SetBrush(brush);
+            dc.SetPen(pen);
+            dc.DrawRectangle(rectTool);
+        }
+    }
+
+    if ((GetWindowStyle() & wxTB_NODIVIDER) == 0)
+    {
+        wxPen pen(*wxLIGHT_GREY);
+        dc.SetPen(pen);
+        int x1 = 0;
+        int y1 = GetClientSize().y-1;
+        int x2 = GetClientSize().x;
+        int y2 = y1;
+        dc.DrawLine(x1, y1, x2, y2);
+    }
 }
 
 #endif // wxUSE_TOOLBAR && wxUSE_BMPBUTTON
 }
 
 #endif // wxUSE_TOOLBAR && wxUSE_BMPBUTTON
index a88ea5fd9c5a63acd1232db28e2307871e6d456a..abc941aef662e6b91cc31d9f74a4b7d01445d1f4 100644 (file)
@@ -103,7 +103,7 @@ bool wxToolbook::Create(wxWindow *parent,
                     wxID_TOOLBOOKTOOLBAR,
                     wxDefaultPosition,
                     wxDefaultSize,
                     wxID_TOOLBOOKTOOLBAR,
                     wxDefaultPosition,
                     wxDefaultSize,
-                    orient|wxTB_TEXT|wxTB_FLAT|wxTB_NODIVIDER|wxNO_BORDER
+                    orient|wxTB_TEXT|wxTB_FLAT|wxNO_BORDER
                  );
     }
     else
                  );
     }
     else
@@ -353,7 +353,7 @@ bool wxToolbook::InsertPage(size_t n,
 
     if (bSelect)
     {
 
     if (bSelect)
     {
-        // GetToolBar()->ToggleTool(n, true);
+        GetToolBar()->ToggleTool(n, true);
         m_selection = n;
     }
     else
         m_selection = n;
     }
     else