58 lines
1.5 KiB
C
58 lines
1.5 KiB
C
#ifndef MYWIN_SCROLLBAR_H__
|
|
#define MYWIN_SCROLLBAR_H__
|
|
|
|
#define SCROLLBAR_ITEM_MAXLEN 20
|
|
|
|
// 定义按键按下的消息
|
|
#define SCROLLBAR_PRESSED 0x00000001
|
|
|
|
typedef struct {
|
|
char *pic_path;
|
|
char txt[SCROLLBAR_ITEM_MAXLEN];
|
|
} Scrollbar_ItemStruct;
|
|
|
|
typedef struct {
|
|
WIN_WindowStruct win;
|
|
int index;
|
|
Scrollbar_ItemStruct *items;
|
|
int itemMaxNum;
|
|
int itemNum;
|
|
int y_step;
|
|
int y_offset;
|
|
uint32_t color_light;
|
|
uint32_t color_dark;
|
|
|
|
int x_inertia; // x方向的惯性
|
|
int y_inertia; // y方向的惯性
|
|
int num_inertia; // 惯性数目
|
|
int timer_inertia; // 惯性定时器
|
|
} WIN_ScrollbarStruct;
|
|
|
|
WIN_ScrollbarStruct *WIN_CreatScrollbar(
|
|
WIN_WindowStruct *base,
|
|
void (*msgLoop)(struct _WIN_WindowStruct *win, WIN_MsgStruct *msg), int x,
|
|
int y, int x_size, int y_size);
|
|
|
|
// 设置条目数
|
|
void SCROLLBAR_SetItemNum(WIN_ScrollbarStruct *bar, int itemNum);
|
|
|
|
// 添加条目
|
|
void SCROLLBAR_AddItem(WIN_ScrollbarStruct *bar, char *item, char *pic_path);
|
|
|
|
// 默认绘制函数
|
|
void SCROLLBAR_DefaultPaint(WIN_ScrollbarStruct *bar);
|
|
|
|
// 默认消息处理函数
|
|
void SCROLLBAR_DefaultMsgLoop(WIN_ScrollbarStruct *bar, WIN_MsgStruct *msg);
|
|
|
|
// 在指定位置弹出菜单
|
|
WIN_ScrollbarStruct *SCROLLBAR_SelectItem(WIN_WindowStruct *base, char **item,
|
|
int itemNum, int x, int y, int x_size,
|
|
int y_size);
|
|
|
|
WIN_ScrollbarStruct *SCROLLBAR_SelectNum(WIN_WindowStruct *base, int min,
|
|
int max, int x, int y, int x_size,
|
|
int y_size);
|
|
|
|
#endif
|