]> git.saurik.com Git - wxWidgets.git/blobdiff - src/univ/topluniv.cpp
Need to use the same instance handles
[wxWidgets.git] / src / univ / topluniv.cpp
index 8918eccaea8415dbbd2b724dc80133b49a8529f3..dea87cf2f57191bb03c0865c44c1035d6f4acae9 100644 (file)
@@ -14,7 +14,7 @@
 // headers
 // ----------------------------------------------------------------------------
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
     #pragma implementation "univtoplevel.h"
 #endif
 
@@ -101,7 +101,7 @@ bool wxTopLevelWindow::Create(wxWindow *parent,
         style &= ~(wxCAPTION | wxMINIMIZE_BOX | wxMAXIMIZE_BOX |
                    wxSYSTEM_MENU | wxRESIZE_BORDER | wxFRAME_TOOL_WINDOW |
                    wxTHICK_FRAME);
-        style = wxSIMPLE_BORDER;
+        style |= wxSIMPLE_BORDER;
         SetExtraStyle(exstyleOrig &
                       ~(wxFRAME_EX_CONTEXTHELP | wxDIALOG_EX_CONTEXTHELP));
     }
@@ -238,7 +238,7 @@ void wxTopLevelWindow::DoSetClientSize(int width, int height)
         wxTopLevelWindowNative::DoSetClientSize(width, height);
 }
 
-void wxTopLevelWindow::OnNcPaint(wxPaintEvent& event)
+void wxTopLevelWindow::OnNcPaint(wxNcPaintEvent& event)
 {
     if ( !ms_drawDecorations || !m_renderer )
         event.Skip();
@@ -296,13 +296,14 @@ int wxTopLevelWindow::GetMinHeight() const
 // icons
 // ----------------------------------------------------------------------------
 
-void wxTopLevelWindow::SetIcon(const wxIcon& icon)
+void wxTopLevelWindow::SetIcons(const wxIconBundle& icons)
 {
-    wxTopLevelWindowNative::SetIcon(icon);
+    wxTopLevelWindowNative::SetIcons(icons);
 
     if ( ms_drawDecorations && m_renderer )
     {
         wxSize size = m_renderer->GetFrameIconSize();
+        const wxIcon& icon = icons.GetIcon( size );
 
         if ( !icon.Ok() || size.x == -1  )
             m_titlebarIcon = icon;
@@ -328,13 +329,49 @@ void wxTopLevelWindow::SetIcon(const wxIcon& icon)
 // interactive manipulation
 // ----------------------------------------------------------------------------
 
+
+static bool wxGetResizingCursor(long hitTestResult, wxCursor& cursor)
+{
+    if ( hitTestResult & wxHT_TOPLEVEL_ANY_BORDER )
+    {
+        switch (hitTestResult)
+        {
+            case wxHT_TOPLEVEL_BORDER_N:
+            case wxHT_TOPLEVEL_BORDER_S:
+                cursor = wxCursor(wxCURSOR_SIZENS);
+                break;
+            case wxHT_TOPLEVEL_BORDER_W:
+            case wxHT_TOPLEVEL_BORDER_E:
+                cursor = wxCursor(wxCURSOR_SIZEWE);
+                break;
+            case wxHT_TOPLEVEL_BORDER_NE:
+            case wxHT_TOPLEVEL_BORDER_SW:
+                cursor = wxCursor(wxCURSOR_SIZENESW);
+                break;
+            case wxHT_TOPLEVEL_BORDER_NW:
+            case wxHT_TOPLEVEL_BORDER_SE:
+                cursor = wxCursor(wxCURSOR_SIZENWSE);
+                break;
+            default:
+                return FALSE;
+                #if 0
+                // not rachable due to earlier return
+                break;
+                #endif
+        }
+        return TRUE;
+    }
+    
+    return FALSE;
+}
+
 #define wxINTERACTIVE_RESIZE_DIR \
           (wxINTERACTIVE_RESIZE_W | wxINTERACTIVE_RESIZE_E | \
            wxINTERACTIVE_RESIZE_S | wxINTERACTIVE_RESIZE_N)
 
 struct wxInteractiveMoveData
 {
-    wxTopLevelWindowBase *m_window;
+    wxTopLevelWindow     *m_window;
     wxEventLoop          *m_evtLoop;
     int                   m_flags;
     wxRect                m_rect;
@@ -437,7 +474,7 @@ void wxInteractiveMoveHandler::OnMouseMove(wxMouseEvent& event)
     }
 }
 
-void wxInteractiveMoveHandler::OnMouseDown(wxMouseEvent& event)
+void wxInteractiveMoveHandler::OnMouseDown(wxMouseEvent& WXUNUSED(event))
 {
     if ( m_data.m_flags & wxINTERACTIVE_WAIT_FOR_INPUT )
     {
@@ -483,6 +520,7 @@ void wxInteractiveMoveHandler::OnKeyDown(wxKeyEvent& event)
         }
 
         wxPoint warp;
+        bool changeCur = FALSE;
         
         if ( m_data.m_flags & wxINTERACTIVE_MOVE )
         {
@@ -499,12 +537,14 @@ void wxInteractiveMoveHandler::OnKeyDown(wxKeyEvent& event)
                 {
                     m_data.m_flags |= wxINTERACTIVE_RESIZE_N;
                     m_data.m_pos.y = m_data.m_window->GetPosition().y;
+                    changeCur = TRUE;
                 }
                 else if ( diff.y > 0 )
                 {
                     m_data.m_flags |= wxINTERACTIVE_RESIZE_S;
                     m_data.m_pos.y = m_data.m_window->GetPosition().y +
                                      m_data.m_window->GetSize().y;
+                    changeCur = TRUE;
                 }
             }
             if ( !(m_data.m_flags & 
@@ -514,15 +554,17 @@ void wxInteractiveMoveHandler::OnKeyDown(wxKeyEvent& event)
                 {
                     m_data.m_flags |= wxINTERACTIVE_RESIZE_W;
                     m_data.m_pos.x = m_data.m_window->GetPosition().x;
+                    changeCur = TRUE;
                 }
                 else if ( diff.x > 0 )
                 {
                     m_data.m_flags |= wxINTERACTIVE_RESIZE_E;
                     m_data.m_pos.x = m_data.m_window->GetPosition().x +
                                      m_data.m_window->GetSize().x;
+                    changeCur = TRUE;
                 }
             }
-            
+
             wxApplyResize(m_data, diff);
             m_data.m_window->SetSize(m_data.m_rect);
 
@@ -543,10 +585,23 @@ void wxInteractiveMoveHandler::OnKeyDown(wxKeyEvent& event)
 
         warp -= m_data.m_window->GetClientAreaOrigin();
         m_data.m_window->WarpPointer(warp.x, warp.y);
+
+        if ( changeCur )
+        {
+            long hit = m_data.m_window->HitTest(warp);
+            wxCursor cur;
+            if ( wxGetResizingCursor(hit, cur) )
+            {
+                if ( m_data.m_sizingCursor )
+                    wxEndBusyCursor();
+                wxBeginBusyCursor(&cur);
+                m_data.m_sizingCursor = TRUE;
+            }
+        }
     }
 }
 
-void wxInteractiveMoveHandler::OnMouseUp(wxMouseEvent& event)
+void wxInteractiveMoveHandler::OnMouseUp(wxMouseEvent& WXUNUSED(event))
 {
     m_data.m_evtLoop->Exit();
 }
@@ -639,7 +694,7 @@ void wxTopLevelWindow::ClickTitleBarButton(long button)
 
 bool wxTopLevelWindow::PerformAction(const wxControlAction& action,
                                      long numArg,
-                                     const wxString& strArg)
+                                     const wxString& WXUNUSED(strArg))
 {
     bool isActive = numArg != 0;
 
@@ -848,31 +903,9 @@ bool wxStdFrameInputHandler::HandleMouseMove(wxInputConsumer *consumer,
 
             if ( hit & wxHT_TOPLEVEL_ANY_BORDER )
             {
-                m_borderCursorOn = TRUE;
                 wxCursor cur;
 
-                switch (hit)
-                {
-                    case wxHT_TOPLEVEL_BORDER_N:
-                    case wxHT_TOPLEVEL_BORDER_S:
-                        cur = wxCursor(wxCURSOR_SIZENS);
-                        break;
-                    case wxHT_TOPLEVEL_BORDER_W:
-                    case wxHT_TOPLEVEL_BORDER_E:
-                        cur = wxCursor(wxCURSOR_SIZEWE);
-                        break;
-                    case wxHT_TOPLEVEL_BORDER_NE:
-                    case wxHT_TOPLEVEL_BORDER_SW:
-                        cur = wxCursor(wxCURSOR_SIZENESW);
-                        break;
-                    case wxHT_TOPLEVEL_BORDER_NW:
-                    case wxHT_TOPLEVEL_BORDER_SE:
-                        cur = wxCursor(wxCURSOR_SIZENWSE);
-                        break;
-                    default:
-                        m_borderCursorOn = FALSE;
-                        break;
-                }
+                m_borderCursorOn = wxGetResizingCursor(hit, cur);
                 if ( m_borderCursorOn )
                 {
                     m_origCursor = win->GetCursor();