]> git.saurik.com Git - wxWidgets.git/blobdiff - src/ribbon/bar.cpp
Use the data scheme to load resources in the WebKitGTK+ implementation, rather than...
[wxWidgets.git] / src / ribbon / bar.cpp
index 3aa34770023c4a13f29e79c9e9dc88dc1c920d83..625324fa7d324f8ca57f75b2e8f15558e4018fa8 100644 (file)
     #pragma hdrstop
 #endif
 
     #pragma hdrstop
 #endif
 
-#include "wx/ribbon/bar.h"
-
 #if wxUSE_RIBBON
 
 #if wxUSE_RIBBON
 
+#include "wx/ribbon/bar.h"
 #include "wx/ribbon/art.h"
 #include "wx/dcbuffer.h"
 
 #include "wx/ribbon/art.h"
 #include "wx/dcbuffer.h"
 
@@ -31,7 +30,7 @@
 
 #include "wx/arrimpl.cpp"
 
 
 #include "wx/arrimpl.cpp"
 
-WX_DEFINE_USER_EXPORTED_OBJARRAY(wxRibbonPageTabInfoArray);
+WX_DEFINE_USER_EXPORTED_OBJARRAY(wxRibbonPageTabInfoArray)
 
 wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED, wxRibbonBarEvent);
 wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING, wxRibbonBarEvent);
 
 wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED, wxRibbonBarEvent);
 wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING, wxRibbonBarEvent);
@@ -39,6 +38,7 @@ wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN, wxRibbonBarEvent);
 wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP, wxRibbonBarEvent);
 wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN, wxRibbonBarEvent);
 wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, wxRibbonBarEvent);
 wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP, wxRibbonBarEvent);
 wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN, wxRibbonBarEvent);
 wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, wxRibbonBarEvent);
+wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK, wxRibbonBarEvent);
 
 IMPLEMENT_CLASS(wxRibbonBar, wxRibbonControl)
 IMPLEMENT_DYNAMIC_CLASS(wxRibbonBarEvent, wxNotifyEvent)
 
 IMPLEMENT_CLASS(wxRibbonBar, wxRibbonControl)
 IMPLEMENT_DYNAMIC_CLASS(wxRibbonBarEvent, wxNotifyEvent)
@@ -54,6 +54,7 @@ BEGIN_EVENT_TABLE(wxRibbonBar, wxRibbonControl)
   EVT_PAINT(wxRibbonBar::OnPaint)
   EVT_RIGHT_DOWN(wxRibbonBar::OnMouseRightDown)
   EVT_RIGHT_UP(wxRibbonBar::OnMouseRightUp)
   EVT_PAINT(wxRibbonBar::OnPaint)
   EVT_RIGHT_DOWN(wxRibbonBar::OnMouseRightDown)
   EVT_RIGHT_UP(wxRibbonBar::OnMouseRightUp)
+  EVT_LEFT_DCLICK(wxRibbonBar::OnMouseDoubleClick)
   EVT_SIZE(wxRibbonBar::OnSize)
 END_EVENT_TABLE()
 
   EVT_SIZE(wxRibbonBar::OnSize)
 END_EVENT_TABLE()
 
@@ -66,7 +67,7 @@ void wxRibbonBar::AddPage(wxRibbonPage *page)
     info.hovered = false;
     // info.rect not set (intentional)
 
     info.hovered = false;
     // info.rect not set (intentional)
 
-    wxMemoryDC dcTemp;
+    wxClientDC dcTemp(this);
     wxString label = wxEmptyString;
     if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
         label = page->GetLabel();
     wxString label = wxEmptyString;
     if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
         label = page->GetLabel();
@@ -108,6 +109,14 @@ bool wxRibbonBar::DismissExpandedPanel()
     return m_pages.Item(m_current_page).page->DismissExpandedPanel();
 }
 
     return m_pages.Item(m_current_page).page->DismissExpandedPanel();
 }
 
+void wxRibbonBar::ShowPanels(bool show)
+{
+    m_arePanelsShown = show;
+    SetMinSize(wxSize(GetSize().GetWidth(), DoGetBestSize().GetHeight()));
+    Realise();
+    GetParent()->Layout();
+}
+
 void wxRibbonBar::SetWindowStyleFlag(long style)
 {
     m_flags = style;
 void wxRibbonBar::SetWindowStyleFlag(long style)
 {
     m_flags = style;
@@ -124,7 +133,7 @@ bool wxRibbonBar::Realize()
 {
     bool status = true;
 
 {
     bool status = true;
 
-    wxMemoryDC dcTemp;
+    wxClientDC dcTemp(this);
     int sep = m_art->GetMetric(wxRIBBON_ART_TAB_SEPARATION_SIZE);
     size_t numtabs = m_pages.GetCount();
     size_t i;
     int sep = m_art->GetMetric(wxRIBBON_ART_TAB_SEPARATION_SIZE);
     size_t numtabs = m_pages.GetCount();
     size_t i;
@@ -210,9 +219,9 @@ void wxRibbonBar::OnMouseMove(wxMouseEvent& evt)
     if(m_tab_scroll_buttons_shown)
     {
 #define SET_FLAG(variable, flag) \
     if(m_tab_scroll_buttons_shown)
     {
 #define SET_FLAG(variable, flag) \
-    { if(((variable) & (flag)) != (flag)) variable |= (flag), refresh_tabs = true; }
+    { if(((variable) & (flag)) != (flag)) { variable |= (flag); refresh_tabs = true; }}
 #define UNSET_FLAG(variable, flag) \
 #define UNSET_FLAG(variable, flag) \
-    { if((variable) & (flag)) variable &= ~(flag), refresh_tabs = true; }
+    { if((variable) & (flag)) { variable &= ~(flag); refresh_tabs = true; }}
 
         if(m_tab_scroll_left_button_rect.Contains(x, y))
             SET_FLAG(m_tab_scroll_left_button_state, wxRIBBON_SCROLL_BTN_HOVERED)
 
         if(m_tab_scroll_left_button_rect.Contains(x, y))
             SET_FLAG(m_tab_scroll_left_button_state, wxRIBBON_SCROLL_BTN_HOVERED)
@@ -377,7 +386,7 @@ void wxRibbonBar::RecalculateTabSizes()
             m_tab_scroll_buttons_shown = true;
         }
         {
             m_tab_scroll_buttons_shown = true;
         }
         {
-            wxMemoryDC temp_dc;
+            wxClientDC temp_dc(this);
             m_tab_scroll_left_button_rect.SetWidth(m_art->GetScrollButtonMinimumSize(temp_dc, this, wxRIBBON_SCROLL_BTN_LEFT | wxRIBBON_SCROLL_BTN_NORMAL | wxRIBBON_SCROLL_BTN_FOR_TABS).GetWidth());
             m_tab_scroll_left_button_rect.SetHeight(m_tab_height);
             m_tab_scroll_left_button_rect.SetX(m_tab_margin_left);
             m_tab_scroll_left_button_rect.SetWidth(m_art->GetScrollButtonMinimumSize(temp_dc, this, wxRIBBON_SCROLL_BTN_LEFT | wxRIBBON_SCROLL_BTN_NORMAL | wxRIBBON_SCROLL_BTN_FOR_TABS).GetWidth());
             m_tab_scroll_left_button_rect.SetHeight(m_tab_height);
             m_tab_scroll_left_button_rect.SetX(m_tab_margin_left);
@@ -537,6 +546,7 @@ wxRibbonBar::wxRibbonBar()
     m_tab_scroll_left_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
     m_tab_scroll_right_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
     m_tab_scroll_buttons_shown = false;
     m_tab_scroll_left_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
     m_tab_scroll_right_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
     m_tab_scroll_buttons_shown = false;
+    m_arePanelsShown = true;
 }
 
 wxRibbonBar::wxRibbonBar(wxWindow* parent,
 }
 
 wxRibbonBar::wxRibbonBar(wxWindow* parent,
@@ -584,6 +594,7 @@ void wxRibbonBar::CommonInit(long style)
     m_tab_scroll_left_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
     m_tab_scroll_right_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
     m_tab_scroll_buttons_shown = false;
     m_tab_scroll_left_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
     m_tab_scroll_right_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
     m_tab_scroll_buttons_shown = false;
+    m_arePanelsShown = true;
 
     if(m_art == NULL)
     {
 
     if(m_art == NULL)
     {
@@ -846,7 +857,7 @@ void wxRibbonBar::ScrollTabBar(int amount)
     if(show_right != (m_tab_scroll_right_button_rect.GetWidth() != 0) ||
         show_left != (m_tab_scroll_left_button_rect.GetWidth() != 0))
     {
     if(show_right != (m_tab_scroll_right_button_rect.GetWidth() != 0) ||
         show_left != (m_tab_scroll_left_button_rect.GetWidth() != 0))
     {
-        wxMemoryDC temp_dc;
+        wxClientDC temp_dc(this);
         if(show_left)
         {
             m_tab_scroll_left_button_rect.SetWidth(m_art->GetScrollButtonMinimumSize(temp_dc, this, wxRIBBON_SCROLL_BTN_LEFT | wxRIBBON_SCROLL_BTN_NORMAL | wxRIBBON_SCROLL_BTN_FOR_TABS).GetWidth());
         if(show_left)
         {
             m_tab_scroll_left_button_rect.SetWidth(m_art->GetScrollButtonMinimumSize(temp_dc, this, wxRIBBON_SCROLL_BTN_LEFT | wxRIBBON_SCROLL_BTN_NORMAL | wxRIBBON_SCROLL_BTN_FOR_TABS).GetWidth());
@@ -903,6 +914,11 @@ void wxRibbonBar::OnMouseRightUp(wxMouseEvent& evt)
     DoMouseButtonCommon(evt, wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP);
 }
 
     DoMouseButtonCommon(evt, wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP);
 }
 
+void wxRibbonBar::OnMouseDoubleClick(wxMouseEvent& evt)
+{
+    DoMouseButtonCommon(evt, wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK);
+}
+
 void wxRibbonBar::DoMouseButtonCommon(wxMouseEvent& evt, wxEventType tab_event_type)
 {
     wxRibbonPageTabInfo *tab = HitTestTabs(evt.GetPosition());
 void wxRibbonBar::DoMouseButtonCommon(wxMouseEvent& evt, wxEventType tab_event_type)
 {
     wxRibbonPageTabInfo *tab = HitTestTabs(evt.GetPosition());
@@ -940,7 +956,7 @@ void wxRibbonBar::RecalculateMinSize()
     }
 
     m_minWidth = min_size.GetWidth();
     }
 
     m_minWidth = min_size.GetWidth();
-    m_minHeight = min_size.GetHeight();
+    m_minHeight = m_arePanelsShown ? min_size.GetHeight() : m_tab_height;
 }
 
 wxSize wxRibbonBar::DoGetBestSize() const
 }
 
 wxSize wxRibbonBar::DoGetBestSize() const
@@ -958,6 +974,10 @@ wxSize wxRibbonBar::DoGetBestSize() const
     {
         best.IncBy(0, m_tab_height);
     }
     {
         best.IncBy(0, m_tab_height);
     }
+    if(!m_arePanelsShown)
+    {
+        best.SetHeight(m_tab_height);
+    }
     return best;
 }
 
     return best;
 }