#include "wx/button.h"
#include "wx/msgdlg.h"
#include "wx/scrolwin.h"
-
+ #include "wx/radiobox.h"
+ #include "wx/slider.h"
+ #include "wx/statusbr.h"
+ #include "wx/toolbar.h"
+ #include "wx/settings.h"
#include <stdio.h>
#endif
wxMenu* wxCurrentPopupMenu = NULL;
#endif // wxUSE_MENUS_NATIVE
-#if !defined(__VISAGECPP__) || (__IBMCPP__ < 400)
-extern wxChar wxCanvasClassName[];
-#endif
wxList* wxWinHandleList = NULL;
// ---------------------------------------------------------------------------
{
m_isBeingDeleted = TRUE;
- OS2DetachWindowMenu();
for (wxWindow* pWin = GetParent(); pWin; pWin = pWin->GetParent())
{
wxFrame* pFrame = wxDynamicCast(pWin, wxFrame);
return wxGetWindowText(GetHWND());
} // end of wxWindowOS2::GetTitle
-void wxWindowOS2::CaptureMouse()
+void wxWindowOS2::DoCaptureMouse()
{
HWND hWnd = GetHwnd();
}
} // end of wxWindowOS2::GetTitle
-void wxWindowOS2::ReleaseMouse()
+void wxWindowOS2::DoReleaseMouse()
{
if (m_bWinCaptured)
{
HWND hWnd = GetHwnd();
- if (hWnd != 0)
- {
- char zFont[128];
- char zFacename[30];
- char zWeight[30];
- char zStyle[30];
-
- //
- // The fonts available for Presentation Params are just three
- // outline fonts, the rest are available to the GPI, so we must
- // map the families to one of these three
- //
- switch(rFont.GetFamily())
- {
- case wxSCRIPT:
- case wxDECORATIVE:
- case wxROMAN:
- strcpy(zFacename,"Times New Roman");
- break;
-
- case wxTELETYPE:
- case wxMODERN:
- strcpy(zFacename, "Courier");
- break;
-
- case wxSWISS:
- case wxDEFAULT:
- default:
- strcpy(zFacename, "Helvetica");
- break;
- }
-
- switch(rFont.GetWeight())
- {
- default:
- case wxNORMAL:
- case wxLIGHT:
- zWeight[0] = '\0';
- break;
-
- case wxBOLD:
- case wxFONTWEIGHT_MAX:
- strcpy(zWeight, "Bold");
- break;
- }
- switch(rFont.GetStyle())
- {
- case wxITALIC:
- case wxSLANT:
- strcpy(zStyle, "Italic");
- break;
-
- default:
- zStyle[0] = '\0';
- break;
- }
- sprintf(zFont, "%d.%s", rFont.GetPointSize(), zFacename);
- if (zWeight[0] != '\0')
- {
- strcat(zFont, " ");
- strcat(zFont, zWeight);
- }
- if (zStyle[0] != '\0')
- {
- strcat(zFont, " ");
- strcat(zFont, zStyle);
- }
- ::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont) + 1, (PVOID)zFont);
- }
+ wxOS2SetFont( hWnd
+ ,rFont
+ );
return(TRUE);
-}
+} // end of wxWindowOS2::SetFont
bool wxWindowOS2::SetCursor(
const wxCursor& rCursor
{
HWND hwnd = (HWND)hWnd;
- wxASSERT_MSG( !m_fnOldWndProc, wxT("subclassing window twice?") );
wxCHECK_RET(::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in SubclassWin") );
- m_fnOldWndProc = (WXFARPROC) ::WinSubclassWindow(hwnd, (PFNWP)wxWndProc);
+ wxAssociateWinWithHandle( hWnd
+ ,(wxWindow*)this
+ );
+ if (!wxCheckWindowWndProc( hWnd
+ ,(WXFARPROC)wxWndProc
+ ))
+ {
+ m_fnOldWndProc = (WXFARPROC) ::WinSubclassWindow(hwnd, (PFNWP)wxWndProc);
+ }
+ else
+ {
+ m_fnOldWndProc = (WXFARPROC)NULL;
+ }
} // end of wxWindowOS2::SubclassWin
void wxWindowOS2::UnsubclassWin()
RECTL vRect;
::WinQueryWindowRect(hWnd, &vRect);
+ if (IsKindOf(CLASSINFO(wxDialog)))
+ {
+ RECTL vTitle;
+ HWND hWndTitle;
+ //
+ // For a Dialog we have to explicitly request the client portion.
+ // For a Frame the hWnd IS the client window
+ //
+ hWndTitle = ::WinWindowFromID(hWnd, FID_TITLEBAR);
+ if (::WinQueryWindowRect(hWndTitle, &vTitle))
+ {
+ if (vTitle.yTop - vTitle.yBottom == 0)
+ {
+ //
+ // Dialog has not been created yet, use a default
+ //
+ vTitle.yTop = 20;
+ }
+ vRect.yTop -= (vTitle.yTop - vTitle.yBottom);
+ }
+
+ ULONG uStyle = ::WinQueryWindowULong(hWnd, QWL_STYLE);
+
+ //
+ // Deal with borders
+ //
+ if (uStyle & FCF_DLGBORDER)
+ {
+ vRect.xLeft += 4;
+ vRect.xRight -= 4;
+ vRect.yTop -= 4;
+ vRect.yBottom += 4;
+ }
+ else if (uStyle & FCF_SIZEBORDER)
+ {
+ vRect.xLeft += 4;
+ vRect.xRight -= 4;
+ vRect.yTop -= 4;
+ vRect.yBottom += 4;
+ }
+ else if (uStyle & FCF_BORDER)
+ {
+ vRect.xLeft += 2;
+ vRect.xRight -= 2;
+ vRect.yTop -= 2;
+ vRect.yBottom += 2;
+ }
+ else // make some kind of adjustment or top sizers ram into the titlebar!
+ {
+ vRect.xLeft += 3;
+ vRect.xRight -= 3;
+ vRect.yTop -= 3;
+ vRect.yBottom += 3;
+ }
+ }
if (pWidth)
- *pWidth = vRect.xRight;
+ *pWidth = vRect.xRight - vRect.xLeft;
if (pHeight)
- *pHeight = vRect.yTop;
+ *pHeight = vRect.yTop - vRect.yBottom;
} // end of wxWindowOS2::DoGetClientSize
void wxWindowOS2::DoMoveWindow(
HWND hParent;
wxWindow* pParent = GetParent();
- if (pParent)
+ if (pParent && !IsKindOf(CLASSINFO(wxDialog)))
{
int nOS2Height = GetOS2ParentHeight(pParent);
int nY2 = nY;
wxWindow* pParent = (wxWindow*)GetParent();
- if (pParent)
+ if (pParent && !IsKindOf(CLASSINFO(wxDialog)))
{
int nOS2Height = GetOS2ParentHeight(pParent);
//
QMSG vMsg;
- while (::WinPeekMsg(vHabmain, &vMsg, (HWND)0, WM_COMMAND,
- WM_COMMAND,PM_REMOVE) && vMsg.msg != WM_QUIT)
+ while (::WinPeekMsg(vHabmain, &vMsg, (HWND)0, WM_COMMAND, WM_COMMAND, PM_REMOVE)
+ && vMsg.msg != WM_QUIT)
{
wxTheApp->DoMessage((WXMSG*)&vMsg);
}
, int nY
)
{
- HWND hWnd = GetHwnd();
- HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0;
+ HWND hWndOwner = GetHwnd();
+ HWND hWndParent = GetHwnd();
HWND hMenu = GetHmenuOf(pMenu);
+ bool bIsWaiting = TRUE;
pMenu->SetInvokingWindow(this);
pMenu->UpdateUI();
wxCurrentPopupMenu = pMenu;
::WinPopupMenu( hWndParent
- ,hWnd
+ ,hWndOwner
,hMenu
,nX
,nY
,0L
- ,PU_MOUSEBUTTON2DOWN | PU_MOUSEBUTTON2 | PU_KEYBOARD
+ ,PU_HCONSTRAIN | PU_VCONSTRAIN | PU_MOUSEBUTTON2DOWN | PU_MOUSEBUTTON2
);
- // we need to do it righ now as otherwise the events are never going to be
- // sent to wxCurrentPopupMenu from ;()
- //
- // note that even eliminating (ugly) wxCurrentPopupMenu global wouldn't
- // help and we'd still need wxYieldForCommandsOnly() as the menu may be
- // destroyed as soon as we return (it can be a local variable in the caller
- // for example) and so we do need to process the event immediately
- wxYieldForCommandsOnly();
+ while(bIsWaiting)
+ {
+ QMSG vMsg;
+
+ while (::WinPeekMsg(vHabmain, &vMsg, (HWND)0, WM_COMMAND, WM_COMMAND, PM_REMOVE)
+ && vMsg.msg != WM_QUIT)
+ {
+ wxTheApp->DoMessage((WXMSG*)&vMsg);
+ }
+ if (vMsg.msg == WM_DESTROY || vMsg.msg == WM_QUIT)
+ break;
+ }
wxCurrentPopupMenu = NULL;
pMenu->SetInvokingWindow(NULL);
#endif //wxUSE_ACCEL
} // end of wxWindowOS2::OS2TranslateMessage
+bool wxWindowOS2::OS2ShouldPreProcessMessage(
+ WXMSG* pMsg
+)
+{
+ // preprocess all messages by default
+ return TRUE;
+} // end of wxWindowOS2::OS2ShouldPreProcessMessage
+
// ---------------------------------------------------------------------------
// message params unpackers
// ---------------------------------------------------------------------------
);
break;
+ case WM_WINDOWPOSCHANGED:
+
+ //
+ // Dialogs under OS/2 do not get WM_SIZE events at all.
+ // Instead they get this, which can function much like WM_SIZE
+ // PSWP contains the new sizes and positioning, PSWP+1 the old
+ // We use this because ADJUSTWINDOWPOS comes BEFORE the new
+ // position is added and our auto layout does a WinQueryWindowRect
+ // to get the CURRENT client size. That is the size used to position
+ // child controls, so we need to already be sized
+ // in order to get the child controls positoned properly.
+ //
+ if (IsKindOf(CLASSINFO(wxDialog)))
+ {
+ PSWP pSwp = (PSWP)PVOIDFROMMP(wParam);
+ PSWP pSwp2 = pSwp++;
+
+ if (!(pSwp->cx == pSwp2->cx &&
+ pSwp->cy == pSwp2->cy))
+ bProcessed = HandleSize( pSwp->cx
+ ,pSwp->cy
+ ,(WXUINT)lParam
+ );
+ }
+ break;
+
case WM_ACTIVATE:
{
WXWORD wState;
#endif // __WXDEBUG__
if (IsKindOf(CLASSINFO(wxFrame)))
mResult = ::WinDefWindowProc(m_hWnd, uMsg, wParam, lParam);
+ else if (IsKindOf(CLASSINFO(wxDialog)))
+ mResult = ::WinDefDlgProc( m_hWnd, uMsg, wParam, lParam);
else
mResult = OS2DefWindowProc(uMsg, wParam, lParam);
}
return mResult;
} // end of wxWindowOS2::OS2WindowProc
+#ifndef __EMX__
+// clashes with wxDlgProc in toplevel.cpp?
//
// Dialog window proc
//
return (MRESULT)0;
}
} // end of wxDlgProc
+#endif
wxWindow* wxFindWinFromHandle(
WXHWND hWnd
{
}
-void wxWindowOS2::OS2DetachWindowMenu()
-{
-#ifndef __WXUNIVERSAL__
- if (m_hMenu)
- {
- HMENU hMenu = (HMENU)m_hMenu;
-
- int nN = (int)::WinSendMsg(hMenu, MM_QUERYITEMCOUNT, 0, 0);
- int i;
-
- for (i = 0; i < nN; i++)
- {
- wxChar zBuf[100];
- int nChars = (int)::WinSendMsg( hMenu
- ,MM_QUERYITEMTEXT
- ,MPFROM2SHORT(i, nN)
- ,zBuf
- );
- if (!nChars)
- {
- wxLogLastError(wxT("GetMenuString"));
- continue;
- }
-
- if (wxStrcmp(zBuf, wxT("&Window")) == 0)
- {
- ::WinSendMsg(hMenu, MM_DELETEITEM, MPFROM2SHORT(i, TRUE), 0);
- break;
- }
- }
- }
-#endif // __WXUNIVERSAL__
-} // end of wxWindowOS2::OS2DetachWindowMenu
-
bool wxWindowOS2::OS2GetCreateWindowCoords(
const wxPoint& rPos
, const wxSize& rSize
//
if (pParent)
{
- if (IsKindOf(CLASSINFO(wxStatusBar)) &&
- pParent->IsKindOf(CLASSINFO(wxFrame)))
+ if ( pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow)) ||
+ pParent->IsKindOf(CLASSINFO(wxScrolledWindow))
+ )
{
- RECTL vRect;
- wxFrame* pFrame = wxDynamicCast(pParent, wxFrame);
+ if (IsKindOf(CLASSINFO(wxStatusBar)) &&
+ pParent->IsKindOf(CLASSINFO(wxFrame)))
+ {
+ RECTL vRect;
+ wxFrame* pFrame = wxDynamicCast(pParent, wxFrame);
- ::WinQueryWindowRect((HWND)pFrame->GetFrame(), &vRect);
- nY = vRect.yTop - (nY + nHeight);
+ ::WinQueryWindowRect((HWND)pFrame->GetFrame(), &vRect);
+ nY = vRect.yTop - (nY + nHeight);
+ }
+ else
+ nY = pParent->GetSize().y - (nY + nHeight);
}
- else
- nY = pParent->GetSize().y - (nY + nHeight);
}
else
{
WXHWND WXUNUSED(hWnd)
)
{
+ //
+ // Notify the parent keeping track of focus for the kbd navigation
+ // purposes that we got it
+ //
+ wxChildFocusEvent vEventFocus((wxWindow *)this);
+ (void)GetEventHandler()->ProcessEvent(vEventFocus);
+
#if wxUSE_CARET
//
// Deal with caret
// Case 1
//
if (pParent->IsKindOf(CLASSINFO(wxDialog)))
- return(pParent->GetSize().y);
+ return(pParent->GetClientSize().y);
//
// Case 2 -- if we are one of the separately built standard Frame