Back to index

lightning-sunbird  0.9+nobinonly
nsNativeThemeMac.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Mike Pinkerton (pinkerton@netscape.com).
00019  * Portions created by the Initial Developer are Copyright (C) 2001
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #include <Appearance.h>
00039 
00040 #include "nsITheme.h"
00041 #include "nsCOMPtr.h"
00042 #include "nsIAtom.h"
00043 #include "nsILookAndFeel.h"
00044 #include "nsIDeviceContext.h"
00045 #include "nsNativeTheme.h"
00046 
00047 class nsNativeThemeMac : private nsNativeTheme,
00048                          public nsITheme
00049 {
00050 public:
00051   nsNativeThemeMac();
00052   virtual ~nsNativeThemeMac();
00053 
00054   NS_DECL_ISUPPORTS
00055 
00056   // The nsITheme interface.
00057   NS_IMETHOD DrawWidgetBackground(nsIRenderingContext* aContext,
00058                                   nsIFrame* aFrame,
00059                                   PRUint8 aWidgetType,
00060                                   const nsRect& aRect,
00061                                   const nsRect& aClipRect);
00062   NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext, 
00063                              nsIFrame* aFrame,
00064                              PRUint8 aWidgetType,
00065                              nsMargin* aResult);
00066 
00067   virtual PRBool GetWidgetPadding(nsIDeviceContext* aContext,
00068                                   nsIFrame* aFrame,
00069                                   PRUint8 aWidgetType,
00070                                   nsMargin* aResult);
00071 
00072   NS_IMETHOD GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame,
00073                                   PRUint8 aWidgetType,
00074                                   nsSize* aResult, PRBool* aIsOverridable);
00075   NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, 
00076                                 nsIAtom* aAttribute, PRBool* aShouldRepaint);
00077   NS_IMETHOD ThemeChanged();
00078   PRBool ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, PRUint8 aWidgetType);
00079   PRBool WidgetIsContainer(PRUint8 aWidgetType);
00080 
00081 protected:
00082 
00083     // Some widths and margins. You'd think there would be metrics for these, but no.
00084   enum {
00085     kAquaPushButtonEndcaps = 14,
00086     kAquaPushButtonTopBottom = 2,
00087     kAquaSmallPushButtonEndcaps = 10,
00088 
00089     kAquaDropdownLeftEndcap = 9,
00090     kAquaDropwdonRightEndcap = 20     // wider on right to encompass the button
00091   };
00092   
00093   nsresult GetSystemColor(PRUint8 aWidgetType, nsILookAndFeel::nsColorID& aColorID);
00094   nsresult GetSystemFont(PRUint8 aWidgetType, nsSystemFontID& aFont);
00095 
00096 
00097   // Appearance Manager drawing routines
00098   void DrawCheckbox ( const Rect& inBoxRect, PRBool inChecked, PRBool inDisabled, PRInt32 inState ) ;
00099   void DrawSmallCheckbox ( const Rect& inBoxRect, PRBool inChecked, PRBool inDisabled, PRInt32 inState );
00100   void DrawRadio ( const Rect& inBoxRect, PRBool inChecked, PRBool inDisabled, PRInt32 inState ) ;
00101   void DrawSmallRadio ( const Rect& inBoxRect, PRBool inChecked, PRBool inDisabled, PRInt32 inState );
00102   void DrawToolbar ( const Rect& inBoxRect ) ;
00103   void DrawEditText ( const Rect& inBoxRect, PRBool inIsDisabled ) ;
00104   void DrawListBox ( const Rect& inBoxRect, PRBool inIsDisabled ) ;
00105   void DrawProgress ( const Rect& inBoxRect, PRBool inIsDisabled, PRBool inIsIndeterminate, 
00106                         PRBool inIsHorizontal, PRInt32 inValue ) ;
00107   void DrawTab ( const Rect& inBoxRect, PRBool inIsDisabled, PRBool inIsFrontmost, 
00108                   PRBool inIsHorizontal, PRBool inTabBottom, PRInt32 inState ) ;
00109   void DrawTabPanel ( const Rect& inBoxRect, PRBool inIsDisabled ) ;
00110   void DrawSeparator ( const Rect& inBoxRect, PRBool inIsDisabled ) ;
00111 //  void DrawScrollArrows ( const Rect& inScrollbarRect, PRBool inIsDisabled, PRInt32 inWidget, PRInt32 inState ) ;
00112   
00113   void DrawButton ( ThemeButtonKind inKind, const Rect& inBoxRect, PRBool inIsDefault, 
00114                       PRBool inDisabled, ThemeButtonValue inValue, ThemeButtonAdornment inAdornment, PRInt32 inState ) ;
00115   void DrawCheckboxRadio ( ThemeButtonKind inKind, const Rect& inBoxRect, PRBool inChecked, 
00116                               PRBool inDisabled, PRInt32 inState ) ;
00117   void DrawMenu ( const Rect& inBoxRect, PRBool inIsDisabled ) ;
00118   void DrawMenuItem ( const Rect& inBoxRect, ThemeMenuItemType itemType, PRBool inIsDisabled,
00119                         PRBool inHover) ;
00120 
00121 private:
00122 
00123   ThemeEraseUPP mEraseProc;
00124   nsCOMPtr<nsIAtom> mMenuActiveAtom;
00125 };