⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simplewindow.h

📁 《BATTLE OF SKY》
💻 H
📖 第 1 页 / 共 2 页
字号:
//       A string specifying the title of the window//    WinStatus//       A WindowStatus specifying whether the window is open, closed, or//       an error has occured//    RefreshCallback//       A RefreshCallbackFunction specifying the function to call when//       the window is exposed. (Default function refreshes screen from//       screen buffer.)//    QuitCallback//       A QuitCallbackFunction specifying the function to call when the//       window is closed//    TimerCallback//       A TimerTickCallbackFunction specifying the function to call when//       the timer expires//    MouseClickCallback//       A MouseClickCallbackFunction specifying the function to call when //       a mouse click occurs//    TimerActive//       A Bool specifying whether the timer is active //    AlarmTime//       An unsigned long int specifying how many milliseconds pass before//       the timer expires//    OldTime//       A long specifying the amount of time that has elapsed since the //       last time the timer was checked//    WinX//       An integer specifying the device x coordinate for the location of//       the upper left corner of the window//    WinY//       An integer specifying the device y coordinate for the location of//       the upper left corner of the window//    WinWidth//       An integer specifying the device width of the window//    WinHeight//       An integer specifying the device height of the window//    LogX//       A float specifying the logical x coordinate for the location of//       the upper left corner of the window//    LogY//       A float specifying the logical y coordinate for the location of//       the upper left corner of the window//    LogWidth//       A float specifying the logical width of the window//    LogHeight//       A float specifying the logical height of the window//-----------------------------------------------------------------------////-----------------------------------------------------------------------\\// Additional functions://    int ApiMain()//       The user defined main function used to interface this library//    int ApiEnd()//       The user defined end function used to handle any clean up duties//       before the program ends//    long GetMilliseconds()//       Returns the number of milliseconds that have passed since 00:00//       Universal Coordinated Time, January 1, 1970.//-----------------------------------------------------------------------//#ifndef SIMPLEWINDOW_H#define SIMPLEWINDOW_H#include "Constants.h"#include <vector>const int    DefaultWidth    = 8;const int    DefaultHeight   = 8;#ifndef USING_CCconst color  DefaultColor     (White);const string DefaultMessage   ("Message");#elseconst color  DefaultColor    = White;const string DefaultMessage  = "Message";#endiftypedef int (*TimerTickCallbackFunction) ();typedef int (*MouseClickCallbackFunction)(const Position &);typedef int (*RefreshCallbackFunction)   ();typedef int (*QuitCallbackFunction)      ();//-----------------------------------------------------------------------\\//  S i m p l e W i n d o w   C l a s s                                  \\class SimpleWindow {   public:      SimpleWindow(const string &WindowTitle,       float Width = DefaultWidth, float Height = DefaultHeight,       const Position &WindowPosition = LogicalOrigin);      SimpleWindow(const char* WindowTitle = "Untitled",       float Width = DefaultWidth, float Height = DefaultHeight,       const Position &WindowPosition = LogicalOrigin);      SimpleWindow(const SimpleWindow &CopyWindow);     ~SimpleWindow();      SimpleWindow operator=(const SimpleWindow &NewWindow);      WindowStatus Open ();      WindowStatus Close();      WindowStatus GetStatus() const;      void DrawBitMap(const Pixmap &PixelMap, const Position &UpperLeft,       const Position &Size);      void Erase(const Position &UpperLeft, float Width, float Height);      void RenderRectangle(const Position &UpperLeft,       const Position &LowerRight, const color &FillColor,       const bool Border = false);      void RenderLine(const Position &Base, const Position &Endpoint,       const color &Color, const float LineWidth);      void RenderEllipse(const Position &UpperLeft,       const Position &LowerRight, const color &FillColor,       const bool Border = false);      void RenderPolygon(const Position PolyPoints[], int NbrPoints,       const color &FillColor, const bool Border = false);      void RenderPolygon(const vector<Position> &PolyPoints, int NPoints,		 const color &Color, const bool Border = false);
      void RenderText(const Position LabelCenter,       const string &Message = DefaultMessage,       const color &TextColor = Black,       const color &BackgroundColor = DefaultColor);      void RenderText(const Position LabelCenter,       const char* Message = DefaultMessage.c_str(),       const color &TextColor = Black,       const color &BackgroundColor = DefaultColor);      void RenderText(const Position &UpperLeft,       const Position &LowerRight,       const string &Message = DefaultMessage,       const color &TextColor = Black,       const color &BackgroundColor = DefaultColor);      void RenderText(const Position &UpperLeft,       const Position &LowerRight,       const char* Message = DefaultMessage.c_str(),       const color &TextColor = Black,       const color &BackgroundColor = DefaultColor);      void Message(const string &Message = DefaultMessage);      float GetWidth    () const;      float GetHeight   () const;      float GetXPosition() const;      float GetYPosition() const;      Position GetCenter  () const;      Position GetPosition() const;      bool  StartTimer(int Interval);      void StopTimer();      void SetQuitCallback      (const QuitCallbackFunction       &Callback);      void SetTimerCallback     (const TimerTickCallbackFunction  &Callback);      void SetRefreshCallback   (const RefreshCallbackFunction    &Callback);      void SetMouseClickCallback(const MouseClickCallbackFunction &Callback);   protected:      virtual Bool  QuitEvent      ();      virtual Bool  RefreshEvent   ();      virtual Bool TimerEvent     ();      virtual Bool  MouseClickEvent(const Position &MousePosn);   private:      Window                     window;      Pixmap                     ScreenBuffer;      string                     Title;      WindowStatus               WinStatus;      RefreshCallbackFunction    RefreshCallback;      QuitCallbackFunction       QuitCallback;      TimerTickCallbackFunction  TimerCallback;      MouseClickCallbackFunction MouseClickCallback;            Bool                       TimerActive;      unsigned long int          AlarmTime;#ifndef USING_CC      long                       OldTime;#else      unsigned long int          OldTime;#endif      int                        WinX;       int                        WinY;       int                        WinWidth;        int                        WinHeight;      float                      LogX;       float                      LogY;       float                      LogWidth;       float                      LogHeight;       void CheckTimer    ();      void ConfigureEvent(const XEvent &Report);   friend class WindowManager;};//-----------------------------------------------------------------------\\//  A d d i t i o n a l  F u n c t i o n s                               \\int ApiMain();int ApiEnd ();long GetMilliseconds();#endif

⌨️ 快捷键说明

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