JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
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) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
51class JUCE_API ResizableWindow : public TopLevelWindow
52{
53public:
54 //==============================================================================
64 ResizableWindow (const String& name,
65 bool addToDesktop);
66
74 ResizableWindow (const String& name,
75 Colour backgroundColour,
76 bool addToDesktop);
77
81 ~ResizableWindow() override;
82
83 //==============================================================================
93 Colour getBackgroundColour() const noexcept;
94
110 void setBackgroundColour (Colour newColour);
111
112 //==============================================================================
121 void setResizable (bool shouldBeResizable,
122 bool useBottomRightCornerResizer);
123
127 bool isResizable() const noexcept;
128
140 void setResizeLimits (int newMinimumWidth,
141 int newMinimumHeight,
142 int newMaximumWidth,
143 int newMaximumHeight) noexcept;
144
146 void setDraggable (bool shouldBeDraggable) noexcept;
147
149 bool isDraggable() const noexcept { return canDrag; }
150
154 ComponentBoundsConstrainer* getConstrainer() noexcept { return constrainer; }
155
163 void setConstrainer (ComponentBoundsConstrainer* newConstrainer);
164
169 void setBoundsConstrained (const Rectangle<int>& newBounds);
170
171
172 //==============================================================================
176 bool isFullScreen() const;
177
185 void setFullScreen (bool shouldBeFullScreen);
186
190 bool isMinimised() const;
191
199 void setMinimised (bool shouldMinimise);
200
204 bool isKioskMode() const;
205
206 //==============================================================================
217 String getWindowStateAsString();
218
228 bool restoreWindowStateFromString (const String& previousState);
229
230
231 //==============================================================================
239 Component* getContentComponent() const noexcept { return contentComponent; }
240
257 void setContentOwned (Component* newContentComponent,
258 bool resizeToFitWhenContentChangesSize);
259
276 void setContentNonOwned (Component* newContentComponent,
277 bool resizeToFitWhenContentChangesSize);
278
283 void clearContentComponent();
284
290 void setContentComponentSize (int width, int height);
291
295 virtual BorderSize<int> getBorderThickness();
296
300 virtual BorderSize<int> getContentComponentBorder();
301
302 //==============================================================================
311 {
312 backgroundColourId = 0x1005700,
313 };
314
315 //==============================================================================
316 #ifndef DOXYGEN
317 [[deprecated ("use setContentOwned and setContentNonOwned instead.")]]
318 void setContentComponent (Component* newContentComponent,
319 bool deleteOldOne = true,
320 bool resizeToFit = false);
321 #endif
322
323 using TopLevelWindow::addToDesktop;
324
325 //==============================================================================
329 struct JUCE_API LookAndFeelMethods
330 {
331 virtual ~LookAndFeelMethods() = default;
332
333 //==============================================================================
334 virtual void drawCornerResizer (Graphics&, int w, int h, bool isMouseOver, bool isMouseDragging) = 0;
335 virtual void drawResizableFrame (Graphics&, int w, int h, const BorderSize<int>&) = 0;
336
337 virtual void fillResizableWindowBackground (Graphics&, int w, int h, const BorderSize<int>&, ResizableWindow&) = 0;
338 virtual void drawResizableWindowBorder (Graphics&, int w, int h, const BorderSize<int>& border, ResizableWindow&) = 0;
339 };
340
341protected:
343 void paint (Graphics&) override;
345 void moved() override;
347 void resized() override;
349 void mouseDown (const MouseEvent&) override;
351 void mouseDrag (const MouseEvent&) override;
353 void mouseUp (const MouseEvent&) override;
355 void lookAndFeelChanged() override;
357 void childBoundsChanged (Component*) override;
359 void parentSizeChanged() override;
361 void visibilityChanged() override;
363 void activeWindowStatusChanged() override;
365 int getDesktopWindowStyleFlags() const override;
366
367 #if JUCE_DEBUG
374 void addChildComponent (Component*, int zOrder = -1);
381 void addAndMakeVisible (Component*, int zOrder = -1);
382 #endif
383
386
387 //==============================================================================
388 // The parameters for these methods have changed - please update your code!
389 void getBorderThickness (int& left, int& top, int& right, int& bottom);
390 void getContentComponentBorder (int& left, int& top, int& right, int& bottom);
391
392private:
393 //==============================================================================
394 Component::SafePointer<Component> contentComponent, splashScreen;
395 bool ownsContentComponent = false, resizeToFitContent = false, fullscreen = false, canDrag = true, dragStarted = false;
396 ComponentDragger dragger;
397 Rectangle<int> lastNonFullScreenPos;
398 ComponentBoundsConstrainer defaultConstrainer;
399 ComponentBoundsConstrainer* constrainer = nullptr;
400 #if JUCE_DEBUG
401 bool hasBeenResized = false;
402 #endif
403
404 void initialise (bool addToDesktop);
405 void updateLastPosIfNotFullScreen();
406 void updateLastPosIfShowing();
407 void setContent (Component*, bool takeOwnership, bool resizeToFit);
408 void updatePeerConstrainer();
409
411};
412
413} // namespace juce
Specifies a set of gaps to be left around the sides of a rectangle.
Represents a colour, also including a transparency value.
Definition juce_Colour.h:38
A class that imposes restrictions on a Component's size or position.
An object to take care of the logic for dragging components around with the mouse.
Holds a pointer to some type of Component, which automatically becomes null if the component is delet...
The base class for all JUCE user-interface objects.
A graphics context, used for drawing a component or image.
Contains position and status information about a mouse event.
Manages a rectangle and allows geometric operations to be performed on it.
A base class for top-level windows that can be dragged around and resized.
bool isDraggable() const noexcept
Returns true if the window can be dragged around by the user.
ColourIds
A set of colour IDs to use to change the colour of various aspects of the window.
ComponentBoundsConstrainer * getConstrainer() noexcept
Returns the bounds constrainer object that this window is using.
Component * getContentComponent() const noexcept
Returns the current content component.
The JUCE String class!
Definition juce_String.h:53
A base class for top-level windows.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
JUCE Namespace.
This abstract base class is implemented by LookAndFeel classes to provide window drawing functionalit...