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

📄 pwin.h

📁 Very very small GUI. Usefull for small system, without OS or small OS. Event driven, support user m
💻 H
📖 第 1 页 / 共 4 页
字号:
    void (*fill_rect)(Pw_GC*   gc, 
                      Pw_Coord x, 
                      Pw_Coord y, 
                      Pw_Coord w, 
                      Pw_Coord h);
};

/**
 *  Graphic context.
 *  A Graphic context carries all the information we need
 *  in order to draw something. Before we can draw anything 
 *  we need to obtain a graphic contex. There are several 
 *  types of graphic contextes depending on where we want 
 *  to draw (display, bitmaps, ...).
 *  @see Pw_Drawable
 */
struct _Pw_GC {
    /** Drawable to wich this graphic context belongs. */
    Pw_Drawable    d;     
    Pw_Int         xoff;     /**< X offset (origin). */
    Pw_Int         yoff;     /**< Y offset (origin). */
    Pw_RegionList  clip_reg; /**< Clip region. */
    int            color;    /**< Current color. */
//    Pw_Color      color;    /**< Current color. */
    Pw_Font*       font;     /**< Current font. */
};

/**
 *  General event data.
 */
struct _Pw_EventData {
    Pw_EventType type; /**< Event type. */
    Pw_Window*   win;  /**< Window from wich this event originated. */
};

struct _Pw_UserEvent {
	Pw_EventData data;
	struct {
		DEV_GUI_MessageType MsgType;		
		union {
			long Data;
			void * Ptr;}UserInfo;
	} MsgData;
};

/**
 *  Key event.
 *  @see Pw_EventData
 */
struct _Pw_KeyEvent {
    /* The location and type of 'data' var must not change! */
    Pw_EventData data;    /**< General event data. */
    Pw_uInt      keycode; /**< Key code of the key pressed/released. */
};

/**
 *  XInput event.
 *  @see Pw_EventData
 */
struct _Pw_XInputEvent {
    /* The location and type of 'data' var must not change! */
    Pw_EventData data; /**< General event data. */
    Pw_uInt      num;  /**< Xinput number. */
    Pw_Int       val;  /**< Xinput value. */
};

/**
 *  Focus event.
 *  @see Pw_EventData
 */
struct _Pw_FocusEvent {
    /* The location and type of 'data' var must not change! */
    Pw_EventData data; /**< General event data. */
};

/**
 *  Mapping event.
 *  @see Pw_EventData
 */
struct _Pw_MappingEvent	{
    /* The location and type of 'data' var must not change! */
    Pw_EventData data; /**< General event data. */
};

/**
 *  Reshape event.
 *  @see Pw_EventData
 */
struct _Pw_ReshapeEvent {
    /* The location and type of 'data' var must not change! */
    Pw_EventData data; /**< General event data. */
};

/**
 *  Destroy event.
 *  @see Pw_EventData
 */
struct _Pw_DestroyEvent	{
    /* The location and type of 'data' var must not change! */
    Pw_EventData data; /**< General event data. */
};

/**
 *  Event union.
 *  @see Pw_EventData
 *  @see Pw_KeyEvent
 *  @see Pw_XInputEvent
 *  @see Pw_FocusEvent
 *  @see Pw_MappingEvent
 *  @see Pw_ReshapeEvent
 *  @see Pw_DestroyEvent
 */
union _Pw_Event	{
    Pw_EventData    data;    /**< General event data. */
    Pw_KeyEvent     key;     /**< Key event. */
    Pw_XInputEvent  xinput;  /**< Xinput event. */
    Pw_FocusEvent   focus;   /**< Focus event. */
    Pw_MappingEvent mapping; /**< Mapping event. */
    Pw_ReshapeEvent reshape; /**< Reshape event. */
    Pw_DestroyEvent destroy; /**< Destroy event. */
	Pw_UserEvent	UserMsg;
};

/**
 *  Timeout.
 *  @see Pw_Display
 */
struct _Pw_Timeout {
    Pw_TimeoutCb cb;        /**< Callback function. */
    Pw_Pointer   data;      /**< Client data. */
    Pw_uLong     time;      /**< Time interval. */
    Pw_uLong     time_left; /**< Time left to callback trigger. */
    Pw_Timeout*  next;      /**< Next timeout in list. */
};

/**
 *  Window.
 *  @see Pw_Display
 */
struct _Pw_Window {
    Pw_Display*   dpy;            /**< Display of this window. */
    Pw_Rectangle  area;           /**< Window area. */
    Pw_Window*    parent;         /**< Parent window. */
    Pw_Window*    children;       /**< First children in child windows list. */
    Pw_uInt       children_num;   /**< Number of children windows. */
    Pw_Window*    prev;           /**< Prev window in list. */
    Pw_Window*    next;           /**< Next window in list. */
    Pw_RegionList clip_reg;       /**< Visible region of window. */
    Pw_Bool       mapped;         /**< True if this window is mapped. When
                                       a window is mapped it is visible on
                                       display. When it is not mapped is
                                       invisible. */
    Pw_Bool       focus_accept;   /**< True if this window accept focus.
                                       If a window accepts focus and it gets
                                       focus, it will receive key events. */
    Pw_EventCb    event_cb;       /**< Window event callback. */
    Pw_RepaintCb  repaint_cb;     /**< Repaint callback. */
    Pw_Int        cdata_id;       /**< Id of client data. */
    Pw_Pointer    cdata;          /**< Clients using this window can store
                                       pointer to some misc data in here. */
};

/**
 *  Display.
 */
struct _Pw_Display {
	int     	_Color_;			// mvd 04-08-07	
    Pw_Coord     width;     /**< Width of display. */
    Pw_Coord     height;    /**< Height of display. */
    Pw_Window    root_win;  /**< Root window of display. */
    Pw_Window*   focus_win; /**< Window that has focus. A window in focus
                                 receives key events. */
    Pw_Timeout*  timeouts;  /**< Display timeouts. */

    /** Windows that will receive specific xinput events. */
    Pw_Window*   xinput_win[PW_XINPUTS_MAX_NUM]; 
                                                
    Pw_DD*       dd;        /**< Display driver functions.*/
    Pw_Bool      close;     /**< True if this display is going to close now. */
};

/* -------------------------------------------------------------------------- */

//extern pw_white_pixel; /**< White pixel definition. */

//extern pw_black_pixel; /**< Black pixel definition. */

/* -------------------------------------------------------------------------- */

/**
 *  Define macro start.
 */
#define PW_MACRO_START do {

/**
 *  Define macro end.
 */
#define PW_MACRO_END   } while (0)

/* -------------------------------------------------------------------------- */

/**
 *  Gets the width of display @p dpy.
 *  @param _dpy_ display @p dpy pointer 
 *  @return the width of display
 *  @see Pw_Display
 */
#define Pw_DisplayGetWidth(_dpy_) \
    ((_dpy_)->width)

/**
 *  Gets the height of display @p dpy.
 *  @param _dpy_ display @p dpy pointer 
 *  @return the height of display
 *  @see Pw_Display
 */
#define Pw_DisplayGetHeight(_dpy_) \
    ((_dpy_)->height)

/**
 *  Gets the root window of display @p dpy.
 *  @param _dpy_ display @p dpy pointer
 *  @return pointer to root window of display
 *  @see Pw_Display
 *  @see Pw_Window
 */
#define Pw_DisplayGetRootWindow(_dpy_) \
    (&(_dpy_)->root_win)

/**
 *  Gets the window in focus of display @p dpy.
 *  @param _dpy_ display @p dpy pointer
 *  @return pointer to window in focus of display
 *  @see Pw_Display
 *  @see Pw_Window
 */
#define Pw_DisplayGetFocusWindow(_dpy_) \
    ((_dpy_)->focus_win)

/**
 *  Closes the display @p dpy.
 *  @param _dpy_ display @p dpy pointer 
 *  @see Pw_Display
 */
#define Pw_DisplayClose(_dpy_) \
    ((_dpy_)->close = TRUE)

/* -------------------------------------------------------------------------- */

/**
 *  Gets the display of window @p win.
 *  @param _win_ window @p win pointer
 *  @return pointer to display of window
 *  @see Pw_Display
 *  @see Pw_Window
 */
#define Pw_WindowGetDisplay(_win_) \
    ((_win_)->dpy)

/**
 *  Gets the x coordinate of window @p win.
 *  @param _win_ window @p win pointer
 *  @return the x coordinate window
 *  @see Pw_Window
 */
#define Pw_WindowGetX(_win_) \
    ((_win_)->area.x)

/**
 *  Sets the x coordinate of window @p win.
 *  @param _win_ window @p win pointer
 *  @param _x_   new x coordinate of window 
 *  @see Pw_Window
 */
#define Pw_WindowSetX(_win_, _x_)         \
    Pw_WindowSetShape((_win_),            \
                      (_x_),              \
                      (_win_)->area.y,    \
                      (_win_)->area.w,    \
                      (_win_)->area.h)

/**
 *  Gets the y coordinate of window @p win.
 *  @param _win_ window @p win pointer
 *  @return the y coordinate window
 *  @see Pw_Window
 */
#define Pw_WindowGetY(_win_) \
    ((_win_)->area.y)

/**
 *  Sets the y coordinate of window @p win.
 *  @param _win_ window @p win pointer
 *  @param _y_   new y coordinate of window 
 *  @see Pw_Window
 */
#define Pw_WindowSetY(_win_, _y_)         \
    Pw_WindowSetShape((_win_),            \
                      (_win_)->area.x,    \
                      (_y_),              \
                      (_win_)->area.w,    \
                      (_win_)->area.h)

/**
 *  Gets the width of window @p win.
 *  @param _win_ window @p win pointer
 *  @return the width of window
 *  @see Pw_Window
 */
#define Pw_WindowGetWidth(_win_) \
    ((_win_)->area.w)

/**
 *  Sets the width of window @p win.
 *  @param _win_   window @p win pointer
 *  @param _width_ new width of window 
 *  @see Pw_Window
 */
#define Pw_WindowSetWidth(_win_, _width_) \
    Pw_WindowSetShape((_win_),            \
                      (_win_)->area.x,    \
                      (_win_)->area.y,    \
                      (_width_),          \
                      (_win_)->area.h)

/**
 *  Gets the height of window @p win.
 *  @param _win_ window @p win pointer
 *  @return the height of window
 *  @see Pw_Window
 */
#define Pw_WindowGetHeight(_win_) \
    ((_win_)->area.h)

/**
 *  Sets the height of window @p win.
 *  @param _win_ window @p win pointer
 *  @param _x_   new height of window 
 *  @see Pw_Window
 */
#define Pw_WindowSetHeight(_win_, _height_) \
    Pw_WindowSetShape((_win_),              \
                      (_win_)->area.x,      \
                      (_win_)->area.y,      \
                      (_win_)->area.w,      \
                      (_height_))          

/**
 *  Gets the position of window @p win.
 *  @param _win_ window @p win pointer
 *  @param _xp_  pointer to x position of window (returned)
 *  @param _yp_  pointer to y position of window (returned)
 *  @see Pw_Window
 */
#define Pw_WindowGetPosition(_win_, _xp_, _yp_) \
    PW_MACRO_START                              \
        *(_xp_) = (_win_)->area.x;              \
        *(_yp_) = (_win_)->area.y;              \
    PW_MACRO_END

/**
 *  Sets the position of window @p win.
 *  @param _win_ window @p win pointer
 *  @param _x_   new x position of window 
 *  @param _y_   new y position of window 
 *  @see Pw_Window
 */
#define Pw_WindowSetPosition(_win_, _x_, _y_)  \
    Pw_WindowSetShape((_win_),                 \
                      (_x_),                   \
                      (_y_),                   \
                      (_win_)->area.w,         \
                      (_win_)->area.h)

/**
 *  Gets the size of window @p win.
 *  @param _win_ window @p win pointer
 *  @param _wp_  pointer to width of window (returned)
 *  @param _hp_  pointer to height of window (returned)
 *  @see Pw_Window
 */
#define Pw_WindowGetSize(_win_, _wp_, _hp_)    \
    PW_MACRO_START                             \
        *(_wp_) = (_win_)->area.w;             \
        *(_hp_) = (_win_)->area.h;             \
    PW_MACRO_END

/**
 *  Sets the size of window @p win.

⌨️ 快捷键说明

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