openshot-audio  0.1.2
juce_ComponentPeer.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_COMPONENTPEER_H_INCLUDED
26 #define JUCE_COMPONENTPEER_H_INCLUDED
27 
28 
29 //==============================================================================
42 {
43 public:
44  //==============================================================================
47  {
48  windowAppearsOnTaskbar = (1 << 0),
50  windowIsTemporary = (1 << 1),
52  windowIgnoresMouseClicks = (1 << 2),
54  windowHasTitleBar = (1 << 3),
57  windowIsResizable = (1 << 4),
58  windowHasMinimiseButton = (1 << 5),
60  windowHasMaximiseButton = (1 << 6),
62  windowHasCloseButton = (1 << 7),
64  windowHasDropShadow = (1 << 8),
66  windowRepaintedExplictly = (1 << 9),
69  windowIgnoresKeyPresses = (1 << 10),
72  windowIsSemiTransparent = (1 << 31)
74  };
75 
76  //==============================================================================
82  ComponentPeer (Component& component, int styleFlags);
83 
85  virtual ~ComponentPeer();
86 
87  //==============================================================================
89  Component& getComponent() noexcept { return component; }
90 
94  int getStyleFlags() const noexcept { return styleFlags; }
95 
99  uint32 getUniqueID() const noexcept { return uniqueID; }
100 
101  //==============================================================================
107  virtual void* getNativeHandle() const = 0;
108 
110  virtual void setVisible (bool shouldBeVisible) = 0;
111 
113  virtual void setTitle (const String& title) = 0;
114 
121  virtual bool setDocumentEditedStatus (bool edited);
122 
128  virtual void setRepresentedFile (const File&);
129 
130  //==============================================================================
138  virtual void setBounds (const Rectangle<int>& newBounds, bool isNowFullScreen) = 0;
139 
141  void updateBounds();
142 
148  virtual Rectangle<int> getBounds() const = 0;
149 
151  virtual Point<float> localToGlobal (Point<float> relativePosition) = 0;
152 
154  virtual Point<float> globalToLocal (Point<float> screenPosition) = 0;
155 
157  Point<int> localToGlobal (Point<int> relativePosition);
158 
160  Point<int> globalToLocal (Point<int> screenPosition);
161 
163  virtual Rectangle<int> localToGlobal (const Rectangle<int>& relativePosition);
164 
166  virtual Rectangle<int> globalToLocal (const Rectangle<int>& screenPosition);
167 
171  Rectangle<int> getAreaCoveredBy (Component& subComponent) const;
172 
174  virtual void setMinimised (bool shouldBeMinimised) = 0;
175 
177  virtual bool isMinimised() const = 0;
178 
180  virtual void setFullScreen (bool shouldBeFullScreen) = 0;
181 
183  virtual bool isFullScreen() const = 0;
184 
186  virtual bool isKioskMode() const;
187 
189  void setNonFullScreenBounds (const Rectangle<int>& newBounds) noexcept;
190 
192  const Rectangle<int>& getNonFullScreenBounds() const noexcept;
193 
195  virtual void setIcon (const Image& newIcon) = 0;
196 
200  void setConstrainer (ComponentBoundsConstrainer* newConstrainer) noexcept;
201 
203  ComponentBoundsConstrainer* getConstrainer() const noexcept { return constrainer; }
204 
211  virtual bool contains (Point<int> localPos, bool trueIfInAChildWindow) const = 0;
212 
217  virtual BorderSize<int> getFrameSize() const = 0;
218 
223  void handleMovedOrResized();
224 
229  virtual void handleScreenSizeChange();
230 
231  //==============================================================================
233  void handlePaint (LowLevelGraphicsContext& contextToPaintTo);
234 
235  //==============================================================================
239  virtual bool setAlwaysOnTop (bool alwaysOnTop) = 0;
240 
242  virtual void toFront (bool makeActive) = 0;
243 
245  virtual void toBehind (ComponentPeer* other) = 0;
246 
250  void handleBroughtToFront();
251 
252  //==============================================================================
254  virtual bool isFocused() const = 0;
255 
257  virtual void grabFocus() = 0;
258 
260  void handleFocusGain();
262  void handleFocusLoss();
263 
264  Component* getLastFocusedSubcomponent() const noexcept;
265 
270  bool handleKeyPress (int keyCode, juce_wchar textCharacter);
271 
275  bool handleKeyUpOrDown (bool isKeyDown);
276 
278  void handleModifierKeysChange();
279 
280  //==============================================================================
285  virtual void textInputRequired (Point<int> position, TextInputTarget&) = 0;
286 
288  virtual void dismissPendingTextInput();
289 
291  TextInputTarget* findCurrentTextInputTarget();
292 
293  //==============================================================================
295  virtual void repaint (const Rectangle<int>& area) = 0;
296 
303  virtual void performAnyPendingRepaintsNow() = 0;
304 
306  virtual void setAlpha (float newAlpha) = 0;
307 
308  //==============================================================================
309  void handleMouseEvent (int touchIndex, Point<float> positionWithinPeer, ModifierKeys newMods, int64 time);
310  void handleMouseWheel (int touchIndex, Point<float> positionWithinPeer, int64 time, const MouseWheelDetails&);
311  void handleMagnifyGesture (int touchIndex, Point<float> positionWithinPeer, int64 time, float scaleFactor);
312 
313  void handleUserClosingWindow();
314 
315  struct DragInfo
316  {
320 
321  bool isEmpty() const noexcept { return files.size() == 0 && text.isEmpty(); }
322  void clear() noexcept { files.clear(); text.clear(); }
323  };
324 
325  bool handleDragMove (const DragInfo&);
326  bool handleDragExit (const DragInfo&);
327  bool handleDragDrop (const DragInfo&);
328 
329  //==============================================================================
333  static int getNumPeers() noexcept;
334 
338  static ComponentPeer* getPeer (int index) noexcept;
339 
341  static ComponentPeer* getPeerFor (const Component*) noexcept;
342 
346  static bool isValidPeer (const ComponentPeer* peer) noexcept;
347 
348  //==============================================================================
349  virtual StringArray getAvailableRenderingEngines() = 0;
350  virtual int getCurrentRenderingEngine() const;
351  virtual void setCurrentRenderingEngine (int index);
352 
353 protected:
354  //==============================================================================
356  const int styleFlags;
359 
360 private:
361  //==============================================================================
362  WeakReference<Component> lastFocusedComponent, dragAndDropTargetComponent;
363  Component* lastDragAndDropCompUnderMouse;
364  const uint32 uniqueID;
365  bool isWindowMinimised;
366  Component* getTargetForKeyPress();
367 
369 };
370 
371 
372 #endif // JUCE_COMPONENTPEER_H_INCLUDED
Rectangle< int > lastNonFullscreenBounds
Definition: juce_ComponentPeer.h:357
String text
Definition: juce_ComponentPeer.h:318
Point< int > position
Definition: juce_ComponentPeer.h:319
Definition: juce_ComponentPeer.h:315
bool isEmpty() const noexcept
Definition: juce_ComponentPeer.h:321
#define noexcept
Definition: juce_CompilerSupport.h:141
void clear()
Definition: juce_StringArray.cpp:115
StyleFlags
Definition: juce_ComponentPeer.h:46
ComponentBoundsConstrainer * getConstrainer() const noexcept
Definition: juce_ComponentPeer.h:203
Definition: juce_ModifierKeys.h:38
Definition: juce_Point.h:39
Definition: juce_String.h:43
Definition: juce_TextInputTarget.h:38
#define JUCE_API
Definition: juce_StandardHeader.h:139
ComponentBoundsConstrainer * constrainer
Definition: juce_ComponentPeer.h:358
Definition: juce_Rectangle.h:36
const int styleFlags
Definition: juce_ComponentPeer.h:356
unsigned int uint32
Definition: juce_MathsFunctions.h:51
Definition: juce_Component.h:33
bool isEmpty() const noexcept
Definition: juce_String.h:302
Definition: juce_MouseEvent.h:329
long long int64
Definition: juce_MathsFunctions.h:60
int size() const noexcept
Definition: juce_StringArray.h:121
Definition: juce_StringArray.h:39
uint32 getUniqueID() const noexcept
Definition: juce_ComponentPeer.h:99
void clear() noexcept
Definition: juce_ComponentPeer.h:322
Definition: juce_BorderSize.h:39
StringArray files
Definition: juce_ComponentPeer.h:317
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_Image.h:54
Definition: juce_LowLevelGraphicsContext.h:43
Component & getComponent() noexcept
Definition: juce_ComponentPeer.h:89
Component & component
Definition: juce_ComponentPeer.h:355
Definition: juce_File.h:45
int getStyleFlags() const noexcept
Definition: juce_ComponentPeer.h:94
Definition: juce_ComponentBoundsConstrainer.h:41
void clear() noexcept
Definition: juce_String.cpp:267
wchar_t juce_wchar
Definition: juce_CharacterFunctions.h:49
Definition: juce_ComponentPeer.h:41