|
|
1.1 ! root 1: #ifndef __FONT_HXX_ ! 2: #define __FONT_HXX_ ! 3: ! 4: #include "canvas.hxx" ! 5: ! 6: //========== CFont ============================================= ! 7: class CFont ! 8: { ! 9: public: ! 10: CFont(HFONT hfont); ! 11: CFont(TCHAR * szFace, int iHeight, ! 12: BOOL fBold = FALSE, BOOL fItalic = FALSE, BOOL fUnder = FALSE); ! 13: ~CFont(); ! 14: BOOL Create(LOGFONT& lf); ! 15: BOOL Update(int iHeight, BOOL fBold=FALSE); ! 16: operator HFONT() ! 17: { return _hfont; }; ! 18: BOOL Choose(HWND hwnd); ! 19: protected: ! 20: HFONT _hfont; ! 21: BOOL _fDel; ! 22: }; ! 23: ! 24: //========== CFontSelect ======================================= ! 25: class CFontSelect ! 26: { ! 27: public: ! 28: CFontSelect(CCanvas &canvas, HFONT hfont) : ! 29: _canvas(canvas) ! 30: { ! 31: _hfontOld = SelectFont(_canvas, hfont); ! 32: }; ! 33: ! 34: ~CFontSelect() ! 35: { ! 36: // Make sure font is not selected, so it can be deleted ! 37: SelectFont(_canvas, _hfontOld); ! 38: } ! 39: protected: ! 40: HFONT _hfontOld; ! 41: CCanvas &_canvas; ! 42: }; ! 43: ! 44: //========== CBlackPen ======================================= ! 45: class CBlackPen ! 46: { ! 47: public: ! 48: CBlackPen(CCanvas &canvas, int iStyle, int iWidth) : ! 49: _canvas(canvas) ! 50: { ! 51: _hPen = CreatePen(iStyle,iWidth,RGB(0,0,0)); ! 52: _hPenOld = SelectPen(_canvas, _hPen); ! 53: }; ! 54: ! 55: ~CBlackPen() ! 56: { ! 57: // release pen ! 58: _hPen = SelectPen(_canvas, _hPenOld); ! 59: DeleteObject(_hPen); ! 60: } ! 61: protected: ! 62: HPEN _hPen; ! 63: HPEN _hPenOld; ! 64: CCanvas &_canvas; ! 65: }; ! 66: ! 67: ! 68: #endif ! 69:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.