openshot-audio  0.1.6
juce_AlertWindow.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_ALERTWINDOW_H_INCLUDED
26 #define JUCE_ALERTWINDOW_H_INCLUDED
27 
28 
29 //==============================================================================
43  private ButtonListener // (can't use Button::Listener due to idiotic VC2005 bug)
44 {
45 public:
46  //==============================================================================
49  {
51  QuestionIcon,
53  WarningIcon,
55  InfoIcon
58  };
59 
60  //==============================================================================
71  AlertWindow (const String& title,
72  const String& message,
73  AlertIconType iconType,
74  Component* associatedComponent = nullptr);
75 
77  ~AlertWindow();
78 
79  //==============================================================================
82  AlertIconType getAlertType() const noexcept { return alertIconType; }
83 
84  //==============================================================================
89  void setMessage (const String& message);
90 
91  //==============================================================================
100  void addButton (const String& name,
101  int returnValue,
102  const KeyPress& shortcutKey1 = KeyPress(),
103  const KeyPress& shortcutKey2 = KeyPress());
104 
106  int getNumButtons() const;
107 
109  void triggerButtonClick (const String& buttonName);
110 
117  void setEscapeKeyCancels (bool shouldEscapeKeyCancel);
118 
119  //==============================================================================
132  void addTextEditor (const String& name,
133  const String& initialContents,
134  const String& onScreenLabel = String::empty,
135  bool isPasswordBox = false);
136 
145  String getTextEditorContents (const String& nameOfTextEditor) const;
146 
148  TextEditor* getTextEditor (const String& nameOfTextEditor) const;
149 
150  //==============================================================================
162  void addComboBox (const String& name,
163  const StringArray& items,
164  const String& onScreenLabel = String::empty);
165 
172  ComboBox* getComboBoxComponent (const String& nameOfList) const;
173 
174  //==============================================================================
180  void addTextBlock (const String& text);
181 
182  //==============================================================================
189  void addProgressBarComponent (double& progressValue);
190 
191  //==============================================================================
198  void addCustomComponent (Component* component);
199 
203  int getNumCustomComponents() const;
204 
211  Component* getCustomComponent (int index) const;
212 
221  Component* removeCustomComponent (int index);
222 
223  //==============================================================================
225  bool containsAnyExtraComponents() const;
226 
227  //==============================================================================
228  // easy-to-use message box functions:
229 
230  #if JUCE_MODAL_LOOPS_PERMITTED
231 
246  static void JUCE_CALLTYPE showMessageBox (AlertIconType iconType,
247  const String& title,
248  const String& message,
249  const String& buttonText = String::empty,
250  Component* associatedComponent = nullptr);
251  #endif
252 
274  static void JUCE_CALLTYPE showMessageBoxAsync (AlertIconType iconType,
275  const String& title,
276  const String& message,
277  const String& buttonText = String::empty,
278  Component* associatedComponent = nullptr,
279  ModalComponentManager::Callback* callback = nullptr);
280 
316  static bool JUCE_CALLTYPE showOkCancelBox (AlertIconType iconType,
317  const String& title,
318  const String& message,
320  const String& button1Text = String::empty,
321  const String& button2Text = String::empty,
322  Component* associatedComponent = nullptr,
323  ModalComponentManager::Callback* callback = nullptr);
324  #else
325  const String& button1Text,
326  const String& button2Text,
327  Component* associatedComponent,
329  #endif
330 
370  static int JUCE_CALLTYPE showYesNoCancelBox (AlertIconType iconType,
371  const String& title,
372  const String& message,
374  const String& button1Text = String::empty,
375  const String& button2Text = String::empty,
376  const String& button3Text = String::empty,
377  Component* associatedComponent = nullptr,
378  ModalComponentManager::Callback* callback = nullptr);
379  #else
380  const String& button1Text,
381  const String& button2Text,
382  const String& button3Text,
383  Component* associatedComponent,
385  #endif
386 
387  //==============================================================================
396  #if JUCE_MODAL_LOOPS_PERMITTED
397  static bool JUCE_CALLTYPE showNativeDialogBox (const String& title,
398  const String& bodyText,
399  bool isOkCancel);
400  #endif
401 
402 
403  //==============================================================================
412  {
413  backgroundColourId = 0x1001800,
414  textColourId = 0x1001810,
415  outlineColourId = 0x1001820
416  };
417 
418  //==============================================================================
423  {
424  virtual ~LookAndFeelMethods() {}
425 
426  virtual AlertWindow* createAlertWindow (const String& title, const String& message,
427  const String& button1,
428  const String& button2,
429  const String& button3,
431  int numButtons,
432  Component* associatedComponent) = 0;
433 
434  virtual void drawAlertBox (Graphics&, AlertWindow&, const Rectangle<int>& textArea, TextLayout&) = 0;
435 
436  virtual int getAlertBoxWindowFlags() = 0;
437 
438  virtual int getAlertWindowButtonHeight() = 0;
439 
440  virtual Font getAlertWindowTitleFont() = 0;
441  virtual Font getAlertWindowMessageFont() = 0;
442  virtual Font getAlertWindowFont() = 0;
443  };
444 
445 protected:
446  //==============================================================================
448  void paint (Graphics&) override;
450  void mouseDown (const MouseEvent&) override;
452  void mouseDrag (const MouseEvent&) override;
454  bool keyPressed (const KeyPress&) override;
456  void buttonClicked (Button*) override;
458  void lookAndFeelChanged() override;
460  void userTriedToCloseWindow() override;
462  int getDesktopWindowStyleFlags() const override;
463 
464 private:
465  //==============================================================================
466  String text;
467  TextLayout textLayout;
468  AlertIconType alertIconType;
469  ComponentBoundsConstrainer constrainer;
470  ComponentDragger dragger;
471  Rectangle<int> textArea;
472  OwnedArray<TextButton> buttons;
473  OwnedArray<TextEditor> textBoxes;
474  OwnedArray<ComboBox> comboBoxes;
475  OwnedArray<ProgressBar> progressBars;
476  Array<Component*> customComps;
477  OwnedArray<Component> textBlocks;
478  Array<Component*> allComps;
479  StringArray textboxNames, comboBoxNames;
480  Component* associatedComponent;
481  bool escapeKeyCancels;
482 
483  void updateLayout (bool onlyIncreaseSize);
484 
486 };
487 
488 #endif // JUCE_ALERTWINDOW_H_INCLUDED
#define JUCE_MODAL_LOOPS_PERMITTED
Definition: juce_PlatformDefs.h:329
Definition: juce_KeyPress.h:37
static const String empty
Definition: juce_String.h:152
Definition: juce_Font.h:39
#define noexcept
Definition: juce_CompilerSupport.h:141
Definition: juce_Button.h:39
Definition: juce_AlertWindow.h:42
Definition: juce_TextLayout.h:38
Definition: juce_TopLevelWindow.h:51
#define JUCE_CALLTYPE
Definition: juce_PlatformDefs.h:50
Definition: juce_AlertWindow.h:50
Definition: juce_ModalComponentManager.h:53
AlertIconType
Definition: juce_AlertWindow.h:48
Definition: juce_String.h:43
#define JUCE_API
Definition: juce_StandardHeader.h:139
Definition: juce_Rectangle.h:36
Definition: juce_AlertWindow.h:422
AlertIconType getAlertType() const noexcept
Definition: juce_AlertWindow.h:82
Definition: juce_Component.h:33
Definition: juce_TextEditor.h:38
Definition: juce_Button.h:162
ColourIds
Definition: juce_AlertWindow.h:411
Definition: juce_StringArray.h:39
virtual ~LookAndFeelMethods()
Definition: juce_AlertWindow.h:424
Definition: juce_Array.h:60
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_GraphicsContext.h:42
Definition: juce_ComboBox.h:44
Definition: juce_ComponentBoundsConstrainer.h:41
Definition: juce_MouseEvent.h:36
Definition: juce_ComponentDragger.h:56