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_LISTHEADER_H
21 #define MLIB_LISTHEADER_H
22 
23 #include "mWidgetDef.h"
24 #include "mListDef.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #define M_LISTHEADER(p)      ((mListHeader *)(p))
31 #define M_LISTHEADER_ITEM(p) ((mListHeaderItem *)(p))
32 
33 typedef struct _mListHeaderItem
34 {
35 	mListItem i;
36 	char *text;
37 	int width;
38 	uint32_t flags;
39 	intptr_t param;
40 }mListHeaderItem;
41 
42 
43 typedef struct
44 {
45 	mList list;
46 	uint32_t style;
47 	int sortup,scrx,fpress,dragLeft;
48 	mListHeaderItem *dragitem,*sortitem;
49 }mListHeaderData;
50 
51 typedef struct _mListHeader
52 {
53 	mWidget wg;
54 	mListHeaderData lh;
55 }mListHeader;
56 
57 
58 enum MLISTHEADER_STYLE
59 {
60 	MLISTHEADER_STYLE_SORT = 1<<0
61 };
62 
63 enum MLISTHEADER_NOTIFY
64 {
65 	MLISTHEADER_N_CHANGE_WIDTH,
66 	MLISTHEADER_N_CHANGE_SORT
67 };
68 
69 enum MLISTHEADER_ITEM_FLAGS
70 {
71 	MLISTHEADER_ITEM_F_RIGHT  = 1<<0,
72 	MLISTHEADER_ITEM_F_FIX    = 1<<1,
73 	MLISTHEADER_ITEM_F_EXPAND = 1<<2
74 };
75 
76 
77 void mListHeaderDestroyHandle(mWidget *p);
78 void mListHeaderCalcHintHandle(mWidget *p);
79 int mListHeaderEventHandle(mWidget *wg,mEvent *ev);
80 
81 mListHeader *mListHeaderNew(int size,mWidget *parent,uint32_t style);
82 
83 mListHeaderItem *mListHeaderGetTopItem(mListHeader *p);
84 void mListHeaderAddItem(mListHeader *p,const char *text,int width,uint32_t flags,intptr_t param);
85 int mListHeaderGetFullWidth(mListHeader *p);
86 void mListHeaderSetScrollPos(mListHeader *p,int scrx);
87 void mListHeaderSetSortParam(mListHeader *p,int index,mBool up);
88 
89 #ifdef __cplusplus
90 }
91 #endif
92 
93 #endif
94