]> git.saurik.com Git - wxWidgets.git/blobdiff - src/ribbon/gallery.cpp
Use Unix EOL format for the new files.
[wxWidgets.git] / src / ribbon / gallery.cpp
index 0a1aa02d0359421e0c8e9bff09ba51e18dc35b71..6d7c300e9254cb9262827308d609dcbb50f9185b 100644 (file)
     #pragma hdrstop
 #endif
 
-#include "wx/ribbon/gallery.h"
-
 #if wxUSE_RIBBON
 
+#include "wx/ribbon/gallery.h"
 #include "wx/ribbon/art.h"
 #include "wx/ribbon/bar.h"
 #include "wx/dcbuffer.h"
@@ -33,6 +32,7 @@
 
 wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED, wxRibbonGalleryEvent);
 wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONGALLERY_SELECTED, wxRibbonGalleryEvent);
+wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONGALLERY_CLICKED, wxRibbonGalleryEvent);
 
 IMPLEMENT_DYNAMIC_CLASS(wxRibbonGalleryEvent, wxCommandEvent)
 IMPLEMENT_CLASS(wxRibbonGallery, wxRibbonControl)
@@ -357,6 +357,13 @@ void wxRibbonGallery::OnMouseUp(wxMouseEvent& evt)
                     notification.SetGalleryItem(m_selected_item);
                     ProcessWindowEvent(notification);
                 }
+
+                wxRibbonGalleryEvent notification(
+                    wxEVT_COMMAND_RIBBONGALLERY_CLICKED, GetId());
+                notification.SetEventObject(this);
+                notification.SetGallery(this);
+                notification.SetGalleryItem(m_selected_item);
+                ProcessWindowEvent(notification);
             }
         }
         m_mouse_active_rect = NULL;
@@ -436,10 +443,20 @@ void wxRibbonGallery::EnsureVisible(const wxRibbonGalleryItem* item)
     if(item == NULL || !item->IsVisible() || IsEmpty())
         return;
 
-    int y = item->GetPosition().GetTop();
-    int base_y = m_items.Item(0)->GetPosition().GetTop();
-    int delta = y - base_y - m_scroll_amount;
-    ScrollLines(delta / m_bitmap_padded_size.GetHeight());
+    if(m_art->GetFlags() & wxRIBBON_BAR_FLOW_VERTICAL)
+    {
+        int x = item->GetPosition().GetLeft();
+        int base_x = m_items.Item(0)->GetPosition().GetLeft();
+        int delta = x - base_x - m_scroll_amount;
+        ScrollLines(delta / m_bitmap_padded_size.GetWidth());
+    }
+    else
+    {
+        int y = item->GetPosition().GetTop();
+        int base_y = m_items.Item(0)->GetPosition().GetTop();
+        int delta = y - base_y - m_scroll_amount;
+        ScrollLines(delta / m_bitmap_padded_size.GetHeight());
+    }
 }
 
 bool wxRibbonGallery::IsHovered() const