📄 gwidgets.h
字号:
GImage m_image; bool m_checked; bool m_dirty;public: GWidgetCheckBox(GWidgetGroup* pParent, int x, int y, int w, int h); virtual ~GWidgetCheckBox(); virtual WidgetType GetType() { return CheckBox; } virtual GImage* GetImage(GRect* pOutRect); void SetSize(int w, int h); void SetChecked(bool checked); bool IsChecked() { return m_checked; }protected: void Update(); virtual void Grab(int x, int y); virtual void Release();};class GWidgetSliderTab : public GWidgetAtomic{public: enum Style { ScrollBarTab, ScrollBarArea, SliderNub, SliderArea, };protected: GImage m_image; bool m_vertical; Style m_eStyle; bool m_dirty;public: GWidgetSliderTab(GWidgetGroup* pParent, int x, int y, int w, int h, bool vertical, Style eStyle); virtual ~GWidgetSliderTab(); virtual WidgetType GetType() { return SliderTab; } virtual GImage* GetImage(GRect* pOutRect); void SetSize(int w, int h); // for internal implementation virtual void OnMouseMove(int dx, int dy);protected: void Update(); virtual void Grab(int x, int y); virtual void Release();};class GWidgetHorizScrollBar : public GWidgetGroupWithCanvas{protected: int m_nViewSize; int m_nModelSize; int m_nPos; GWidgetVCRButton* m_pLeftButton; GWidgetVCRButton* m_pRightButton; GWidgetSliderTab* m_pLeftTab; GWidgetSliderTab* m_pTab; GWidgetSliderTab* m_pRightTab;public: GWidgetHorizScrollBar(GWidgetGroup* pParent, int x, int y, int w, int h, int nViewSize, int nModelSize); virtual ~GWidgetHorizScrollBar(); virtual WidgetType GetType() { return HScrollBar; } void SetViewSize(int n) { m_nViewSize = n; m_dirty = true; } void SetModelSize(int n) { m_nModelSize = n; m_dirty = true; } int GetPos() { return m_nPos; } void SetPos(int n) { m_nPos = n; m_dirty = true; } void SetSize(int w, int h); // for internal implementation virtual void OnPushVCRButton(GWidgetVCRButton* pButton); virtual void OnSlideTab(GWidgetSliderTab* pTab, int dx, int dy); virtual void OnClickTab(GWidgetSliderTab* pTab);protected: virtual void Update(); int GetButtonWidth();};class GWidgetVertScrollBar : public GWidgetGroupWithCanvas{protected: int m_nViewSize; int m_nModelSize; int m_nPos; GWidgetVCRButton* m_pUpButton; GWidgetVCRButton* m_pDownButton; GWidgetSliderTab* m_pAboveTab; GWidgetSliderTab* m_pTab; GWidgetSliderTab* m_pBelowTab;public: GWidgetVertScrollBar(GWidgetGroup* pParent, int x, int y, int w, int h, int nViewSize, int nModelSize); virtual ~GWidgetVertScrollBar(); virtual WidgetType GetType() { return VScrollBar; } void SetViewSize(int n) { m_nViewSize = n; m_dirty = true; } void SetModelSize(int n) { m_nModelSize = n; m_dirty = true; } int GetPos() { return m_nPos; } void SetPos(int n) { m_nPos = n; m_dirty = true; } void SetSize(int w, int h); // for internal implementation virtual void OnPushVCRButton(GWidgetVCRButton* pButton); virtual void OnSlideTab(GWidgetSliderTab* pTab, int dx, int dy); virtual void OnClickTab(GWidgetSliderTab* pTab);protected: virtual void Update(); int GetButtonHeight();};class GWidgetTextBox : public GWidgetAtomic{protected: GImage m_image; GString m_text; bool m_dirty; bool m_bGotFocus; bool m_bPassword; int m_nAnchorPos; int m_nCursorPos; int m_nMouseDelta;public: GWidgetTextBox(GWidgetGroup* pParent, int x, int y, int w, int h); virtual ~GWidgetTextBox(); virtual WidgetType GetType() { return TextBox; } virtual GImage* GetImage(GRect* pOutRect); GString* GetText() { return &m_text; } void SetText(const char* szText); virtual void OnChar(char c); void SetPassword() { m_bPassword = true; }protected: void Update(); virtual void Grab(int x, int y); virtual void Release(); virtual void OnGetFocus(); virtual void OnLoseFocus(); virtual void OnMouseMove(int dx, int dy);};class GWidgetListBoxItem : public GWidgetAtomic{protected: GString* m_sText; int m_nIndex;public: GWidgetListBoxItem(GWidgetListBox* pParent, const wchar_t* wszText); virtual ~GWidgetListBoxItem(); virtual WidgetType GetType() { return ListBoxItem; } virtual GImage* GetImage(GRect* pOutRect) { return NULL; } virtual void Draw(GWidgetGroupWithCanvas* pTarget); GString* GetText() { return m_sText; }protected: virtual void Grab(int x, int y); virtual void Release() { }};class GWidgetListBox : public GWidgetGroupWithCanvas{friend class GWidgetListBoxItem;public: enum BaseColor { red, yellow, green, cyan, blue, magenta, };protected: int m_nSelectedIndex; int m_nScrollPos; BaseColor m_eBaseColor;public: // Takes ownership of pItems GWidgetListBox(GWidgetGroup* pParent, int x, int y, int w, int h); virtual ~GWidgetListBox(); virtual WidgetType GetType() { return ListBox; } void SetSize(int w, int h); void SetBaseColor(BaseColor eBaseColor) { m_eBaseColor = eBaseColor; m_dirty = true; } int GetSelection() { return m_nSelectedIndex; } void SetSelection(int n); int GetScrollPos() { return m_nScrollPos; } void SetScrollPos(int n); int GetSize(); GWidgetListBoxItem* GetItem(int n); void Clear();protected: virtual void Update(); void OnGrabItem(int nIndex); void SetItemRect(GRect* pRect, int nIndex);};class GWidgetGrid : public GWidgetGroupWithCanvas{protected: GPointerArray* m_pRows; int m_nColumns; int m_nRowHeight; GWidget** m_pColumnHeaders; int* m_nColumnWidths; GWidgetVertScrollBar* m_pVertScrollBar; GWidgetHorizScrollBar* m_pHorizScrollBar;public: // Takes ownership of pItems GWidgetGrid(GWidgetGroup* pParent, GPointerArray* pItems, int nColumns, int x, int y, int w, int h); virtual ~GWidgetGrid(); virtual WidgetType GetType() { return Grid; } virtual GWidgetAtomic* FindAtomicWidget(int x, int y); void SetSize(int w, int h); int GetRowHeight() { return m_nRowHeight; } void SetRowHeight(int n) { m_nRowHeight = n; m_dirty = true; } int GetHScrollPos() { return m_pHorizScrollBar->GetPos(); } int GetVScrollPos() { return m_pVertScrollBar->GetPos(); } void SetHScrollPos(int n); void SetVScrollPos(int n); // Adds an empty row to the grid void AddBlankRow(); // Returns the complete collection of all cell widgets GPointerArray* GetRows() { return m_pRows; } // Returns the number of columns int GetColumnCount() { return m_nColumns; } // Gets the widget in the specified cell GWidget* GetWidget(int col, int row); // Sets the widget in the specified cell void SetWidget(int col, int row, GWidget* pWidget); // Sets the widget in a column header GWidget* GetColumnHeader(int col); // Gets the widget in a column header void SetColumnHeader(int col, GWidget* pWidget); // Gets the width of a column int GetColumnWidth(int col); // Sets the width of a column void SetColumnWidth(int col, int nWidth); // Redraws the cell. It doesn't tell the widget in that cell to redraw itself, so // you should do that before calling UpdateCell. //void UpdateCell(int col, int row); // Deletes all the rows and all the widgets in them void FlushItems(); // for internal implementation virtual void OnVertScroll(GWidgetVertScrollBar* pScrollBar); // for internal implementation virtual void OnHorizScroll(GWidgetHorizScrollBar* pScrollBar);protected: virtual void Update();};class GWidgetFileSystemBrowser : public GWidgetGroup{protected: GWidgetTextLabel* m_pPath; GWidgetGrid* m_pFiles; GPointerArray* m_pListItems; char* m_szExtension; char m_szPath[256];public: // szExtension should be NULL if you want to allow all extensions GWidgetFileSystemBrowser(GWidgetGroup* pParent, int x, int y, int w, int h, const char* szExtension); virtual ~GWidgetFileSystemBrowser(); virtual WidgetType GetType() { return FileSystemBrowser; } virtual GImage* GetImage(GRect* pOutRect) { return NULL; } virtual void Draw(GWidgetGroupWithCanvas* pTarget); // for internal implementation virtual void OnClickTextLabel(GWidgetTextLabel* pLabel);protected: void ReloadFileList(); void AddFilename(bool bDir, const char* szFilename);};class GWidgetPolarLineGraph : public GWidgetAtomic{protected: GImage m_image; int m_nValues; float* m_pValues; bool m_dirty; int m_nSelected; GColor m_cBackground; GColor m_cForeground; GColor m_cShading; GColor m_cSelected;public: GWidgetPolarLineGraph(GWidgetGroup* pParent, int x, int y, int w, int h, int nValues); virtual ~GWidgetPolarLineGraph(); virtual WidgetType GetType() { return PolarChart; } virtual GImage* GetImage(GRect* pOutRect); void SetSize(int w, int h); void SetValueCount(int n); void SetValue(int n, float value); float GetValue(int n) { return m_pValues[n]; } float GetSelectedValue() { return m_pValues[m_nSelected]; } int GetSelection() { return m_nSelected; } void SetSelection(int n); // Sets the text color void SetForegroundColor(GColor c) { m_cForeground = c; } // The default background color is transparent. If you want an opaque // or semi-opaque background then you should call this method. void SetBackgroundColor(GColor c) { m_cBackground = c; } // Sets the text color void SetShadingColor(GColor c) { m_cShading = c; } // Sets which axis is selected void SetSelected(int n) { m_nSelected = n; }protected: void Update(); virtual void Grab(int x, int y); virtual void Release();};class GWidgetPolarBarGraph : public GWidgetAtomic{protected: GImage m_image; int m_nValues; float* m_pValues; bool m_dirty; int m_nSelected; GColor m_cBackground; GColor m_cForeground; GColor m_cSelected;public: GWidgetPolarBarGraph(GWidgetGroup* pParent, int x, int y, int w, int h, int nValues); virtual ~GWidgetPolarBarGraph(); virtual WidgetType GetType() { return PolarChart; } virtual GImage* GetImage(GRect* pOutRect); void SetSize(int w, int h); void SetValueCount(int n); void SetValue(int n, float value); float GetValue(int n) { return m_pValues[n]; } float GetSelectedValue() { return m_pValues[m_nSelected]; } int GetSelection() { return m_nSelected; } void SetSelection(int n); // Sets the text color void SetForegroundColor(GColor c) { m_cForeground = c; } // The default background color is transparent. If you want an opaque // or semi-opaque background then you should call this method. void SetBackgroundColor(GColor c) { m_cBackground = c; } // Sets which axis is selected void SetSelected(int n) { m_nSelected = n; }protected: void Update(); virtual void Grab(int x, int y); virtual void Release();};class GWidgetVertSlider : public GWidgetGroupWithCanvas{protected: float m_fPos; GWidgetSliderTab* m_pAboveTab; GWidgetSliderTab* m_pTab; GWidgetSliderTab* m_pBelowTab;public: GWidgetVertSlider(GWidgetGroup* pParent, int x, int y, int w, int h); virtual ~GWidgetVertSlider(); virtual WidgetType GetType() { return VertSlider; } float GetPos() { return m_fPos; } void SetPos(float f); void SetSize(int w, int h); // for internal implementation virtual void OnSlideTab(GWidgetSliderTab* pTab, int dx, int dy); virtual void OnClickTab(GWidgetSliderTab* pTab);protected: virtual void Update();};class GWidgetMagnitudeGraph : public GWidgetAtomic{protected: GImage m_image; int m_nValues; float* m_pValues; int m_nStartIndex; bool m_dirty; bool m_bOwnValues; GColor m_cBackground; GColor m_cForeground; GColor m_cGridLines;public: GWidgetMagnitudeGraph(GWidgetGroup* pParent, int x, int y, int w, int h); virtual ~GWidgetMagnitudeGraph(); virtual WidgetType GetType() { return PolarChart; } virtual GImage* GetImage(GRect* pOutRect); void SetValues(float* pValues, int nValues, bool bOwn); void SetStartIndex(int n); // Sets the text color void SetForegroundColor(GColor c) { m_cForeground = c; } // The default background color is transparent. If you want an opaque // or semi-opaque background then you should call this method. void SetBackgroundColor(GColor c) { m_cBackground = c; } // Sets the text color void SetGridLinesColor(GColor c) { m_cGridLines = c; }protected: void Update(); virtual void Grab(int x, int y); virtual void Release();};#endif // __GWIDGETS_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -