mGNCS API Reference  v1.5.0
A new control set and a new framework for MiniGUI apps
msliderpiece.h
1 //
3 // IMPORTANT NOTICE
4 //
5 // The following open source license statement does not apply to any
6 // entity in the Exception List published by FMSoft.
7 //
8 // For more information, please visit:
9 //
10 // https://www.fmsoft.cn/exception-list
11 //
13 /*
14  * This file is part of mGNCS, a component for MiniGUI.
15  *
16  * Copyright (C) 2008~2018, Beijing FMSoft Technologies Co., Ltd.
17  *
18  * This program is free software: you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation, either version 3 of the License, or
21  * (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program. If not, see <http://www.gnu.org/licenses/>.
30  *
31  * Or,
32  *
33  * As this program is a library, any link to this program must follow
34  * GNU General Public License version 3 (GPLv3). If you cannot accept
35  * GPLv3, you need to be licensed from FMSoft.
36  *
37  * If you have got a commercial license of this program, please use it
38  * under the terms and conditions of the commercial license.
39  *
40  * For more information about the commercial license, please refer to
41  * <http://www.minigui.com/blog/minigui-licensing-policy/>.
42  */
43 #if defined (_MGNCSCTRL_SCROLLBAR) || defined (_MGNCSCTRL_TRACKBAR)
44 
45 #ifndef _MGUI_NCSCTRL_SLIDERPIECE_H
46 #define _MGUI_NCSCTRL_SLIDERPIECE_H
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 typedef struct _mSliderPieceClass mSliderPieceClass;
53 typedef struct _mSliderPiece mSliderPiece;
54 
55 #define mSliderPieceClassHeader(clss, superCls) \
56  mContainerPieceClassHeader(clss, superCls) \
57  int (*stepLine)(clss*, BOOL forward); \
58  int (*stepPage)(clss*, BOOL forward);
59 
60 struct _mSliderPieceClass
61 {
62  mSliderPieceClassHeader(mSliderPiece, mContainerPiece)
63 };
64 
65 MGNCS_EXPORT extern mSliderPieceClass g_stmSliderPieceCls;
66 
67 #define mSliderPieceHeader(clss) \
68  mContainerPieceHeader(clss) \
69  mHotPiece * thumb; \
70  unsigned char flags; \
71  unsigned char thumb_state; \
72  unsigned short line_step; \
73  unsigned short page_step; \
74  unsigned short cur_pos; \
75  unsigned short min; \
76  unsigned short max;
77 
78 #define NCSS_SLIDERPIECE_VERT 0x01
79 #define NCSS_SLIDERPIECE_TICK 0x02
80 #define NCSS_SLIDERPIECE_MIN 0x04
81 #define NCSS_SLIDERPIECE_MAX 0x08
82 #define NCSS_SLIDERPIECE_CENTERTHUMB 0x10 //the start point at the center of thumb
83 
84 #define mSliderPiece_setVert(self) (((self)->flags)|= NCSS_SLIDERPIECE_VERT)
85 #define mSliderPiece_setHorz(self) (((self)->flags)&= (~NCSS_SLIDERPIECE_VERT))
86 #define mSliderPiece_isVert(self) ((((self)->flags)&NCSS_SLIDERPIECE_VERT) == NCSS_SLIDERPIECE_VERT)
87 
88 #define mSliderPiece_setTick(self) (((self)->flags)|=NCSS_SLIDERPIECE_TICK)
89 #define mSliderPiece_clearTick(self) (((self)->flags)&=(~NCSS_SLIDERPIECE_TICK))
90 #define mSliderPiece_isTick(self) (((self)->flags)&NCSS_SLIDERPIECE_TICK)
91 
92 #define mSliderPiece_setMin(self) (((self)->flags)|=NCSS_SLIDERPIECE_MIN)
93 #define mSliderPiece_clearMin(self) (((self)->flags)&=(~NCSS_SLIDERPIECE_MIN))
94 #define mSliderPiece_isMin(self) ((self)->flags & NCSS_SLIDERPIECE_MIN)
95 
96 #define mSliderPiece_setMax(self) (((self)->flags)|=NCSS_SLIDERPIECE_MAX)
97 #define mSliderPiece_clearMax(self) (((self)->flags)&=(~NCSS_SLIDERPIECE_MAX))
98 #define mSliderPiece_isMax(self) ((self)->flags & NCSS_SLIDERPIECE_MAX)
99 
100 #define mSliderPiece_setCenterThumb(self) (((self)->flags) |= NCSS_SLIDERPIECE_CENTERTHUMB)
101 #define mSliderPiece_clearCenterThumb(self) (((self)->flags) &= (~NCSS_SLIDERPIECE_CENTERTHUMB))
102 #define mSliderPiece_isCenterThumb(self) ((self)->flags & NCSS_SLIDERPIECE_CENTERTHUMB)
103 
104 struct _mSliderPiece
105 {
106  mSliderPieceHeader(mSliderPiece)
107 };
108 
109 enum mSliderPieceProps{
110  NCSP_SLIDERPIECE_POS = SLIDERPIECE_PROP_BEGIN,
111  NCSP_SLIDERPIECE_LINESTEP ,
112  NCSP_SLIDERPIECE_PAGESTEP ,
113  NCSP_SLIDERPIECE_MAX,
114  NCSP_SLIDERPIECE_MIN,
115  NCSP_SLIDERPIECE_TICK,
116 
117  NCSP_SLIDERPIECE_DIRECTION = PIECECOMM_PROP_DIRECTION
118 };
119 
120 enum mSliderPieceEvent
121 {
122  NCSN_SLIDERPIECE_POSCHANGED = SLIDERPIECE_EVENT_BEGIN,
123  NCSN_SLIDERPIECE_REACHMAX,
124  NCSN_SLIDERPIECE_REACHMIN
125 };
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
131 #endif
132 #endif //_MGNCSCTRL_SCROLLBAR _MGNCSCTRL_TRACKBAR