code_twain/sln/sdk/include/win/ui/ui_util.h

526 lines
57 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// function: windows utilities
//
// author: Gongbing
//
// date: 2019-10-23
//
//
#pragma once
#ifndef _INCLUDED_REF_
#define _INCLUDED_REF_
#include "../../ref/ref.h"
#endif
#include <atlimage.h>
#include <string>
#include "GdiPlus.h"
#pragma comment(lib,"gdiplus.lib")
namespace ui_util
{
enum{ GROUP_NONE = -1, };
enum
{
BTN_STATU_NORMAL = 0,
BTN_STATU_HOVER,
BTN_STATU_PRESS,
BTN_STATU_DISABLED,
BTN_STATU_CHECKED,
BTN_STATU_UNCHECKED,
BTN_STATU_COUNT,
};
enum slider_type // bit mask
{
SLIDER_VERT_ONLY = 0x01,
SLIDER_HORZ_ONLY = 0x02,
SLIDER_BOTH = 0x03,
};
enum user_id_beginning // message, timer id ... beginning for user
{
USER_MSG_BEGINNING = WM_USER + 100,
USER_TIMER_BEGINNING = 100,
};
enum
{
MENU_ALIGN_TOPLEFT = 0,
MENU_ALIGN_TOPRIGHT,
MENU_ALIGN_BOTTOMLEFT,
MENU_ALIGN_BOTTOMRIGHT,
LIST_ALIGN_LEFT = 0,
LIST_ALIGN_CENTER,
LIST_ALIGN_RIGHT,
};
enum
{
GRID_ELEMENT_TYPE_NONE = 0,
GRID_ELEMENT_TYPE_TEXT,
GRID_ELEMENT_TYPE_COLOR,
GRID_ELEMENT_TYPE_BITMAP,
GRID_ELEMENT_TYPE_ICON,
GRID_ELEMENT_TYPE_IMAGE,
GRID_ELEMENT_TYPE_SPLIT,
GRID_ELEMENT_TYPE_USER, // user defined element, must derrived from IUserCtrl
};
enum // caret command
{
CARET_CREATE = 1, // LPARAM: MAKELPARAM(w, h)
CARET_SHOW, // LPARAM: MAKELPARAM(x, y)
CARET_HIDE, // LPARAM: unused
CARET_QUERY, // LPARAM: LPRECT to receive the caret size
};
enum // enumeration used in IEventHandler
{
EVENT_CONVERT_COORDINATE = 1, // WPARAM: (bool), true - client to screen; LPARAM: LPPOINT
EVENT_NEED_REPAINT,
EVENT_MOUSE_ENTER = 10,
EVENT_MOUSE_MOVE,
EVENT_MOUSE_LBUTTON_DOWN,
EVENT_MOUSE_LBUTTON_UP,
EVENT_MOUSE_RBUTTON_DOWN,
EVENT_MOUSE_RBUTTON_UP, // in list control, WPARAM is sub-item, LPARAM is item
EVENT_MOUSE_WHEEL,
EVENT_MOUSE_CLICK,
EVENT_MOUSE_DOUBLE_CLICK, // in list control, WPARAM is sub-item, LPARAM is item
EVENT_MOUSE_LEAVE,
EVENT_KEYBOARD_DOWN = 100,
EVENT_KEYBOARD_UP,
EVENT_CHAR,
EVENT_NEED_TIMER = 200, // WPARAM: elapse in millisecond, 0 for cancel; LPARAM: parameter for call ISkinElement::timer_task(lparam)
EVENT_CARET_REQ, // WPARAM: see 'caret command' LPARAM: see 'caret command'
EVENT_STATU_CHANGED, // WPARAM: old statu; LPARAM: new statu
EVENT_POS_CHANGED, // WPARAM: coordinate y increament or 0 for scrollbar; LPARAM: coordinate x increament or position increment for scrollbar
EVENT_ZPOS_CHANGED, // WPARAM: old z value; LPARAM: new z value
// compound controls events ...
EVENT_SELECTION_CHANGED = 300, // WPARAM: old item, LPARAM: new item
EVENT_LIST_HEAD_CLICKED, // WPARAM: unused LPARAM: head index
EVENT_DELETE_ITEM, // WPARAM: bool*, set to 'false' to prevent be deleted LPARAM: item
EVENT_MENU_COMMAND, // WPARAM: IMenu* LPARAM: menu ID.
};
__declspec(novtable) struct IUserCtrl;
__declspec(novtable) struct IImage;
typedef struct grid_ele
{
int type; // GRID_ELEMENT_TYPE_xxx
union
{
COLORREF clr; // GRID_ELEMENT_TYPE_COLOR
HBITMAP bmp; // GRID_ELEMENT_TYPE_BITMAP
HICON icon; // GRID_ELEMENT_TYPE_ICON
IUserCtrl *ctrl; // GRID_ELEMENT_TYPE_USER
IImage *img; // GRID_ELEMENT_TYPE_IMAGE
};
}GRIDELE;
__declspec(novtable) struct IImage : public ref_util::IRef
{
COM_API_DECLARE(bool, load_file(const wchar_t* img_path_file));
COM_API_DECLARE(int, get_width(void));
COM_API_DECLARE(int, get_height(void));
COM_API_DECLARE(void, draw_img(HDC hdc, LPRECT dest));
};
__declspec(novtable) struct ISkinElement : public ref_util::IRef
{
COM_API_DECLARE(bool, set_image(HINSTANCE hinst, UINT img_res_id, const wchar_t* res_type = L"PNG"));
COM_API_DECLARE(bool, set_image(const wchar_t* img_file));
COM_API_DECLARE(void, set_visible(bool visible));
COM_API_DECLARE(void, set_location(int x, int y, int dst_w = -1, int dst_h = -1));
COM_API_DECLARE(void, offset(int x_off, int y_off));
COM_API_DECLARE(void, expand_size(int w_adden, int h_adden));
COM_API_DECLARE(int, set_custom_cursor(const wchar_t* cursor_name = NULL/*IDC_ARROW*/, HINSTANCE cursor_module = NULL)); // return prev-zorder
COM_API_DECLARE(int, set_group_id(int gid = GROUP_NONE)); // return prev-id
COM_API_DECLARE(int, set_z_order(int zorder)); // return prev-zorder. 0 is on the raw window, 1 is on 0, and so on ...
COM_API_DECLARE(unsigned char, set_transparency(unsigned char trans)); // return previous transparency. trans: [(hide)0-255(opaque)]
COM_API_DECLARE(void, enable_drag(int xmin = -1, int xmax = -1, int ymin = -1, int ymax = -1)); // all be -1 would disable drag
COM_API_DECLARE(bool, timer_task(LPARAM lp, POINT mouse)); // return whether need redrawing
COM_API_DECLARE(SIZE, get_size(void));
COM_API_DECLARE(int, get_left(void));
COM_API_DECLARE(int, get_top(void));
COM_API_DECLARE(int, get_right(void));
COM_API_DECLARE(int, get_bottom(void));
COM_API_DECLARE(int, get_width(void));
COM_API_DECLARE(int, get_height(void));
COM_API_DECLARE(int, get_z_order(void));
COM_API_DECLARE(int, get_pixel(int x, int y));
COM_API_DECLARE(int, get_id(void));
COM_API_DECLARE(int, get_group_id(void));
COM_API_DECLARE(bool, get_custom_cursor(const wchar_t** name, HINSTANCE* inst)); // return whether has custom cursor
COM_API_DECLARE(bool, is_point_in(int x, int y, bool ignore_visible = false));
COM_API_DECLARE(bool, is_visible(void));
COM_API_DECLARE(const Gdiplus::Image*, image(void));
};
__declspec(novtable) struct ICtrlScheme : public ref_util::IRef
{
// all the parameter 'ele' would be menu if the highest bit was set, and the rest is the ID of the menu
COM_API_DECLARE(int, caret_color(void));
COM_API_DECLARE(int, grid_line_color(ISkinElement* ele));
COM_API_DECLARE(int, dragging_line_color(ISkinElement* ele));
COM_API_DECLARE(int, text_color(ISkinElement* ele, bool disabled = false));
COM_API_DECLARE(int, menu_background_color(ISkinElement* ele));
COM_API_DECLARE(int*, list_control_header_color(ISkinElement* ele)); // 4 dims for normal, hover, press, disable
COM_API_DECLARE(int, list_control_selected_background(ISkinElement* ele));
COM_API_DECLARE(int, menu_selected_background(ISkinElement* ele));
COM_API_DECLARE(int, scrollbar_width(ISkinElement* ele));
COM_API_DECLARE(int, scrollbar_background_color(ISkinElement* ele));
COM_API_DECLARE(int*, scrollbar_slider_color(ISkinElement* ele)); // 4 dims for normal, hover, press, disable
COM_API_DECLARE(int*, scrollbar_button_color(ISkinElement* ele)); // 4 dims for normal, hover, press, disable
COM_API_DECLARE(float, scrollbar_button_size_ratio(ISkinElement* ele));// the ratio of width to height or height to width
COM_API_DECLARE(int, margin_left(ISkinElement* ele));
COM_API_DECLARE(int, margin_right(ISkinElement* ele));
COM_API_DECLARE(int, margin_top(ISkinElement* ele));
COM_API_DECLARE(int, margin_bottom(ISkinElement* ele));
COM_API_DECLARE(int, combox_btn_width(ISkinElement* ele));
COM_API_DECLARE(int, combox_background(ISkinElement* ele, int statu = ui_util::BTN_STATU_NORMAL));
COM_API_DECLARE(int, combox_border_color(ISkinElement* ele));
};
__declspec(novtable) struct IText : public ISkinElement
{
COM_API_DECLARE(void, set_text(const wchar_t* text));
COM_API_DECLARE(bool, set_align(int align = LIST_ALIGN_LEFT));
COM_API_DECLARE(HFONT, set_font(HFONT font)); // return previous font
COM_API_DECLARE(int, set_text_color(int color)); // return previous color
COM_API_DECLARE(int, set_background_color(int color = 0)); // return previous color. no background if color == 0
COM_API_DECLARE(bool, set_multiline(bool multi_line)); // return previous multiline. NO effect now :(
COM_API_DECLARE(DWORD, get_text(wchar_t* buf, DWORD len)); // return real text length
COM_API_DECLARE(DWORD, get_text_width(HWND hwnd)); // return real text length in pixel in single line
COM_API_DECLARE(int, get_align(void));
};
__declspec(novtable) struct IButton : public ISkinElement
{
COM_API_DECLARE(bool, set_statu(int statu = BTN_STATU_NORMAL)); // return whether the statu is different to previous
COM_API_DECLARE(void, adjust_command_area(int right_addend, int bottom_addend = 0, int left_addend = 0, int top_addend = 0));
COM_API_DECLARE(void, set_enabled(bool enabled = true));
COM_API_DECLARE(void, reg_continuous_mousedown_event(bool reg, DWORD elapse = 5/*milliseconds*/));
COM_API_DECLARE(bool, is_enabled(void));
COM_API_DECLARE(int, get_statu(void));
};
__declspec(novtable) struct ICheckButton : public IButton
{
COM_API_DECLARE(bool, set_checked(bool checked)); // return previous statu
COM_API_DECLARE(bool, flip_check_statu(void)); // return the statu after flipped
COM_API_DECLARE(bool, is_checked(void));
};
__declspec(novtable) struct ISlider : public ISkinElement
{
COM_API_DECLARE(void, set_range(int x_min = -1, int x_max = -1, int y_min = -1, int y_max = -1));
COM_API_DECLARE(void, set_pos(int pos));
COM_API_DECLARE(void, set_as_splitter(bool splitter = false));
COM_API_DECLARE(int, get_pos(void));
};
__declspec(novtable) struct IScrollBar : public ISkinElement
{
COM_API_DECLARE(int, set_range(int upper, int lower = 0)); // return error code
COM_API_DECLARE(int, set_step(int step = 1)); // return prev-step
COM_API_DECLARE(int, set_page(int page_size = 12)); // return prev-page-size
COM_API_DECLARE(int, set_pos(int pos = 0)); // return new-pos
COM_API_DECLARE(int, goto_prev_page(void)); // return new-pos
COM_API_DECLARE(int, goto_next_page(void)); // return new-pos
COM_API_DECLARE(void, set_slider_shown(bool show));
COM_API_DECLARE(void, set_enabled(bool enabled = true));
COM_API_DECLARE(bool, is_vertical(void));
COM_API_DECLARE(int, get_range(int* lower = NULL)); // return upper-range
COM_API_DECLARE(int, get_pos(void));
COM_API_DECLARE(int, get_page(void)); // return page size
};
__declspec(novtable) struct IListCtrl : public ISkinElement
{
COM_API_DECLARE(int, insert_column(COLORREF clr, int width, int align = ui_util::LIST_ALIGN_LEFT, int index = -1)); // return column index
COM_API_DECLARE(int, insert_column(const wchar_t* text, int width, int align = ui_util::LIST_ALIGN_LEFT, int index = -1)); // return column index
COM_API_DECLARE(int, insert_column(HBITMAP hBmp, int width, int align = ui_util::LIST_ALIGN_LEFT, int index = -1)); // return column index
COM_API_DECLARE(int, insert_column(const GRIDELE& ele, int width, int align = ui_util::LIST_ALIGN_LEFT, int index = -1)); // return column index
COM_API_DECLARE(int, set_column(int index, GRIDELE* ele/*[in] - new item; [out] - old item*/)); // return error code
COM_API_DECLARE(int, set_column_text(int index, const wchar_t* text)); // return error code
COM_API_DECLARE(int, set_column_width(int index, int width)); // return error code
COM_API_DECLARE(int, remove_column(int index)); // return error code
COM_API_DECLARE(int, show_header(bool show = true)); // return error code
COM_API_DECLARE(HFONT, set_header_font(HFONT font)); // set the header font, return previous font. this control will not destroy the font !!!
COM_API_DECLARE(HFONT, set_font(HFONT font)); // set the list font, return previous font. this control will not destroy the font !!!
COM_API_DECLARE(int, insert_item(const wchar_t* text, int index = -1)); // return item index
COM_API_DECLARE(int, insert_item(HBITMAP hBmp, int index = -1)); // return item index
COM_API_DECLARE(int, insert_item(COLORREF clr, int index = -1)); // return item index
COM_API_DECLARE(int, insert_item(IImage* img, int index = -1)); // return item index
COM_API_DECLARE(int, insert_item(const GRIDELE& ele, int index = -1)); // return item index
COM_API_DECLARE(int, remove_item(int index)); // return error code
COM_API_DECLARE(void, reset_content(void)); // remove all items
COM_API_DECLARE(DWORD_PTR, set_item_data(int index, DWORD_PTR data));
COM_API_DECLARE(DWORD_PTR, get_item_data(int index));
COM_API_DECLARE(int, set_sub_item(int index, int sub_item, COLORREF clr));
COM_API_DECLARE(int, set_sub_item(int index, int sub_item, const wchar_t* text));
COM_API_DECLARE(int, set_sub_item(int index, int sub_item, HBITMAP hBmp));
COM_API_DECLARE(int, set_sub_item(int index, int sub_item, IImage* img));
COM_API_DECLARE(int, set_sub_item_as_image(int index, int sub_item, const wchar_t* img_file));
COM_API_DECLARE(int, set_sub_item(int index, int sub_item, const GRIDELE& ele));
COM_API_DECLARE(bool, set_transparent(bool transparent)); // no background if transparent, return previous
COM_API_DECLARE(int, set_cur_sel(int item));
COM_API_DECLARE(void, show_grid_line(bool show));
COM_API_DECLARE(int, find(const wchar_t* text, int find_col = 0, int find_from = 0));
COM_API_DECLARE(int, find(COLORREF clr, int find_col = 0, int find_from = 0));
COM_API_DECLARE(int, find(HBITMAP hBmp, int find_col = 0, int find_from = 0));
COM_API_DECLARE(int, find(HICON hIcon, int find_col = 0, int find_from = 0));
COM_API_DECLARE(int, find(const GRIDELE& ele, int find_col = 0, int find_from = 0));
COM_API_DECLARE(void, sort(int col = 0, bool ascend = true, bool(__stdcall *is_less)(int row_left, int row_right, int col, void* user) = NULL, void* user = NULL));
COM_API_DECLARE(int, copy(int type = GRID_ELEMENT_TYPE_TEXT)); // copy given content to clipboard, return error code
COM_API_DECLARE(bool, get_item(int index, int sub_item, GRIDELE* ele, wchar_t* text = NULL, int *chars = NULL/*[in] - space of the text, [out] - real text length*/));
COM_API_DECLARE(bool, get_item_rect(int index, int sub_item, RECT* rect));
COM_API_DECLARE(int, get_item_count(void));
COM_API_DECLARE(void, get_real_size(SIZE* size, bool desired = false));
COM_API_DECLARE(bool, enable_rbutton_select(bool enable));
COM_API_DECLARE(bool, enable_multi_selection(bool enable));
COM_API_DECLARE(int, get_cur_sel(int* sel = NULL/*to receive the selection item*/, int* num = NULL/*[in] - sel elements, [out] - real count*/)); // return first selection item
COM_API_DECLARE(int, set_item_selected(int index, bool selected));
COM_API_DECLARE(int, clear_selection(void)); // return the first selected item, -1 is none
COM_API_DECLARE(int, hit_test(int x, int y));
COM_API_DECLARE(void, ensure_visible(int index));
COM_API_DECLARE(int, get_top_visible_item(void));
COM_API_DECLARE(int, get_sorting_column(bool* ascend)); // return current sort column, -1 is none
};
__declspec(novtable) struct IMenu : public ref_util::IRef
{
COM_API_DECLARE(HFONT, set_font(HFONT font)); // return previous font
COM_API_DECLARE(void, popup_menu(int x, int y, int align = MENU_ALIGN_TOPLEFT));
COM_API_DECLARE(int, insert_menu(const wchar_t* text, WORD cmd_id, HICON icon = NULL, int index_by_pos = -1));
COM_API_DECLARE(int, insert_menu(COLORREF clr, WORD cmd_id, HICON icon = NULL, int index_by_pos = -1));
COM_API_DECLARE(int, insert_menu(HBITMAP bmp, WORD cmd_id, HICON icon = NULL, int index_by_pos = -1));
COM_API_DECLARE(int, insert_split(WORD id, int index_by_pos = -1));
COM_API_DECLARE(IMenu*, create_child_menu(DWORD cmd_id)); // create a child popup menu for a menu item
COM_API_DECLARE(void, remove_menu(WORD cmd_id));
COM_API_DECLARE(void, remove_menu_by_pos(WORD pos));
COM_API_DECLARE(void, enable_menu(WORD cmd_id, bool enable = true));
COM_API_DECLARE(void, check_menu(WORD cmd_id, bool checked = true));
COM_API_DECLARE(void, destroy(void));
// added for transport user parameters ...
COM_API_DECLARE(void*, set_data(void* data)); // return previous data
COM_API_DECLARE(void*, get_data(void)); // return previous data
};
__declspec(novtable) struct IComboBox : public ISkinElement
{
COM_API_DECLARE(HFONT, set_font(HFONT font)); // return previous font
COM_API_DECLARE(int, insert_item(const wchar_t* text, int index = -1)); // return item index
COM_API_DECLARE(int, insert_item(HBITMAP hBmp, int index = -1)); // return item index
COM_API_DECLARE(int, insert_item(COLORREF clr, int index = -1)); // return item index
COM_API_DECLARE(int, insert_item(const GRIDELE& ele, int index = -1)); // return item index
COM_API_DECLARE(int, remove_item(int index)); // return error code
COM_API_DECLARE(void, reset_content(void)); // remove all items
COM_API_DECLARE(void, set_editable(bool editable)); // true to enable input values in edit
COM_API_DECLARE(int, set_cur_sel(int item)); // return selection item index after this
COM_API_DECLARE(int, set_list_height(int height));
COM_API_DECLARE(DWORD_PTR, set_item_data(int index, DWORD_PTR data));
COM_API_DECLARE(bool, set_transparent(bool transparent)); // no background if transparent, return previous
COM_API_DECLARE(int, find(const wchar_t* text, int find_from = 0));
COM_API_DECLARE(int, find(COLORREF clr, int find_from = 0));
COM_API_DECLARE(int, find(HBITMAP hBmp, int find_from = 0));
COM_API_DECLARE(int, find(const GRIDELE& ele, int find_from = 0));
COM_API_DECLARE(int, get_item_count(void));
COM_API_DECLARE(int, get_cur_sel(void));
COM_API_DECLARE(DWORD_PTR, get_item_data(int index));
COM_API_DECLARE(bool, get_item(int index, GRIDELE* ele, wchar_t* text = NULL, int *chars = NULL/*[in] - space of the text, [out] - real text length*/));
};
__declspec(novtable) struct IEdit : public ISkinElement
{
COM_API_DECLARE(HFONT, set_font(HFONT font));
COM_API_DECLARE(void, set_text(const wchar_t* text, HFONT font = NULL));
COM_API_DECLARE(int, set_text_color(int clr));
COM_API_DECLARE(bool, set_transparent(bool transp));
COM_API_DECLARE(bool, set_multiline(bool multi));
COM_API_DECLARE(bool, set_read_only(bool read_only));
COM_API_DECLARE(bool, set_password(bool pwd));
COM_API_DECLARE(void, set_sel(int begin, int end)); // same as 'clear_selection' if end < begin
COM_API_DECLARE(void, clear_selection(void)); // clear selection, like end < begin in 'set_sel'
COM_API_DECLARE(int, copy(void)); // copy to clipboard, return content length
COM_API_DECLARE(int, cut(void)); // copy to clipboard, return content length
COM_API_DECLARE(int, paste(void)); // paste to edit, return content length
COM_API_DECLARE(bool, undo(void)); // copy to clipboard, return content length
COM_API_DECLARE(int, get_text(wchar_t** buf/*call free_text_buf to free this*/)); // return content length
COM_API_DECLARE(void, free_text_buf(wchar_t* buf)); // to free the buf which returned in 'get_text'
};
__declspec(novtable) struct IUserCtrl : public ref_util::IRef
{
COM_API_DECLARE(bool, is_need_draw(void)); // return whether need painting
COM_API_DECLARE(void, draw(HDC hdc, int cx, int cy));
COM_API_DECLARE(SIZE, get_size(void));
//COM_API_DECLARE(bool, on_mouse_event(int ev_type, WPARAM wp, LPARAM lp)); // return whether need redraw
};
__declspec(novtable) struct IEventHandler : public ref_util::IRef
{
COM_API_DECLARE(int, on_event(ISkinElement* ele, int event_type, WPARAM wp, LPARAM lp));
};
__declspec(novtable) struct ISkinWndSinker : public IEventHandler
{
// set handled be 'true' to notify do not handle this message again
COM_API_DECLARE(LRESULT, on_message(UINT msg, WPARAM wp, LPARAM lp, bool* handled));
COM_API_DECLARE(void, on_draw(Gdiplus::Graphics& gp, HDC hdc, RECT& r));
};
__declspec(novtable) struct ISkinWnd : public ref_util::IRef
{
// wnd
COM_API_DECLARE(HWND, create_window(DWORD style = WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, DWORD style_ex = WS_EX_LAYERED, HWND parent = NULL));
COM_API_DECLARE(HWND, native_window(void)); // return the native window handle
COM_API_DECLARE(void, show(bool show, bool top_most = false)); // caller should provides message-recycle
COM_API_DECLARE(int, do_modal(HWND parent, bool hide_parent = false, bool show = true)); // the parameter 'show' is used for such as silent circumstance
COM_API_DECLARE(void, set_window_size(int cx, int cy));
COM_API_DECLARE(void, center_window(void));
COM_API_DECLARE(void, set_location(int x, int y, int cx = -1, int cy = -1));
COM_API_DECLARE(unsigned char, set_transparency(unsigned char trans)); // return previous transparency. trans: [(hide)0-255(opaque)]
COM_API_DECLARE(bool, register_timer(int msg, int elapse/*milliseconds*/)); // will receive the message 'msg' in ISkinWndSinker::on_message()
COM_API_DECLARE(void, unregister_timer(int msg));
COM_API_DECLARE(void, enable_quick_draw(bool enable)); // to allow store memory DCs for every level on z_order, the elements should have no intercross in the same Z order
COM_API_DECLARE(void, enable_draw_icon(bool enable, int x = 1, int y = 1, int w = 16, int h = 16));
COM_API_DECLARE(void, redraw(void));
COM_API_DECLARE(bool, remove_skin(int id));
COM_API_DECLARE(void, quit(void));
// function: bring/cancel self or other hwnd of topmost
// topmost: true - set topmost; false - cancel topmost
// hwnd: the window to be set or unset topmost, if it was NULL then set self
// keep_ms: milliseconds to keep topmost, -1 is forever
COM_API_DECLARE(void, bring_to_topmost(bool topmost = true, HWND hwnd = NULL, DWORD keep_ms = -1));
// UI-elements adding-function ...
// NOTE: 1 - following returned objects should NOT call release() to free them unless you call add_ref() before !!!
// 2 - all the 'resource ID' parameter would be cosindered as 'const wchar_t*' to point the local path image file
// if parameter 'res' was NULL !!!
COM_API_DECLARE(ISkinElement*, add_image(int id, HINSTANCE res, UINT img_res_id, int x, int y, int z = 0, int dst_w = -1, int dst_h = -1, const wchar_t* pResType = L"PNG"));
COM_API_DECLARE(IText*, add_static_text(int id, HINSTANCE res, UINT img_res_id, int x, int y, int z = 0, int dst_w = -1, int dst_h = -1, const wchar_t* pResType = L"PNG"));
COM_API_DECLARE(IButton*, add_button(int id, HINSTANCE res, UINT normal_id, UINT hover_id, UINT press_id, UINT disable_id
, int x, int y, int z = 0, int dst_w = -1, int dst_h = -1, const wchar_t* pResType = L"PNG"));
COM_API_DECLARE(ICheckButton*, add_check_button(int id, HINSTANCE res, UINT unsel_normal_id, UINT unsel_hover_id, UINT unsel_press_id
, UINT sel_normal_id, UINT sel_hover_id, UINT sel_press_id, UINT disable_id
, int x, int y, int z = 0, int dst_w = -1, int dst_h = -1
, bool selected = true, const wchar_t* pResType = L"PNG"));
COM_API_DECLARE(ISlider*, add_slider(int id, slider_type type, HINSTANCE res, UINT normal_id, UINT hover_id, UINT press_id, UINT disable_id
, int x, int y, int z = 0, int dst_w = -1, int dst_h = -1, const wchar_t* pResType = L"PNG"));
COM_API_DECLARE(IScrollBar*, add_scrollbar(int id, bool vert, int x, int y, int w, int h, int z));
COM_API_DECLARE(IListCtrl*, add_list_control(int id, int x, int y, int w, int h, int z));
COM_API_DECLARE(IComboBox*, add_combox(int id, int x, int y, int w, int h, int z));
COM_API_DECLARE(IEdit*, add_edit_control(int id, int x, int y, int w, int h, int z));
// UI-elements adding-function END
COM_API_DECLARE(ISkinElement*, find(int id));
COM_API_DECLARE(ISkinElement*, hit_test(int x, int y));
COM_API_DECLARE(void, set_group_visible(int group_id, bool visible, bool include_none_group = false));
};
/////////////////////////////////////////////////////////////////////////////////////
// ui controls ...
//__declspec(novtable) struct ICtrl : public ref_util::IRef
//{
// COM_API_DECLARE(bool, IsVisible(void));
// COM_API_DECLARE(bool, IsCaptured(void));
// COM_API_DECLARE(bool, IsEnabled(void));
// COM_API_DECLARE(const RECT&, GetArea(void));
// COM_API_DECLARE(bool, SetDrawBorder(bool bDraw));
// COM_API_DECLARE(int, SetBackground(int nMode = OPAQUE, BOOL bRepaint = FALSE));
// COM_API_DECLARE(COLORREF, SetBackgroundColor(COLORREF clr = RGB(255, 255, 255), BOOL bRepaint = FALSE));
// COM_API_DECLARE(IMenu*, SetMenu(IMenu* pMenu));
// COM_API_DECLARE(IMenu*, GetMenu(void));
// COM_API_DECLARE(ICtrl*, SetFocusCtrl(void));
// COM_API_DECLARE(ACTION, SetActions(LPACTION pActs));
// COM_API_DECLARE(ACTION, GetAction(void));
// COM_API_DECLARE(bool, SetAcceptFiles(bool bAccept));
// COM_API_DECLARE(bool, GetAcceptFiles(void));
// COM_API_DECLARE(void, MoveCtrl(const RECT& rect, BOOL bRepaint = FALSE));
// COM_API_DECLARE(void, Offest(int dx, int dy, BOOL bRepaint = FALSE));
// COM_API_DECLARE(bool, SetVisible(bool bVisible));
// COM_API_DECLARE(bool, EnableCtrl(bool bEnabled));
// COM_API_DECLARE(float, SetTransparency(float fTransp, bool bRedraw = false));
//};
//__declspec(novtable) struct IScrollBar : public ICtrl
//{
// COM_API_DECLARE(void, SetRange(int nMax, int nMin = 0));
// COM_API_DECLARE(void, SetPos(int pos = 0));
//};
//__declspec(novtable) struct IImage : public ICtrl
//{
// COM_API_DECLARE(IMGSRC, SetImageSource(IMGSRC imgSrc));
// COM_API_DECLARE(IMGSRC, SetImageSource(COLORREF clr));
// COM_API_DECLARE(IMGSRC, SetImageSource(HBITMAP hBmp, PasteMethod nPasteMethod, DWORD dwRop = SRCCOPY));
// COM_API_DECLARE(IMGSRC, SetImageSource(HICON hIcon, PasteMethod nPasteMethod, DWORD dwRop = SRCCOPY));
// COM_API_DECLARE(IMGSRC, GetImageSource(void));
//};
//__declspec(novtable) struct IText : public ICtrl
//{
// COM_API_DECLARE(int, GetText(TCHAR* pBuf, size_t size));
// COM_API_DECLARE(void, SetText(const TCHAR* pText, TCHAR* pOld = NULL, size_t size = 0));
// COM_API_DECLARE(COLORREF, SetTextColor(COLORREF clr));
// COM_API_DECLARE(COLORREF, GetTextColor(void));
// COM_API_DECLARE(HFONT, SetFont(HFONT hFont, bool bDueFree = true));
// COM_API_DECLARE(HFONT, GetFont(void));
//};
//__declspec(novtable) struct IEdit : public IText
//{
// COM_API_DECLARE(int, Copy(void)); // return how many chars have been copied to clipboard
// COM_API_DECLARE(int, Cut(void)); // return how many chars have been copied to clipboard
// COM_API_DECLARE(int, Paste(void)); // return how many chars have been pasted from clipboard
// COM_API_DECLARE(void, Clear(void));
// COM_API_DECLARE(bool, SetReadOnly(BOOL bReadOnly)); // return previous value
// COM_API_DECLARE(bool, SetMultiLine(bool bEnable));
// COM_API_DECLARE(void, SetSel(int nBegin, int nEnd = -1));
// COM_API_DECLARE(bool, SetPassword(BOOL bPassword));
// COM_API_DECLARE(bool, Undo(void));
// COM_API_DECLARE(void, SetOnTextChanging(Action fn, void* param)); // fn(this, LPTEXTCHANGE, param)
//};
//__declspec(novtable) struct IComboBox : public ICtrl
//{
// COM_API_DECLARE(int, GetCurSel(void));
// COM_API_DECLARE(int, SetCurSel(int nIndex));
// COM_API_DECLARE(int, GetItemCount(void));
// COM_API_DECLARE(bool, GetItemText(int nItem, TCHAR* pBuf, int size));
// COM_API_DECLARE(bool, GetItemColor(int nItem, COLORREF* pClr));
// COM_API_DECLARE(int, InsertItem(const TCHAR* pText, int nIndex = -1));
// COM_API_DECLARE(int, InsertItem(HBITMAP hBmp, int nIndex = -1));
// COM_API_DECLARE(int, InsertItem(COLORREF clr, int nIndex = -1));
// COM_API_DECLARE(int, DeleteItem(int nIndex));
// COM_API_DECLARE(int, Find(const TCHAR* pText, int nFindFrom = 0));
// COM_API_DECLARE(int, Find(COLORREF clr, int nFindFrom = 0));
// COM_API_DECLARE(int, Find(HBITMAP hBmp, int nFindFrom = 0));
// COM_API_DECLARE(DWORD_PTR, SetItemData(int index, DWORD_PTR data));
// COM_API_DECLARE(DWORD_PTR, GetItemData(int index));
// COM_API_DECLARE(void, SetSelChanged(Action fn, void* param));
// COM_API_DECLARE(void, SetDropListSize(int width, int height));
// COM_API_DECLARE(void, ResetContent(void));
//};
// ui controls ends
/////////////////////////////////////////////////////////////////////////////////////
// NOTE: all user defined message should beginning from USER_MSG_BEGINNING !!!
PORT_API(ATOM) register_skin_window(const wchar_t* cls, UINT icon, UINT icon_small, HINSTANCE inst = NULL, DWORD style = CS_HREDRAW | CS_VREDRAW, const wchar_t* cursor = IDC_ARROW);
PORT_API(ISkinWnd*) create_skin_window(ISkinWndSinker* wnd_sinker); // if failed, try calling register_skin_window() first
PORT_API(IMenu*) create_menu(WORD menu_id, IEventHandler* menu_handler);
PORT_API(HFONT) get_font(int height, int weight = FW_NORMAL, bool italy = false, bool underline = false, int char_set = GB2312_CHARSET, const wchar_t* name = L"宋体"); // do NOT free the returned font
PORT_API(int) get_font_height(HFONT font);
PORT_API(void) clear_font(void); // while 'get_font' will store the font for later using, call this function to free these stored fonts
PORT_API(IImage*) load_image_file(const wchar_t* path_file);
PORT_API(void) set_control_schemer(ICtrlScheme* cs);
PORT_API(ICtrlScheme*) get_control_schemer(void);
};