dc.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/dfb/dc.h
  3. // Purpose: wxDC class
  4. // Author: Vaclav Slavik
  5. // Created: 2006-08-07
  6. // Copyright: (c) 2006 REA Elektronik GmbH
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_DFB_DC_H_
  10. #define _WX_DFB_DC_H_
  11. #include "wx/defs.h"
  12. #include "wx/region.h"
  13. #include "wx/dc.h"
  14. #include "wx/dfb/dfbptr.h"
  15. wxDFB_DECLARE_INTERFACE(IDirectFBSurface);
  16. //-----------------------------------------------------------------------------
  17. // wxDFBDCImpl
  18. //-----------------------------------------------------------------------------
  19. class WXDLLIMPEXP_CORE wxDFBDCImpl : public wxDCImpl
  20. {
  21. public:
  22. // ctors
  23. wxDFBDCImpl(wxDC *owner) : wxDCImpl(owner) { m_surface = NULL; }
  24. wxDFBDCImpl(wxDC *owner, const wxIDirectFBSurfacePtr& surface)
  25. : wxDCImpl(owner)
  26. {
  27. DFBInit(surface);
  28. }
  29. bool IsOk() const { return m_surface != NULL; }
  30. // implement base class pure virtuals
  31. // ----------------------------------
  32. virtual void Clear();
  33. virtual bool StartDoc(const wxString& message);
  34. virtual void EndDoc();
  35. virtual void StartPage();
  36. virtual void EndPage();
  37. virtual void SetFont(const wxFont& font);
  38. virtual void SetPen(const wxPen& pen);
  39. virtual void SetBrush(const wxBrush& brush);
  40. virtual void SetBackground(const wxBrush& brush);
  41. virtual void SetBackgroundMode(int mode);
  42. #if wxUSE_PALETTE
  43. virtual void SetPalette(const wxPalette& palette);
  44. #endif
  45. virtual void SetLogicalFunction(wxRasterOperationMode function);
  46. virtual void DestroyClippingRegion();
  47. virtual wxCoord GetCharHeight() const;
  48. virtual wxCoord GetCharWidth() const;
  49. virtual void DoGetTextExtent(const wxString& string,
  50. wxCoord *x, wxCoord *y,
  51. wxCoord *descent = NULL,
  52. wxCoord *externalLeading = NULL,
  53. const wxFont *theFont = NULL) const;
  54. virtual bool CanDrawBitmap() const { return true; }
  55. virtual bool CanGetTextExtent() const { return true; }
  56. virtual int GetDepth() const;
  57. virtual wxSize GetPPI() const;
  58. // Returns the surface (and increases its ref count)
  59. wxIDirectFBSurfacePtr GetDirectFBSurface() const { return m_surface; }
  60. protected:
  61. // implementation
  62. wxCoord XDEV2LOG(wxCoord x) const { return DeviceToLogicalX(x); }
  63. wxCoord XDEV2LOGREL(wxCoord x) const { return DeviceToLogicalXRel(x); }
  64. wxCoord YDEV2LOG(wxCoord y) const { return DeviceToLogicalY(y); }
  65. wxCoord YDEV2LOGREL(wxCoord y) const { return DeviceToLogicalYRel(y); }
  66. wxCoord XLOG2DEV(wxCoord x) const { return LogicalToDeviceX(x); }
  67. wxCoord XLOG2DEVREL(wxCoord x) const { return LogicalToDeviceXRel(x); }
  68. wxCoord YLOG2DEV(wxCoord y) const { return LogicalToDeviceY(y); }
  69. wxCoord YLOG2DEVREL(wxCoord y) const { return LogicalToDeviceYRel(y); }
  70. // initializes the DC from a surface, must be called if default ctor
  71. // was used
  72. void DFBInit(const wxIDirectFBSurfacePtr& surface);
  73. virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
  74. wxFloodFillStyle style = wxFLOOD_SURFACE);
  75. virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
  76. virtual void DoDrawPoint(wxCoord x, wxCoord y);
  77. virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
  78. virtual void DoDrawArc(wxCoord x1, wxCoord y1,
  79. wxCoord x2, wxCoord y2,
  80. wxCoord xc, wxCoord yc);
  81. virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
  82. double sa, double ea);
  83. virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
  84. virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
  85. wxCoord width, wxCoord height,
  86. double radius);
  87. virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
  88. virtual void DoCrossHair(wxCoord x, wxCoord y);
  89. virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
  90. virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
  91. bool useMask = false);
  92. virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
  93. virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
  94. double angle);
  95. virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
  96. wxDC *source, wxCoord xsrc, wxCoord ysrc,
  97. wxRasterOperationMode rop = wxCOPY, bool useMask = false,
  98. wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
  99. virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
  100. wxCoord width, wxCoord height);
  101. virtual void DoSetDeviceClippingRegion(const wxRegion& region);
  102. virtual void DoGetSize(int *width, int *height) const;
  103. virtual void DoGetSizeMM(int* width, int* height) const;
  104. virtual void DoDrawLines(int n, const wxPoint points[],
  105. wxCoord xoffset, wxCoord yoffset);
  106. virtual void DoDrawPolygon(int n, const wxPoint points[],
  107. wxCoord xoffset, wxCoord yoffset,
  108. wxPolygonFillMode fillStyle = wxODDEVEN_RULE);
  109. // implementation from now on:
  110. protected:
  111. wxIDirectFBFontPtr GetCurrentFont() const;
  112. private:
  113. // Unified implementation of DrawIcon, DrawBitmap and Blit:
  114. void DoDrawSubBitmap(const wxBitmap &bmp,
  115. wxCoord x, wxCoord y, wxCoord w, wxCoord h,
  116. wxCoord destx, wxCoord desty, int rop, bool useMask);
  117. bool DoBlitFromSurface(const wxIDirectFBSurfacePtr& src,
  118. wxCoord srcx, wxCoord srcy,
  119. wxCoord w, wxCoord h,
  120. wxCoord dstx, wxCoord dsty);
  121. // selects colour into surface's state
  122. void SelectColour(const wxColour& clr);
  123. protected:
  124. wxIDirectFBSurfacePtr m_surface;
  125. double m_mm_to_pix_x, m_mm_to_pix_y;
  126. friend class WXDLLIMPEXP_FWD_CORE wxOverlayImpl; // for Init
  127. DECLARE_ABSTRACT_CLASS(wxDFBDCImpl)
  128. };
  129. #endif // _WX_DFB_DC_H_