openshot-audio  0.1.6
juce_ResizableWindow.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_RESIZABLEWINDOW_H_INCLUDED
26 #define JUCE_RESIZABLEWINDOW_H_INCLUDED
27 
28 
29 //==============================================================================
50 {
51 public:
52  //==============================================================================
62  ResizableWindow (const String& name,
63  bool addToDesktop);
64 
72  ResizableWindow (const String& name,
73  Colour backgroundColour,
74  bool addToDesktop);
75 
79  ~ResizableWindow();
80 
81  //==============================================================================
91  Colour getBackgroundColour() const noexcept;
92 
108  void setBackgroundColour (Colour newColour);
109 
110  //==============================================================================
119  void setResizable (bool shouldBeResizable,
120  bool useBottomRightCornerResizer);
121 
125  bool isResizable() const noexcept;
126 
138  void setResizeLimits (int newMinimumWidth,
139  int newMinimumHeight,
140  int newMaximumWidth,
141  int newMaximumHeight) noexcept;
142 
144  void setDraggable (bool shouldBeDraggable) noexcept;
145 
147  bool isDraggable() const noexcept { return canDrag; }
148 
152  ComponentBoundsConstrainer* getConstrainer() noexcept { return constrainer; }
153 
161  void setConstrainer (ComponentBoundsConstrainer* newConstrainer);
162 
167  void setBoundsConstrained (const Rectangle<int>& bounds);
168 
169 
170  //==============================================================================
174  bool isFullScreen() const;
175 
183  void setFullScreen (bool shouldBeFullScreen);
184 
188  bool isMinimised() const;
189 
197  void setMinimised (bool shouldMinimise);
198 
202  bool isKioskMode() const;
203 
204  //==============================================================================
215  String getWindowStateAsString();
216 
226  bool restoreWindowStateFromString (const String& previousState);
227 
228 
229  //==============================================================================
237  Component* getContentComponent() const noexcept { return contentComponent; }
238 
255  void setContentOwned (Component* newContentComponent,
256  bool resizeToFitWhenContentChangesSize);
257 
274  void setContentNonOwned (Component* newContentComponent,
275  bool resizeToFitWhenContentChangesSize);
276 
281  void clearContentComponent();
282 
288  void setContentComponentSize (int width, int height);
289 
293  virtual BorderSize<int> getBorderThickness();
294 
298  virtual BorderSize<int> getContentComponentBorder();
299 
300  //==============================================================================
309  {
310  backgroundColourId = 0x1005700,
311  };
312 
313  //==============================================================================
314  // Deprecated: use setContentOwned() and setContentNonOwned() instead.
315  JUCE_DEPRECATED (void setContentComponent (Component* newContentComponent,
316  bool deleteOldOne = true,
317  bool resizeToFit = false));
319 
320  //==============================================================================
325  {
326  virtual ~LookAndFeelMethods() {}
327 
328  //==============================================================================
329  virtual void drawCornerResizer (Graphics&, int w, int h, bool isMouseOver, bool isMouseDragging) = 0;
330  virtual void drawResizableFrame (Graphics&, int w, int h, const BorderSize<int>&) = 0;
331 
332  virtual void fillResizableWindowBackground (Graphics&, int w, int h, const BorderSize<int>&, ResizableWindow&) = 0;
333  virtual void drawResizableWindowBorder (Graphics&, int w, int h, const BorderSize<int>& border, ResizableWindow&) = 0;
334  };
335 
336 protected:
338  void paint (Graphics&) override;
340  void moved() override;
342  void resized() override;
344  void mouseDown (const MouseEvent&) override;
346  void mouseDrag (const MouseEvent&) override;
348  void mouseUp (const MouseEvent&) override;
350  void lookAndFeelChanged() override;
352  void childBoundsChanged (Component*) override;
354  void parentSizeChanged() override;
356  void visibilityChanged() override;
358  void activeWindowStatusChanged() override;
360  int getDesktopWindowStyleFlags() const override;
361 
362  #if JUCE_DEBUG
363 
369  void addChildComponent (Component*, int zOrder = -1);
376  void addAndMakeVisible (Component*, int zOrder = -1);
377  #endif
378 
381 
382 private:
383  //==============================================================================
384  Component::SafePointer<Component> contentComponent;
385  bool ownsContentComponent, resizeToFitContent, fullscreen, canDrag, dragStarted;
386  ComponentDragger dragger;
387  Rectangle<int> lastNonFullScreenPos;
388  ComponentBoundsConstrainer defaultConstrainer;
389  ComponentBoundsConstrainer* constrainer;
390  #if JUCE_DEBUG
391  bool hasBeenResized;
392  #endif
393 
394  void initialise (bool addToDesktop);
395  void updateLastPosIfNotFullScreen();
396  void updateLastPosIfShowing();
397  void setContent (Component*, bool takeOwnership, bool resizeToFit);
398 
399  #if JUCE_CATCH_DEPRECATED_CODE_MISUSE
400  // The parameters for these methods have changed - please update your code!
401  JUCE_DEPRECATED (void getBorderThickness (int& left, int& top, int& right, int& bottom));
402  JUCE_DEPRECATED (void getContentComponentBorder (int& left, int& top, int& right, int& bottom));
403  #endif
404 
406 };
407 
408 
409 #endif // JUCE_RESIZABLEWINDOW_H_INCLUDED
Definition: juce_ResizableWindow.h:49
void addToDesktop()
Definition: juce_TopLevelWindow.cpp:261
bool isDraggable() const noexcept
Definition: juce_ResizableWindow.h:147
#define noexcept
Definition: juce_CompilerSupport.h:141
Component * getContentComponent() const noexcept
Definition: juce_ResizableWindow.h:237
virtual ~LookAndFeelMethods()
Definition: juce_ResizableWindow.h:326
Definition: juce_TopLevelWindow.h:51
Definition: juce_String.h:43
ScopedPointer< ResizableCornerComponent > resizableCorner
Definition: juce_ResizableWindow.h:379
#define JUCE_API
Definition: juce_StandardHeader.h:139
#define const
Definition: juce_Rectangle.h:36
Definition: juce_Colour.h:35
Definition: juce_Component.h:33
png_const_structrp png_const_inforp int png_fixed_point * width
Definition: juce_PNGLoader.cpp:2339
#define JUCE_DEPRECATED(functionDef)
Definition: juce_PlatformDefs.h:319
friend class ResizableWindow
Definition: juce_TopLevelWindow.h:154
Definition: juce_BorderSize.h:39
Definition: juce_ResizableWindow.h:324
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_GraphicsContext.h:42
ComponentBoundsConstrainer * getConstrainer() noexcept
Definition: juce_ResizableWindow.h:152
JUCE_DEPRECATED(Point< int > relativePositionToGlobal(Point< int >) const)
ScopedPointer< ResizableBorderComponent > resizableBorder
Definition: juce_ResizableWindow.h:380
Definition: juce_ComponentBoundsConstrainer.h:41
ColourIds
Definition: juce_ResizableWindow.h:308
Definition: juce_MouseEvent.h:36
Definition: juce_ComponentDragger.h:56