dcclient.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/motif/dcclient.h
  3. // Purpose: wxClientDCImpl, wxPaintDCImpl and wxWindowDCImpl classes
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 17/09/98
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_DCCLIENT_H_
  11. #define _WX_DCCLIENT_H_
  12. #include "wx/motif/dc.h"
  13. class WXDLLIMPEXP_FWD_CORE wxWindow;
  14. //-----------------------------------------------------------------------------
  15. // wxWindowDCImpl
  16. //-----------------------------------------------------------------------------
  17. class WXDLLIMPEXP_CORE wxWindowDCImpl : public wxMotifDCImpl
  18. {
  19. public:
  20. wxWindowDCImpl(wxDC *owner);
  21. wxWindowDCImpl(wxDC *owner, wxWindow *win);
  22. virtual ~wxWindowDCImpl();
  23. // TODO this function is Motif-only for now - should it go into base class?
  24. void Clear(const wxRect& rect);
  25. // implement base class pure virtuals
  26. // ----------------------------------
  27. virtual void Clear();
  28. virtual void SetFont(const wxFont& font);
  29. virtual void SetPen(const wxPen& pen);
  30. virtual void SetBrush(const wxBrush& brush);
  31. virtual void SetBackground(const wxBrush& brush);
  32. virtual void SetBackgroundMode(int mode);
  33. virtual void SetPalette(const wxPalette& palette);
  34. virtual void SetLogicalFunction( wxRasterOperationMode function );
  35. virtual void SetTextForeground(const wxColour& colour);
  36. virtual void SetTextBackground(const wxColour& colour);
  37. virtual wxCoord GetCharHeight() const;
  38. virtual wxCoord GetCharWidth() const;
  39. virtual void DoGetTextExtent(const wxString& string,
  40. wxCoord *x, wxCoord *y,
  41. wxCoord *descent = NULL,
  42. wxCoord *externalLeading = NULL,
  43. const wxFont *theFont = NULL) const;
  44. virtual bool CanDrawBitmap() const;
  45. virtual bool CanGetTextExtent() const;
  46. virtual int GetDepth() const;
  47. virtual wxSize GetPPI() const;
  48. virtual void DestroyClippingRegion();
  49. // Helper function for setting clipping
  50. void SetDCClipping(WXRegion region);
  51. // implementation from now on
  52. // --------------------------
  53. WXGC GetGC() const { return m_gc; }
  54. WXGC GetBackingGC() const { return m_gcBacking; }
  55. WXDisplay* GetDisplay() const { return m_display; }
  56. bool GetAutoSetting() const { return (m_autoSetting != 0); } // See comment in dcclient.cpp
  57. void SetAutoSetting(bool flag) { m_autoSetting = flag; }
  58. protected:
  59. // note that this function will call colour.SetPixel,
  60. // and will do one of curCol = colour, curCol = wxWHITE, curCol = wxBLACK
  61. // roundToWhite has an effect for monochrome display only
  62. // if roundToWhite == true then the colour will be set to white unless
  63. // it is RGB 0x000000;if roundToWhite == true the colour wull be set to
  64. // black unless it id RGB 0xffffff
  65. WXPixel CalculatePixel(wxColour& colour, wxColour& curCol,
  66. bool roundToWhite) const;
  67. // sets the foreground pixel taking into account the
  68. // currently selected logical operation
  69. void SetForegroundPixelWithLogicalFunction(WXPixel pixel);
  70. virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
  71. wxFloodFillStyle style = wxFLOOD_SURFACE);
  72. virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
  73. virtual void DoDrawPoint(wxCoord x, wxCoord y);
  74. virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
  75. virtual void DoDrawArc(wxCoord x1, wxCoord y1,
  76. wxCoord x2, wxCoord y2,
  77. wxCoord xc, wxCoord yc);
  78. virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
  79. double sa, double ea);
  80. virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
  81. virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
  82. wxCoord width, wxCoord height,
  83. double radius);
  84. virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
  85. virtual void DoCrossHair(wxCoord x, wxCoord y);
  86. virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
  87. virtual void DoDrawRotatedText(const wxString &text, wxCoord x, wxCoord y, double angle);
  88. virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
  89. wxDC *source, wxCoord xsrc, wxCoord ysrc,
  90. wxRasterOperationMode rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
  91. virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
  92. wxCoord width, wxCoord height);
  93. virtual void DoSetDeviceClippingRegion(const wxRegion& region);
  94. virtual void DoDrawLines(int n, const wxPoint points[],
  95. wxCoord xoffset, wxCoord yoffset);
  96. virtual void DoDrawPolygon(int n, const wxPoint points[],
  97. wxCoord xoffset, wxCoord yoffset,
  98. wxPolygonFillMode fillStyle = wxODDEVEN_RULE);
  99. void DoGetSize( int *width, int *height ) const;
  100. // common part of constructors
  101. void Init();
  102. WXGC m_gc;
  103. WXGC m_gcBacking;
  104. WXDisplay* m_display;
  105. wxWindow* m_window;
  106. // Pixmap for drawing on
  107. WXPixmap m_pixmap;
  108. // Last clipping region set on th GC, this is the combination
  109. // of paint clipping region and all user-defined clipping regions
  110. WXRegion m_clipRegion;
  111. // Not sure if we'll need all of these
  112. WXPixel m_backgroundPixel;
  113. wxColour m_currentColour;
  114. int m_currentPenWidth ;
  115. int m_currentPenJoin ;
  116. int m_currentPenCap ;
  117. int m_currentPenDashCount ;
  118. wxX11Dash* m_currentPenDash ;
  119. wxBitmap m_currentStipple ;
  120. int m_currentStyle ;
  121. int m_currentFill ;
  122. int m_autoSetting ; // See comment in dcclient.cpp
  123. DECLARE_DYNAMIC_CLASS(wxWindowDCImpl)
  124. };
  125. class WXDLLIMPEXP_CORE wxPaintDCImpl: public wxWindowDCImpl
  126. {
  127. public:
  128. wxPaintDCImpl(wxDC *owner) : wxWindowDCImpl(owner) { }
  129. wxPaintDCImpl(wxDC *owner, wxWindow* win);
  130. virtual ~wxPaintDCImpl();
  131. DECLARE_DYNAMIC_CLASS(wxPaintDCImpl)
  132. };
  133. class WXDLLIMPEXP_CORE wxClientDCImpl: public wxWindowDCImpl
  134. {
  135. public:
  136. wxClientDCImpl(wxDC *owner) : wxWindowDCImpl(owner) { }
  137. wxClientDCImpl(wxDC *owner, wxWindow* win)
  138. : wxWindowDCImpl(owner, win) { }
  139. DECLARE_DYNAMIC_CLASS(wxClientDCImpl)
  140. };
  141. #endif // _WX_DCCLIENT_H_