📄 wxskinnableframe.h
字号:
/* * Roadnav * wxSkinnableFrame.h * * Copyright (c) 2004 - 2006 Richard L. Lynch <rllynch@users.sourceforge.net> * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License * as published by the Free Software Foundation. * * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *////////////////////////////////////////////////////////////////////////////////// \file////// Contains the wxSkinnableFrame class and its support code -/// converts a regular frame into a skinnable one./////////////////////////////////////////////////////////////////////////////////#ifndef WXSKINNABLEFRAME_H#define WXSKINNABLEFRAME_H#include <wx/minifram.h>#include "tinyxml.h"#include <vector>#include <map>#include <string>#define TIMER_REFRESH 2std::vector<wxString> EnumerateSkins();//////////////////////////////////////////////////////////////////////////////////// \brief This class represents a coordinate that's dependent upon the/// height/width of the control.////// The formula for used is offset1 + (offset2 + max) * multiplier,/// where offset1, offset2, and multiplier are constants. Max is/// the height or width of the control./////////////////////////////////////////////////////////////////////////////////class wxSkinnableFrame_ProportionalCoordinate{ public: wxSkinnableFrame_ProportionalCoordinate(); void Load(TiXmlElement * root); int Resolve(int iMax); int m_iOffset1; int m_iOffset2; double m_fMultiplier;};//////////////////////////////////////////////////////////////////////////////////// \brief Represents a pair of wxSkinnableFrame_ProportionalCoordinate objects/////////////////////////////////////////////////////////////////////////////////class wxSkinnableFrame_ProportionalPoint{ public: void Load(TiXmlElement * root); wxPoint Resolve(wxPoint cMax); wxSkinnableFrame_ProportionalCoordinate m_cX; wxSkinnableFrame_ProportionalCoordinate m_cY;};//////////////////////////////////////////////////////////////////////////////////// \brief Represents a control that is sized and positioned using a pair/// of wxSkinnableFrame_ProportionalPoint objects/////////////////////////////////////////////////////////////////////////////////class wxSkinnableFrame_LayoutControl{ public: wxSkinnableFrame_LayoutControl(); void Position(wxSize szParent, wxSize szParentWnd); public: enum EType { ctControl, ctButton, ctImage, ctText }; wxSkinnableFrame_ProportionalPoint m_coTopLeft; wxSkinnableFrame_ProportionalPoint m_coBottomRight; EType m_eType; wxString m_strName; int m_iShowMinHeight; int m_iShowMinWidth; /// If this is greater than or equal to zero, causes the width of this /// control to be reduced to m_cCenterWidth, and it to be centered /// horizontally at the coordinates specified by m_coTopLeft and /// m_coBottomRight wxCoord m_cCenterWidth; /// Pointer to the control being positioned wxControl * m_pControl; /// Text to prepend to label wxString m_strPrepend; /// Text to append to label wxString m_strAppend;};//////////////////////////////////////////////////////////////////////////////////// \brief Base class used to make a skinnable frame/////////////////////////////////////////////////////////////////////////////////class wxSkinnableFrame : public wxFrame{ public: wxSkinnableFrame(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxT("frame")); ~wxSkinnableFrame(); bool LoadSkin(wxString strPath, bool bIsFilename); void AddNamedControl(wxControl * pCtl, wxString strName); void SetNamedText(wxString strName, wxString strNewLabel, bool bNeedLock = true); void OnSize(wxSizeEvent & evEvent); void OnTimerRefresh(wxTimerEvent& event); protected: /// Override this to map a string name of a menu ID /// to its numerical ID virtual int MapNameToID(wxString strName) = 0; /// Override this with a function that creates a /// control called strName virtual void CreateNamedControl(wxString strName); virtual void DeleteNamedControl(wxString strName, wxControl * pControl); private: wxString GetDataFilename(wxString strName); bool LoadSkinLayout(TiXmlElement * root); bool LoadSkinLayoutControl(TiXmlElement * root); bool LoadSkinLayoutButton(TiXmlElement * root); bool LoadSkinLayoutImage(TiXmlElement * root); bool LoadSkinLayoutText(TiXmlElement * root); bool LoadSkinGlobal(TiXmlElement * root); bool ApplyControlCommonAttributes(TiXmlElement * root, wxSkinnableFrame_LayoutControl * psLayoutControl, wxControl * pControl); void UnloadSkin(); /// Map of controls that have not been assigned to m_vPositionedControls yet std::map<std::string,wxControl *> m_mapUnassignedControls; /// Array of controls that have been loaded and positioned by the skin std::vector<wxSkinnableFrame_LayoutControl> m_vPositionedControls; /// Path to the skin wxString m_strSkinPath; /// Default font used for this frame wxFont m_fntDefault; wxMutex m_mxSkin; wxTimer * m_pTimerRefresh; DECLARE_EVENT_TABLE()};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -