LCOV - code coverage report
Current view: directory - widget/xpwidgets - nsXPLookAndFeel.h (source / functions) Found Hit Coverage
Test: app.info Lines: 4 0 0.0 %
Date: 2012-06-02 Functions: 2 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      26                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : #ifndef __nsXPLookAndFeel
      39                 : #define __nsXPLookAndFeel
      40                 : 
      41                 : #include "mozilla/LookAndFeel.h"
      42                 : 
      43                 : class nsLookAndFeel;
      44                 : 
      45                 : struct nsLookAndFeelIntPref
      46                 : {
      47                 :   const char* name;
      48                 :   mozilla::LookAndFeel::IntID id;
      49                 :   bool isSet;
      50                 :   PRInt32 intVar;
      51                 : };
      52                 : 
      53                 : struct nsLookAndFeelFloatPref
      54                 : {
      55                 :   const char* name;
      56                 :   mozilla::LookAndFeel::FloatID id;
      57                 :   bool isSet;
      58                 :   float floatVar;
      59                 : };
      60                 : 
      61                 : #define CACHE_BLOCK(x)     ((x) >> 5)
      62                 : #define CACHE_BIT(x)       (1 << ((x) & 31))
      63                 : 
      64                 : #define COLOR_CACHE_SIZE   (CACHE_BLOCK(LookAndFeel::eColorID_LAST_COLOR) + 1)
      65                 : #define IS_COLOR_CACHED(x) (CACHE_BIT(x) & nsXPLookAndFeel::sCachedColorBits[CACHE_BLOCK(x)])
      66                 : #define CLEAR_COLOR_CACHE(x) nsXPLookAndFeel::sCachedColors[(x)] =0; \
      67                 :               nsXPLookAndFeel::sCachedColorBits[CACHE_BLOCK(x)] &= ~(CACHE_BIT(x));
      68                 : #define CACHE_COLOR(x, y)  nsXPLookAndFeel::sCachedColors[(x)] = y; \
      69                 :               nsXPLookAndFeel::sCachedColorBits[CACHE_BLOCK(x)] |= CACHE_BIT(x);
      70                 : 
      71                 : class nsXPLookAndFeel: public mozilla::LookAndFeel
      72                 : {
      73                 : public:
      74                 :   virtual ~nsXPLookAndFeel();
      75                 : 
      76                 :   static nsLookAndFeel* GetInstance();
      77                 :   static void Shutdown();
      78                 : 
      79                 :   void Init();
      80                 : 
      81                 :   //
      82                 :   // All these routines will return NS_OK if they have a value,
      83                 :   // in which case the nsLookAndFeel should use that value;
      84                 :   // otherwise we'll return NS_ERROR_NOT_AVAILABLE, in which case, the
      85                 :   // platform-specific nsLookAndFeel should use its own values instead.
      86                 :   //
      87                 :   nsresult GetColorImpl(ColorID aID, nscolor &aResult);
      88                 :   virtual nsresult GetIntImpl(IntID aID, PRInt32 &aResult);
      89                 :   virtual nsresult GetFloatImpl(FloatID aID, float &aResult);
      90                 : 
      91                 :   // This one is different: there are no override prefs (fixme?), so
      92                 :   // there is no XP implementation, only per-system impls.
      93                 :   virtual bool GetFontImpl(FontID aID, nsString& aName,
      94                 :                            gfxFontStyle& aStyle) = 0;
      95                 : 
      96                 :   virtual void RefreshImpl();
      97                 : 
      98               0 :   virtual PRUnichar GetPasswordCharacterImpl()
      99                 :   {
     100               0 :     return PRUnichar('*');
     101                 :   }
     102                 : 
     103               0 :   virtual bool GetEchoPasswordImpl()
     104                 :   {
     105               0 :     return false;
     106                 :   }
     107                 : 
     108                 : protected:
     109                 :   nsXPLookAndFeel();
     110                 : 
     111                 :   static void IntPrefChanged(nsLookAndFeelIntPref *data);
     112                 :   static void FloatPrefChanged(nsLookAndFeelFloatPref *data);
     113                 :   static void ColorPrefChanged(unsigned int index, const char *prefName);
     114                 :   void InitFromPref(nsLookAndFeelIntPref* aPref);
     115                 :   void InitFromPref(nsLookAndFeelFloatPref* aPref);
     116                 :   void InitColorFromPref(PRInt32 aIndex);
     117                 :   virtual nsresult NativeGetColor(ColorID aID, nscolor &aResult) = 0;
     118                 :   bool IsSpecialColor(ColorID aID, nscolor &aColor);
     119                 : 
     120                 :   static int OnPrefChanged(const char* aPref, void* aClosure);
     121                 : 
     122                 :   static bool sInitialized;
     123                 :   static nsLookAndFeelIntPref sIntPrefs[];
     124                 :   static nsLookAndFeelFloatPref sFloatPrefs[];
     125                 :   /* this length must not be shorter than the length of the longest string in the array
     126                 :    * see nsXPLookAndFeel.cpp
     127                 :    */
     128                 :   static const char sColorPrefs[][38];
     129                 :   static PRInt32 sCachedColors[LookAndFeel::eColorID_LAST_COLOR];
     130                 :   static PRInt32 sCachedColorBits[COLOR_CACHE_SIZE];
     131                 :   static bool sUseNativeColors;
     132                 : 
     133                 :   static nsLookAndFeel* sInstance;
     134                 :   static bool sShutdown;
     135                 : };
     136                 : 
     137                 : #endif

Generated by: LCOV version 1.7