From c3d434725bd76bc0306b9751e722ed70bd776876 Mon Sep 17 00:00:00 2001 From: David Webster Date: Thu, 5 Aug 1999 04:05:25 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3278 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/os2/control.h | 2 +- include/wx/os2/dc.h | 11 +- include/wx/os2/window.h | 1 + src/os2/dc.cpp | 296 ++++++++++----------------------------- src/os2/dialog.cpp | 15 +- src/os2/frame.cpp | 15 +- src/os2/makefile.va | 3 + src/os2/window.cpp | 6 + 8 files changed, 97 insertions(+), 252 deletions(-) diff --git a/include/wx/os2/control.h b/include/wx/os2/control.h index c75756a72a..d2aac6bbc7 100644 --- a/include/wx/os2/control.h +++ b/include/wx/os2/control.h @@ -21,7 +21,7 @@ #include "wx/validate.h" // General item class -class WXDLLEXPORT wxControl: public wxWindow +class WXDLLEXPORT wxControl: public wxControlBase { DECLARE_ABSTRACT_CLASS(wxControl) public: diff --git a/include/wx/os2/dc.h b/include/wx/os2/dc.h index 90a77078b5..75026782c3 100644 --- a/include/wx/os2/dc.h +++ b/include/wx/os2/dc.h @@ -16,6 +16,7 @@ #pragma interface "dc.h" #endif +#include "wx/window.h" #include "wx/pen.h" #include "wx/brush.h" #include "wx/icon.h" @@ -156,16 +157,6 @@ class WXDLLEXPORT wxDC: public wxDCBase private: - void ComputeScaleAndOrigin(void); - long XDEV2LOG(long x) const; - long XDEV2LOGREL(long x) const; - long YDEV2LOG(long y) const; - long YDEV2LOGREL(long y) const; - long XLOG2DEV(long x) const; - long XLOG2DEVREL(long x) const; - long YLOG2DEV(long y) const; - long YLOG2DEVREL(long y) const; - #if WXWIN_COMPATIBILITY // function hiding warning supression virtual void GetTextExtent( const wxString& string diff --git a/include/wx/os2/window.h b/include/wx/os2/window.h index 12d2e8d66b..f4b1798468 100644 --- a/include/wx/os2/window.h +++ b/include/wx/os2/window.h @@ -146,6 +146,7 @@ public: // same as DoSetSize() for the client size virtual void DoSetClientSize(int width, int height); virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); + virtual WXWidget GetHandle() const; // --------------------------------------------------------------------------- // wxWindowBase virtual implementations that need to be overriden diff --git a/src/os2/dc.cpp b/src/os2/dc.cpp index c32e0528d4..7a95c3ab97 100644 --- a/src/os2/dc.cpp +++ b/src/os2/dc.cpp @@ -36,42 +36,70 @@ IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) long wxDCBase::DeviceToLogicalX(long x) const { - return XDEV2LOG(x); + long new_x = x - m_deviceOriginX; + if (new_x > 0) + return (long)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; + else + return (long)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; }; long wxDCBase::DeviceToLogicalY(long y) const { - return YDEV2LOG(y); + long new_y = y - m_deviceOriginY; + if (new_y > 0) + return (long)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; + else + return (long)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; }; long wxDCBase::DeviceToLogicalXRel(long x) const { - return XDEV2LOGREL(x); + if (x > 0) + return (long)((double)(x) / m_scaleX + 0.5); + else + return (long)((double)(x) / m_scaleX - 0.5); }; long wxDCBase::DeviceToLogicalYRel(long y) const { - return YDEV2LOGREL(y); + if (y > 0) + return (long)((double)(y) / m_scaleY + 0.5); + else + return (long)((double)(y) / m_scaleY - 0.5); }; long wxDCBase::LogicalToDeviceX(long x) const { - return XLOG2DEV(x); + long new_x = x - m_logicalOriginX; + if (new_x > 0) + return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; + else + return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; }; long wxDCBase::LogicalToDeviceY(long y) const { - return YLOG2DEV(y); + long new_y = y - m_logicalOriginY; + if (new_y > 0) + return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; + else + return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; }; long wxDCBase::LogicalToDeviceXRel(long x) const { - return XLOG2DEVREL(x); + if (x > 0) + return (long)((double)(x) * m_scaleX + 0.5); + else + return (long)((double)(x) * m_scaleX - 0.5); }; long wxDCBase::LogicalToDeviceYRel(long y) const { - return YLOG2DEVREL(y); + if (y > 0) + return (long)((double)(y) * m_scaleY + 0.5); + else + return (long)((double)(y) * m_scaleY - 0.5); }; //----------------------------------------------------------------------------- @@ -80,161 +108,79 @@ long wxDCBase::LogicalToDeviceYRel(long y) const wxDC::wxDC(void) { - m_ok = FALSE; - m_optimize = FALSE; - m_autoSetting = FALSE; - m_colour = TRUE; - m_clipping = FALSE; - - m_mm_to_pix_x = 1.0; - m_mm_to_pix_y = 1.0; - - m_logicalOriginX = 0; - m_logicalOriginY = 0; - m_deviceOriginX = 0; - m_deviceOriginY = 0; - m_internalDeviceOriginX = 0; - m_internalDeviceOriginY = 0; - m_externalDeviceOriginX = 0; - m_externalDeviceOriginY = 0; - - m_logicalScaleX = 1.0; - m_logicalScaleY = 1.0; - m_userScaleX = 1.0; - m_userScaleY = 1.0; - m_scaleX = 1.0; - m_scaleY = 1.0; - - m_mappingMode = wxMM_TEXT; - m_needComputeScaleX = FALSE; - m_needComputeScaleY = FALSE; - - m_signX = 1; // default x-axis left to right - m_signY = 1; // default y-axis top down - - m_maxX = m_maxY = -100000; - m_minY = m_minY = 100000; - - m_logicalFunction = wxCOPY; -// m_textAlignment = wxALIGN_TOP_LEFT; - m_backgroundMode = wxTRANSPARENT; - - m_textForegroundColour = *wxBLACK; - m_textBackgroundColour = *wxWHITE; - m_pen = *wxBLACK_PEN; - m_font = *wxNORMAL_FONT; - m_brush = *wxTRANSPARENT_BRUSH; - m_backgroundBrush = *wxWHITE_BRUSH; - -// m_palette = wxAPP_COLOURMAP; + m_owner = NULL; + m_bitmap = NULL; + + m_oldBitmap = 0; + m_oldPen = 0; + m_oldBrush = 0; + m_oldFont = 0; + m_oldPalette = 0; + m_hDC = 0; + m_hDCCount = 0; }; wxDC::~wxDC(void) { + // TODO: }; void wxDC::DestroyClippingRegion(void) { - m_clipping = FALSE; + // TODO: }; -void wxDC::GetSize( int* width, int* height ) const +void wxDC::DoGetSize( int* width, int* height ) const { - *width = m_maxX-m_minX; - *height = m_maxY-m_minY; + // TODO: }; -void wxDC::GetSizeMM( long* width, long* height ) const +void wxDC::DoGetSizeMM( int* width, int* height ) const { - int w = 0; - int h = 0; - GetSize( &w, &h ); - *width = long( double(w) / (m_scaleX*m_mm_to_pix_x) ); - *height = long( double(h) / (m_scaleY*m_mm_to_pix_y) ); + // TODO: }; void wxDC::SetMapMode( int mode ) { - switch (mode) - { - case wxMM_TWIPS: - SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); - break; - case wxMM_POINTS: - SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); - break; - case wxMM_METRIC: - SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); - break; - case wxMM_LOMETRIC: - SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); - break; - default: - case wxMM_TEXT: - SetLogicalScale( 1.0, 1.0 ); - break; - }; - if (mode != wxMM_TEXT) - { - m_needComputeScaleX = TRUE; - m_needComputeScaleY = TRUE; - }; + // TODO: }; void wxDC::SetUserScale( double x, double y ) { - // allow negative ? -> no - m_userScaleX = x; - m_userScaleY = y; - ComputeScaleAndOrigin(); -}; + m_userScaleX = x; + m_userScaleY = y; -void wxDC::GetUserScale( double *x, double *y ) -{ - if (x) *x = m_userScaleX; - if (y) *y = m_userScaleY; + SetMapMode(m_mappingMode); }; void wxDC::SetLogicalScale( double x, double y ) { - // allow negative ? - m_logicalScaleX = x; - m_logicalScaleY = y; - ComputeScaleAndOrigin(); + // TODO: }; void wxDC::SetLogicalOrigin( long x, long y ) { - m_logicalOriginX = x * m_signX; // is this still correct ? - m_logicalOriginY = y * m_signY; - ComputeScaleAndOrigin(); + // TODO: }; void wxDC::SetDeviceOrigin( long x, long y ) { - m_externalDeviceOriginX = x; - m_externalDeviceOriginY = y; - ComputeScaleAndOrigin(); + // TODO: }; void wxDC::SetInternalDeviceOrigin( long x, long y ) { - m_internalDeviceOriginX = x; - m_internalDeviceOriginY = y; - ComputeScaleAndOrigin(); + // TODO: }; void wxDC::GetInternalDeviceOrigin( long *x, long *y ) { - if (x) *x = m_internalDeviceOriginX; - if (y) *y = m_internalDeviceOriginY; + // TODO: }; void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) { - m_signX = (xLeftRight ? 1 : -1); - m_signY = (yBottomUp ? -1 : 1); - ComputeScaleAndOrigin(); + // TODO: }; @@ -246,8 +192,10 @@ int wxDC::GetDepth() const wxSize wxDC::GetPPI() const { + int x = 1; + int y = 1; // TODO: - return (1); + return (wxSize(x,y)); } void wxDC::GetTextExtent( const wxString& string ,long* x @@ -260,13 +208,13 @@ void wxDC::GetTextExtent( const wxString& string // TODO: } -void wxDC::GetCharWidth() const +long wxDC::GetCharWidth() const { // TODO return(1); } -void wxDC::GetCharHeight() const +long wxDC::GetCharHeight() const { // TODO return(1); @@ -314,7 +262,7 @@ void wxDC::SetPalette(const wxPalette& palette) void wxDC::DoFloodFill( long x ,long y ,const wxColour& col - ,int style = wxFLOOD_SURFACE + ,int style ) { // TODO @@ -385,7 +333,7 @@ void wxDC::DoDrawIcon(const wxIcon& icon, long x, long y) void wxDC::DoDrawBitmap( const wxBitmap &bmp ,long x, long y - ,bool useMask = FALSE + ,bool useMask ) { // TODO @@ -403,24 +351,14 @@ bool wxDC::DoBlit( long xdest ,wxDC *source ,long xsrc ,long ysrc - ,int rop = wxCOPY - ,bool useMask = FALSE + ,int rop + ,bool useMask ) { // TODO return(TRUE); } -void wxDC::DoGetSize(int *width, int *height) const -{ - // TODO -} - -void wxDC::DoGetSizeMM(int* width, int* height) const -{ - // TODO -} - void wxDC::DoDrawLines( int n, wxPoint points[] ,long xoffset, long yoffset ) @@ -430,7 +368,7 @@ void wxDC::DoDrawLines( int n, wxPoint points[] void wxDC::DoDrawPolygon(int n, wxPoint points[] ,long xoffset, long yoffset - ,int fillStyle = wxODDEVEN_RULE + ,int fillStyle ) { // TODO @@ -458,95 +396,5 @@ void wxDC::DoDrawSpline(wxList *points) // // Private functions // -long wxDC::XDEV2LOG(long x) const -{ - long new_x = x - m_deviceOriginX; - if (new_x > 0) - return (long)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; - else - return (long)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; -} - -long wxDC::XDEV2LOGREL(long x) const -{ - if (x > 0) - return (long)((double)(x) / m_scaleX + 0.5); - else - return (long)((double)(x) / m_scaleX - 0.5); -} - -long wxDC::YDEV2LOG(long y) const -{ - long new_y = y - m_deviceOriginY; - if (new_y > 0) - return (long)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; - else - return (long)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; -} - -long wxDC::YDEV2LOGREL(long y) const -{ - if (y > 0) - return (long)((double)(y) / m_scaleY + 0.5); - else - return (long)((double)(y) / m_scaleY - 0.5); -} - -long wxDC::XLOG2DEV(long x) const -{ - long new_x = x - m_logicalOriginX; - if (new_x > 0) - return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; - else - return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; -} - -long wxDC::XLOG2DEVREL(long x) const -{ - if (x > 0) - return (long)((double)(x) * m_scaleX + 0.5); - else - return (long)((double)(x) * m_scaleX - 0.5); -} - -long wxDC::YLOG2DEV(long y) const -{ - long new_y = y - m_logicalOriginY; - if (new_y > 0) - return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; - else - return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; -} - -long wxDC::YLOG2DEVREL(long y) const -{ - if (y > 0) - return (long)((double)(y) * m_scaleY + 0.5); - else - return (long)((double)(y) * m_scaleY - 0.5); -} - -void wxDC::ComputeScaleAndOrigin(void) -{ - // CMB: copy scale to see if it changes - double origScaleX = m_scaleX; - double origScaleY = m_scaleY; - m_scaleX = m_logicalScaleX * m_userScaleX; - m_scaleY = m_logicalScaleY * m_userScaleY; - - m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX; - m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY; - - // CMB: if scale has changed call SetPen to recalulate the line width - if (m_scaleX != origScaleX || m_scaleY != origScaleY) - { - // this is a bit artificial, but we need to force wxDC to think - // the pen has changed - wxPen* pen = & GetPen(); - wxPen tempPen; - m_pen = tempPen; - SetPen(* pen); - } -}; diff --git a/src/os2/dialog.cpp b/src/os2/dialog.cpp index bf3cae5e35..f15bd2b353 100644 --- a/src/os2/dialog.cpp +++ b/src/os2/dialog.cpp @@ -55,7 +55,7 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetName(name); - + if (!parent) wxTopLevelWindows.Append(this); @@ -78,7 +78,7 @@ void wxDialog::SetModal(bool flag) else if ( m_windowStyle & wxDIALOG_MODAL ) m_windowStyle -= wxDIALOG_MODAL ; - + wxModelessWindows.DeleteObject(this); if (!flag) wxModelessWindows.Append(this); @@ -132,11 +132,6 @@ bool wxDialog::IsIconized() const return FALSE; } -void wxDialog::SetClientSize(int width, int height) -{ - // TODO -} - void wxDialog::GetPosition(int *x, int *y) const { // TODO @@ -254,12 +249,12 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event) // The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog. static wxList closing; - + if ( closing.Member(this) ) return; - + closing.Append(this); - + wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); cancelEvent.SetEventObject( this ); GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog diff --git a/src/os2/frame.cpp b/src/os2/frame.cpp index 0a15c650af..794d42bf4d 100644 --- a/src/os2/frame.cpp +++ b/src/os2/frame.cpp @@ -14,6 +14,7 @@ #endif #include "wx/frame.h" +#include "wx/event.h" #include "wx/statusbr.h" #include "wx/toolbar.h" #include "wx/menuitem.h" @@ -47,12 +48,12 @@ bool wxFrame::m_useNativeStatusBar = FALSE; wxFrame::wxFrame() { - m_frameToolBar = NULL ; m_frameMenuBar = NULL; m_frameStatusBar = NULL; - m_windowParent = NULL; m_iconized = FALSE; + + m_frameToolBar = NULL ; } bool wxFrame::Create(wxWindow *parent, @@ -200,7 +201,7 @@ wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id, dc.SetFont(statusBar->GetFont()); long x, y; - dc.GetTextExtent("X", &x, &y); + dc.GetTextExtent("X", &x, &y, NULL, NULL, NULL, FALSE); int height = (int)( (y * 1.1) + 2* statusBar->GetBorderY()); @@ -214,7 +215,7 @@ wxStatusBar* wxFrame::CreateStatusBar(int number, long style, wxWindowID id, const wxString& name) { // Calling CreateStatusBar twice is an error. - wxCHECK_MSG( m_frameStatusBar == NULL, FALSE, + wxCHECK_MSG( m_frameStatusBar == NULL, FALSE, "recreating status bar in wxFrame" ); m_frameStatusBar = OnCreateStatusBar(number, style, id, @@ -262,7 +263,7 @@ void wxFrame::SetMenuBar(wxMenuBar *menuBar) m_frameMenuBar = NULL; return; } - + m_frameMenuBar = menuBar; // TODO @@ -332,7 +333,7 @@ void wxFrame::OnSize(wxSizeEvent& event) { wxWindow *win = (wxWindow *)node->Data(); if ( !win->IsKindOf(CLASSINFO(wxFrame)) && - !win->IsKindOf(CLASSINFO(wxDialog)) && + !win->IsKindOf(CLASSINFO(wxDialog)) && (win != GetStatusBar()) && (win != GetToolBar()) ) { @@ -435,7 +436,7 @@ void wxFrame::Command(int id) void wxFrame::ProcessCommand(int id) { - wxCommandEvent commandEvent(wxEVENT_TYPE_MENU_COMMAND, id); + wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, id); commandEvent.SetInt( id ); commandEvent.SetEventObject( this ); diff --git a/src/os2/makefile.va b/src/os2/makefile.va index 1d9e08b016..c01477a096 100644 --- a/src/os2/makefile.va +++ b/src/os2/makefile.va @@ -183,6 +183,9 @@ COMMONOBJS = \ OS2OBJS = \ + ..\os2\$D\dc.obj \ + ..\os2\$D\dialog.obj \ + ..\os2\$D\frame.obj \ ..\os2\$D\window.obj \ HTMLOBJS = \ diff --git a/src/os2/window.cpp b/src/os2/window.cpp index 4a04ebeca9..1cbf08b8c1 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -495,6 +495,12 @@ wxObject* wxWindow::GetChild(int number) const return((wxObject*)this); } +WXWidget wxWindow::GetHandle() const +{ + // TODO: + return((WXWidget)m_hWnd); +} + void wxWindow::PMDetachWindowMenu() { if ( m_hMenu ) -- 2.45.2