]> git.saurik.com Git - wxWidgets.git/blobdiff - src/aui/auibook.cpp
fixed wxOverlay to handle wxWindowDC/wxClientDC in the same way wxMac does
[wxWidgets.git] / src / aui / auibook.cpp
index 0bff20b468e59ec353fc4c88a00f1b090f52a666..c9dd3278738657b9c9ae5e75e6e184a2cb95d24e 100644 (file)
@@ -179,6 +179,11 @@ private:
      0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFE, 0x03, 0xF8, 0x01, 0xF0, 0x19, 0xF3,
      0xB8, 0xE3, 0xF0, 0xE1, 0xE0, 0xE0, 0xF0, 0xE1, 0xB8, 0xE3, 0x19, 0xF3,
      0x01, 0xF0, 0x03, 0xF8, 0x0F, 0xFE, 0xFF, 0xFF };
+#elif defined( __WXGTK__)       
+ static unsigned char close_bits[]={    
+     0xff, 0xff, 0xff, 0xff, 0x07, 0xf0, 0xfb, 0xef, 0xdb, 0xed, 0x8b, 0xe8,    
+     0x1b, 0xec, 0x3b, 0xee, 0x1b, 0xec, 0x8b, 0xe8, 0xdb, 0xed, 0xfb, 0xef,    
+     0x07, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };          
 #else
  static unsigned char close_bits[]={
      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xf3, 0xcf, 0xf9,
@@ -1398,6 +1403,9 @@ void wxAuiTabContainer::SetTabOffset(size_t offset)
 // provide custom drawing capabilities
 void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd)
 {
+    if (!raw_dc || !raw_dc->IsOk())
+        return;
+
     wxMemoryDC dc;
     wxBitmap bmp;
     size_t i;
@@ -1408,6 +1416,8 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd)
     bmp.Create(m_rect.GetWidth(), m_rect.GetHeight());
     dc.SelectObject(bmp);
 
+    if (!dc.IsOk())
+        return;
 
     // find out if size of tabs is larger than can be
     // afforded on screen
@@ -1731,7 +1741,9 @@ bool wxAuiTabContainer::ButtonHitTest(int x, int y,
     for (i = 0; i < button_count; ++i)
     {
         wxAuiTabContainerButton& button = m_buttons.Item(i);
-        if (button.rect.Contains(x,y))
+        if (button.rect.Contains(x,y) &&
+            !(button.cur_state & (wxAUI_BUTTON_STATE_HIDDEN |
+                                   wxAUI_BUTTON_STATE_DISABLED)))
         {
             if (hit)
                 *hit = &button;
@@ -1743,7 +1755,9 @@ bool wxAuiTabContainer::ButtonHitTest(int x, int y,
     for (i = 0; i < button_count; ++i)
     {
         wxAuiTabContainerButton& button = m_tab_close_buttons.Item(i);
-        if (button.rect.Contains(x,y))
+        if (button.rect.Contains(x,y) &&
+            !(button.cur_state & (wxAUI_BUTTON_STATE_HIDDEN |
+                                   wxAUI_BUTTON_STATE_DISABLED)))
         {
             if (hit)
                 *hit = &button;
@@ -1829,6 +1843,7 @@ wxAuiTabCtrl::wxAuiTabCtrl(wxWindow* parent,
     m_click_pt = wxDefaultPosition;
     m_is_dragging = false;
     m_hover_button = NULL;
+    m_pressed_button = NULL;
 }
 
 wxAuiTabCtrl::~wxAuiTabCtrl()
@@ -1862,6 +1877,8 @@ void wxAuiTabCtrl::OnLeftDown(wxMouseEvent& evt)
     m_click_pt = wxDefaultPosition;
     m_is_dragging = false;
     m_click_tab = NULL;
+    m_pressed_button = NULL;
+
 
     wxWindow* wnd;
     if (TabHitTest(evt.m_x, evt.m_y, &wnd))
@@ -1876,16 +1893,17 @@ void wxAuiTabCtrl::OnLeftDown(wxMouseEvent& evt)
         m_click_pt.y = evt.m_y;
         m_click_tab = wnd;
     }
-
+    
     if (m_hover_button)
     {
-        m_hover_button->cur_state = wxAUI_BUTTON_STATE_PRESSED;
+        m_pressed_button = m_hover_button;
+        m_pressed_button->cur_state = wxAUI_BUTTON_STATE_PRESSED;
         Refresh();
         Update();
     }
 }
 
-void wxAuiTabCtrl::OnLeftUp(wxMouseEvent&)
+void wxAuiTabCtrl::OnLeftUp(wxMouseEvent& evt)
 {
     if (GetCapture() == this)
         ReleaseMouse();
@@ -1900,19 +1918,31 @@ void wxAuiTabCtrl::OnLeftUp(wxMouseEvent&)
         return;
     }
 
-    if (m_hover_button)
+    if (m_pressed_button)
     {
-        m_hover_button->cur_state = wxAUI_BUTTON_STATE_HOVER;
+        // make sure we're still clicking the button
+        wxAuiTabContainerButton* button = NULL;
+        if (!ButtonHitTest(evt.m_x, evt.m_y, &button))
+            return;
+            
+        if (button != m_pressed_button)
+        {
+            m_pressed_button = NULL;
+            return;
+        }
+
         Refresh();
         Update();
 
-        if (!(m_hover_button->cur_state & wxAUI_BUTTON_STATE_DISABLED))
+        if (!(m_pressed_button->cur_state & wxAUI_BUTTON_STATE_DISABLED))
         {
             wxAuiNotebookEvent evt(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, m_windowId);
-            evt.SetInt(m_hover_button->id);
+            evt.SetInt(m_pressed_button->id);
             evt.SetEventObject(this);
             GetEventHandler()->ProcessEvent(evt);
         }
+        
+        m_pressed_button = NULL;
     }
 
     m_click_pt = wxDefaultPosition;
@@ -2703,8 +2733,12 @@ void wxAuiNotebook::OnTabDragMotion(wxCommandEvent& evt)
     {
         wxWindow* tab_ctrl = ::wxFindWindowAtPoint(screen_pt);
         
+        // if we aren't over any window, stop here
+        if (!tab_ctrl)
+            return;
+            
         // make sure we are not over the hint window
-        if (tab_ctrl && !tab_ctrl->IsKindOf(CLASSINFO(wxFrame)))
+        if (!tab_ctrl->IsKindOf(CLASSINFO(wxFrame)))
         {
             while (tab_ctrl)
             {
@@ -2719,12 +2753,20 @@ void wxAuiNotebook::OnTabDragMotion(wxCommandEvent& evt)
                 
                 if (nb != this)
                 {
-                    wxRect hint_rect = tab_ctrl->GetRect();
+                    wxRect hint_rect = tab_ctrl->GetClientRect();
                     tab_ctrl->ClientToScreen(&hint_rect.x, &hint_rect.y);
                     m_mgr.ShowHint(hint_rect);
                     return;
                 }
-                
+            }
+        }
+         else
+        {
+            if (!dest_tabs)
+            {
+                // we are either over a hint window, or not over a tab
+                // window, and there is no where to drag to, so exit
+                return;
             }
         }
     }