📄 rulerdrawer.h
字号:
/* * * rulerdrawer.h * Copyright (C) 2006 Michael H. Overlin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact at poster_printer@yahoo.com */#ifndef RULERDRAWER_H#define RULERDRAWER_H#include "fontkeeper.h"#include "types.h"#include <windows.h>#include <vector>class RulerPlacementSpec;typedef class RulerDrawer* PRulerDrawer;class RulerDrawer {public: RulerDrawer( IN const std::vector<uint>& viTicks, IN uint uiMinTickPixelSeparation, IN uint uiMinLabelPixelSeparation, IN double dUnits, IN int iLabelMult, IN const tstring& tstrUnitLabel, IN int iStart, IN int iStop ) ; ~RulerDrawer() ; const tstring& GetUnitLabel(void) const { return m_tstrUnitLabel; } // BASE ON SAY AT LEAST ONE LABEL *ALWAYS* GUARANTEED TO SHOW (AMOUNTS TO MAX STRETCH) // THIS IMPLIES THAT A VIEW DIMENSION SHOULD BE INCLUDED IN CONSTRUCTION (IE RW(rDest)) // AND SAY A MINIMUM NUMBER OF DEVICE UNITS BETWEEN TICK MARKS // IF HDC NULL, ASSUME LOGICAL COORDS & DEVICE COORDS AT SAME SCALE // OFFSET OF rDest DOES NOT MATTER, ONLY WIDTH & HEIGHT -- OOPS // NEGATIVE SIZE => CAN'T DRAW // TEMP -- FIX !! BOOL CanDraw(IN const RulerPlacementSpec &rps, IN OUT LogFontKeeper& lfk) const; VOID Draw(OUT HDC hdc, IN const RulerPlacementSpec &rps, IN OUT LogFontKeeper& lfk) const;private: void SetFont(OUT LogFontKeeper& lfk, LONG lTextHeight) const; double m_dUnits; uint m_iLabelMult; int m_iStart; int m_iStop; std::vector<uint> m_vTicks; uint m_uiMinTickPixelSeparation; uint m_uiMinLabelPixelSeparation; std::vector<uint> m_vuiTickMults; uint m_cTicksPerDiv; uint m_cTicks; tstring m_tstrUnitLabel; std::vector<uint> m_viTickLevels; uint m_cMaxLabelDigits; PTSTR m_ptstrLabels; std::vector<uint> m_vuiLabelSizes; HPEN m_hpen;};class RulerDrawerProvider {public: ~RulerDrawerProvider() {} virtual const RulerDrawer *GetRulerDrawer(const double& dExtent) const = 0;};class RulerPlacementSpec {public: enum Direction { eVertical, eHorizontal }; RulerPlacementSpec(IN RulerPlacementSpec::Direction dir, IN const RECT& rDest, IN const double &dTopLeft, IN const double &dBottomRight) { m_dir = dir; m_rDest = rDest; m_dTopLeft = dTopLeft; m_dBottomRight = dBottomRight; } RulerPlacementSpec(IN const RulerPlacementSpec &rps) { *this = rps; } RulerPlacementSpec(IN RulerPlacementSpec::Direction dir) { m_dir = dir; } RulerPlacementSpec(void) {} RulerPlacementSpec& operator =(const RulerPlacementSpec & rps) { memcpy(this, &rps, sizeof(*this)); return *this; } BOOL operator ==(const RulerPlacementSpec& rps) const { return memcmp(this, &rps, sizeof(*this)) == 0; } BOOL operator !=(const RulerPlacementSpec& rps) const { return !(*this == rps); } RulerPlacementSpec::Direction m_dir; RECT m_rDest; double m_dTopLeft; double m_dBottomRight;};class Ruler {public: Ruler(const RulerDrawer *prd, const RulerPlacementSpec& rps, LogFontKeeper *plfk) { Set(prd, rps, plfk); } Ruler(const Ruler& or) { *this = or; } Ruler(void) { m_prd = NULL; m_plfk = NULL; m_bCanDraw = FALSE; } BOOL Set(const RulerDrawer *prd, const RulerPlacementSpec& ors, LogFontKeeper *plfk) ; void Draw(OUT HDC hdc) ; BOOL CanDraw(void) const { return m_bCanDraw; } const RulerPlacementSpec& GetPlacement(void) const { return m_rps; } const tstring& GetUnitLabel(void) const { return m_prd->GetUnitLabel(); } BOOL HasUnitLabel(void) const { return m_bCanDraw; } Ruler& operator =(const Ruler& r) { memcpy(this, &r, sizeof(*this)); return *this; } BOOL operator ==(const Ruler &or) const { return !(*this != or); } BOOL operator !=(const Ruler &or) const ;private: BOOL m_bCanDraw; RulerPlacementSpec m_rps; const RulerDrawer *m_prd; LogFontKeeper *m_plfk;};BOOL RulerUnitLabelChanged(const Ruler &rNew, const Ruler &rOld);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -