gui.h
来自「一个由Mike Gashler完成的机器学习方面的includes neural」· C头文件 代码 · 共 117 行
H
117 行
// --------------------------------------------------------
// This demo file is dedicated to the Public Domain. See:
// http://creativecommons.org/licenses/publicdomain
// --------------------------------------------------------
#ifndef __GUI_H__#define __GUI_H__#include <SDL/SDL.h>#include "../GClasses/GWidgets.h"class ControllerBase;class GPointerArray;class GArffRelation;inline Uint32* getPixMem32(SDL_Surface *surface, int x, int y){ return (Uint32*)((Uint8*)surface->pixels + y * surface->pitch + (x << 2));}inline Uint16* getPixMem16(SDL_Surface *pScreen, int x, int y){ return (Uint16*)pScreen->pixels + y * pScreen->pitch / 2 + x;}class ViewBase{protected: SDL_Surface* m_pScreen; GRect m_screenRect;public: ViewBase(); virtual ~ViewBase(); void Update(); virtual void OnChar(char c) {} virtual void OnMouseDown(int nButton, int x, int y) {} virtual void OnMouseUp(int nButton, int x, int y) {} virtual bool OnMousePos(int x, int y) { return false; }protected: static void BlitImage(SDL_Surface* pScreen, int x, int y, GImage* pImage); static void StretchClipAndBlitImage(SDL_Surface* pScreen, GRect* pDestRect, GRect* pClipRect, GImage* pImage); virtual void Draw(SDL_Surface* pScreen) = 0; void DrawDot(SDL_Surface *pScreen, int x, int y, GColor col, int nSize); void SetScreenSize(int x, int y);};class ControllerBase{protected: enum KeyState { Normal, Holding, Repeating, }; static char* s_szAppPath; static GImage* s_pManualImage; bool m_bKeepRunning; int m_keyboard[SDLK_LAST]; int m_mouse[4]; int m_mouseX; int m_mouseY; KeyState m_eKeyState; SDLKey m_lastPressedKey; double m_dKeyRepeatTimer; ViewBase* m_pView;public: ControllerBase(); virtual ~ControllerBase(); static void SetAppPath(char* szAppPath); static const char* GetAppPath() { return s_szAppPath; } static GImage* GetManualImage() { return s_pManualImage; } bool HandleEvents(double dTimeDelta); void Quit() { m_bKeepRunning = false; }protected: void HandleKeyPress(SDLKey eKey, SDLMod mod); void HandleMouseClick(int nButton);};void OpenFile(const char* szFilename);void OpenAppFile(const char* szRelativeFilename);class GWidgetRelation : public GWidgetGrid{protected: GArffRelation* m_pRelation; GPointerArray* m_pRows;public: GWidgetRelation(GArffRelation* pRelation, GWidgetGroup* pParent, int x, int y, int w, int h); virtual ~GWidgetRelation();protected: GPointerArray* MakeRows(); virtual void OnSelectTextTab(GWidgetTextTab* pTab);};#endif // __GUI_H__
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?