DISTRHO Plugin Framework
 All Classes Functions Variables Modules Pages
Window.hpp
1 /*
2  * DISTRHO Plugin Framework (DPF)
3  * Copyright (C) 2012-2014 Filipe Coelho <falktx@falktx.com>
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any purpose with
6  * or without fee is hereby granted, provided that the above copyright notice and this
7  * permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
10  * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
11  * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
13  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #ifndef DGL_WINDOW_HPP_INCLUDED
18 #define DGL_WINDOW_HPP_INCLUDED
19 
20 #include "Geometry.hpp"
21 
22 START_NAMESPACE_DGL
23 
24 // -----------------------------------------------------------------------
25 
26 class App;
27 class Widget;
28 class StandaloneWindow;
29 
30 class Window
31 {
32 public:
33  /**
34  File browser options.
35  */
37  const char* startDir;
38  const char* title;
39  uint width;
40  uint height;
41 
42  /**
43  File browser buttons.
44 
45  0 means hidden.
46  1 means visible and unchecked.
47  2 means visible and checked.
48  */
49  struct Buttons {
50  uint listAllFiles;
51  uint showHidden;
52  uint showPlaces;
53 
54  /** Constuctor for default values */
56  : listAllFiles(2),
57  showHidden(1),
58  showPlaces(1) {}
59  } buttons;
60 
61  /** Constuctor for default values */
63  : startDir(nullptr),
64  title(nullptr),
65  width(0),
66  height(0),
67  buttons() {}
68  };
69 
70  explicit Window(App& app);
71  explicit Window(App& app, Window& parent);
72  explicit Window(App& app, intptr_t parentId);
73  virtual ~Window();
74 
75  void show();
76  void hide();
77  void close();
78  void exec(bool lockWait = false);
79 
80  void focus();
81  void repaint() noexcept;
82 
83  bool openFileBrowser(const FileBrowserOptions& options);
84 
85  bool isVisible() const noexcept;
86  void setVisible(bool yesNo);
87 
88  bool isResizable() const noexcept;
89  void setResizable(bool yesNo);
90 
91  uint getWidth() const noexcept;
92  uint getHeight() const noexcept;
93  Size<uint> getSize() const noexcept;
94  void setSize(uint width, uint height);
95  void setSize(Size<uint> size);
96 
97  const char* getTitle() const noexcept;
98  void setTitle(const char* title);
99 
100  void setTransientWinId(uintptr_t winId);
101 
102  App& getApp() const noexcept;
103  intptr_t getWindowId() const noexcept;
104 
105  void addIdleCallback(IdleCallback* const callback);
106  void removeIdleCallback(IdleCallback* const callback);
107 
108 protected:
109  virtual void onDisplayBefore();
110  virtual void onDisplayAfter();
111  virtual void onReshape(uint width, uint height);
112  virtual void onClose();
113 
114  virtual void fileBrowserSelected(const char* filename);
115 
116 private:
117  struct PrivateData;
118  PrivateData* const pData;
119  friend class App;
120  friend class Widget;
121  friend class StandaloneWindow;
122 
123  virtual void _addWidget(Widget* const widget);
124  virtual void _removeWidget(Widget* const widget);
125  void _idle();
126 
127  DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Window)
128 };
129 
130 // -----------------------------------------------------------------------
131 
132 END_NAMESPACE_DGL
133 
134 #endif // DGL_WINDOW_HPP_INCLUDED
FileBrowserOptions()
Definition: Window.hpp:62
Definition: Window.hpp:30
Buttons()
Definition: Window.hpp:55
Definition: StandaloneWindow.hpp:28
Definition: Geometry.hpp:132
Definition: Window.hpp:36
Definition: Base.hpp:176
Definition: Window.hpp:49
Definition: Widget.hpp:51
Definition: App.hpp:41