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_FILELISTVIEW_H
21 #define MLIB_FILELISTVIEW_H
22 
23 #include "mListView.h"
24 #include "mStrDef.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #define M_FILELISTVIEW(p)  ((mFileListView *)(p))
31 
32 typedef struct
33 {
34 	uint32_t style;
35 	mStr strDir,
36 		strFilter;
37 	uint8_t sort_type,sort_up;
38 }mFileListViewData;
39 
40 typedef struct _mFileListView
41 {
42 	mWidget wg;
43 	mScrollViewData sv;
44 	mListViewData lv;
45 	mFileListViewData flv;
46 }mFileListView;
47 
48 enum MFILELISTVIEW_STYLE
49 {
50 	MFILELISTVIEW_S_MULTI_SEL = 1<<0,
51 	MFILELISTVIEW_S_ONLY_DIR  = 1<<1,
52 	MFILELISTVIEW_S_SHOW_HIDDEN_FILES = 1<<2
53 };
54 
55 enum MFILELISTVIEW_NOTIFY
56 {
57 	MFILELISTVIEW_N_SELECT_FILE,
58 	MFILELISTVIEW_N_DBLCLK_FILE,
59 	MFILELISTVIEW_N_CHANGE_DIR
60 };
61 
62 enum MFILELISTVIEW_FILETYPE
63 {
64 	MFILELISTVIEW_FILETYPE_NONE,
65 	MFILELISTVIEW_FILETYPE_FILE,
66 	MFILELISTVIEW_FILETYPE_DIR
67 };
68 
69 
70 void mFileListViewDestroyHandle(mWidget *p);
71 int mFileListViewEventHandle(mWidget *wg,mEvent *ev);
72 
73 mFileListView *mFileListViewNew(int size,mWidget *parent,uint32_t style);
74 
75 void mFileListViewSetDirectory(mFileListView *p,const char *path);
76 void mFileListViewSetFilter(mFileListView *p,const char *filter);
77 void mFileListViewSetShowHiddenFiles(mFileListView *p,int type);
78 void mFileListViewSetSortType(mFileListView *p,int type,mBool up);
79 
80 void mFileListViewUpdateList(mFileListView *p);
81 void mFileListViewMoveDir_parent(mFileListView *p);
82 
83 int mFileListViewGetSelectFileName(mFileListView *p,mStr *str,mBool bFullPath);
84 int mFileListViewGetSelectMultiName(mFileListView *p,mStr *str);
85 
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 #endif
91