// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
+//
// For compilers that support precompilation, includes "wx.h".
+//
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include <string.h>
-// place compiler, OS specific includes here
-
+//
+// Place compiler, OS specific includes here
+//
-// standard macros -- these are for OS/2 PM, but most GUI's have something similar
+//
+// Standard macros -- these are for OS/2 PM, but most GUI's have something similar
+//
#ifndef GET_X_LPARAM
+//
// SHORT1FROMMP -- LOWORD
+//
#define GET_X_LPARAM(mp) ((unsigned short)(unsigned long)(mp))
+//
// SHORT2FROMMP -- HIWORD
+//
#define GET_Y_LPARAM(mp) ((unsigned short)(unsigned long)(mp >> 16))
#endif // GET_X_LPARAM
// global variables
// ---------------------------------------------------------------------------
-// the last Windows message we got (MT-UNSAFE)
-extern WXMSGID s_currentMsg;
-extern wxList WXDLLEXPORT wxPendingDelete;
-extern wxChar wxCanvasClassName[];
+//
+// The last Windows message we got (MT-UNSAFE)
+//
+extern WXMSGID s_currentMsg;
-wxMenu *wxCurrentPopupMenu = NULL;
-wxList *wxWinHandleList = NULL;
+wxMenu* wxCurrentPopupMenu = NULL;
+extern wxList WXDLLEXPORT wxPendingDelete;
+extern wxChar* wxCanvasClassName;
+wxList* wxWinHandleList = NULL;
// ---------------------------------------------------------------------------
// private functions
// ---------------------------------------------------------------------------
+
+//
// the window proc for all our windows; most gui's have something similar
+//
MRESULT wxWndProc( HWND hWnd
,ULONG message
,MPARAM mp1
,MPARAM mp2
);
-void wxRemoveHandleAssociation(wxWindow *win);
-void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win);
-wxWindow *wxFindWinFromHandle(WXHWND hWnd);
+#ifdef __WXDEBUG__
+ const char *wxGetMessageName(int message);
+#endif //__WXDEBUG__
+
+void wxRemoveHandleAssociation(wxWindow* pWin);
+void wxAssociateWinWithHandle( HWND hWnd
+ ,wxWindow* pWin
+ );
+wxWindow* wxFindWinFromHandle(WXHWND hWnd);
+
+//
+// This magical function is used to translate VK_APPS key presses to right
+// mouse clicks
+//
+static void TranslateKbdEventToMouse( wxWindow* pWin
+ ,int* pX
+ ,int* pY
+ ,MPARAM* pFlags
+ );
+
+//
+// get the current state of SHIFT/CTRL keys
+//
+static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000) != 0; }
+static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000) != 0; }
// ---------------------------------------------------------------------------
// event tables
// ---------------------------------------------------------------------------
-#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
-#endif
BEGIN_EVENT_TABLE(wxWindow, wxWindowBase)
EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
// implementation
// ===========================================================================
-// Find an item given the MS Windows id
-wxWindow *wxWindow::FindItem(long id) const
+//
+// Find an item given the PM Window id
+//
+wxWindow* wxWindow::FindItem(
+ long lId
+) const
{
- wxWindowList::Node *current = GetChildren().GetFirst();
- while (current)
- {
- wxWindow *childWin = current->GetData();
+ wxControl* pItem = wxDynamicCast( this
+ ,wxControl
+ );
- wxWindow *wnd = childWin->FindItem(id);
- if ( wnd )
- return wnd;
-
- if ( childWin->IsKindOf(CLASSINFO(wxControl)) )
+ if (pItem)
+ {
+ //
+ // I it we or one of our "internal" children?
+ //
+ if (pItem->GetId() == lId ||
+ (pItem->GetSubcontrols().Index(lId) != wxNOT_FOUND))
{
- wxControl *item = (wxControl *)childWin;
- if ( item->GetId() == id )
- return item;
- else
- {
- // In case it's a 'virtual' control (e.g. radiobox)
- if ( item->GetSubcontrols().Member((wxObject *)id) )
- return item;
- }
+ return pItem;
}
-
- current = current->GetNext();
}
- return NULL;
-}
+ wxWindowList::Node* pCurrent = GetChildren().GetFirst();
-// Find an item given the MS Windows handle
-wxWindow *wxWindow::FindItemByHWND(WXHWND hWnd, bool controlOnly) const
+ while (pCurrent)
+ {
+ wxWindow* pChildWin = pCurrent->GetData();
+ wxWindow* pWnd = pChildWin->FindItem(lId);
+
+ if (pWnd)
+ return pWnd;
+
+ pCurrent = pCurrent->GetNext();
+ }
+ return(NULL);
+} // end of wxWindow::FindItem
+
+//
+// Find an item given the PM Window handle
+//
+wxWindow* wxWindow::FindItemByHWND(
+ WXHWND hWnd
+, bool bControlOnly
+) const
{
- wxWindowList::Node *current = GetChildren().GetFirst();
- while (current)
+ wxWindowList::Node* pCurrent = GetChildren().GetFirst();
+
+ while (pCurrent)
{
- wxWindow *parent = current->GetData();
+ wxWindow* pParent = pCurrent->GetData();
+ //
// Do a recursive search.
- wxWindow *wnd = parent->FindItemByHWND(hWnd);
- if ( wnd )
- return wnd;
+ //
+ wxWindow* pWnd = pParent->FindItemByHWND(hWnd);
+
+ if (pWnd)
+ return(pWnd);
- if ( !controlOnly || parent->IsKindOf(CLASSINFO(wxControl)) )
+ if (!bControlOnly || pParent->IsKindOf(CLASSINFO(wxControl)))
{
- wxWindow *item = current->GetData();
- if ( item->GetHWND() == hWnd )
- return item;
+ wxWindow* pItem = pCurrent->GetData();
+
+ if (pItem->GetHWND() == hWnd)
+ return(pItem);
else
{
- if ( item->ContainsHWND(hWnd) )
- return item;
+ if (pItem->ContainsHWND(hWnd))
+ return(pItem);
}
}
-
- current = current->GetNext();
+ pCurrent = pCurrent->GetNext();
}
- return NULL;
-}
+ return(NULL);
+} // end of wxWindow::FindItemByHWND
+//
// Default command handler
-bool wxWindow::OS2Command(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id))
+//
+bool wxWindow::OS2Command(
+ WXUINT WXUNUSED(uParam)
+, WXWORD WXUNUSED(uId)
+)
{
- return FALSE;
+ return(FALSE);
}
// ----------------------------------------------------------------------------
void wxWindow::Init()
{
- // generic
+ //
+ // Generic
+ //
InitBase();
+ //
// PM specific
- m_doubleClickAllowed = 0;
- m_winCaptured = FALSE;
+ //
+ m_bDoubleClickAllowed = 0;
+ m_bWinCaptured = FALSE;
m_isBeingDeleted = FALSE;
- m_oldWndProc = 0;
- m_useCtl3D = FALSE;
- m_mouseInWindow = FALSE;
+ m_fnOldWndProc = 0;
+ m_bUseCtl3D = FALSE;
+ m_bMouseInWindow = FALSE;
+ //
// wxWnd
+ //
m_hMenu = 0;
-
m_hWnd = 0;
- // pass WM_GETDLGCODE to DefWindowProc()
+ //
+ // Pass WM_GETDLGCODE to DefWindowProc()
m_lDlgCode = 0;
- m_xThumbSize = 0;
- m_yThumbSize = 0;
- m_backgroundTransparent = FALSE;
+ m_nXThumbSize = 0;
+ m_nYThumbSize = 0;
+ m_bBackgroundTransparent = FALSE;
- // as all windows are created with WS_VISIBLE style...
+ //
+ // As all windows are created with WS_VISIBLE style...
+ //
m_isShown = TRUE;
#if wxUSE_MOUSEEVENT_HACK
- m_lastMouseX =
- m_lastMouseY = -1;
- m_lastMouseEvent = -1;
+ m_lLastMouseX =
+ m_lLastMouseY = -1;
+ m_nLastMouseEvent = -1;
#endif // wxUSE_MOUSEEVENT_HACK
-}
+} // wxWindow::Init
+//
// Destructor
+//
wxWindow::~wxWindow()
{
m_isBeingDeleted = TRUE;
OS2DetachWindowMenu();
- // delete handlers?
if (m_parent)
m_parent->RemoveChild(this);
DestroyChildren();
if (m_hWnd)
{
- if(!WinDestroyWindow(GetHWND()))
+ if(!::WinDestroyWindow(GetHWND()))
wxLogLastError(wxT("DestroyWindow"));
+ //
// remove hWnd <-> wxWindow association
+ //
wxRemoveHandleAssociation(this);
}
-}
-
-bool wxWindow::Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
-{
- wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindow without parent") );
-
- if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
- return FALSE;
-
- parent->AddChild(this);
-
- // TODO: PM Specific initialization
- OS2Create(m_windowId, parent, wxCanvasClassName, this, NULL,
- pos.x, pos.y,
- WidthDefault(size.x), HeightDefault(size.y),
- msflags, NULL, exStyle);
- return TRUE;
-}
+} // end of wxWindow::~wxWindow
+
+bool wxWindow::Create(
+ wxWindow* pParent
+, wxWindowID vId
+, const wxPoint& rPos
+, const wxSize& rSize
+, long lStyle
+, const wxString& rName
+)
+{
+ wxCHECK_MSG(pParent, FALSE, wxT("can't create wxWindow without parent"));
+
+ if ( !CreateBase( pParent
+ ,vId
+ ,rPos
+ ,rSize
+ ,lStyle
+ ,wxDefaultValidator
+ ,rName
+ ))
+ return(FALSE);
+
+ pParent->AddChild(this);
+
+ ULONG ulFlags = 0L;
+
+ //
+ // Frame windows and their derivatives only
+ //
+ if (lStyle & wxBORDER)
+ ulFlags |= FCF_BORDER;
+ if (lStyle & wxTHICK_FRAME )
+ ulFlags |= FCF_SIZEBORDER;
+
+ //
+ // Some generic window styles
+ //
+ ulFlags |= WS_VISIBLE;
+ if (lStyle & wxCLIP_CHILDREN )
+ ulFlags |= WS_CLIPCHILDREN;
+
+ bool bWant3D;
+ WXDWORD dwExStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &bWant3D);
+
+ //
+ // OS/2 PM doesn't have "extended" styles but if the library specifies
+ // them and we are creating a frame window then at least give it a border
+ //
+ if ( bWant3D ||
+ (m_windowStyle & wxSIMPLE_BORDER) ||
+ (m_windowStyle & wxRAISED_BORDER ) ||
+ (m_windowStyle & wxSUNKEN_BORDER) ||
+ (m_windowStyle & wxDOUBLE_BORDER)
+ )
+ {
+ ulFlags |= FCF_BORDER;
+ }
+ OS2Create( m_windowId
+ ,pParent
+ ,wxCanvasClassName
+ ,this
+ ,NULL
+ ,rPos.x
+ ,rPos.y
+ ,WidthDefault(rSize.x)
+ ,HeightDefault(rSize.y)
+ ,ulFlags
+ ,NULL
+ ,dwExStyle
+ );
+ return(TRUE);
+} // end of wxWindow::Create
// ---------------------------------------------------------------------------
// basic operations
void wxWindow::SetFocus()
{
- // TODO:
-}
+ HWND hWnd = GetHwnd();
+
+ if (hWnd)
+ ::WinSetFocus(HWND_DESKTOP, hWnd);
+} // end of wxWindow::SetFocus
-wxWindow* wxWindow::FindFocus()
+wxWindow* wxWindowBase::FindFocus()
{
- wxWindow* window = NULL;
- // TODO:
- return(window);
-}
+ HWND hWnd = ::WinQueryFocus(HWND_DESKTOP);
-bool wxWindow::Enable(bool enable) // check if base implementation is OK
+ if (hWnd)
+ {
+ return wxFindWinFromHandle((WXHWND)hWnd);
+ }
+ return NULL;
+} // wxWindowBase::FindFocus
+
+bool wxWindow::Enable(
+ bool bEnable
+)
{
- // TODO:
+ if (!wxWindowBase::Enable(bEnable))
+ return(FALSE);
+
+ HWND hWnd = GetHwnd();
+
+ if ( hWnd )
+ ::WinEnableWindow(hWnd, (BOOL)bEnable);
+
+ wxWindowList::Node* pNode = GetChildren().GetFirst();
+
+ while (pNode)
+ {
+ wxWindow* pChild = pNode->GetData();
+
+ pChild->Enable(bEnable);
+ pNode = pNode->GetNext();
+ }
return(TRUE);
-}
+} // end of wxWindow::Enable
-bool wxWindow::Show(bool show) // check if base implementation is OK
+bool wxWindow::Show(
+ bool bShow
+)
{
- // TODO:
+ if (!wxWindowBase::Show(bShow))
+ return(FALSE);
+
+ HWND hWnd = GetHwnd();
+
+ ::WinShowWindow(hWnd, bShow);
+
+ if (bShow)
+ {
+ ::WinSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER);
+ }
return(TRUE);
-}
+} // end of wxWindow::Show
void wxWindow::Raise()
{
- // TODO:
-}
+ ::WinSetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_ACTIVATE);
+} // end of wxWindow::Raise
void wxWindow::Lower()
{
- // TODO:
-}
+ ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER | SWP_DEACTIVATE);
+} // end of wxWindow::Lower
-void wxWindow::SetTitle( const wxString& title)
+void wxWindow::SetTitle(
+ const wxString& rTitle
+)
{
- SetWindowText(GetHwnd(), title.c_str());
-}
+ ::WinSetWindowText(GetHwnd(), rTitle.c_str());
+} // end of wxWindow::SetTitle
wxString wxWindow::GetTitle() const
{
return wxGetWindowText(GetHWND());
-}
+} // end of wxWindow::GetTitle
void wxWindow::CaptureMouse()
{
- // TODO:
-}
+ HWND hWnd = GetHwnd();
+
+ if (hWnd && !m_bWinCaptured)
+ {
+ ::WinSetCapture(HWND_DESKTOP, hWnd);
+ m_bWinCaptured = TRUE;
+ }
+} // end of wxWindow::GetTitle
void wxWindow::ReleaseMouse()
{
- // TODO:
-}
+ if (m_bWinCaptured)
+ {
+ ::WinSetCapture(HWND_DESKTOP, NULLHANDLE);
+ m_bWinCaptured = FALSE;
+ }
+} // end of wxWindow::ReleaseMouse
-bool wxWindow::SetFont(const wxFont& f)
+bool wxWindow::SetFont(
+ const wxFont& rFont
+)
{
- // TODO:
+ if (!wxWindowBase::SetFont(rFont))
+ {
+ // nothing to do
+ return(FALSE);
+ }
+
+ HWND hWnd = GetHwnd();
+
+ if (hWnd != 0)
+ {
+ wxChar zFont[128];
+
+ sprintf(zFont, "%d.%s", rFont.GetPointSize(), rFont.GetFaceName().c_str());
+ return(::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont), (PVOID)zFont));
+ }
return(TRUE);
}
-bool wxWindow::SetCursor(const wxCursor& cursor) // check if base implementation is OK
+bool wxWindow::SetCursor(
+ const wxCursor& rCursor
+) // check if base implementation is OK
{
- // TODO:
- return(TRUE);
-}
+ if ( !wxWindowBase::SetCursor(rCursor))
+ {
+ // no change
+ return FALSE;
+ }
+
+ wxASSERT_MSG( m_cursor.Ok(),
+ wxT("cursor must be valid after call to the base version"));
+
+ HWND hWnd = GetHwnd();
+ POINTL vPoint;
+ RECTL vRect;
+ HPS hPS;
+ HRGN hRGN;
+
+ hPS = ::WinGetPS(hWnd);
-void wxWindow::WarpPointer(int x_pos, int y_pos)
+ ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
+ ::WinQueryWindowRect(hWnd, &vRect);
+
+ hRGN = ::GpiCreateRegion(hPS, 1L, &vRect);
+
+ if ((::GpiPtInRegion(hPS, hRGN, &vPoint) == PRGN_INSIDE) && !wxIsBusy())
+ {
+ ::WinSetPointer(HWND_DESKTOP, (HPOINTER)m_cursor.GetHCURSOR());
+ }
+ return TRUE;
+} // end of wxWindow::SetCursor
+
+void wxWindow::WarpPointer(
+ int nXPos
+, int nYPos
+)
{
- // TODO:
-}
+ int nX = nXPos;
+ int nY = nYPos;
+ RECTL vRect;
+
+ ::WinQueryWindowRect(GetHwnd(), &vRect);
+ nX += vRect.xLeft;
+ nY += vRect.yBottom;
+
+ ::WinSetPointerPos(HWND_DESKTOP, (LONG)nX, (LONG)(nY));
+} // end of wxWindow::WarpPointer
#if WXWIN_COMPATIBILITY
void wxWindow::OS2DeviceToLogical (float *x, float *y) const
// ---------------------------------------------------------------------------
#if WXWIN_COMPATIBILITY
-void wxWindow::SetScrollRange(int orient, int range, bool refresh)
-{
- // TODO:
+void wxWindow::SetScrollRange(
+ int nOrient
+, int nRange
+, bool bRefresh
+)
+{
+ ::WinSendMsg(GetHwnd(), SBM_SETSCROLLBAR, (MPARAM)0, MPFROM2SHORT(0, nRange));
+} // end of wxWindow::SetScrollRange
+
+void wxWindow::SetScrollPage(
+ int nOrient
+, int nPage
+, bool bRefresh
+)
+{
+ if ( orient == wxHORIZONTAL )
+ m_xThumbSize = page;
+ else
+ m_yThumbSize = page;
}
-void wxWindow::SetScrollPage(int orient, int page, bool refresh)
+int wxWindow::OldGetScrollRange(
+ int nOrient
+) const
{
- // TODO:
-}
+ MRESULT mRc;
+ HWND hWnd = GetHwnd();
-int wxWindow::OldGetScrollRange(int orient) const
-{
- // TODO:
- return 0;
-}
+ if (hWnd)
+ {
+ mRc = WinSendMsg(hWnd, SBM_QUERYRANGE, (MPARAM)0L, (MPARAM)0L);
+ return(SHORT2FROMMR(mRc));
+ }
+ return 0;
+} // end of wxWindow::OldGetScrollRange
+
+int wxWindow::GetScrollPage(
+ int nOrient
+) const
+{
+ if (nOrient == wxHORIZONTAL)
+ return m_nXThumbSize;
+ else
+ return m_nYThumbSize;
+} // end of wxWindow::GetScrollPage
+#endif // WXWIN_COMPATIBILITY
-int wxWindow::GetScrollPage(int orient) const
+int wxWindow::GetScrollPos(
+ int nOrient
+) const
{
- // TODO:
- return(1);
-}
+ return((int)::WinSendMsg(GetHwnd(), SBM_QUERYPOS, (MPARAM)NULL, (MPARAM)NULL));
+} // end of wxWindow::GetScrollPos
-int wxWindow::GetScrollPos(int orient) const
+int wxWindow::GetScrollRange(
+ int nOrient
+) const
{
- // TODO:
- return(1);
-}
+ MRESULT mr;
-int wxWindow::GetScrollRange(int orient) const
-{
- // TODO:
- return(1);
-}
+ mr = ::WinSendMsg(GetHwnd(), SBM_QUERYRANGE, (MPARAM)NULL, (MPARAM)NULL);
+ return((int)SHORT2FROMMR(mr));
+} // end of wxWindow::GetScrollRange
-int wxWindow::GetScrollThumb(int orient) const
+int wxWindow::GetScrollThumb(
+ int nOrient
+) const
{
- // TODO:
- return(1);
-}
+ WNDPARAMS vWndParams;
+ PSBCDATA pSbcd;
+
+ ::WinSendMsg(GetHwnd(), WM_QUERYWINDOWPARAMS, (MPARAM)&vWndParams, (MPARAM)NULL);
+ pSbcd = (PSBCDATA)vWndParams.pCtlData;
+ return((int)pSbcd->posThumb);
+} // end of wxWindow::GetScrollThumb
-void wxWindow::SetScrollPos( int orient
- ,int pos
- ,bool refresh
- )
+void wxWindow::SetScrollPos(
+ int nOrient
+, int nPos
+, bool bRefresh
+)
{
- // TODO:
-}
+ ::WinSendMsg(GetHwnd(), SBM_SETPOS, (MPARAM)nPos, (MPARAM)NULL);
+} // end of wxWindow::SetScrollPos(
-void wxWindow::SetScrollbar( int orient
- ,int pos
- ,int thumbVisible
- ,int range
- ,bool refresh
- )
+void wxWindow::SetScrollbar(
+ int nOrient
+, int nPos
+, int nThumbVisible
+, int nRange
+, bool bRefresh
+)
{
- // TODO:
-}
+ ::WinSendMsg(GetHwnd(), SBM_SETSCROLLBAR, (MPARAM)nPos, MPFROM2SHORT(0, nRange));
+ if (nOrient == wxHORIZONTAL)
+ {
+ m_nXThumbSize = nThumbVisible;
+ }
+ else
+ {
+ m_nYThumbSize = nThumbVisible;
+ }
+} // end of wxWindow::SetScrollbar
-void wxWindow::ScrollWindow( int dx
- ,int dy
- ,const wxRect* rect
- )
+void wxWindow::ScrollWindow(
+ int nDx
+, int nDy
+, const wxRect* pRect
+)
{
- // TODO:
-}
+ RECTL vRect2;
+
+ if (pRect)
+ {
+ vRect2.xLeft = pRect->x;
+ vRect2.yTop = pRect->y;
+ vRect2.xRight = pRect->x + pRect->width;
+ vRect2.yBottom = pRect->y + pRect->height;
+ }
+
+ if (pRect)
+ ::WinScrollWindow(GetHwnd(), (LONG)nDx, (LONG)nDy, &vRect2, NULL, NULLHANDLE, NULL, 0L);
+ else
+ ::WinScrollWindow(GetHwnd(), nDx, nDy, NULL, NULL, NULLHANDLE, NULL, 0L);
+} // end of wxWindow::ScrollWindow
// ---------------------------------------------------------------------------
// subclassing
// ---------------------------------------------------------------------------
-void wxWindow::SubclassWin(WXHWND hWnd)
+void wxWindow::SubclassWin(
+ WXHWND hWnd
+)
{
- wxASSERT_MSG( !m_oldWndProc, wxT("subclassing window twice?") );
+ HAB hab;
+ HWND hwnd = (HWND)hWnd;
- HWND hwnd = (HWND)hWnd;
-/*
-* TODO: implement something like this:
-* wxCHECK_RET( ::IsWindow(hwnd), wxT("invalid HWND in SubclassWin") );
-*
-* wxAssociateWinWithHandle(hwnd, this);
-*
-* m_oldWndProc = (WXFARPROC) GetWindowLong(hwnd, GWL_WNDPROC);
-* SetWindowLong(hwnd, GWL_WNDPROC, (LONG) wxWndProc);
-*/
-}
+ wxASSERT_MSG( !m_fnOldWndProc, wxT("subclassing window twice?") );
+
+ wxCHECK_RET(::WinIsWindow(hab, hwnd), wxT("invalid HWND in SubclassWin") );
+
+ wxAssociateWinWithHandle(hwnd, this);
+
+ m_fnOldWndProc = (WXFARPROC) ::WinSubclassWindow(hwnd, (PFNWP)wxWndProc);
+ ::WinSetWindowULong(hwnd, QWS_USER, (ULONG)wxWndProc);
+} // end of wxWindow::SubclassWin
void wxWindow::UnsubclassWin()
{
-/*
-* TODO:
+ HAB hab;
wxRemoveHandleAssociation(this);
+ //
// Restore old Window proc
- HWND hwnd = GetHwnd();
- if ( hwnd )
+ //
+ HWND hwnd = GetHwnd();
+
+ if (hwnd)
{
m_hWnd = 0;
- wxCHECK_RET( ::IsWindow(hwnd), wxT("invalid HWND in UnsubclassWin") );
+ wxCHECK_RET( ::WinIsWindow(hab, hwnd), wxT("invalid HWND in UnsubclassWin") );
- FARPROC farProc = (FARPROC) GetWindowLong(hwnd, GWL_WNDPROC);
- if ( (m_oldWndProc != 0) && (farProc != (FARPROC) m_oldWndProc) )
+ PFNWP fnProc = (PFNWP)::WinQueryWindowULong(hwnd, QWS_USER);
+ if ( (m_fnOldWndProc != 0) && (fnProc != (PFNWP) m_fnOldWndProc))
{
- SetWindowLong(hwnd, GWL_WNDPROC, (LONG) m_oldWndProc);
- m_oldWndProc = 0;
+ WinSubclassWindow(hwnd, (PFNWP)m_fnOldWndProc);
+ m_fnOldWndProc = 0;
}
}
-*/
-}
+} // end of wxWindow::UnsubclassWin
+//
// Make a Windows extended style from the given wxWindows window style
-WXDWORD wxWindow::MakeExtendedStyle(long style, bool eliminateBorders)
-{
- // TODO:
- WXDWORD exStyle = 0;
-/*
- if ( style & wxTRANSPARENT_WINDOW )
- exStyle |= WS_EX_TRANSPARENT;
-
- if ( !eliminateBorders )
- {
- if ( style & wxSUNKEN_BORDER )
- exStyle |= WS_EX_CLIENTEDGE;
- if ( style & wxDOUBLE_BORDER )
- exStyle |= WS_EX_DLGMODALFRAME;
- if ( style & wxRAISED_BORDER )
- exStyle |= WS_EX_WINDOWEDGE;
- if ( style & wxSTATIC_BORDER )
- exStyle |= WS_EX_STATICEDGE;
- }
-*/
+//
+WXDWORD wxWindow::MakeExtendedStyle(
+ long lStyle
+, bool bEliminateBorders
+)
+{
+ //
+ // PM does not support extended style
+ //
+ WXDWORD exStyle = 0;
return exStyle;
-}
+} // end of wxWindow::MakeExtendedStyle
+//
// Determines whether native 3D effects or CTL3D should be used,
// applying a default border style if required, and returning an extended
// style to pass to CreateWindowEx.
-WXDWORD wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle,
- bool *want3D) const
+//
+WXDWORD wxWindow::Determine3DEffects(
+ WXDWORD dwDefaultBorderStyle
+, bool* pbWant3D
+) const
{
- DWORD exStyle; // remove after implementation doe
-/* TODO: this ought to be fun
-*
- // If matches certain criteria, then assume no 3D effects
- // unless specifically requested (dealt with in MakeExtendedStyle)
- if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl)) || (m_windowStyle & wxNO_BORDER) )
- {
- *want3D = FALSE;
- return MakeExtendedStyle(m_windowStyle, FALSE);
- }
-
- // Determine whether we should be using 3D effects or not.
- bool nativeBorder = FALSE; // by default, we don't want a Win95 effect
-
- // 1) App can specify global 3D effects
- *want3D = wxTheApp->GetAuto3D();
-
- // 2) If the parent is being drawn with user colours, or simple border specified,
- // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
- if ( GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS) || (m_windowStyle & wxSIMPLE_BORDER) )
- *want3D = FALSE;
-
- // 3) Control can override this global setting by defining
- // a border style, e.g. wxSUNKEN_BORDER
- if ( m_windowStyle & wxSUNKEN_BORDER )
- *want3D = TRUE;
-
- // 4) If it's a special border, CTL3D can't cope so we want a native border
- if ( (m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSTATIC_BORDER) )
- {
- *want3D = TRUE;
- nativeBorder = TRUE;
- }
-
- // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
- // effects from extended style
-#if wxUSE_CTL3D
- if ( *want3D )
- nativeBorder = FALSE;
-#endif
+ WXDWORD dwStyle = 0L;
- DWORD exStyle = MakeExtendedStyle(m_windowStyle, !nativeBorder);
-
- // If we want 3D, but haven't specified a border here,
- // apply the default border style specified.
- // TODO what about non-Win95 WIN32? Does it have borders?
-#if defined(__WIN95__) && !wxUSE_CTL3D
- if ( defaultBorderStyle && (*want3D) && ! ((m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER ) ||
- (m_windowStyle & wxSTATIC_BORDER) || (m_windowStyle & wxSIMPLE_BORDER) ))
- exStyle |= defaultBorderStyle; // WS_EX_CLIENTEDGE;
-#endif
-*/
- return exStyle;
-}
+ //
+ // Native PM does not have any specialize 3D effects like WIN32 does
+ //
+ *pbWant3D = FALSE;
+ return dwStyle;
+} // end of wxWindow::Determine3DEffects
#if WXWIN_COMPATIBILITY
-void wxWindow::OnCommand(wxWindow& win, wxCommandEvent& event)
-{
- // TODO:
-}
-
-wxObject* wxWindow::GetChild(int number) const
+void wxWindow::OnCommand(
+ wxWindow& rWin
+, wxCommandEvent& rEvent
+)
{
- // TODO:
- return((wxObject*)this);
-}
-
-void wxWindow::OnDefaultAction(wxControl *initiatingItem)
-{
- // TODO:
-}
+ if (GetEventHandler()->ProcessEvent(rEvent))
+ return;
+ if (m_parent)
+ m_parent->GetEventHandler()->OnCommand( rWin
+ ,rEvent
+ );
+} // end of wxWindow::OnCommand
+
+wxObject* wxWindow::GetChild(
+ int nNumber
+) const
+{
+ //
+ // Return a pointer to the Nth object in the Panel
+ //
+ wxNode* pNode = GetChildren().First();
+ int n = nNumber;
+
+ while (pNode && n--)
+ pNode = pNode->Next();
+ if (pNode)
+ {
+ wxObject* pObj = (wxObject*)pNode->Data();
+ return(pObj);
+ }
+ else
+ return NULL;
+} // end of wxWindow::GetChild
#endif // WXWIN_COMPATIBILITY
+//
// Setup background and foreground colours correctly
+//
void wxWindow::SetupColours()
{
if ( GetParent() )
SetBackgroundColour(GetParent()->GetBackgroundColour());
-}
+} // end of wxWindow::SetupColours
-void wxWindow::OnIdle(wxIdleEvent& event)
+void wxWindow::OnIdle(
+ wxIdleEvent& rEvent
+)
{
- // TODO:
-}
+ //
+ // Check if we need to send a LEAVE event
+ //
+ if (m_bMouseInWindow)
+ {
+ POINTL vPoint;
+ ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
+ if (::WinWindowFromPoint(HWND_DESKTOP, &vPoint, FALSE) != (HWND)GetHwnd())
+ {
+ //
+ // Generate a LEAVE event
+ //
+ m_bMouseInWindow = FALSE;
+
+ //
+ // Unfortunately the mouse button and keyboard state may have changed
+ // by the time the OnIdle function is called, so 'state' may be
+ // meaningless.
+ //
+ int nState = 0;
+
+ if (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) != 0)
+ nState |= VK_SHIFT;
+ if (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) != 0);
+ nState |= VK_CTRL;
+
+ wxMouseEvent rEvent(wxEVT_LEAVE_WINDOW);
+
+ InitMouseEvent( rEvent
+ ,vPoint.x
+ ,vPoint.y
+ ,nState
+ );
+ (void)GetEventHandler()->ProcessEvent(rEvent);
+ }
+ }
+ UpdateWindowUI();
+} // end of wxWindow::OnIdle
+
+//
// Set this window to be the child of 'parent'.
-bool wxWindow::Reparent(wxWindow *parent)
+//
+bool wxWindow::Reparent(
+ wxWindow* pParent
+)
{
- if ( !wxWindowBase::Reparent(parent) )
+ if (!wxWindowBase::Reparent(pParent))
return FALSE;
- // TODO:
- return FALSE;
-}
+
+ HWND hWndChild = GetHwnd();
+ HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0;
+
+ ::WinSetParent(hWndChild, hWndParent, TRUE);
+ return TRUE;
+} // end of wxWindow::Reparent
void wxWindow::Clear()
{
- // TODO:
-}
+ wxClientDC vDc(this);
+ wxBrush vBrush( GetBackgroundColour()
+ ,wxSOLID
+ );
-void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
+ vDc.SetBackground(vBrush);
+ vDc.Clear();
+} // end of wxWindow::Clear
+
+void wxWindow::Refresh(
+ bool bEraseBack
+, const wxRect* pRect
+)
{
- // TODO:
-}
+ HWND hWnd = GetHwnd();
+
+ if (hWnd)
+ {
+ if (pRect)
+ {
+ RECTL vOs2Rect;
+
+ vOs2Rect.xLeft = pRect->x;
+ vOs2Rect.yTop = pRect->y;
+ vOs2Rect.xRight = pRect->x + pRect->width;
+ vOs2Rect.yBottom = pRect->y + pRect->height;
+
+ ::WinInvalidateRect(hWnd, &vOs2Rect, bEraseBack);
+ }
+ else
+ ::WinInvalidateRect(hWnd, NULL, bEraseBack);
+ }
+} // end of wxWindow::Refresh
// ---------------------------------------------------------------------------
// drag and drop
// ---------------------------------------------------------------------------
#if wxUSE_DRAG_AND_DROP
-void wxWindow::SetDropTarget(wxDropTarget *pDropTarget)
+void wxWindow::SetDropTarget(
+ wxDropTarget* pDropTarget
+)
{
- // TODO:
-}
+ 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 wxWindow::SetDropTarget
#endif
+//
// old style file-manager drag&drop support: we retain the old-style
// DragAcceptFiles in parallel with SetDropTarget.
-void wxWindow::DragAcceptFiles(bool accept)
+//
+void wxWindow::DragAcceptFiles(
+ bool bAccept
+)
{
- // TODO:
-}
+ HWND hWnd = GetHwnd();
+
+ if (hWnd && bAccept)
+ ::DrgAcceptDroppedFiles(hWnd, NULL, NULL, DO_COPY, 0L);
+} // end of wxWindow::DragAcceptFiles
// ----------------------------------------------------------------------------
// tooltips
#if wxUSE_TOOLTIPS
-void wxWindow::DoSetToolTip(wxToolTip *tooltip)
+void wxWindow::DoSetToolTip(
+ wxToolTip* pTooltip
+)
{
- wxWindowBase::DoSetToolTip(tooltip);
+ wxWindowBase::DoSetToolTip(pTooltip);
- if ( m_tooltip )
+ if (m_tooltip)
m_tooltip->SetWindow(this);
-}
+} // end of wxWindow::DoSetToolTip
#endif // wxUSE_TOOLTIPS
// ---------------------------------------------------------------------------
// Get total size
-void wxWindow::DoGetSize( int *width, int *height ) const
-{
- // TODO:
-}
+void wxWindow::DoGetSize(
+ int* pWidth
+, int* pHeight
+) const
+{
+ HWND hWnd = GetHwnd();
+ RECTL vRect;
+
+ ::WinQueryWindowRect(hWnd, &vRect);
+
+ if (pWidth)
+ *pWidth = vRect.xRight - vRect.xLeft;
+ if (pHeight )
+ // OS/2 PM is backwards from windows
+ *pHeight = vRect.yTop - vRect.yBottom;
+} // end of wxWindow::DoGetSize
+
+void wxWindow::DoGetPosition(
+ int* pX
+, int* pY
+) const
+{
+ HWND hWnd = GetHwnd();
+ RECT vRect;
+ POINTL vPoint;
+
+ ::WinQueryWindowRect(hWnd, &vRect);
+
+ vPoint.x = vRect.xLeft;
+ vPoint.y = vRect.yBottom;
+
+ //
+ // We do the adjustments with respect to the parent only for the "real"
+ // children, not for the dialogs/frames
+ //
+ if (!IsTopLevel())
+ {
+ HWND hParentWnd = 0;
+ wxWindow* pParent = GetParent();
-void wxWindow::DoGetPosition( int *x, int *y ) const
-{
- // TODO:
-}
+ if (pParent)
+ hParentWnd = GetWinHwnd(pParent);
-void wxWindow::DoScreenToClient( int *x, int *y ) const
-{
- // TODO:
-}
+ //
+ // Since we now have the absolute screen coords, if there's a parent we
+ // must subtract its bottom left corner
+ //
+ if (hParentWnd)
+ {
+ RECTL vRect2;
-void wxWindow::DoClientToScreen( int *x, int *y ) const
-{
- // TODO:
-}
+ ::WinQueryWindowRect(hParentWnd, &vRect2);
+ vPoint.x -= vRect.xLeft;
+ vPoint.y -= vRect.yBottom;
+ }
-// Get size *available for subwindows* i.e. excluding menu bar etc.
-void wxWindow::DoGetClientSize( int *width, int *height ) const
+ //
+ // We may be faking the client origin. So a window that's really at (0,
+ // 30) may appear (to wxWin apps) to be at (0, 0).
+ //
+ wxPoint vPt(pParent->GetClientAreaOrigin());
+
+ vPoint.x -= vPt.x;
+ vPoint.y -= vPt.y;
+ }
+
+ if (pX)
+ *pX = vPoint.x;
+ if (pY)
+ *pY = vPoint.y;
+} // end of wxWindow::DoGetPosition
+
+void wxWindow::DoScreenToClient(
+ int* pX
+, int* pY
+) const
{
- // TODO:
-}
+ HWND hWnd = GetHwnd();
+ SWP vSwp;
-void wxWindow::DoMoveWindow(int x, int y, int width, int height)
+ ::WinQueryWindowPos(hWnd, &vSwp);
+
+ if (pX)
+ *pX -= vSwp.x;
+ if (pY)
+ *pY -= vSwp.y;
+} // end of wxWindow::DoScreenToClient
+
+void wxWindow::DoClientToScreen(
+ int* pX
+, int* pY
+) const
{
- // TODO:
-}
+ HWND hWnd = GetHwnd();
+ SWP vSwp;
+
+ ::WinQueryWindowPos(hWnd, &vSwp);
+
+ if (pX)
+ *pX += vSwp.x;
+ if (pY)
+ *pY += vSwp.y;
+} // end of wxWindow::DoClientToScreen
+
+//
+// Get size *available for subwindows* i.e. excluding menu bar etc.
+// Must be a frame type window
+//
+void wxWindow::DoGetClientSize(
+ int* pWidth
+, int* pHeight
+) const
+{
+ HWND hWnd = GetHwnd();
+ HWND hWndClient;
+ RECTL vRect;
+
+ hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
+ ::WinQueryWindowRect(hWndClient, &vRect);
+
+ if (pWidth)
+ *pWidth = vRect.xRight;
+ if (pHeight)
+ *pHeight = vRect.yTop;
+} // end of wxWindow::DoGetClientSize
+
+void wxWindow::DoMoveWindow(
+ int nX
+, int nY
+, int nWidth
+, int nHeight
+)
+{
+ if ( !::WinSetWindowPos( GetHwnd()
+ ,HWND_TOP
+ ,(LONG)nX
+ ,(LONG)nY
+ ,(LONG)nWidth
+ ,(LONG)nHeight
+ ,SWP_SIZE | SWP_MOVE
+ ))
+ {
+ wxLogLastError("MoveWindow");
+ }
+} // end of wxWindow::DoMoveWindow
-// set the size of the window: if the dimensions are positive, just use them,
+//
+// Set the size of the window: if the dimensions are positive, just use them,
// but if any of them is equal to -1, it means that we must find the value for
// it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
// which case -1 is a valid value for x and y)
// If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
// the width/height to best suit our contents, otherwise we reuse the current
// width/height
-void wxWindow::DoSetSize(int x, int y,
- int width, int height,
- int sizeFlags)
-{
- // TODO:
-}
+//
+void wxWindow::DoSetSize(
+ int nX
+, int nY
+, int nWidth
+, int nHeight
+, int nSizeFlags
+)
+{
+ //
+ // Get the current size and position...
+ //
+ int nCurrentX;
+ int nCurrentY;
+ int nCurrentWidth;
+ int nCurrentHeight;
+ wxSize vSize(-1, -1);
+
+ GetPosition( &nCurrentX
+ ,&nCurrentY
+ );
+ GetSize( &nCurrentWidth
+ ,&nCurrentHeight
+ );
+
+ //
+ // ... and don't do anything (avoiding flicker) if it's already ok
+ //
+ if ( nX == nCurrentX &&
+ nY == nCurrentY &&
+ nWidth == nCurrentWidth &&
+ nHeight == nCurrentHeight
+ )
+ {
+ return;
+ }
-// for a generic window there is no natural best size - just use the current one
-wxSize wxWindow::DoGetBestSize()
-{
- return GetSize();
-}
+ if (nX == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ nX = nCurrentX;
+ if (nY == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ nY = nCurrentY;
-void wxWindow::DoSetClientSize(int width, int height)
-{
- // TODO:
-}
+ AdjustForParentClientOrigin( nX
+ ,nY
+ ,nSizeFlags
+ );
+
+ if (nWidth == -1)
+ {
+ if (nSizeFlags & wxSIZE_AUTO_WIDTH)
+ {
+ vSize = DoGetBestSize();
+ nWidth = vSize.x;
+ }
+ else
+ {
+ //
+ // Just take the current one
+ //
+ nWidth = nCurrentWidth;
+ }
+ }
+
+ if (nHeight == -1)
+ {
+ if (nSizeFlags & wxSIZE_AUTO_HEIGHT)
+ {
+ if (vSize.x == -1)
+ {
+ vSize = DoGetBestSize();
+ }
+ nHeight = vSize.y;
+ }
+ else
+ {
+ // just take the current one
+ nHeight = nCurrentHeight;
+ }
+ }
+
+ DoMoveWindow( nX
+ ,nY
+ ,nWidth
+ ,nHeight
+ );
+} // end of wxWindow::DoSetSize
+
+void wxWindow::DoSetClientSize(
+ int nWidth
+, int nHeight
+)
+{
+ wxWindow* pParent = GetParent();
+ HWND hWnd = GetHwnd();
+ HWND hParentWnd = (HWND)0;
+ HWND hClientWnd = (HWND)0;
+ RECTL vRect;
+ RECT vRect2;
+ RECT vRect3;
+
+ hClientWnd = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
+ ::WinQueryWindowRect(hClientWnd, &vRect2);
+
+ if (pParent)
+ hParentWnd = (HWND) pParent->GetHWND();
+
+ ::WinQueryWindowRect(hWnd, &vRect);
+ ::WinQueryWindowRect(hParentWnd, &vRect3);
+ //
+ // Find the difference between the entire window (title bar and all)
+ // and the client area; add this to the new client size to move the
+ // window. OS/2 is backward from windows on height
+ //
+ int nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth;
+ int nActualHeight = vRect2.yTop - vRect2.yBottom - vRect.yTop + nHeight;
+
+ //
+ // If there's a parent, must subtract the parent's bottom left corner
+ // since MoveWindow moves relative to the parent
+ //
+ POINTL vPoint;
+
+ vPoint.x = vRect2.xLeft;
+ vPoint.y = vRect2.yBottom;
+ if (pParent)
+ {
+ vPoint.x -= vRect3.xLeft;
+ vPoint.y -= vRect3.yBottom;
+ }
+
+ DoMoveWindow( vPoint.x
+ ,vPoint.y
+ ,nActualWidth
+ ,nActualHeight
+ );
+
+ wxSizeEvent vEvent( wxSize( nWidth
+ ,nHeight
+ )
+ ,m_windowId
+ );
+
+ vEvent.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(vEvent);
+} // end of wxWindow::DoSetClientSize
wxPoint wxWindow::GetClientAreaOrigin() const
{
return wxPoint(0, 0);
-}
+} // end of wxWindow::GetClientAreaOrigin
+
+void wxWindow::AdjustForParentClientOrigin(
+ int& rX
+, int& rY
+, int nSizeFlags
+)
+{
+ //
+ // Don't do it for the dialogs/frames - they float independently of their
+ // parent
+ //
+ if (!IsTopLevel())
+ {
+ wxWindow* pParent = GetParent();
-void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags)
-{
- // TODO:
-}
+ if (!(nSizeFlags & wxSIZE_NO_ADJUSTMENTS) && pParent)
+ {
+ wxPoint vPoint(pParent->GetClientAreaOrigin());
+ rX += vPoint.x;
+ rY += vPoint.y;
+ }
+ }
+} // end of wxWindow::AdjustForParentClientOrigin
// ---------------------------------------------------------------------------
// text metrics
// ---------------------------------------------------------------------------
-int wxWindow::GetCharHeight() const
+int wxWindow::GetCharHeight() const
{
- // TODO:
- return(1);
-}
+ HPS hPs;
+ FONTMETRICS vFontMetrics;
+ BOOL bRc;
-int wxWindow::GetCharWidth() const
-{
- // TODO:
- return(1);
-}
+ hPs = ::WinGetPS(GetHwnd());
+
+ if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics))
+ return (0);
+ else
+ return(vFontMetrics.lMaxAscender + vFontMetrics.lMaxDescender);
+ ::WinReleasePS(hPs);
+} // end of wxWindow::GetCharHeight
-void wxWindow::GetTextExtent( const wxString& string
- ,int* x
- ,int* y
- ,int* descent
- ,int* externalLeading
- ,const wxFont* theFont
- ) const
+int wxWindow::GetCharWidth() const
{
- // TODO:
+ HPS hPs;
+ FONTMETRICS vFontMetrics;
+
+ hPs = ::WinGetPS(GetHwnd());
+
+ if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics))
+ return (0);
+ else
+ return(vFontMetrics.lAveCharWidth);
+ ::WinReleasePS(hPs);
+} // end of wxWindow::GetCharWidth
+
+void wxWindow::GetTextExtent(
+ const wxString& rString
+, int* pX
+, int* pY
+, int* pDescent
+, int* pExternalLeading
+, const wxFont* pTheFont
+) const
+{
+ const wxFont* pFontToUse = pTheFont;
+ HPS hPs;
+
+ hPs = ::WinGetPS(GetHwnd());
+/*
+// TODO: Will have to play with fonts later
+
+ if (!pFontToUse)
+ pFontToUse = &m_font;
+
+ HFONT hFnt = 0;
+ HFONT hFfontOld = 0;
+
+ if (pFontToUse && pFontToUse->Ok())
+ {
+ ::GpiCreateLog
+ hFnt = (HFONT)((wxFont *)pFontToUse)->GetResourceHandle(); // const_cast
+ if (hFnt)
+ hFontOld = (HFONT)SelectObject(dc,fnt);
+ }
+
+ SIZE sizeRect;
+ TEXTMETRIC tm;
+ GetTextExtentPoint(dc, string, (int)string.Length(), &sizeRect);
+ GetTextMetrics(dc, &tm);
+
+ if ( fontToUse && fnt && hfontOld )
+ SelectObject(dc, hfontOld);
+
+ ReleaseDC(hWnd, dc);
+
+ if ( x )
+ *x = sizeRect.cx;
+ if ( y )
+ *y = sizeRect.cy;
+ if ( descent )
+ *descent = tm.tmDescent;
+ if ( externalLeading )
+ *externalLeading = tm.tmExternalLeading;
+*/
+ ::WinReleasePS(hPs);
}
#if wxUSE_CARET && WXWIN_COMPATIBILITY
// Caret manipulation
// ---------------------------------------------------------------------------
-void wxWindow::CreateCaret(int w, int h)
+void wxWindow::CreateCaret(
+ int nWidth
+, int nHeight
+)
{
- // TODO:
-}
+ SetCaret(new wxCaret( this
+ ,nWidth
+ ,nHeight
+ ));
+} // end of wxWindow::CreateCaret
-void wxWindow::CreateCaret(const wxBitmap *bitmap)
+void wxWindow::CreateCaret(
+ const wxBitmap* pBitmap
+)
{
- // TODO:
-}
+ wxFAIL_MSG("not implemented");
+} // end of wxWindow::CreateCaret
-void wxWindow::ShowCaret(bool show)
+void wxWindow::ShowCaret(
+ bool bShow
+)
{
- // TODO:
-}
+ wxCHECK_RET( m_caret, "no caret to show" );
+
+ m_caret->Show(bShow);
+} // end of wxWindow::ShowCaret
void wxWindow::DestroyCaret()
{
- // TODO:
-}
+ SetCaret(NULL);
+} // end of wxWindow::DestroyCaret
-void wxWindow::SetCaretPos(int x, int y)
+void wxWindow::SetCaretPos(
+ int nX
+, int nY)
{
- // TODO:
-}
+ wxCHECK_RET( m_caret, "no caret to move" );
-void wxWindow::GetCaretPos(int *x, int *y) const
+ m_caret->Move( nX
+ ,nY
+ );
+} // end of wxWindow::SetCaretPos
+
+void wxWindow::GetCaretPos(
+ int* pX
+, int* pY
+) const
{
- // TODO:
-}
+ wxCHECK_RET( m_caret, "no caret to get position of" );
+
+ m_caret->GetPosition( pX
+ ,pY
+ );
+} // end of wxWindow::GetCaretPos
#endif //wxUSE_CARET
// pre/post message processing
// ===========================================================================
-MRESULT wxWindow::OS2DefWindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+MRESULT wxWindow::OS2DefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
// TODO:
return (MRESULT)0;
void wxWindow::UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd)
{
- *nCtlColor = CTLCOLOR_BTN;
+ *nCtlColor = 0; // TODO: CTLCOLOR_BTN;
*hwnd = (WXHWND)lParam;
*hdc = (WXHDC)wParam;
}
void wxWindow::UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
WXWORD *item, WXWORD *flags, WXHMENU *hmenu)
{
- *item = (WXWORD)wParam;
+ *item = (WXWORD)LOWORD(wParam);
*flags = HIWORD(wParam);
*hmenu = (WXHMENU)lParam;
}
wxWindow *wxWndHook = NULL;
// Main window proc
-MRESULT wxWndProc(HWND hWnd, UINT message, MPARAM wParam, MPARAM lParam)
+MRESULT wxWndProc(HWND hWnd, ULONG message, MPARAM wParam, MPARAM lParam)
{
// trace all messages - useful for the debugging
#ifdef __WXDEBUG__
else
{
if ( wnd )
- rc = wnd->OS2WindowProc(hWnd, message, wParam, lParam);
+ rc = wnd->OS2WindowProc(message, wParam, lParam);
else
- rc = DefWindowProc( hWnd, message, wParam, lParam );
+ rc = 0; //TODO: DefWindowProc( hWnd, message, wParam, lParam );
}
return rc;
}
-MRESULT wxWindow::OS2WindowProc(HWND hWnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+MRESULT wxWindow::OS2WindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
// did we process the message?
bool processed = FALSE;
rc.result = MSWDefWindowProc(message, wParam, lParam);
}
*/
- return rc.result;
+ return (MRESULT)0;
}
// Dialog window proc
-MRESULT wxDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+MRESULT wxDlgProc(HWND hWnd, UINT message, MPARAM wParam, MPARAM lParam)
{
// TODO:
/*
return (MRESULT)0;
}
-wxList *wxWinHandleList = NULL;
wxWindow *wxFindWinFromHandle(WXHWND hWnd)
{
wxNode *node = wxWinHandleList->Find((long)hWnd);
#if wxUSE_DRAG_AND_DROP
if ( m_dropTarget != NULL )
{
- m_dropTarget->Revoke(m_hWnd);
+// m_dropTarget->Revoke(m_hWnd);
delete m_dropTarget;
m_dropTarget = NULL;
bool WXUNUSED(minimized),
WXHWND WXUNUSED(activate))
{
+ // TODO:
+ /*
wxActivateEvent event(wxEVT_ACTIVATE,
(state == WA_ACTIVE) || (state == WA_CLICKACTIVE),
m_windowId);
event.SetEventObject(this);
return GetEventHandler()->ProcessEvent(event);
+ */
+ return FALSE;
}
bool wxWindow::HandleSetFocus(WXHWND WXUNUSED(hwnd))
if ( GetHWND() == hWnd )
{
// don't set cursor when the mouse is not in the client part
+// TODO
+/*
if ( nHitTest == HTCLIENT || nHitTest == HTERROR )
{
HCURSOR hcursor = 0;
return TRUE;
}
}
+*/
}
return FALSE;
// owner drawn stuff
// ---------------------------------------------------------------------------
-bool wxWindow::MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *itemStruct)
+bool wxWindow::OS2OnDrawItem(int id, WXDRAWITEMSTRUCT *itemStruct)
{
// TODO:
/*
WXLPARAM lParam)
{
WXHBRUSH hBrush = 0;
-
+// TODO:
+/*
if ( nCtlColor == CTLCOLOR_DLG )
{
hBrush = OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
*brush = hBrush;
return hBrush != 0;
+*/
+ return FALSE;
}
// Define for each class of dialog and control
bool wxWindow::HandlePaint()
{
// TODO:
- Return FALSE;
+ return FALSE;
}
bool wxWindow::HandleEraseBkgnd(WXHDC hdc)
{
// Prevents flicker when dragging
- if ( ::IsIconic(GetHwnd()) )
- return TRUE;
+// if ( ::IsIconic(GetHwnd()) )
+// return TRUE;
wxDC dc;
bool wxWindow::HandleGetMinMaxInfo(void *mmInfo)
{
+// TODO:
+/*
MINMAXINFO *info = (MINMAXINFO *)mmInfo;
bool rc = FALSE;
}
return rc;
+*/
+ return FALSE;
}
// ---------------------------------------------------------------------------
wxMenu *popupMenu = wxCurrentPopupMenu;
wxCurrentPopupMenu = NULL;
- return popupMenu->MSWCommand(cmd, id);
+ return popupMenu->OS2Command(cmd, id);
}
wxWindow *win = FindItem(id);
}
if ( win )
- return win->MSWCommand(cmd, id);
+ return win->OS2Command(cmd, id);
return FALSE;
}
void wxWindow::InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags)
{
+// TODO:
+/*
event.m_x = x;
event.m_y = y;
event.m_shiftDown = ((flags & MK_SHIFT) != 0);
m_lastMouseY = y;
m_lastMouseEvent = event.GetEventType();
#endif // wxUSE_MOUSEEVENT_HACK
-
+*/
}
bool wxWindow::HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags)
bool wxWindow::HandleMouseMove(int x, int y, WXUINT flags)
{
- if ( !m_mouseInWindow )
+ if ( !m_bMouseInWindow )
{
// Generate an ENTER event
- m_mouseInWindow = TRUE;
+ m_bMouseInWindow = TRUE;
wxMouseEvent event(wxEVT_ENTER_WINDOW);
InitMouseEvent(event, x, y, flags);
{
wxWindow *child = wxFindWinFromHandle(control);
if ( child )
- return child->MSWOnScroll(orientation, wParam, pos, control);
+ return child->OS2OnScroll(orientation, wParam, pos, control);
}
wxScrollWinEvent event;
// Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
// in active frames and dialogs, regardless of where the focus is.
-static HHOOK wxTheKeyboardHook = 0;
-static FARPROC wxTheKeyboardHookProc = 0;
+//static HHOOK wxTheKeyboardHook = 0;
+//static FARPROC wxTheKeyboardHookProc = 0;
int wxKeyboardHook(int nCode, WORD wParam, DWORD lParam);
void wxSetKeyboardHook(bool doIt)
return NULL;
}
+#endif // __WXDEBUG__
+