textmeasure.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/private/textmeasure.h
  3. // Purpose: wxMSW-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_MSW_PRIVATE_TEXTMEASURE_H_
  10. #define _WX_MSW_PRIVATE_TEXTMEASURE_H_
  11. #include "wx/msw/wrapwin.h"
  12. // ----------------------------------------------------------------------------
  13. // wxTextMeasure for MSW.
  14. // ----------------------------------------------------------------------------
  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. void Init();
  30. virtual void BeginMeasuring();
  31. virtual void EndMeasuring();
  32. virtual void DoGetTextExtent(const wxString& string,
  33. wxCoord *width,
  34. wxCoord *height,
  35. wxCoord *descent = NULL,
  36. wxCoord *externalLeading = NULL);
  37. virtual bool DoGetPartialTextExtents(const wxString& text,
  38. wxArrayInt& widths,
  39. double scaleX);
  40. // We use either the HDC of the provided wxDC or an HDC created for our
  41. // window.
  42. HDC m_hdc;
  43. // If we change the font in BeginMeasuring(), we restore it to the old one
  44. // in EndMeasuring().
  45. HFONT m_hfontOld;
  46. wxDECLARE_NO_COPY_CLASS(wxTextMeasure);
  47. };
  48. #endif // _WX_MSW_PRIVATE_TEXTMEASURE_H_