📄 skin.h
字号:
#define SIE_SLIDER_CHANGED 0x00000002#define SIE_GAIN_FOCUS 0x00010000#define SIE_LOST_FOCUS 0x00020000/** * \var int (* skin_event_cb_t) (HWND hwnd, skin_item_t* item, int event, void* data) * * Event callback of skin item. * * The event can be one of the following values: * * - SIE_GAIN_FOCUS\n * The item gained the focus. * - SIE_LOST_FOCUS\n * The item losted the focus. * - SIE_BUTTON_CLICKED\n * The button item has been clicked. * - SIE_SLIDER_CHNAGED\n * The position of the slider item has changed. */typedef int (* skin_event_cb_t) (HWND hwnd, skin_item_t* item, int event, void* data);#define MSG_CB_GOON 0#define MSG_CB_DEF_GOON 1#define MSG_CB_STOP 2/** * \var int (* skin_msg_cb_t) (HWND hwnd, int message, WPARAM wparam, LPARAM lparam, int* result) * * This is the type of message callback function of a skin window. * * Before a skin window processes a message, it will call the message * callback function if the application defined it. * * The application defined message callback function can process the message * as a normal window procedure and return the result through the parameter \a result. * However, the return value of a message callback function can be used * to control the behavior of the skin window's message handling procedure. * It can be one of the following values: * * - MSG_CB_GOON * The message should be processed by skin window procedure, and * the result of the callback will be ignored. * - MSG_CB_DEF_GOON * The message should be processed by the default window procedure, and * the result of the callback will be ignored. * - MSG_CB_STOP * The message should not be processed, and the result is valid. */typedef int (* skin_msg_cb_t) (HWND hwnd, int message, WPARAM wparam, LPARAM lparam, int* result);#define SKIN_STYLE_NONE 0x00000000#define SKIN_STYLE_TOOLTIP 0x00000001/** Skin header information structure */struct skin_head_s{ /** The name of the skin. */ char* name; /** * The style of the skin, can be OR'ed by the following values: * - SKIN_STYLE_TOOLTIP * The skin has tooltip window. */ DWORD style; /** The pointer to the array of the bitmaps used by the skin. */ const BITMAP* bmps; /** The pointer to the array of the logical fonts used by the skin. */ const LOGFONT* fonts; /** The index of the background bitmap in the bitmap array. */ int bk_bmp_index; /** The number of the items in this skin. */ int nr_items; /** The pointer to the array of skin items. */ skin_item_t* items; /** The attached private data with the skin by application. */ DWORD attached; /******** start of internal fields ********/ /* The event callback function of the skin. */ skin_event_cb_t event_cb; /* The window message procedure of the skin window. */ skin_msg_cb_t msg_cb; /**** The fields initialized when skin_init called. ****/ /* The rectangle heap for hit-test regions. */ BLOCKHEAP rc_heap; /**** The fields initialized when create_skin_main_window or create_skin_control called. ****/ /* The handle of window in which the skin locates. */ HWND hwnd; /* The handle of tool tip window. */ HWND tool_tip; /* The old x and y. */ int oldx, oldy; /* The current hilighted item. */ skin_item_t* hilighted; /* cached identifier. */ int cached_id; /* the item whose identifier is cached_id. */ skin_item_t* cached_item;};/** Skin header information structure */typedef struct skin_set_s{ /** The version of the skin, currently is 3. */ int version; /** The author of the skin. */ char* author; /** The pointer to the array of the bitmaps used by the skin set. */ BITMAP* bmps; /** The pointer to the array of the logical fonts used by the skin set. */ LOGFONT* fonts; /** The number of the skins in the set. */ int nr_skins; /** The pointer to the skin objects array. */ skin_head_t* skins;} skin_set_t;#ifdef __cplusplusextern "C" {#endif /* __cplusplus *//** * \fn skin_set_t* skin_set_load (MG_RWops* source) * \brief Loads a set of skins from a MG_RWops object which defines the skin set. * * This function loads and returns a skin objects set from the MG_RWops * object \a source which defines the skin. * * This function will load the bitmap objects and create the logical * fonts for the skin set, then create the skin_set_t object and * its skin and skin items. * * The source should have the following layout: * * \code * * { * global { * version: 3 * author: <the name of the author> * } * bitmaps { * <id of bitmap 1> { * name: <file name of the bitmap> * } * <id of bitmap 2> { * name: <file name of the bitmap> * } * ... * } * fonts { * <id of font 1> { * name: <name of the font> * } * <id of font 2> { * name: <name of the font> * } * ... * } * skins { * <name of skin1> { * items { * <id of item1> { * style: * x: * y: * test_rect: * bmp_id: * tip: * type_data { * ... * } * } * <id of item2> { * style: * x: * y: * test_rect: * bmp_id: * tip: * type_data { * ... * } * } * ... * } * } * <name of skin2> { * items { * ... * } * } * <name of skin3> { * items { * ... * } * } * } * } * * \endcode * * * \return This function returns the pointer to the skin set * when success, otherwise NULL. * * \sa general_rw_fns, skin_set_unload, skin_init */MG_EXPORT skin_set_t* skin_set_load (MG_RWops* skin_info);/** * \fn void skin_set_unload (skin_set_t* skin_set) * \brief Unloads a skin set. * * This function unloads the skin set \a skin_set. It destroies * the bitmap objects, the logical fonts, and the skin objects. * * \sa skin_set_load, skin_destroy */MG_EXPORT void skin_set_unload (skin_set_t* skin_set);/** * \fn skin_head_t* skin_set_find_skin (skin_set_t* skin_set, const char* skin_name) * \brief Finds a skin object in a skin set. * * This function finds a skin object which matches the name \a skin_name in a skin set. * * \sa skin_set_load */MG_EXPORT skin_head_t* skin_set_find_skin (skin_set_t* skin_set, const char* skin_name);/** * \fn BOOL skin_init (skin_head_t* skin, skin_event_cb_t event_cb, skin_msg_cb_t msg_cb) * \brief Initializes a skin. * * This function initializes a skin \a skin before it can be used. * The initialization of a skin includes skin items initialization, etc, * such as creating the hit-test region, allocating space for label, and so on. * * \param skin The pointer to the skin object. The skin can be * a object returned by \a skin_set_find_skin or a hard-coded * skin_head_t structure. * \param event_cb The item event callback of the skin. * \param msg_cb The window message callback of the skin window. * * \return TRUE for success, otherwise FALSE. * * \sa skin_set_load, skin_destroy, skin_set_find_skin */MG_EXPORT BOOL skin_init (skin_head_t* skin, skin_event_cb_t event_cb, skin_msg_cb_t msg_cb);/** * \fn void skin_deinit (skin_head_t* skin) * \brief Deinitializes an initialized skin. * * This function deinitializes a skin, opposed to skin_init. * * \param skin The pointer to the skin object. * * \sa skin_set_load, skin_init */MG_EXPORT void skin_deinit (skin_head_t* skin);/** * \fn HWND create_skin_main_window (skin_head_t* skin, HWND hosting, int x, int y, int w, int h, BOOL modal) * \brief Creates a main window for a skin. * * This function creates a main window for the skin pointed to by \a skin. * The main window will have no caption, no menu, and no frame. However, * the window's caption string will be the name of the skin object. * * \param skin The pointer to the initialized skin object. * \param hosting The the hosting main window. * \param x X-coordinate of the expected main window. * \param y Y-coordinate of the expected main window. * \param w The width of the expected main window. * \param h The height of the expected main window. * \param modal Whether to be a modal or modeless main window. * * \return The handle to the main window. * * \note The skin will store itself as the main window's additional data, * so application should not call SetWindowAdditionalData to store * other value. * * \sa skin_set_load, create_skin_control */MG_EXPORT HWND create_skin_main_window (skin_head_t* skin, HWND hosting, int x, int y, int w, int h, BOOL modal);/** * \fn HWND create_skin_control (skin_head_t* skin, HWND parent, int id, int x, int y, int w, int h) * \brief Creates a control for a skin. * * This function creates a control for the skin pointed to by \a skin. * * \param skin The pointer to the initialized skin object. * \param parent The handle to the parent window of the expected control. * \param id The identifier of the expected control. * \param x X-coordinate of the expected control in the parent window's client area. * \param y Y-coordinate of the expected control in the parent window's client area. * \param w The width of the expected control. * \param h The height of the expected control. * * \return The handle to the control. * * \note The skin will store itself as the control's additional data, * so application should not call SetWindowAdditionalData to store other value. * * You can also create a skin control by calling CreateWindowEx in the following manner: * \code * CreateWindowEx (CTRL_SKIN, "", WS_VISIBLE | WS_CHILD, WS_EX_NONE, id, x, y, w, h, parent, (DWORD) skin); * \endcode * * \sa skin_set_load, create_skin_main_window */MG_EXPORT HWND create_skin_control (skin_head_t* skin, HWND parent, int id, int x, int y, int w, int h);
/**
* \fn BOOL is_skin_main_window (HWND hwnd)
* \brief whether a window is skin_main_window or not.
*
* The function judges whether a window is skin_main_window or not by \a hwnd.
*
* \param hwnd The handle to the skin window.
*
* \return TRUE if it is , and FALSE if it isn't.
*
* \sa create_skin_main_window
*/
MG_EXPORT BOOL is_skin_main_window (HWND hwnd);
/** * \fn void destroy_skin_window (HWND hwnd) * \brief Destroies a skin window. *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -