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
};
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_
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
// ------------------------------------------------------------------------
// 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
wxWindowDC(wxWindow *win);
virtual ~wxWindowDC();
+
+ // PM specific stuff
+ HPS m_hPS;
+private:
+ HAB m_hab;
+ SIZEL m_PageSize;
};
class WXDLLEXPORT wxClientDC : public wxWindowDC
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;
};
#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_
AddHandler(new wxICOFileHandler);
*/
}
+
+void wxBitmap::SetHBITMAP(WXHBITMAP bmp)
+{
+ if (!M_BITMAPDATA)
+ m_refData = new wxBitmapRefData;
+
+ M_BITMAPDATA->m_hBitmap = bmp;
+}
+
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;
};
}
#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
//
#include "wx/log.h"
#include "wx/window.h"
-#include "wx/msw/private.h"
+#include "wx/os2/private.h"
#include "wx/dcclient.h"
// global variables
// ----------------------------------------------------------------------------
-static PAINTSTRUCT g_paintStruct;
+static RECT g_paintStruct;
#ifdef __WXDEBUG__
// a global variable which we check to verify that wxPaintDC are only
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));
}
//
// 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--;
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));
}
{
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;
}
}
}
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));
}
if ( !--info->count )
{
- ::EndPaint(GetWinHwnd(m_canvas), &g_paintStruct);
+ ::WinEndPaint(m_hPS);
ms_cache.Remove(index);
}
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());
..\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
cursor.obj \
data.obj \
dc.obj \
+ dcclient.obj \
+ dcmemory.obj \
+ dcprint.obj \
+ dcscreen.obj \
dialog.obj \
frame.obj \
window.obj
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