diff --git a/src/os2/app.cpp b/src/os2/app.cpp index 1bc4e217ef..51041ae1c3 100644 --- a/src/os2/app.cpp +++ b/src/os2/app.cpp @@ -184,7 +184,7 @@ bool wxApp::RegisterWindowClasses( if (!::WinRegisterClass( vHab ,wxFrameClassName ,(PFNWP)wxWndProc - ,CS_SIZEREDRAW | CS_SYNCPAINT + ,CS_SIZEREDRAW | CS_MOVENOTIFY | CS_SYNCPAINT ,sizeof(ULONG) )) { @@ -210,7 +210,7 @@ bool wxApp::RegisterWindowClasses( if (!::WinRegisterClass( vHab ,wxMDIFrameClassName ,(PFNWP)wxWndProc - ,CS_SIZEREDRAW | CS_SYNCPAINT + ,CS_SIZEREDRAW | CS_MOVENOTIFY | CS_SYNCPAINT ,0 )) { diff --git a/src/os2/dc.cpp b/src/os2/dc.cpp index 05dbc01904..e686cfbe1e 100644 --- a/src/os2/dc.cpp +++ b/src/os2/dc.cpp @@ -42,6 +42,13 @@ static const int VIEWPORT_EXTENT = 1000; static const int MM_POINTS = 9; static const int MM_METRIC = 10; +// --------------------------------------------------------------------------- +// private functions +// --------------------------------------------------------------------------- + +// convert degrees to radians +static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; } + // =========================================================================== // implementation // =========================================================================== @@ -52,17 +59,17 @@ static const int MM_METRIC = 10; wxDC::wxDC(void) { - m_canvas = NULL; + m_pCanvas = NULL; - m_oldBitmap = 0; - m_oldPen = 0; - m_oldBrush = 0; - m_oldFont = 0; - m_oldPalette = 0; + m_hOldBitmap = 0; + m_hOldPen = 0; + m_hOldBrush = 0; + m_hOldFont = 0; + m_hOldPalette = 0; - m_bOwnsDC = FALSE; - m_hDC = 0; - m_hDCCount = 0; + m_bOwnsDC = FALSE; + m_hDC = 0; + m_nDCCount = 0; }; wxDC::~wxDC(void) @@ -77,52 +84,59 @@ void wxDC::SelectOldObjects(WXHDC dc) { if (dc) { - if (m_oldBitmap) + if (m_hOldBitmap) { // ::SelectObject((HDC) dc, (HBITMAP) m_oldBitmap); - if (m_selectedBitmap.Ok()) + if (m_vSelectedBitmap.Ok()) { - m_selectedBitmap.SetSelectedInto(NULL); + m_vSelectedBitmap.SetSelectedInto(NULL); } } - m_oldBitmap = 0; - if (m_oldPen) + m_hOldBitmap = 0; + if (m_hOldPen) { // ::SelectObject((HDC) dc, (HPEN) m_oldPen); } - m_oldPen = 0; - if (m_oldBrush) + m_hOldPen = 0; + if (m_hOldBrush) { // ::SelectObject((HDC) dc, (HBRUSH) m_oldBrush); } - m_oldBrush = 0; - if (m_oldFont) + m_hOldBrush = 0; + if (m_hOldFont) { // ::SelectObject((HDC) dc, (HFONT) m_oldFont); } - m_oldFont = 0; - if (m_oldPalette) + m_hOldFont = 0; + if (m_hOldPalette) { // ::SelectPalette((HDC) dc, (HPALETTE) m_oldPalette, TRUE); } - m_oldPalette = 0; + m_hOldPalette = 0; } - m_brush = wxNullBrush; - m_pen = wxNullPen; - m_palette = wxNullPalette; - m_font = wxNullFont; + m_brush = wxNullBrush; + m_pen = wxNullPen; + m_palette = wxNullPalette; + m_font = wxNullFont; m_backgroundBrush = wxNullBrush; - m_selectedBitmap = wxNullBitmap; + m_vSelectedBitmap = wxNullBitmap; } // --------------------------------------------------------------------------- // clipping // --------------------------------------------------------------------------- -void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region) -{ - // TODO +#define DO_SET_CLIPPING_BOX() \ +{ \ + RECT rect; \ + \ + GetClipBox(GetHdc(), &rect); \ + \ + m_clipX1 = (wxCoord) XDEV2LOG(rect.left); \ + m_clipY1 = (wxCoord) YDEV2LOG(rect.top); \ + m_clipX2 = (wxCoord) XDEV2LOG(rect.right); \ + m_clipY2 = (wxCoord) YDEV2LOG(rect.bottom); \ } void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y @@ -132,14 +146,9 @@ void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y // TODO } -void wxDC::DoClipping(WXHDC dc) +void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region) { - if (m_clipping && dc) - { -// TODO: -// IntersectClipRect((HDC) dc, XLOG2DEV(m_clipX1), YLOG2DEV(m_clipY1), -// XLOG2DEV(m_clipX2), YLOG2DEV(m_clipY2)); - } + // TODO } void wxDC::DestroyClippingRegion(void) @@ -213,6 +222,12 @@ void wxDC::DoDrawArc( wxCoord x1, wxCoord y1 // TODO } +void wxDC::DoDrawCheckMark(wxCoord x1, wxCoord y1, + wxCoord width, wxCoord height) +{ + // TODO +} + void wxDC::DoDrawPoint(wxCoord x, wxCoord y) { // TODO @@ -280,6 +295,11 @@ void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y) // TODO } +void wxDC::DrawAnyText(const wxString& text, wxCoord x, wxCoord y) +{ + // TODO +} + void wxDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) @@ -496,71 +516,43 @@ void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y ) wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const { - wxCoord new_x = x - m_deviceOriginX; - if (new_x > 0) - return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; - else - return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; -}; + return (wxCoord) (((x) - m_deviceOriginX)/(m_logicalScaleX*m_userScaleX*m_signX*m_scaleX) - m_logicalOriginX); +} wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const { - if (x > 0) - return (wxCoord)((double)(x) / m_scaleX + 0.5); - else - return (wxCoord)((double)(x) / m_scaleX - 0.5); -}; + return (wxCoord) ((x)/(m_logicalScaleX*m_userScaleX*m_signX*m_scaleX)); +} wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const { - wxCoord new_y = y - m_deviceOriginY; - if (new_y > 0) - return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; - else - return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; -}; + return (wxCoord) (((y) - m_deviceOriginY)/(m_logicalScaleY*m_userScaleY*m_signY*m_scaleY) - m_logicalOriginY); +} wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const { - if (y > 0) - return (wxCoord)((double)(y) / m_scaleY + 0.5); - else - return (wxCoord)((double)(y) / m_scaleY - 0.5); -}; + return (wxCoord) ((y)/(m_logicalScaleY*m_userScaleY*m_signY*m_scaleY)); +} wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const { - wxCoord new_x = x - m_logicalOriginX; - if (new_x > 0) - return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; - else - return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; -}; + return (wxCoord) ((x - m_logicalOriginX)*m_logicalScaleX*m_userScaleX*m_signX*m_scaleX + m_deviceOriginX); +} wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const { - if (x > 0) - return (wxCoord)((double)(x) * m_scaleX + 0.5); - else - return (wxCoord)((double)(x) * m_scaleX - 0.5); -}; + return (wxCoord) (x*m_logicalScaleX*m_userScaleX*m_signX*m_scaleX); +} wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const { - wxCoord new_y = y - m_logicalOriginY; - if (new_y > 0) - return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; - else - return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; -}; + return (wxCoord) ((y - m_logicalOriginY)*m_logicalScaleY*m_userScaleY*m_signY*m_scaleY + m_deviceOriginY); +} wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const { - if (y > 0) - return (wxCoord)((double)(y) * m_scaleY + 0.5); - else - return (wxCoord)((double)(y) * m_scaleY - 0.5); -}; + return (wxCoord) (y*m_logicalScaleY*m_userScaleY*m_signY*m_scaleY); +} // --------------------------------------------------------------------------- // bit blit diff --git a/src/os2/frame.cpp b/src/os2/frame.cpp index a8bc699880..8459cad963 100644 --- a/src/os2/frame.cpp +++ b/src/os2/frame.cpp @@ -351,7 +351,6 @@ void wxFrame::DoShowWindow( ) { ::WinShowWindow(m_hFrame, (BOOL)bShowCmd); - ::WinShowWindow(GetHwnd(), (BOOL)bShowCmd); } // end of wxFrame::DoShowWindow bool wxFrame::Show( @@ -852,7 +851,7 @@ bool wxFrame::OS2Create( ,HWND_TOP // Sibling ,(ULONG)nId // ID ,(PVOID)&vFrameCtlData // Creation data - ,NULL // Window Pres Params + ,NULL // Window Pres Params )) == 0L) { return FALSE; @@ -867,7 +866,7 @@ bool wxFrame::OS2Create( ,0L ,0L ,m_hFrame - ,HWND_BOTTOM + ,HWND_TOP ,(unsigned long)FID_CLIENT ,NULL ,NULL @@ -885,7 +884,7 @@ bool wxFrame::OS2Create( ,nY ,nWidth ,nHeight - ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE + ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE | SWP_ZORDER )) return FALSE; @@ -901,10 +900,6 @@ bool wxFrame::OS2Create( else if (vSwp[i].hwnd == m_hTitleBar) memcpy(&m_vSwpTitleBar, &vSwp[i], sizeof(SWP)); } - - // - // Set the client window's background, otherwise it is transparent! - // return TRUE; } // end of wxFrame::OS2Create diff --git a/src/os2/window.cpp b/src/os2/window.cpp index cd44444b7c..ef559b7aa9 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -2394,6 +2394,7 @@ bool wxWindow::OS2Create( wxLogError("Can't create window of class %s!. Error: %s\n", zClass, sError); return FALSE; } + ::WinSetWindowULong(m_hWnd, QWL_USER, (ULONG) this); wxWndHook = NULL; #ifdef __WXDEBUG__