textmeasure.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/gtk/private/textmeasure.h
  3. // Purpose: wxGTK-specific declaration of wxTextMeasure class
  4. // Author: Manuel Martin
  5. // Created: 2012-10-05
  6. // Copyright: (c) 1997-2012 wxWidgets team
  7. // Licence: wxWindows licence
  8. ///////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_GTK_PRIVATE_TEXTMEASURE_H_
  10. #define _WX_GTK_PRIVATE_TEXTMEASURE_H_
  11. // ----------------------------------------------------------------------------
  12. // wxTextMeasure
  13. // ----------------------------------------------------------------------------
  14. class WXDLLIMPEXP_FWD_CORE wxWindowDCImpl;
  15. class wxTextMeasure : public wxTextMeasureBase
  16. {
  17. public:
  18. wxEXPLICIT wxTextMeasure(const wxDC *dc, const wxFont *font = NULL)
  19. : wxTextMeasureBase(dc, font)
  20. {
  21. Init();
  22. }
  23. wxEXPLICIT wxTextMeasure(const wxWindow *win, const wxFont *font = NULL)
  24. : wxTextMeasureBase(win, font)
  25. {
  26. Init();
  27. }
  28. protected:
  29. // Common part of both ctors.
  30. void Init();
  31. virtual void BeginMeasuring();
  32. virtual void EndMeasuring();
  33. virtual void DoGetTextExtent(const wxString& string,
  34. wxCoord *width,
  35. wxCoord *height,
  36. wxCoord *descent = NULL,
  37. wxCoord *externalLeading = NULL);
  38. virtual bool DoGetPartialTextExtents(const wxString& text,
  39. wxArrayInt& widths,
  40. double scaleX);
  41. // This class is only used for DC text measuring with GTK+ 2 as GTK+ 3 uses
  42. // Cairo and not Pango for this. However it's still used even with GTK+ 3
  43. // for window text measuring, so the context and the layout are still
  44. // needed.
  45. #ifndef __WXGTK3__
  46. wxWindowDCImpl *m_wdc;
  47. #endif // GTK+ < 3
  48. PangoContext *m_context;
  49. PangoLayout *m_layout;
  50. wxDECLARE_NO_COPY_CLASS(wxTextMeasure);
  51. };
  52. #endif // _WX_GTK_PRIVATE_TEXTMEASURE_H_