]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/window.cpp
Put OnIdle() back. Without deleting pending objects, frames that have
[wxWidgets.git] / src / os2 / window.cpp
index ce34797831607c4a650dbb6e9572c1e65aba87b1..affeabe47e5588111935250d5a1448f18901c9d7 100644 (file)
     #include "wx/app.h"
     #include "wx/panel.h"
     #include "wx/layout.h"
+    #include "wx/checkbox.h"
+    #include "wx/combobox.h"
     #include "wx/dialog.h"
     #include "wx/frame.h"
     #include "wx/listbox.h"
     #include "wx/button.h"
+    #include "wx/bmpbuttn.h"
     #include "wx/msgdlg.h"
     #include "wx/scrolwin.h"
     #include "wx/radiobox.h"
+    #include "wx/radiobut.h"
     #include "wx/slider.h"
     #include "wx/statbox.h"
     #include "wx/statusbr.h"
@@ -506,6 +510,14 @@ bool wxWindowOS2::Enable(
     if ( hWnd )
         ::WinEnableWindow(hWnd, (BOOL)bEnable);
 
+    //
+    // The logic below doesn't apply to the top level windows -- otherwise
+    // showing a modal dialog would result in total greying out (and ungreying
+    // out later) of everything which would be really ugly
+    //
+    if (IsTopLevel())
+        return TRUE;
+
     wxWindowList::Node*             pNode = GetChildren().GetFirst();
 
     while (pNode)
@@ -1352,7 +1364,8 @@ void wxWindowOS2::OnIdle(
             (void)GetEventHandler()->ProcessEvent(rEvent);
         }
     }
-    UpdateWindowUI();
+    if (wxUpdateUIEvent::CanUpdate(this))
+        UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
 } // end of wxWindowOS2::OnIdle
 
 //
@@ -1442,14 +1455,7 @@ void wxWindowOS2::SetDropTarget(
   wxDropTarget*                     pDropTarget
 )
 {
-    if (m_dropTarget != 0)
-    {
-        m_dropTarget->Revoke(m_hWnd);
-        delete m_dropTarget;
-    }
     m_dropTarget = pDropTarget;
-    if (m_dropTarget != 0)
-        m_dropTarget->Register(m_hWnd);
 } // end of wxWindowOS2::SetDropTarget
 #endif
 
@@ -2222,6 +2228,8 @@ static void wxYieldForCommandsOnly()
     {
         wxTheApp->DoMessage((WXMSG*)&vMsg);
     }
+    if (vMsg.msg == WM_QUIT)
+        ::WinPostMsg(NULL, WM_QUIT, 0, 0);
 }
 #endif // wxUSE_MENUS_NATIVE
 
@@ -2415,6 +2423,14 @@ bool wxWindowOS2::OS2ProcessMessage(
                                 pBtn->OS2Command(BN_CLICKED, 0 /* unused */);
                                 return TRUE;
                             }
+                            else if (!IsTopLevel())
+                            {
+                                //
+                                // if not a top level window, let parent
+                                // handle it
+                                //
+                                return FALSE;
+                            }
                             // else: but if it does not it makes sense to make
                             //       it work like a TAB - and that's what we do.
                             //       Note that Ctrl-Enter always works this way.
@@ -2803,6 +2819,11 @@ MRESULT wxWindowOS2::OS2WindowProc(
                                                                    ,&nX
                                                                    ,&nY
                                                                   );
+                    if (!pWin->IsOfStandardClass())
+                    {
+                        if (uMsg == WM_BUTTON1DOWN && pWin->AcceptsFocus() )
+                            pWin->SetFocus();
+                    }
                     bProcessed = pWin->HandleMouseEvent( uMsg
                                                         ,nX
                                                         ,nY
@@ -2969,6 +2990,26 @@ MRESULT wxWindowOS2::OS2WindowProc(
         case WM_CONTROL:
             switch(SHORT2FROMMP(wParam))
             {
+                case BN_PAINT:
+                    {
+                        HWND                hWnd = ::WinWindowFromID((HWND)GetHwnd(), SHORT1FROMMP(wParam));
+                        wxWindowOS2*        pWin = wxFindWinFromHandle(hWnd);
+
+                        if (!pWin)
+                        {
+                            bProcessed = FALSE;
+                            break;
+                        }
+                        if (pWin->IsKindOf(CLASSINFO(wxBitmapButton)))
+                        {
+                            wxBitmapButton*     pBitmapButton = wxDynamicCast(pWin, wxBitmapButton);
+
+                            pBitmapButton->OS2OnDraw((WXDRAWITEMSTRUCT *)lParam);
+                        }
+                        return 0;
+                    }
+                    break;
+
                 case BKN_PAGESELECTEDPENDING:
                     {
                         PPAGESELECTNOTIFY  pPage = (PPAGESELECTNOTIFY)lParam;
@@ -3474,7 +3515,7 @@ bool wxWindowOS2::HandleCreate(
 bool wxWindowOS2::HandleDestroy()
 {
     wxWindowDestroyEvent            vEvent((wxWindow*)this);
-
+    vEvent.SetId(GetId());
     (void)GetEventHandler()->ProcessEvent(vEvent);
 
     //
@@ -3483,7 +3524,6 @@ bool wxWindowOS2::HandleDestroy()
 #if wxUSE_DRAG_AND_DROP
     if (m_dropTarget != NULL)
     {
-        m_dropTarget->Revoke(m_hWnd);
         delete m_dropTarget;
         m_dropTarget = NULL;
     }
@@ -3940,6 +3980,21 @@ void wxWindowOS2::OnSysColourChanged(
 // painting
 // ---------------------------------------------------------------------------
 
+void wxWindow::OnPaint (
+  wxPaintEvent&                     rEvent
+)
+{
+    HDC                             hDC = (HDC)wxPaintDC::FindDCInCache((wxWindow*) rEvent.GetEventObject());
+
+    if (hDC != 0)
+    {
+        OS2DefWindowProc( (WXUINT)WM_PAINT
+                         ,(WXWPARAM)hDC
+                         ,(WXLPARAM)0
+                        );
+    }
+} // end of wxWindow::OnPaint
+
 bool wxWindowOS2::HandlePaint()
 {
     HRGN                            hRgn;
@@ -4593,7 +4648,10 @@ void wxWindowOS2::MoveChildren(
   int                               nDiff
 )
 {
-    if (GetAutoLayout())
+    //
+    // We want to handle top levels ourself, manually
+    //
+    if (!IsTopLevel() && GetAutoLayout())
     {
         Layout();
     }