juce_DocumentWindow.h

Go to the documentation of this file.
00001 /*
00002   ==============================================================================
00003 
00004    This file is part of the JUCE library - "Jules' Utility Class Extensions"
00005    Copyright 2004-7 by Raw Material Software ltd.
00006 
00007   ------------------------------------------------------------------------------
00008 
00009    JUCE can be redistributed and/or modified under the terms of the
00010    GNU General Public License, as published by the Free Software Foundation;
00011    either version 2 of the License, or (at your option) any later version.
00012 
00013    JUCE is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with JUCE; if not, visit www.gnu.org/licenses or write to the
00020    Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00021    Boston, MA 02111-1307 USA
00022 
00023   ------------------------------------------------------------------------------
00024 
00025    If you'd like to release a closed-source product which uses JUCE, commercial
00026    licenses are also available: visit www.rawmaterialsoftware.com/juce for
00027    more information.
00028 
00029   ==============================================================================
00030 */
00031 
00032 #ifndef __JUCE_DOCUMENTWINDOW_JUCEHEADER__
00033 #define __JUCE_DOCUMENTWINDOW_JUCEHEADER__
00034 
00035 #include "juce_ResizableWindow.h"
00036 #include "../buttons/juce_Button.h"
00037 #include "../menus/juce_MenuBarComponent.h"
00038 
00039 
00040 //==============================================================================
00063 class JUCE_API  DocumentWindow   : public ResizableWindow
00064 {
00065 public:
00066     //==============================================================================
00071     enum TitleBarButtons
00072     {
00073         minimiseButton = 1,
00074         maximiseButton = 2,
00075         closeButton = 4,
00076 
00078         allButtons = 7
00079     };
00080 
00081     //==============================================================================
00098     DocumentWindow (const String& name,
00099                     const Colour& backgroundColour,
00100                     const int requiredButtons,
00101                     const bool addToDesktop = true);
00102 
00108     ~DocumentWindow();
00109 
00110     //==============================================================================
00116     void setName (const String& newName);
00117 
00124     void setIcon (const Image* imageToUse);
00125 
00127     void setTitleBarHeight (const int newHeight);
00128 
00130     int getTitleBarHeight() const;
00131 
00141     void setTitleBarButtonsRequired (const int requiredButtons,
00142                                      const bool positionTitleBarButtonsOnLeft);
00143 
00149     void setTitleBarTextCentred (const bool textShouldBeCentred);
00150 
00162     void setMenuBar (MenuBarModel* menuBarModel,
00163                      const int menuBarHeight = 0);
00164 
00165     //==============================================================================
00186     virtual void closeButtonPressed();
00187 
00193     virtual void minimiseButtonPressed();
00194 
00201     virtual void maximiseButtonPressed();
00202 
00203     //==============================================================================
00205     Button* getCloseButton() const throw();
00206 
00208     Button* getMinimiseButton() const throw();
00209 
00211     Button* getMaximiseButton() const throw();
00212 
00213 
00214     //==============================================================================
00216     void paint (Graphics& g);
00218     void resized();
00220     void lookAndFeelChanged();
00222     const BorderSize getBorderThickness();
00224     const BorderSize getContentComponentBorder();
00226     void mouseDoubleClick (const MouseEvent& e);
00228     void userTriedToCloseWindow();
00230     void activeWindowStatusChanged();
00232     int getDesktopWindowStyleFlags() const;
00234     void parentHierarchyChanged();
00235 
00236 
00237     //==============================================================================
00238     juce_UseDebuggingNewOperator
00239 
00240 private:
00241     int titleBarHeight, menuBarHeight, requiredButtons;
00242     bool positionTitleBarButtonsOnLeft, drawTitleTextCentred;
00243     Button* titleBarButtons [3];
00244     Image* titleBarIcon;
00245     MenuBarComponent* menuBar;
00246     MenuBarModel* menuBarModel;
00247 
00248     class ButtonListenerProxy   : public ButtonListener
00249     {
00250     public:
00251         ButtonListenerProxy();
00252         void buttonClicked (Button* button);
00253 
00254         DocumentWindow* owner;
00255 
00256     } buttonListener;
00257 
00258     int getBorderSize() const;
00259     void repaintTitleBar();
00260 
00261     DocumentWindow (const DocumentWindow&);
00262     const DocumentWindow& operator= (const DocumentWindow&);
00263 };
00264 
00265 
00266 #endif   // __JUCE_DOCUMENTWINDOW_JUCEHEADER__