]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/notebook.cpp
Added intermediate state (m_showOnIdle) indicating that
[wxWidgets.git] / src / msw / notebook.cpp
index 4792bbef1cdb2f1953be602be30841f7533b82c7..a7fcdfa20261e770a221b02a2c705c6563b3bd76 100644 (file)
 
 #if wxUSE_NOTEBOOK
 
-// wxWidgets
+#include  "wx/notebook.h"
+
 #ifndef WX_PRECOMP
-  #include  "wx/string.h"
-  #include  "wx/dc.h"
+    #include  "wx/string.h"
+    #include  "wx/dc.h"
+    #include  "wx/log.h"
+    #include  "wx/event.h"
+    #include  "wx/app.h"
+    #include  "wx/dcclient.h"
+    #include  "wx/dcmemory.h"
+    #include  "wx/control.h"
 #endif  // WX_PRECOMP
 
-#include  "wx/log.h"
 #include  "wx/imaglist.h"
-#include  "wx/event.h"
-#include  "wx/control.h"
-#include  "wx/notebook.h"
-#include  "wx/app.h"
 #include  "wx/sysopt.h"
-#include  "wx/dcclient.h"
-#include  "wx/dcmemory.h"
 
 #include  "wx/msw/private.h"
 
 #include  <windowsx.h>
-
-#include <commctrl.h>
-
 #include "wx/msw/winundef.h"
 
+// include <commctrl.h> "properly"
+#include "wx/msw/wrapcctl.h"
+
 #if wxUSE_UXTHEME
     #include "wx/msw/uxtheme.h"
 #endif
@@ -268,6 +268,15 @@ bool wxNotebook::Create(wxWindow *parent,
                         long style,
                         const wxString& name)
 {
+    if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
+    {
+#if defined(__POCKETPC__)
+        style |= wxBK_BOTTOM | wxNB_FLAT;
+#else
+        style |= wxBK_TOP;
+#endif
+    }
+
 #ifdef __WXWINCE__
     // Not sure why, but without this style, there is no border
     // around the notebook tabs.
@@ -275,14 +284,14 @@ bool wxNotebook::Create(wxWindow *parent,
         style |= wxBORDER_SUNKEN;
 #endif
 
-#if !wxUSE_UXTHEME 
+#if !wxUSE_UXTHEME
     // ComCtl32 notebook tabs simply don't work unless they're on top if we have uxtheme, we can
     // work around it later (after control creation), but if we don't have uxtheme, we have to clear
     // those styles
     const int verComCtl32 = wxApp::GetComCtl32Version();
     if ( verComCtl32 == 600 )
     {
-        style &= ~(wxNB_BOTTOM | wxNB_LEFT | wxNB_RIGHT);
+        style &= ~(wxBK_BOTTOM | wxBK_LEFT | wxBK_RIGHT);
     }
 #endif //wxUSE_UXTHEME
 
@@ -345,17 +354,17 @@ bool wxNotebook::Create(wxWindow *parent,
         // create backing store
         UpdateBgBrush();
     }
-    
+
     // comctl32.dll 6.0 doesn't support non-top tabs with visual styles (the
     // control is simply not rendered correctly), so we disable themes
     // if possible, otherwise we simply clear the styles.
     // It's probably not possible to have UXTHEME without ComCtl32 6 or better, but lets
     // check it anyway.
     const int verComCtl32 = wxApp::GetComCtl32Version();
-    if ( verComCtl32 == 600 ) 
+    if ( verComCtl32 == 600 )
     {
         // check if we use themes at all -- if we don't, we're still okay
-        if ( wxUxThemeEngine::GetIfActive() && (style & (wxNB_BOTTOM|wxNB_LEFT|wxNB_RIGHT)))
+        if ( wxUxThemeEngine::GetIfActive() && (style & (wxBK_BOTTOM|wxBK_LEFT|wxBK_RIGHT)))
         {
             wxUxThemeEngine::GetIfActive()->SetWindowTheme((HWND)this->GetHandle(), L"", L"");
             SetBackgroundColour(GetThemeBackgroundColour());    //correct the background color for the new non-themed control
@@ -585,26 +594,29 @@ void wxNotebook::SetTabSize(const wxSize& sz)
 
 wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
 {
+    // we can't use TabCtrl_AdjustRect here because it only works for wxNB_TOP
     wxSize sizeTotal = sizePage;
 
-    // We need to make getting tab size part of the wxWidgets API.
     wxSize tabSize;
-    if (GetPageCount() > 0)
+    if ( GetPageCount() > 0 )
     {
         RECT rect;
-        TabCtrl_GetItemRect((HWND) GetHWND(), 0, & rect);
+        TabCtrl_GetItemRect(GetHwnd(), 0, &rect);
         tabSize.x = rect.right - rect.left;
         tabSize.y = rect.bottom - rect.top;
     }
-    if ( HasFlag(wxBK_LEFT) || HasFlag(wxBK_RIGHT) )
+
+    // add an extra margin in both directions
+    const int MARGIN = 8;
+    if ( IsVertical() )
     {
-        sizeTotal.x += tabSize.x + 7;
-        sizeTotal.y += 7;
+        sizeTotal.x += MARGIN;
+        sizeTotal.y += tabSize.y + MARGIN;
     }
-    else
+    else // horizontal layout
     {
-        sizeTotal.x += 7;
-        sizeTotal.y += tabSize.y + 7;
+        sizeTotal.x += tabSize.x + MARGIN;
+        sizeTotal.y += MARGIN;
     }
 
     return sizeTotal;
@@ -802,13 +814,15 @@ int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
         *flags = 0;
 
         if ((hitTestInfo.flags & TCHT_NOWHERE) == TCHT_NOWHERE)
-            *flags |= wxNB_HITTEST_NOWHERE;
+            *flags |= wxBK_HITTEST_NOWHERE;
         if ((hitTestInfo.flags & TCHT_ONITEM) == TCHT_ONITEM)
-            *flags |= wxNB_HITTEST_ONITEM;
+            *flags |= wxBK_HITTEST_ONITEM;
         if ((hitTestInfo.flags & TCHT_ONITEMICON) == TCHT_ONITEMICON)
-            *flags |= wxNB_HITTEST_ONICON;
+            *flags |= wxBK_HITTEST_ONICON;
         if ((hitTestInfo.flags & TCHT_ONITEMLABEL) == TCHT_ONITEMLABEL)
-            *flags |= wxNB_HITTEST_ONLABEL;
+            *flags |= wxBK_HITTEST_ONLABEL;
+        if ( item == wxNOT_FOUND && GetPageSize().Inside(pt) )
+            *flags |= wxBK_HITTEST_ONPAGE;
     }
 
     return item;
@@ -861,7 +875,7 @@ void wxNotebook::OnPaint(wxPaintEvent& WXUNUSED(event))
     HBRUSH hbr = (HBRUSH)m_hbrBackground;
 #else
     HBRUSH hbr = 0;
-#endif    
+#endif
     wxBrush brush;
     if ( !hbr )
     {
@@ -1042,25 +1056,6 @@ void wxNotebook::OnSelChange(wxNotebookEvent& event)
   event.Skip();
 }
 
-bool wxNotebook::MSWTranslateMessage(WXMSG *wxmsg)
-{
-    const MSG * const msg = (MSG *)wxmsg;
-
-    // intercept TAB, CTRL+TAB and CTRL+SHIFT+TAB for processing by wxNotebook.
-    // TAB will be passed to the currently selected page, CTRL+TAB and
-    // CTRL+SHIFT+TAB will be processed by the notebook itself. do not
-    // intercept SHIFT+TAB. This goes to the parent of the notebook which will
-    // process it.
-    if ( msg->message == WM_KEYDOWN && msg->wParam == VK_TAB &&
-            msg->hwnd == GetHwnd() &&
-                (wxIsCtrlDown() || !wxIsShiftDown()) )
-    {
-        return MSWProcessMessage(wxmsg);
-    }
-
-    return false;
-}
-
 void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
 {
     if ( event.IsWindowChange() ) {