1 /*$
2  Copyright (C) 2013-2020 Azel.
3 
4  This file is part of AzPainter.
5 
6  AzPainter is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  AzPainter is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 $*/
19 
20 #ifndef MLIB_SCROLLBAR_H
21 #define MLIB_SCROLLBAR_H
22 
23 #include "mWidgetDef.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #define M_SCROLLBAR(p)  ((mScrollBar *)(p))
30 
31 typedef struct _mScrollBar mScrollBar;
32 
33 typedef struct
34 {
35 	uint32_t style;
36 	int min,max,page,pos,
37 		range,fpress,dragDiff;
38 	void (*handle)(mScrollBar *,int,int);
39 }mScrollBarData;
40 
41 struct _mScrollBar
42 {
43 	mWidget wg;
44 	mScrollBarData sb;
45 };
46 
47 
48 enum MSCROLLBAR_STYLE
49 {
50 	MSCROLLBAR_S_HORZ = 0,
51 	MSCROLLBAR_S_VERT = 1<<0
52 };
53 
54 enum MSCROLLBAR_NOTIFY
55 {
56 	MSCROLLBAR_N_HANDLE
57 };
58 
59 enum MSCROLLBAR_NOTIFY_HANDLE_FLAGS
60 {
61 	MSCROLLBAR_N_HANDLE_F_CHANGE  = 1<<0,
62 	MSCROLLBAR_N_HANDLE_F_PRESS   = 1<<1,
63 	MSCROLLBAR_N_HANDLE_F_MOTION  = 1<<2,
64 	MSCROLLBAR_N_HANDLE_F_RELEASE = 1<<3,
65 	MSCROLLBAR_N_HANDLE_F_PAGE    = 1<<4
66 };
67 
68 
69 #define MSCROLLBAR_WIDTH  15
70 
71 
72 void mScrollBarDrawHandle(mWidget *p,mPixbuf *pixbuf);
73 int mScrollBarEventHandle(mWidget *wg,mEvent *ev);
74 
75 mScrollBar *mScrollBarNew(int size,mWidget *parent,uint32_t style);
76 
77 mBool mScrollBarIsTopPos(mScrollBar *p);
78 mBool mScrollBarIsBottomPos(mScrollBar *p);
79 int mScrollBarGetPos(mScrollBar *p);
80 void mScrollBarSetStatus(mScrollBar *p,int min,int max,int page);
81 void mScrollBarSetPage(mScrollBar *p,int page);
82 mBool mScrollBarSetPos(mScrollBar *p,int pos);
83 mBool mScrollBarSetPosToEnd(mScrollBar *p);
84 mBool mScrollBarMovePos(mScrollBar *p,int dir);
85 
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 #endif
91