mGNCS4Touch API Reference  v1.5.0
A set of mGNCS-compliant controls for devices with a touch screen.
mtableviewpiece.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  * \file
15  * \author FMSoft
16  * \date
17  *
18  \verbatim
19 
20  This file is part of mGNCS4Touch, one of MiniGUI components.
21 
22  Copyright (C) 2008-2018 FMSoft (http://www.fmsoft.cn).
23 
24  This program is free software: you can redistribute it and/or modify
25  it under the terms of the GNU General Public License as published by
26  the Free Software Foundation, either version 3 of the License, or
27  (at your option) any later version.
28 
29  This program is distributed in the hope that it will be useful,
30  but WITHOUT ANY WARRANTY; without even the implied warranty of
31  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32  GNU General Public License for more details.
33 
34  You should have received a copy of the GNU General Public License
35  along with this program. If not, see <http://www.gnu.org/licenses/>.
36 
37  Or,
38 
39  As this program is a library, any link to this program must follow
40  GNU General Public License version 3 (GPLv3). If you cannot accept
41  GPLv3, you need to be licensed from FMSoft.
42 
43  If you have got a commercial license of this program, please use it
44  under the terms and conditions of the commercial license.
45 
46  For more information about the commercial license, please refer to
47  <http://www.minigui.com/blog/minigui-licensing-policy/>.
48 
49  \endverbatim
50 */
51 
52 #ifndef _MGNCS_TABLEVIEWPIECE_H
53 #define _MGNCS_TABLEVIEWPIECE_H
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif /* __cplusplus */
58 
59 typedef struct _mTableViewPiece mTableViewPiece;
60 typedef struct _mTableViewPieceClass mTableViewPieceClass;
61 
62 typedef struct _mIndexPath{
63  int section;
64  int row;
65 }mIndexPath;
66 
67 
68 typedef enum _TableViewAnimType {
69  NCS_TABLEVIEW_ANIMATIONNONE = 0,
70  NCS_TABLEVIEW_ANIMATIONFADE,
71  NCS_TABLEVIEW_ANIMATIONZOOM,
72  NCS_TABLEVIEW_ANIMATIONLEFT,
73 }TableViewAnimType;
74 
75 enum mTableViewSeparatorStyle{
76  NCS_TABLEVIEW_SEPARATORSTYLE_NONE = 0,
77  NCS_TABLEVIEW_SEPARATORSTYLE_SINGLINE,
78  NCS_TABLEVIEW_SEPARATORSTYLE_MAX,
79 };
80 
81 enum mTableViewPieceState{
82  NCS_TABLEVIEW_NORMAL = 0,
83  NCS_TABLEVIEW_EDIT,
84 };
85 
86 enum mTableViewPieceEvent {
87  NCSN_TABLEVIEW_CONTENTCLICKED= USER_PIECE_EVENT_BEGIN + 0x400,
88 };
89 
90 enum {
91  NCS_TABLEVIEW_GROUP_STYLE = 0,
92  NCS_TABLEVIEW_INDEX_STYLE,
93  NCS_TABLEVIEW_INDEXLOCATE_STYLE, /* 带索引定位条风格*/
94 };
95 
96 enum mTableViewItemPieceType {
97  NCS_TABLEVIEW_NORMALROWTYPE = 0,
98  NCS_TABLEVIEW_SEPARATORTYPE,
99  NCS_TABLEVIEW_SECTIONTYPE,
100  NCS_TABLEVIEW_TITLETYPE,
101 };
102 
103 #define MSG_TABLEVIEWPIECE_STATE_CHANGED (MSG_USER + 100)
104 #define MSG_TABLEVIEWPIECE_DELITEM (MSG_USER + 101)
105 
106 #define NCS_TABLEVIEW_GROUPGAP 30
107 #define NCS_TABLEVIEW_INDEXLOCATE_W 30
108 #define NCS_TABLEVIEW_INDEXLOCATE_Y 0
109 
110 #define NCS_TABLEVIEW_SEPARATOR_DEFAULTCOLOR 0xffced3d6
111 
112 #define mTableViewPieceHeader(clss) \
113  mScrollViewPieceHeader(clss) \
114  mTableViewItemPiece* focusPiece; \
115  int mode;\
116  int style; \
117  POINT indexPos;\
118  mIndexLocatePiece* indexLocate; \
119  mPanelPiece* tablePanel; \
120  DWORD separatorColor;\
121  int rowHeight;\
122  int separatorStyle;
123 
124 struct _mTableViewPiece
125 {
126  mTableViewPieceHeader(mTableViewPiece)
127 };
128 
129 #define mTableViewPieceClassHeader(clss, superCls) \
130  mScrollViewPieceClassHeader(clss, superCls) \
131  void (*changeMode)(clss*); \
132  void (*getDefaultRowRect)(clss* self, RECT* rect); \
133  mPanelPiece* (*createSeparatorLine)(clss* self, BOOL border); \
134  mPanelPiece* (*createDefaultRow)(clss* self, mTableViewItemPiece* item_piece);\
135  void (*reloadData)(clss* self);\
136  mPanelPiece* (*createIndexSectionHead)(clss* self, int section); \
137  mPanelPiece* (*createIndexSectionContent)(clss* self, int section);\
138  mPanelPiece* (*createGroupSectionContent)(clss* self, int section);\
139  mTableViewItemPiece* (*indexPathToItem)(clss* self, const mIndexPath* indexpath);\
140  void (*itemToIndexPath)(clss* self, const mTableViewItemPiece* item, mIndexPath* indexpath);\
141  void (*insertRowAtIndexPath)(clss* self, const mIndexPath* indexpath, TableViewAnimType animtype);\
142  void (*deleteRowAtIndexPath)(clss* self, const mIndexPath* indexpath, TableViewAnimType animtype);\
143  void (*rectForHeaderInSection)(clss* self, int section, RECT* rect); \
144  void (*rectForRowAtIndexPath)(clss* self, const mIndexPath* indexpath, RECT* rect);\
145  void (*rectForSection)(clss* self, int section, RECT* rect);\
146  void (*setSeparatorStyle)(clss* self, enum mTableViewSeparatorStyle);\
147  void (*setSeparatorColor)(clss* self, DWORD color);\
148  /* public interface. */ \
149  BOOL (*willSelectRowAtIndexPath)(clss* self, const mIndexPath* indexpath);\
150  void (*onCommitInsertRowAtIndexPath)(clss* self, const mIndexPath* indexpath); \
151  void (*onCommitDeleteRowAtIndexPath)(clss* self, const mIndexPath* indexpath); \
152  mTableViewItemPiece* (*createItemForRow)(clss* self, const mIndexPath* indexpath);\
153  int (*numberOfSections)(clss* self); \
154  int (*numberOfRowsInSection)(clss* self, int section);\
155  const char* (*titleForSection)(clss* self, int section); \
156  const char* (*indexForSection)(clss* self, int section);\
157  void (*rowDidSelectAtIndexPath)(clss* self, const mIndexPath* indexpath);
158 
159 
160 struct _mTableViewPieceClass
161 {
162  mTableViewPieceClassHeader(mTableViewPiece, mScrollViewPiece)
163 };
164 
165 MGNCS_EXPORT extern mTableViewPieceClass g_stmTableViewPieceCls;
166 
167 #ifdef __cplusplus
168 }
169 #endif /* __cplusplus */
170 
171 #endif /* _MGNCS_TABLEVIEWPIECE_H */