mGNCS API Reference  v1.2.0
A new control set and a new framework for MiniGUI apps
msliderpiece.h
1 /*
2  * This file is part of mGNCS, a component for MiniGUI.
3  *
4  * Copyright (C) 2008~2018, Beijing FMSoft Technologies Co., Ltd.
5  *
6  * This program 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  * This program 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  * Or,
20  *
21  * As this program is a library, any link to this program must follow
22  * GNU General Public License version 3 (GPLv3). If you cannot accept
23  * GPLv3, you need to be licensed from FMSoft.
24  *
25  * If you have got a commercial license of this program, please use it
26  * under the terms and conditions of the commercial license.
27  *
28  * For more information about the commercial license, please refer to
29  * <http://www.minigui.com/en/about/licensing-policy/>.
30  */
31 #if defined (_MGNCSCTRL_SCROLLBAR) || defined (_MGNCSCTRL_TRACKBAR)
32 
33 #ifndef _MGUI_NCSCTRL_SLIDERPIECE_H
34 #define _MGUI_NCSCTRL_SLIDERPIECE_H
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 typedef struct _mSliderPieceClass mSliderPieceClass;
41 typedef struct _mSliderPiece mSliderPiece;
42 
43 #define mSliderPieceClassHeader(clss, superCls) \
44  mContainerPieceClassHeader(clss, superCls) \
45  int (*stepLine)(clss*, BOOL forward); \
46  int (*stepPage)(clss*, BOOL forward);
47 
48 struct _mSliderPieceClass
49 {
50  mSliderPieceClassHeader(mSliderPiece, mContainerPiece)
51 };
52 
53 MGNCS_EXPORT extern mSliderPieceClass g_stmSliderPieceCls;
54 
55 #define mSliderPieceHeader(clss) \
56  mContainerPieceHeader(clss) \
57  mHotPiece * thumb; \
58  unsigned char flags; \
59  unsigned char thumb_state; \
60  unsigned short line_step; \
61  unsigned short page_step; \
62  unsigned short cur_pos; \
63  unsigned short min; \
64  unsigned short max;
65 
66 #define NCSS_SLIDERPIECE_VERT 0x01
67 #define NCSS_SLIDERPIECE_TICK 0x02
68 #define NCSS_SLIDERPIECE_MIN 0x04
69 #define NCSS_SLIDERPIECE_MAX 0x08
70 #define NCSS_SLIDERPIECE_CENTERTHUMB 0x10 //the start point at the center of thumb
71 
72 #define mSliderPiece_setVert(self) (((self)->flags)|= NCSS_SLIDERPIECE_VERT)
73 #define mSliderPiece_setHorz(self) (((self)->flags)&= (~NCSS_SLIDERPIECE_VERT))
74 #define mSliderPiece_isVert(self) ((((self)->flags)&NCSS_SLIDERPIECE_VERT) == NCSS_SLIDERPIECE_VERT)
75 
76 #define mSliderPiece_setTick(self) (((self)->flags)|=NCSS_SLIDERPIECE_TICK)
77 #define mSliderPiece_clearTick(self) (((self)->flags)&=(~NCSS_SLIDERPIECE_TICK))
78 #define mSliderPiece_isTick(self) (((self)->flags)&NCSS_SLIDERPIECE_TICK)
79 
80 #define mSliderPiece_setMin(self) (((self)->flags)|=NCSS_SLIDERPIECE_MIN)
81 #define mSliderPiece_clearMin(self) (((self)->flags)&=(~NCSS_SLIDERPIECE_MIN))
82 #define mSliderPiece_isMin(self) ((self)->flags & NCSS_SLIDERPIECE_MIN)
83 
84 #define mSliderPiece_setMax(self) (((self)->flags)|=NCSS_SLIDERPIECE_MAX)
85 #define mSliderPiece_clearMax(self) (((self)->flags)&=(~NCSS_SLIDERPIECE_MAX))
86 #define mSliderPiece_isMax(self) ((self)->flags & NCSS_SLIDERPIECE_MAX)
87 
88 #define mSliderPiece_setCenterThumb(self) (((self)->flags) |= NCSS_SLIDERPIECE_CENTERTHUMB)
89 #define mSliderPiece_clearCenterThumb(self) (((self)->flags) &= (~NCSS_SLIDERPIECE_CENTERTHUMB))
90 #define mSliderPiece_isCenterThumb(self) ((self)->flags & NCSS_SLIDERPIECE_CENTERTHUMB)
91 
92 struct _mSliderPiece
93 {
94  mSliderPieceHeader(mSliderPiece)
95 };
96 
97 enum mSliderPieceProps{
98  NCSP_SLIDERPIECE_POS = SLIDERPIECE_PROP_BEGIN,
99  NCSP_SLIDERPIECE_LINESTEP ,
100  NCSP_SLIDERPIECE_PAGESTEP ,
101  NCSP_SLIDERPIECE_MAX,
102  NCSP_SLIDERPIECE_MIN,
103  NCSP_SLIDERPIECE_TICK,
104 
105  NCSP_SLIDERPIECE_DIRECTION = PIECECOMM_PROP_DIRECTION
106 };
107 
108 enum mSliderPieceEvent
109 {
110  NCSN_SLIDERPIECE_POSCHANGED = SLIDERPIECE_EVENT_BEGIN,
111  NCSN_SLIDERPIECE_REACHMAX,
112  NCSN_SLIDERPIECE_REACHMIN
113 };
114 
115 #ifdef __cplusplus
116 }
117 #endif
118 
119 #endif
120 #endif //_MGNCSCTRL_SCROLLBAR _MGNCSCTRL_TRACKBAR