451ed7d24eabc2600ad511560f491256efa464d5
[sdk] / documentor / src / SettingsDialog.ec
1 import "ecere"
2 import "Documentor"
3
4 class SettingsDialog : Window
5 {
6    text = $"Settings";
7    background = activeBorder;
8    borderStyle = fixed;
9    hasMaximize = true;
10    hasMinimize = true;
11    hasClose = true;
12    tabCycle = true;
13    size = { 436, 120 };
14    anchor = { horz = -83, vert = -104 };
15    
16    Label docLabel { this, text = $"Documentation Path:", anchor = { left = 16, top = 16 }, labeledWindow = pathEditBox };
17
18    Button browseBtn 
19    { 
20       this, text = "...", font = { "Tahoma", 8.25f, bold = true }, hotKey = f2;
21       anchor = { right = 20, top = 16 };
22       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
23       {
24          if(settingsFileDialog.Modal() == ok) // open the file dialog box, and wait for confirmation that all is okay.
25          {
26             pathEditBox.contents = settingsFileDialog.filePath; // display the selected directory in the edit box
27          }
28          return true;
29       }     
30    };
31
32    FileDialog settingsFileDialog
33    {
34       type = selectDir, text = $"Select a path"; // set the file dialog box to choose a directory instead of a file.
35    };
36
37    Button saveBtn 
38    { 
39       this, text = $"Save", size = { 68, 21 }, position = { 224, 56 }, isDefault = true;
40
41       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
42       {
43          delete settings.docDir;
44          settings.docDir = CopyString(pathEditBox.contents); // Store the path entered into the edit box
45          settingsContainer.Save(); // write that path to the ini file
46          Destroy(0); // close the window
47          return true;
48       }  
49    };
50
51    Button cancelBtn 
52    { 
53       this, text = $"Cancel", size = { 68, 21 }, position = { 304, 56 }, hotKey = escape;
54
55       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
56       {
57          Destroy(0); // close the window without making any changes
58          return true;
59       }
60    };
61    EditBox pathEditBox { this, size = { 214, 19 }, contents = settings.docDir, anchor = { right = 41, top = 16 } };
62 }