acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
file_dialog.h
1// Created by camilo on 2023-02-21 04:00 BRT <3ThomasBorregaardSorensen!!
2#pragma once
3
4
5#include "acme/filesystem/filesystem/dialog_base.h"
6
7
8namespace file
9{
10
11
12 class CLASS_DECL_ACME file_dialog_filter_item
13 {
14
15 public:
16
17 ::string m_strName;
18 ::string m_strPatternList;
19
20
21 ::string get_main_extension() const;
22 ::string_array_base get_preserve_extensions() const;
23
24 };
25
26 class CLASS_DECL_ACME file_dialog_filter :
27 public ::array < file_dialog_filter_item >
28 {
29
30 public:
31
32 using ::array < file_dialog_filter_item >::array;
33
34 ::collection::index find_first_with_extension(const ::scoped_string & scopedstrExtension);
35 ::string_array_base get_all_related_extensions() const;
36 ::string_array_base get_pattern_list() const;
37
38 };
39
40
41 //CLASS_DECL_ACME string_array_base get_pattern_list(const file_dialog_filter & filedialogfiltera);
42
43
44 class CLASS_DECL_ACME file_dialog :
45 virtual public ::file::dialog_base
46 {
47 public:
48
49
50 //void * m_poswindow;
51 // void * m_posdata;
52 // ::pointer < ::user::element> m_puserelement;
53 // file_dialog_filter m_filedialogfilter;
54 // ::function < void(::pointer<file_dialog>) > m_function;
55 // ::file::path m_pathStartFolder;
56 // ::particle_array m_particleaHold;
57 // ::file::path_array_base m_patha;
58
59
60 file_dialog_filter m_filedialogfilter;
61 ::function < void(::pointer<file_dialog>) > m_procedureResponse;
62
63
64 bool m_bMultiple;
65 bool m_bSave;
66 ::collection::index m_iFilter;
67
68
69
70 file_dialog();
71 ~file_dialog() override;
72
73// void start()
74// {
75//
76// node()->operating_system_file_dialog(this);
77//
78// }
79
80 void pick_single_file(
81 ::user::element * puserelement,
82 const file_dialog_filter& filedialogfiltera,
83 const ::function < void(::pointer<file_dialog>) >& function,
84 bool save,
85 const ::file::path & pathStartFolder = {});
86
87
88 void pick_multiple_file(
89 ::user::element * puserelement,
90 const file_dialog_filter & filedialogfiltera,
91 const ::function < void(::pointer<file_dialog>) >& function,
92 const ::file::path & pathStartFolder = {});
93
94 // void pick_single_file(
95 //::user::element * pelement
97 // // void * poswindow,
98 // // void * posdata,
99 // const ::array < ::pair < ::string, ::string > > & filetypes,
100 // const ::function < void(::pointer<operating_system_file_dialog>) > & function,
101 // const ::file::path & pathStartDir,
102 // bool bSave,
103 // bool bMultiple) :
104 // m_poswindow(poswindow),
105 // m_posdata(posdata),
106 // m_filetypes(filetypes),
107 // m_function(function),
108 // m_pathStartDir(pathStartDir),
109 // m_bSave(bSave),
110 // m_bMultiple(bMultiple)
111 // {
112 // initialize(pparticle);
113 // }
114
115 ::file::path _get_file_path() const;
116
117 ::file::path get_file_path() const;
118
119 ::file::path process_file_path(const ::file::path & path) const;
120
121 const ::file::file_dialog_filter_item * get_selected_filter() const;
122
123 ::string get_selected_filter_main_extension() const;
124
125 //void do_callback();
126
127 void on_dialog_response() override;
128
129 };
130
131
132 inline void path::defer_set_extension(const ::file::file_dialog* pdialog)
133 {
134
135 if (::is_null(pdialog))
136 {
137
138 return;
139
140 }
141
142 auto pfilteritem = pdialog->get_selected_filter();
143
144 if (::is_null(pfilteritem))
145 {
146
147 return;
148
149 }
150
151 return defer_set_extension(
152 pfilteritem->get_preserve_extensions(),
153 pdialog->m_filedialogfilter.get_all_related_extensions());
154
155 }
156
157
158
159} // namespace file
160
161
162
Definition dialog_base.h:13
Definition file_dialog.h:13
Definition file_dialog.h:28
Definition path.h:52
Definition _template_forward_declaration.h:297
Definition filesystem.h:16