Back to index

lightning-sunbird  0.9+nobinonly
nsNativeThemeWin.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is the Mozilla browser.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 1999
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Tim Hill (tim@prismelite.com)
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #include "nsITheme.h"
00041 #include "nsCOMPtr.h"
00042 #include "nsIAtom.h"
00043 #include "nsNativeTheme.h"
00044 #include <windows.h>
00045 
00046 class nsNativeThemeWin : private nsNativeTheme,
00047                          public nsITheme {
00048 public:
00049   NS_DECL_ISUPPORTS
00050 
00051   // The nsITheme interface.
00052   NS_IMETHOD DrawWidgetBackground(nsIRenderingContext* aContext,
00053                                   nsIFrame* aFrame,
00054                                   PRUint8 aWidgetType,
00055                                   const nsRect& aRect,
00056                                   const nsRect& aClipRect);
00057 
00058   NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext, 
00059                              nsIFrame* aFrame,
00060                              PRUint8 aWidgetType,
00061                              nsMargin* aResult);
00062 
00063   virtual PRBool GetWidgetPadding(nsIDeviceContext* aContext,
00064                                   nsIFrame* aFrame,
00065                                   PRUint8 aWidgetType,
00066                                   nsMargin* aResult);
00067 
00068   NS_IMETHOD GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame,
00069                                   PRUint8 aWidgetType,
00070                                   nsSize* aResult,
00071                                   PRBool* aIsOverridable);
00072 
00073   NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, 
00074                                 nsIAtom* aAttribute, PRBool* aShouldRepaint);
00075 
00076   NS_IMETHOD ThemeChanged();
00077 
00078   PRBool ThemeSupportsWidget(nsPresContext* aPresContext, 
00079                              nsIFrame* aFrame,
00080                              PRUint8 aWidgetType);
00081 
00082   PRBool WidgetIsContainer(PRUint8 aWidgetType);
00083 
00084   nsNativeThemeWin();
00085   virtual ~nsNativeThemeWin();
00086 
00087 protected:
00088   void CloseData();
00089   HANDLE GetTheme(PRUint8 aWidgetType);
00090   nsresult GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType,
00091                                 PRInt32& aPart, PRInt32& aState);
00092   nsresult ClassicGetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType,
00093                                    PRInt32& aPart, PRInt32& aState, PRBool& aFocused);
00094   nsresult ClassicDrawWidgetBackground(nsIRenderingContext* aContext,
00095                                   nsIFrame* aFrame,
00096                                   PRUint8 aWidgetType,
00097                                   const nsRect& aRect,
00098                                   const nsRect& aClipRect);
00099   nsresult ClassicGetWidgetBorder(nsIDeviceContext* aContext, 
00100                              nsIFrame* aFrame,
00101                              PRUint8 aWidgetType,
00102                              nsMargin* aResult);
00103 
00104   nsresult ClassicGetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame,
00105                                   PRUint8 aWidgetType,
00106                                   nsSize* aResult,
00107                                   PRBool* aIsOverridable);
00108 
00109   PRBool ClassicThemeSupportsWidget(nsPresContext* aPresContext, 
00110                              nsIFrame* aFrame,
00111                              PRUint8 aWidgetType);
00112 
00113 private:
00114   HMODULE mThemeDLL;
00115   HANDLE mButtonTheme;
00116   HANDLE mTextFieldTheme;
00117   HANDLE mTooltipTheme;
00118   HANDLE mToolbarTheme;
00119   HANDLE mRebarTheme;
00120   HANDLE mProgressTheme;
00121   HANDLE mScrollbarTheme;
00122   HANDLE mStatusbarTheme;
00123   HANDLE mTabTheme;
00124   HANDLE mTreeViewTheme;
00125   HANDLE mComboBoxTheme;
00126   HANDLE mHeaderTheme;
00127 
00128   nsCOMPtr<nsIAtom> mInputAtom;
00129   nsCOMPtr<nsIAtom> mInputCheckedAtom;
00130   nsCOMPtr<nsIAtom> mTypeAtom;
00131 };
00132 
00133 // Creator function
00134 extern NS_METHOD NS_NewNativeThemeWin(nsISupports *aOuter, REFNSIID aIID, void **aResult);