X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6f7e96d8432dc78bd9b0fa7db78090ca6d8cc04c..c5453c7956e115a1e7290f01cbbd730a5d8f3448:/src/ribbon/gallery.cpp diff --git a/src/ribbon/gallery.cpp b/src/ribbon/gallery.cpp index 6d7c300e92..926f0cdc3e 100644 --- a/src/ribbon/gallery.cpp +++ b/src/ribbon/gallery.cpp @@ -30,9 +30,9 @@ #include "wx/msw/private.h" #endif -wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED, wxRibbonGalleryEvent); -wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONGALLERY_SELECTED, wxRibbonGalleryEvent); -wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONGALLERY_CLICKED, wxRibbonGalleryEvent); +wxDEFINE_EVENT(wxEVT_RIBBONGALLERY_HOVER_CHANGED, wxRibbonGalleryEvent); +wxDEFINE_EVENT(wxEVT_RIBBONGALLERY_SELECTED, wxRibbonGalleryEvent); +wxDEFINE_EVENT(wxEVT_RIBBONGALLERY_CLICKED, wxRibbonGalleryEvent); IMPLEMENT_DYNAMIC_CLASS(wxRibbonGalleryEvent, wxCommandEvent) IMPLEMENT_CLASS(wxRibbonGallery, wxRibbonControl) @@ -76,6 +76,7 @@ BEGIN_EVENT_TABLE(wxRibbonGallery, wxRibbonControl) EVT_LEAVE_WINDOW(wxRibbonGallery::OnMouseLeave) EVT_LEFT_DOWN(wxRibbonGallery::OnMouseDown) EVT_LEFT_UP(wxRibbonGallery::OnMouseUp) + EVT_LEFT_DCLICK(wxRibbonGallery::OnMouseDClick) EVT_MOTION(wxRibbonGallery::OnMouseMove) EVT_PAINT(wxRibbonGallery::OnPaint) EVT_SIZE(wxRibbonGallery::OnSize) @@ -196,7 +197,7 @@ void wxRibbonGallery::OnMouseMove(wxMouseEvent& evt) { m_hovered_item = hovered_item; wxRibbonGalleryEvent notification( - wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED, GetId()); + wxEVT_RIBBONGALLERY_HOVER_CHANGED, GetId()); notification.SetEventObject(this); notification.SetGallery(this); notification.SetGalleryItem(hovered_item); @@ -250,7 +251,7 @@ void wxRibbonGallery::OnMouseLeave(wxMouseEvent& WXUNUSED(evt)) { m_hovered_item = NULL; wxRibbonGalleryEvent notification( - wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED, GetId()); + wxEVT_RIBBONGALLERY_HOVER_CHANGED, GetId()); notification.SetEventObject(this); notification.SetGallery(this); ProcessWindowEvent(notification); @@ -340,7 +341,7 @@ void wxRibbonGallery::OnMouseUp(wxMouseEvent& evt) else if(m_mouse_active_rect == &m_extension_button_rect) { m_extension_button_state = wxRIBBON_GALLERY_BUTTON_HOVERED; - wxCommandEvent notification(wxEVT_COMMAND_BUTTON_CLICKED, + wxCommandEvent notification(wxEVT_BUTTON, GetId()); notification.SetEventObject(this); ProcessWindowEvent(notification); @@ -351,7 +352,7 @@ void wxRibbonGallery::OnMouseUp(wxMouseEvent& evt) { m_selected_item = m_active_item; wxRibbonGalleryEvent notification( - wxEVT_COMMAND_RIBBONGALLERY_SELECTED, GetId()); + wxEVT_RIBBONGALLERY_SELECTED, GetId()); notification.SetEventObject(this); notification.SetGallery(this); notification.SetGalleryItem(m_selected_item); @@ -359,7 +360,7 @@ void wxRibbonGallery::OnMouseUp(wxMouseEvent& evt) } wxRibbonGalleryEvent notification( - wxEVT_COMMAND_RIBBONGALLERY_CLICKED, GetId()); + wxEVT_RIBBONGALLERY_CLICKED, GetId()); notification.SetEventObject(this); notification.SetGallery(this); notification.SetGalleryItem(m_selected_item); @@ -372,6 +373,15 @@ void wxRibbonGallery::OnMouseUp(wxMouseEvent& evt) } } +void wxRibbonGallery::OnMouseDClick(wxMouseEvent& evt) +{ + // The 2nd click of a double-click should be handled as a click in the + // same way as the 1st click of the double-click. This is useful for + // scrolling through the gallery. + OnMouseDown(evt); + OnMouseUp(evt); +} + void wxRibbonGallery::SetItemClientObject(wxRibbonGalleryItem* itm, wxClientData* data) { @@ -398,14 +408,31 @@ bool wxRibbonGallery::ScrollLines(int lines) if(m_scroll_limit == 0 || m_art == NULL) return false; + return ScrollPixels(lines * GetScrollLineSize()); +} + +int wxRibbonGallery::GetScrollLineSize() const +{ + if(m_art == NULL) + return 32; + int line_size = m_bitmap_padded_size.GetHeight(); if(m_art->GetFlags() & wxRIBBON_BAR_FLOW_VERTICAL) line_size = m_bitmap_padded_size.GetWidth(); - if(lines < 0) + + return line_size; +} + +bool wxRibbonGallery::ScrollPixels(int pixels) +{ + if(m_scroll_limit == 0 || m_art == NULL) + return false; + + if(pixels < 0) { if(m_scroll_amount > 0) { - m_scroll_amount += lines * line_size; + m_scroll_amount += pixels; if(m_scroll_amount <= 0) { m_scroll_amount = 0; @@ -418,11 +445,11 @@ bool wxRibbonGallery::ScrollLines(int lines) return true; } } - else if(lines > 0) + else if(pixels > 0) { if(m_scroll_amount < m_scroll_limit) { - m_scroll_amount += lines * line_size; + m_scroll_amount += pixels; if(m_scroll_amount >= m_scroll_limit) { m_scroll_amount = m_scroll_limit;