gwidgets.h

来自「一个由Mike Gashler完成的机器学习方面的includes neural」· C头文件 代码 · 共 1,090 行 · 第 1/2 页

H
1,090
字号
	float GetProgress() { return m_fProgress; }};class GWidgetCheckBox : public GWidgetAtomic{protected:	bool m_checked;public:	GWidgetCheckBox(GWidgetGroup* pParent, int x, int y, int w, int h);	virtual ~GWidgetCheckBox();	virtual WidgetType GetType() { return CheckBox; }	virtual void Draw(GImage* pCanvas, int x, int y);	void SetChecked(bool checked);	bool IsChecked() { return m_checked; }protected:	virtual void Grab(int button, int x, int y);	virtual void Release(int button);};class GWidgetSliderTab : public GWidgetAtomic{public:	enum Style	{		ScrollBarTab,		ScrollBarArea,		SliderNub,		SliderArea,	};protected:	bool m_vertical;	Style m_eStyle;public:	GWidgetSliderTab(GWidgetGroup* pParent, int x, int y, int w, int h, bool vertical, Style eStyle);	virtual ~GWidgetSliderTab();	virtual WidgetType GetType() { return SliderTab; }	virtual void Draw(GImage* pCanvas, int x, int y);	void SetSize(int w, int h);	// for internal implementation	virtual void OnMouseMove(int dx, int dy);protected:	virtual void Grab(int button, int x, int y);	virtual void Release(int button);};class GWidgetHorizScrollBar : public GWidgetGroup{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);	void SetModelSize(int n);	int GetPos() { return m_nPos; }	void SetPos(int n);	// for internal implementation	virtual void OnPushVCRButton(GWidgetVCRButton* pButton);	virtual void OnSlideTab(GWidgetSliderTab* pTab, int dx, int dy);	virtual void OnClickTab(GWidgetSliderTab* pTab);	virtual void Draw(GImage* pCanvas, int x, int y);protected:	int GetButtonWidth();};class GWidgetVertScrollBar : public GWidgetGroup{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);	void SetModelSize(int n);	int GetPos() { return m_nPos; }	void SetPos(int n);	// for internal implementation	virtual void OnPushVCRButton(GWidgetVCRButton* pButton);	virtual void OnSlideTab(GWidgetSliderTab* pTab, int dx, int dy);	virtual void OnClickTab(GWidgetSliderTab* pTab);	virtual void Draw(GImage* pCanvas, int x, int y);protected:	int GetButtonHeight();};class GWidgetTextBox : public GWidgetAtomic{protected:	GString m_text;	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 void Draw(GImage* pCanvas, int x, int y);	GString* GetText() { return &m_text; }	void SetText(const char* szText);	virtual void OnChar(char c);	void SetPassword() { m_bPassword = true; }protected:	virtual void Grab(int button, int x, int y);	virtual void Release(int button);	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; }	GString* GetText() { return m_sText; }	virtual void Draw(GImage* pCanvas, int x, int y);protected:	virtual void Grab(int button, int x, int y);	virtual void Release(int button)	{	}};class GWidgetListBox : public GWidgetGroup{friend class GWidgetListBoxItem;protected:	int m_nSelectedIndex;	int m_nScrollPos;	GColor m_baseColor;public:	// Takes ownership of pItems	GWidgetListBox(GWidgetGroup* pParent, int x, int y, int w, int h);	virtual ~GWidgetListBox();	virtual WidgetType GetType() { return ListBox; }	void SetBaseColor(GColor c);	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();	virtual void Draw(GImage* pCanvas, int x, int y);protected:	void OnGrabItem(int nIndex);	void SetItemRect(GRect* pRect, int nIndex);};class GWidgetGrid : public GWidgetGroup{protected:	GPointerArray* m_pRows;	int m_nColumns;	int m_nRowHeight;	GWidget** m_pColumnHeaders;	int* m_nColumnWidths;	GWidgetVertScrollBar* m_pVertScrollBar;	GWidgetHorizScrollBar* m_pHorizScrollBar;	GColor m_cBackground;public:	// Takes ownership of pItems	GWidgetGrid(GWidgetGroup* pParent, GPointerArray* pItems, int nColumns, int x, int y, int w, int h, GColor cBackground = 0xff000000);	virtual ~GWidgetGrid();	virtual WidgetType GetType() { return Grid; }	virtual GWidgetAtomic* FindAtomicWidget(int x, int y);	int GetRowHeight() { return m_nRowHeight; }	void SetRowHeight(int n);	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);	// 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);	virtual void Draw(GImage* pCanvas, int x, int y);	virtual void Tattle(GWidget* pChild);};class GWidgetFileSystemBrowser : public GWidgetGroup{protected:	GWidgetTextLabel* m_pPath;	GWidgetGrid* m_pFiles;	GPointerArray* m_pListItems;	char* m_szExtensions;	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* szExtensions);	virtual ~GWidgetFileSystemBrowser();	virtual WidgetType GetType() { return FileSystemBrowser; }	// for internal implementation	virtual void OnClickTextLabel(GWidgetTextLabel* pLabel);	virtual void Draw(GImage* pCanvas, int x, int y);protected:	void ReloadFileList();	void AddFilename(bool bDir, const char* szFilename);};/*class GWidgetPolarLineGraph : public GWidgetAtomic{protected:	int m_nValues;	float* m_pValues;	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 void Draw(GImage* pCanvas, int x, int y);	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:	virtual void Grab(int button, int x, int y);	virtual void Release(int button);};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 void Draw(GImage* pCanvas, int x, int y);	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:	virtual void Grab(int button, int x, int y);	virtual void Release(int button);};*/class GWidgetVertSlider : public GWidgetGroup{protected:	bool m_dirty;	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);	// for internal implementation	virtual void OnSlideTab(GWidgetSliderTab* pTab, int dx, int dy);	virtual void OnClickTab(GWidgetSliderTab* pTab);	virtual void Draw(GImage* pCanvas, int x, int y);};/*// This is a wrapping histogram. It could be used for a load-meter.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 void Draw(GImage* pCanvas, int x, int y);	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; }};*/// A painting canvasclass GWidgetCanvas : public GWidgetAtomic{protected:	GImage* m_pImageIn;	GImage* m_pSelectionMask;	float m_fZoom;	int m_nHScroll;	int m_nVScroll;	bool m_pressed;	int m_nMouseX, m_nMouseY;public:	GWidgetCanvas(GWidgetGroup* pParent, int x, int y, int w, int h, GImage* pImage);	virtual ~GWidgetCanvas();	virtual WidgetType GetType() { return Canvas; }	virtual void Draw(GImage* pCanvas, int x, int y);	void SetDirty();	// for internal implementation	virtual void OnMouseMove(int dx, int dy);	float GetZoom() { return m_fZoom; }	void SetZoom(float f);	void ZoomToFit();	void SetHorizScroll(int x);	void SetVertScroll(int y);	void SetImage(GImage* pImage);	// Only the alpha channel of the mask is used. The other values should be	// constant, or else the selection border will cut through the selection.	// If you change what is selected, you should call this method again, even	// though it may still be the same mask image.	void SetSelectionMask(GImage* pMask);protected:	virtual void Grab(int button, int x, int y);	virtual void Release(int button);};#endif // __GWIDGETS_H__

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?