]> git.saurik.com Git - wxWidgets.git/commitdiff
*** empty log message ***
authorDavid Webster <Dave.Webster@bhmi.com>
Sat, 2 Oct 1999 01:44:39 +0000 (01:44 +0000)
committerDavid Webster <Dave.Webster@bhmi.com>
Sat, 2 Oct 1999 01:44:39 +0000 (01:44 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3788 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/os2/bitmap.h
include/wx/os2/dc.h
include/wx/os2/dcclient.h
include/wx/os2/dcmemory.h
include/wx/os2/dcprint.h
src/os2/bitmap.cpp
src/os2/dc.cpp
src/os2/dcclient.cpp
src/os2/frame.cpp
src/os2/makefile.va

index 1d2f5417e504c6b8279007c583323deefe1fd556..1dec7c28aa27b855da36dd8bdff6da4570472fa2 100644 (file)
@@ -81,7 +81,9 @@ public:
   wxPalette     m_bitmapPalette;
   int           m_quality;
 
-/*  WXHBITMAP     m_hBitmap; TODO: platform-specific handle */
+  WXHBITMAP     m_hBitmap;
+  wxDC *        m_selectedInto; // So bitmap knows whether it's been selected into
+
   wxMask *      m_bitmapMask; // Optional mask
 };
 
@@ -184,14 +186,13 @@ public:
 protected:
   static wxList sm_handlers;
 
-/*
   // TODO: Implementation
 public:
   void SetHBITMAP(WXHBITMAP bmp);
   inline WXHBITMAP GetHBITMAP() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_hBitmap : 0); }
-  bool FreeResource(bool force = FALSE);
-*/
-
+  inline void SetSelectedInto(wxDC *dc) { if (M_BITMAPDATA) M_BITMAPDATA->m_selectedInto = dc; }
+  inline wxDC *GetSelectedInto(void) const { return (M_BITMAPDATA ? M_BITMAPDATA->m_selectedInto : (wxDC*) NULL); }
+//  bool FreeResource(bool force = FALSE);
 };
 #endif
   // _WX_BITMAP_H_
index 75026782c301900d038cb2941c4bf4e92e4e549c..8c0bd11552b56954305e9559106ff69e4a14f6dc 100644 (file)
@@ -155,6 +155,20 @@ class WXDLLEXPORT wxDC: public wxDCBase
     virtual void SetInternalDeviceOrigin( long x, long y );
     virtual void GetInternalDeviceOrigin( long *x, long *y );
 
+    virtual void SetRop(WXHDC cdc);
+    virtual void DoClipping(WXHDC cdc);
+    virtual void SelectOldObjects(WXHDC dc);
+
+    wxWindow *GetWindow() const { return m_canvas; }
+    void SetWindow(wxWindow *win) { m_canvas = win; }
+
+    WXHDC GetHDC() const { return m_hDC; }
+    void SetHDC(WXHDC dc, bool bOwnsDC = FALSE)
+    {
+        m_hDC = dc;
+        m_bOwnsDC = bOwnsDC;
+    }
+
 private:
 
 #if WXWIN_COMPATIBILITY
@@ -177,13 +191,14 @@ protected:
     // ------------------------------------------------------------------------
 
     // Owner canvas and selected in bitmap (if bitmap is GDI object selected)
-    wxWindow*         m_owner;
-    wxBitmap*         m_bitmap;
+    wxWindow*         m_canvas;
+    wxBitmap          m_selectedBitmap;
 
     // our HDC and its usage count: we only free it when the usage count drops
     // to 0
     WXHDC             m_hDC;
     int               m_hDCCount;
+    bool              m_bOwnsDC:1;
 
     // Store all old GDI objects when do a SelectObject, so we can select them
     // back in (this unselecting user's objects) so we can safely delete the
index 21d1a42e53304c5d702b3d5052e8350b1081f245..45d2ee10889952b713c64cd1e08863324369e14c 100644 (file)
@@ -47,6 +47,12 @@ public:
     wxWindowDC(wxWindow *win);
 
     virtual ~wxWindowDC();
+
+    // PM specific stuff
+    HPS                     m_hPS;
+private:
+    HAB                     m_hab;
+    SIZEL                   m_PageSize;
 };
 
 class WXDLLEXPORT wxClientDC : public wxWindowDC
index c6c57376420c83bf866bdbd71898ab7f362a0421..7ee412ee163ccc8e461613008372446330477768 100644 (file)
@@ -25,11 +25,12 @@ class WXDLLEXPORT wxMemoryDC: public wxPaintDC
   public:
     wxMemoryDC(void);
     wxMemoryDC( wxDC *dc ); // Create compatible DC
+
     ~wxMemoryDC(void);
     virtual void SelectObject( const wxBitmap& bitmap );
     void GetSize( int *width, int *height ) const;
 
-  private: 
+  private:
     friend wxPaintDC;
     wxBitmap  m_selected;
 };
index 2ea66d15bf9af88206f360d8311719bc9b3cef4b..faeaf40180ca15d85330cacb2ab0dd0c493bd93c 100644 (file)
 #pragma interface "dcprint.h"
 #endif
 
+#if wxUSE_PRINTING_ARCHITECTURE
+
 #include "wx/dc.h"
+#include "wx/cmndata.h"
 
 class WXDLLEXPORT wxPrinterDC: public wxDC
 {
  public:
   DECLARE_CLASS(wxPrinterDC)
 
-  // Create a printer DC
-  wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output, bool interactive = TRUE, int orientation = wxPORTRAIT);
+   // Create a printer DC [obsolete]
+   wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output, bool interactive = TRUE, int orientation = wxPORTRAIT);
+
+   // Create from print data
+   wxPrinterDC(const wxPrintData& data);
+
+   wxPrinterDC(WXHDC theDC);
+
+   ~wxPrinterDC();
 
-  ~wxPrinterDC();
+    bool StartDoc(const wxString& message);
+    void EndDoc(void);
+    void StartPage(void);
+    void EndPage(void);
+
+protected:
+    wxPrintData         m_printData;
 };
 
+// Gets an HDC for the specified printer configuration
+WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& data);
+
+#endif // wxUSE_PRINTING_ARCHITECTURE
+
 #endif
     // _WX_DCPRINT_H_
 
index 1e6255f55162f1ea94dba34153f66508a6906847..036eb640ed948980b078f3424fbb2e6b2edc4639 100644 (file)
@@ -428,3 +428,12 @@ void wxBitmap::InitStandardHandlers()
     AddHandler(new wxICOFileHandler);
 */
 }
+
+void wxBitmap::SetHBITMAP(WXHBITMAP bmp)
+{
+  if (!M_BITMAPDATA)
+  m_refData = new wxBitmapRefData;
+
+  M_BITMAPDATA->m_hBitmap = bmp;
+}
+
index 7a95c3ab970d8d3de36a3f3b671a015701174828..8b435b6b01fcdcdb6230d0e4834b6ea37d1b0c3d 100644 (file)
@@ -108,14 +108,15 @@ long wxDCBase::LogicalToDeviceYRel(long y) const
 
 wxDC::wxDC(void)
 {
-    m_owner  = NULL;
-    m_bitmap = NULL;
+    m_canvas  = NULL;
 
     m_oldBitmap  = 0;
     m_oldPen     = 0;
     m_oldBrush   = 0;
     m_oldFont    = 0;
     m_oldPalette = 0;
+
+    m_bOwnsDC = FALSE;
     m_hDC        = 0;
     m_hDCCount   = 0;
 };
@@ -393,6 +394,94 @@ void wxDC::DoDrawSpline(wxList *points)
 }
 #endif
 
+void wxDC::SetRop(WXHDC dc)
+{
+    if (!dc || m_logicalFunction < 0)
+        return;
+
+    int c_rop;
+    // These may be wrong
+    switch (m_logicalFunction)
+    {
+// TODO: Figure this stuff out
+        //    case wxXOR: c_rop = R2_XORPEN; break;
+//    case wxXOR: c_rop = R2_NOTXORPEN; break;
+//    case wxINVERT: c_rop = R2_NOT; break;
+//    case wxOR_REVERSE: c_rop = R2_MERGEPENNOT; break;
+//    case wxAND_REVERSE: c_rop = R2_MASKPENNOT; break;
+//    case wxCLEAR: c_rop = R2_WHITE; break;
+//    case wxSET: c_rop = R2_BLACK; break;
+//    case wxSRC_INVERT: c_rop = R2_NOTCOPYPEN; break;
+//    case wxOR_INVERT: c_rop = R2_MERGENOTPEN; break;
+//    case wxAND: c_rop = R2_MASKPEN; break;
+//    case wxOR: c_rop = R2_MERGEPEN; break;
+//    case wxAND_INVERT: c_rop = R2_MASKNOTPEN; break;
+//    case wxEQUIV:
+//    case wxNAND:
+//    case wxCOPY:
+    default:
+//      c_rop = R2_COPYPEN;
+        break;
+    }
+//    SetROP2((HDC) dc, c_rop);
+}
+
+void wxDC::DoClipping(WXHDC dc)
+{
+    if (m_clipping && dc)
+    {
+//      TODO:
+//      IntersectClipRect((HDC) dc, XLOG2DEV(m_clipX1), YLOG2DEV(m_clipY1),
+//                                  XLOG2DEV(m_clipX2), YLOG2DEV(m_clipY2));
+    }
+}
+
+// This will select current objects out of the DC,
+// which is what you have to do before deleting the
+// DC.
+void wxDC::SelectOldObjects(WXHDC dc)
+{
+    if (dc)
+    {
+        if (m_oldBitmap)
+        {
+//            ::SelectObject((HDC) dc, (HBITMAP) m_oldBitmap);
+            if (m_selectedBitmap.Ok())
+            {
+                m_selectedBitmap.SetSelectedInto(NULL);
+            }
+        }
+        m_oldBitmap = 0;
+        if (m_oldPen)
+        {
+//            ::SelectObject((HDC) dc, (HPEN) m_oldPen);
+        }
+        m_oldPen = 0;
+        if (m_oldBrush)
+        {
+//            ::SelectObject((HDC) dc, (HBRUSH) m_oldBrush);
+        }
+        m_oldBrush = 0;
+        if (m_oldFont)
+        {
+//            ::SelectObject((HDC) dc, (HFONT) m_oldFont);
+        }
+        m_oldFont = 0;
+        if (m_oldPalette)
+        {
+//            ::SelectPalette((HDC) dc, (HPALETTE) m_oldPalette, TRUE);
+        }
+        m_oldPalette = 0;
+    }
+
+    m_brush = wxNullBrush;
+    m_pen = wxNullPen;
+    m_palette = wxNullPalette;
+    m_font = wxNullFont;
+    m_backgroundBrush = wxNullBrush;
+    m_selectedBitmap = wxNullBitmap;
+}
+
 //
 // Private functions
 //
index 75ffabc6ff7b5998f4c8182176a351e9e98e504f..6a17297ce5279f88be887294da67cd60d17295fd 100644 (file)
@@ -32,7 +32,7 @@
 #include "wx/log.h"
 #include "wx/window.h"
 
-#include "wx/msw/private.h"
+#include "wx/os2/private.h"
 
 #include "wx/dcclient.h"
 
@@ -72,7 +72,7 @@ WX_DEFINE_OBJARRAY(wxArrayDCInfo);
 // global variables
 // ----------------------------------------------------------------------------
 
-static PAINTSTRUCT g_paintStruct;
+static RECT        g_paintStruct;
 
 #ifdef __WXDEBUG__
     // a global variable which we check to verify that wxPaintDC are only
@@ -100,7 +100,19 @@ wxWindowDC::wxWindowDC(wxWindow *the_canvas)
   m_canvas = the_canvas;
   m_hDC = (WXHDC) ::WinOpenWindowDC(GetWinHwnd(the_canvas) );
   m_hDCCount++;
-
+  //
+  // default under PM is that Window and Client DC's are the same
+  // so we offer a separate Presentation Space to use for the
+  // entire window.  Otherwise, calling BeginPaint will just create
+  // chached-micro client presentation space
+  //
+   m_hPS = GpiCreatePS( m_hab
+                       ,m_hDC
+                       ,&m_PageSize
+                       ,PU_PELS | GPIF_LONG | GPIA_ASSOC
+                      );
+  ::GpiAssociate(m_hPS, NULLHANDLE);
+  ::GpiAssociate(m_hPS, m_hDC);
   SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID));
 }
 
@@ -113,8 +125,12 @@ wxWindowDC::~wxWindowDC()
     //
     // In PM one does not explicitly close or release an open WindowDC
     // They automatically close with the window, unless explicitly detached
+    // but we need to destroy our PS
     //
-    m_hDC = 0;
+    ::GpiAssociate(m_hPS, NULLHANDLE);
+    ::GpiDestroyPS(m_hPS);
+    m_hPS = NULLHANDLE;
+    m_hDC = NULLHANDLE;
   }
 
   m_hDCCount--;
@@ -132,13 +148,15 @@ wxClientDC::wxClientDC()
 wxClientDC::wxClientDC(wxWindow *the_canvas)
 {
   m_canvas = the_canvas;
-  m_hDC = (WXHDC) ::GetDC(GetWinHwnd(the_canvas));
 
-  // the background mode is only used for text background
-  // and is set in DrawText() to OPAQUE as required, other-
-  // wise always TRANSPARENT, RR
-  ::SetBkMode( GetHdc(), TRANSPARENT );
+  //
+  // default under PM is that Window and Client DC's are the same
+  //
+  m_hDC = (WXHDC) ::WinOpenWindowDC(GetWinHwnd(the_canvas));
 
+  //
+  // Default mode is BM_LEAVEALONE so we make no call Set the mix
+  //
   SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID));
 }
 
@@ -148,7 +166,9 @@ wxClientDC::~wxClientDC()
   {
     SelectOldObjects(m_hDC);
 
-    ::ReleaseDC(GetWinHwnd(m_canvas), GetHdc());
+    // We don't explicitly release Device contexts in PM and
+    // the cached micro PS is already gone
+
     m_hDC = 0;
   }
 }
@@ -205,15 +225,9 @@ wxPaintDC::wxPaintDC(wxWindow *canvas)
     }
     else // not in cache, create a new one
     {
-        m_hDC = (WXHDC)::BeginPaint(GetWinHwnd(m_canvas), &g_paintStruct);
+        m_hDC = (WXHDC)::WinBeginPaint(GetWinHwnd(m_canvas), NULLHANDLE, &g_paintStruct);
         ms_cache.Add(new wxPaintDCInfo(m_canvas, this));
     }
-
-    // the background mode is only used for text background
-    // and is set in DrawText() to OPAQUE as required, other-
-    // wise always TRANSPARENT, RR
-    ::SetBkMode( GetHdc(), TRANSPARENT );
-
     SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID));
 }
 
@@ -230,7 +244,7 @@ wxPaintDC::~wxPaintDC()
 
         if ( !--info->count )
         {
-            ::EndPaint(GetWinHwnd(m_canvas), &g_paintStruct);
+            ::WinEndPaint(m_hPS);
 
             ms_cache.Remove(index);
         }
index 794d42bf4d21b1a8515c3822dee9c1086d046d27..e84c30b9d2d9434631ec78774ca62ed7d72c1fe6 100644 (file)
@@ -201,7 +201,7 @@ wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id,
     dc.SetFont(statusBar->GetFont());
 
     long x, y;
-    dc.GetTextExtent("X", &x, &y, NULL, NULL, NULL, FALSE);
+    dc.GetTextExtent("X", &x, &y, NULL, NULL, NULL);
 
     int height = (int)( (y  * 1.1) + 2* statusBar->GetBorderY());
 
index e71ae97613b434982be95b0b31bdb15c925b6f3e..9d303dd72c019a4abbf431c3cea2636fef817732 100644 (file)
@@ -300,6 +300,10 @@ OS2OBJS = \
   ..\os2\$D\cursor.obj \
   ..\os2\$D\data.obj \
   ..\os2\$D\dc.obj \
+  ..\os2\$D\dcclient.obj \
+  ..\os2\$D\dcmemory.obj \
+  ..\os2\$D\dcprint.obj \
+  ..\os2\$D\dcscreen.obj \
   ..\os2\$D\dialog.obj \
   ..\os2\$D\frame.obj \
   ..\os2\$D\window.obj
@@ -322,6 +326,10 @@ OS2LIBOBJS = \
   cursor.obj \
   data.obj \
   dc.obj \
+  dcclient.obj \
+  dcmemory.obj \
+  dcprint.obj \
+  dcscreen.obj \
   dialog.obj \
   frame.obj \
   window.obj
@@ -488,6 +496,10 @@ $(OS2LIBOBJS):
   copy ..\os2\$D\cursor.obj
   copy ..\os2\$D\data.obj
   copy ..\os2\$D\dc.obj
+  copy ..\os2\$D\dcclient.obj
+  copy ..\os2\$D\dcmemory.obj
+  copy ..\os2\$D\dcprint.obj
+  copy ..\os2\$D\dcscreen.obj
   copy ..\os2\$D\dialog.obj
   copy ..\os2\$D\frame.obj
   copy ..\os2\$D\window.obj