explorer: misc
[ede] / newexplorer / src / ExplorerWindow.ec
1 import "Explorer"
2 import "IconBag"
3 import "ToolBar"
4
5 enum ExplorerToolId
6 {
7    none,
8    newWindow, goBack, goForward, goUp, goHome,
9    browse,
10    panelTree, panelSearch,
11    addressBar,
12    refresh,
13    viewList, viewDetails, viewIcons, viewCards, viewShowcase, viewCustom,
14    previewPictures
15 };
16
17 class ExplorerWindow : Window
18 {
19    text = "Ecere Explorer";
20    background = activeBorder;
21    borderStyle = sizable;
22    hasMaximize = true;
23    hasMinimize = true;
24    hasClose = true;
25    size = { 840, 480 };
26    minClientSize = { 600, 300 };
27    nativeDecorations = true;
28
29    IconBag<ExplorerToolId> iconBag
30    {
31       //window = guiApp.desktop;
32       window = this;
33       alphaBlend = true;
34       iconNames =
35       [
36          "<:ecere>emblems/unreadable.png",     /* none */
37
38          "<:ecere>actions/windowNew.png",            /* newWindow */
39          "<:ecere>actions/goPrevious.png",           /* goBack */
40          "<:ecere>actions/goNext.png",               /* goForward */
41          "<:ecere>actions/goUp.png",                 /* goUp */
42          "<:ecere>actions/goHome.png",               /* goHome */
43
44          ":browse.png",                                           /* browse */
45
46          ":panel-tree.png",                                       /* panelTree */
47          "<:ecere>actions/editFind.png",             /* panelSearch */
48
49          "<:ecere>emblems/unreadable.png",     /* addressBar */
50
51          "<:ecere>actions/viewRefresh.png",          /* refresh */
52
53          ":view-list.png",                                        /* viewList */
54          ":view-details.png",                                     /* viewDetails */
55          ":view-icons.png",                                       /* viewIcons */
56          ":view-cards.png",                                       /* viewCards */
57          ":view-showcase-right.png",                              /* viewShowcase */
58          ":view-custom.png",                                      /* viewCustom */
59          
60          "<:ecere>mimeTypes/image.png"     /* previewPictures */
61       ];
62    };
63
64    Stacker stack
65    {
66       this;
67       gap = 0;
68       direction = vertical;
69       background = activeBorder;
70       //opacity = 1.0f;
71       
72       anchor = { left = 0, top = 0, right = 0, bottom = 0 };
73       //moveable = false;
74    };
75
76    ToolBar/*<ExplorerToolId>*/ toolBar
77    {
78       stack, this;
79       iconBag = iconBag;
80       size = { h = 32 };
81       //moveable = false;
82
83       void NotifyToolClick(ToolButton button)
84       {
85          ExplorerToolId id = (ExplorerToolId)button.id;
86          switch(id)
87          {
88             case none:
89                break;
90             case newWindow:
91                ExplorerWindow { }.Create();
92                break;
93             case goBack:
94             case goForward:
95                break;
96             case goUp:
97             {
98                char * path = view.path;
99                char * newPath = new char[strlen(path)];
100                StripLastDirectory(path, newPath);
101                view.path = newPath;
102                delete newPath;
103                break;
104             }
105             case panelTree:
106                // TODO TOFIX : need to fix Stacker for this to work
107                tree.visible = button.checked;
108                //search.visible = !button.checked;
109                panels.size = { panels.size.w, panels.size.h }; // TOFIX : another Stacker fix needed
110                break;
111             case panelSearch:
112                // TODO TOFIX : need to fix Stacker for this to work
113                //search.visible = button.checked;
114                tree.visible = !button.checked;
115                panels.size = { panels.size.w, panels.size.h }; // TOFIX : another Stacker fix needed
116                break;
117             case refresh:
118                if(tree.visible)
119                   tree.Refresh();
120                view.Refresh();
121                break;
122             case previewPictures:
123                view.previewPictures = button.checked;
124                view.Refresh();
125                break;
126             case viewList:
127             case viewDetails:
128             case viewIcons:
129             case viewCards:
130             case viewShowcase:
131                //SwitchViews(toolId);
132                break;
133          }
134       }
135    };
136
137    Window s1 { toolBar, size = { w = 8 } };
138    ToolButton goBack { toolBar, this, id = ExplorerToolId::goBack };
139    Window s2 { toolBar, size = { w = 2 } };
140    ToolButton goForward { toolBar, this, id = ExplorerToolId::goForward };
141    Window s3 { toolBar, size = { w = 2 } };
142    ToolButton refresh { toolBar, this, id = ExplorerToolId::refresh };
143    Window s4 { toolBar, size = { w = 2 } };
144    ToolButton goHome { toolBar, this, id = ExplorerToolId::goHome };
145    Window s5 { toolBar, size = { w = 8 } };
146    PathBox addressBar
147    {
148       toolBar, this;
149       size = { 300, 23 }, id = ExplorerToolId::addressBar;
150       typeExpected = directory;
151
152       bool OnKeyDown(Key key, unichar ch)
153       {
154          if((SmartKey)key == enter)
155          {
156             // how to make enter effect a modification
157             // how to implement in PathBox
158          }
159          return true;
160       }
161
162       bool NotifyModified(PathBox pathBox)
163       {
164          view.path = pathBox.path;
165          return true;
166       }
167    };
168    FlipStacker { toolBar, spring = previous };
169    Window s6 { toolBar, size = { w = 8 } };
170    ToolButton goUp { toolBar, this, id = ExplorerToolId::goUp };
171    Window s7 { toolBar, size = { w = 8 } };
172    GroupToggleToolButton selectedPanel;
173    GroupToggleToolButton panelTree   { toolBar, this, id = ExplorerToolId::panelTree, selected = &selectedPanel, checked = true };
174    GroupToggleToolButton panelSearch { toolBar, this, id = ExplorerToolId::panelSearch, selected = &selectedPanel };
175    selectedPanel = panelTree;
176    Window s8 { toolBar, size = { w = 8 } };
177    OptionToolButton selectedView;
178    OptionToolButton viewList     { toolBar, this, id = ExplorerToolId::viewList, selected = &selectedView, checked = true };
179    OptionToolButton viewDetails  { toolBar, this, id = ExplorerToolId::viewDetails, selected = &selectedView };
180    OptionToolButton viewIcons    { toolBar, this, id = ExplorerToolId::viewIcons, selected = &selectedView };
181    OptionToolButton viewTiles    { toolBar, this, id = ExplorerToolId::viewCards, selected = &selectedView };
182    OptionToolButton viewShowcase { toolBar, this, id = ExplorerToolId::viewShowcase, selected = &selectedView };
183    selectedView = viewList;
184    Window s9 { toolBar, size = { w = 8 } };
185    ToggleToolButton previewPictures { toolBar, this, id = ExplorerToolId::previewPictures };
186
187    Window s10 { toolBar, size = { w = 8 } };
188    ToolButton newWindow { toolBar, this, id = ExplorerToolId::newWindow };
189    Window s11 { toolBar, size = { w = 8 } };
190
191    /*void OnDestroy()
192    {
193       iconBag.window = null;
194       delete iconBag;
195    }*/
196
197    bool OnLoadGraphics()
198    {
199       iconBag.Load();
200       return true;
201    }
202
203    void OnUnloadGraphics()
204    {
205       iconBag.Unload();
206    }
207
208    Stacker panels
209    {
210       stack, this;
211       gap = 0;
212       direction = horizontal;
213       background = yellow;//activeBorder;
214       //opacity = 1.0f;
215
216       anchor.left = 0;
217       anchor.bottom = 0;
218       anchor.right = 0;
219    };
220
221    //FlipStacker flipStack { stack, spring = previous };
222
223    /*SearchPanel searchPanel
224    {
225       panels, this;
226    };*/
227
228    /*Tree*/FileSystemBox tree
229    {
230       panels, this;
231       size = { w = 240 };
232       anchor.top = 0;
233       anchor.bottom = 0;
234       navigateFolders = true;
235       treeBranches = true;
236       foldersOnly = true;
237       borderStyle = none;
238       visible = false;
239    };
240
241    FileSystemBox view
242    {
243       panels, this;
244       anchor.top = 0;
245       anchor.bottom = 0;
246       anchor.right = 0;
247       locationBox = addressBar;
248       navigateFolders = true;
249       borderStyle = none;
250    };
251
252    // Preview / Showcase
253    /*PreviewArea previewArea
254    {
255       panels, this;
256    };*/
257
258    //FlipStacker flipPanels { panels, spring = previous };
259
260    bool OnPostCreate()
261    {
262       addressBar.path = view.path;
263       return true;
264    }
265 }
266
267 //class TreeFileSystemBox : FileSystemBox { }