Back to index

lightning-sunbird  0.9+nobinonly
Defines | Typedefs | Functions | Variables
nsNativeThemeWin.cpp File Reference
#include <windows.h>
#include "nsNativeThemeWin.h"
#include "nsRenderingContextWin.h"
#include "nsDeviceContextWin.h"
#include "nsRect.h"
#include "nsSize.h"
#include "nsTransform2D.h"
#include "nsThemeConstants.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIFrame.h"
#include "nsIEventStateManager.h"
#include "nsINameSpaceManager.h"
#include "nsILookAndFeel.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIMenuFrame.h"
#include "nsUnicharUtils.h"
#include <malloc.h>

Go to the source code of this file.

Defines

#define THEME_COLOR   204
#define THEME_FONT   210
#define TS_NORMAL   1
#define TS_HOVER   2
#define TS_ACTIVE   3
#define TS_DISABLED   4
#define TS_FOCUSED   5
#define TB_CHECKED   5
#define TB_HOVER_CHECKED   6
#define BP_BUTTON   1
#define BP_RADIO   2
#define BP_CHECKBOX   3
#define TFP_TEXTFIELD   1
#define TFS_READONLY   6
#define TREEVIEW_BODY   1
#define SP_BUTTON   1
#define SP_THUMBHOR   2
#define SP_THUMBVERT   3
#define SP_TRACKSTARTHOR   4
#define SP_TRACKENDHOR   5
#define SP_TRACKSTARTVERT   6
#define SP_TRACKENDVERT   7
#define SP_GRIPPERHOR   8
#define SP_GRIPPERVERT   9
#define PP_BAR   1
#define PP_BARVERT   2
#define PP_CHUNK   3
#define PP_CHUNKVERT   4
#define TABP_TAB   4
#define TABP_TAB_SELECTED   5
#define TABP_PANELS   9
#define TABP_PANEL   10
#define TTP_STANDARD   1
#define CBP_DROPMARKER   1

Typedefs

typedef HANDLE(WINAPI * OpenThemeDataPtr )(HWND hwnd, LPCWSTR pszClassList)
typedef HRESULT(WINAPI * CloseThemeDataPtr )(HANDLE hTheme)
typedef HRESULT(WINAPI * DrawThemeBackgroundPtr )(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
typedef HRESULT(WINAPI * GetThemeContentRectPtr )(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, RECT *pContentRect)
typedef HRESULT(WINAPI * GetThemePartSizePtr )(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, int ts, SIZE *psz)
typedef HRESULT(WINAPI * GetThemeSysFontPtr )(HANDLE hTheme, int iFontId, OUT LOGFONT *pFont)
typedef HRESULT(WINAPI * GetThemeColorPtr )(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, OUT COLORREF *pFont)

Functions

static void GetNativeRect (const nsRect &aSrc, RECT &aDst)
static void DrawTab (HDC hdc, const RECT &R, PRInt32 aPosition, PRBool aSelected, PRBool aDrawLeft, PRBool aDrawRight)
NS_METHOD NS_NewNativeTheme (nsISupports *aOuter, REFNSIID aIID, void **aResult)

Variables

static OpenThemeDataPtr openTheme = NULL
static CloseThemeDataPtr closeTheme = NULL
static DrawThemeBackgroundPtr drawThemeBG = NULL
static GetThemeContentRectPtr getThemeContentRect = NULL
static GetThemePartSizePtr getThemePartSize = NULL
static GetThemeSysFontPtr getThemeSysFont = NULL
static GetThemeColorPtr getThemeColor = NULL
static const char kThemeLibraryName [] = "uxtheme.dll"

Define Documentation

#define BP_BUTTON   1

Definition at line 80 of file nsNativeThemeWin.cpp.

Definition at line 82 of file nsNativeThemeWin.cpp.

#define BP_RADIO   2

Definition at line 81 of file nsNativeThemeWin.cpp.

Definition at line 118 of file nsNativeThemeWin.cpp.

#define PP_BAR   1

Definition at line 103 of file nsNativeThemeWin.cpp.

#define PP_BARVERT   2

Definition at line 104 of file nsNativeThemeWin.cpp.

#define PP_CHUNK   3

Definition at line 105 of file nsNativeThemeWin.cpp.

Definition at line 106 of file nsNativeThemeWin.cpp.

#define SP_BUTTON   1

Definition at line 92 of file nsNativeThemeWin.cpp.

Definition at line 99 of file nsNativeThemeWin.cpp.

Definition at line 100 of file nsNativeThemeWin.cpp.

Definition at line 93 of file nsNativeThemeWin.cpp.

Definition at line 94 of file nsNativeThemeWin.cpp.

Definition at line 96 of file nsNativeThemeWin.cpp.

Definition at line 98 of file nsNativeThemeWin.cpp.

Definition at line 95 of file nsNativeThemeWin.cpp.

Definition at line 97 of file nsNativeThemeWin.cpp.

#define TABP_PANEL   10

Definition at line 112 of file nsNativeThemeWin.cpp.

Definition at line 111 of file nsNativeThemeWin.cpp.

#define TABP_TAB   4

Definition at line 109 of file nsNativeThemeWin.cpp.

Definition at line 110 of file nsNativeThemeWin.cpp.

#define TB_CHECKED   5

Definition at line 76 of file nsNativeThemeWin.cpp.

Definition at line 77 of file nsNativeThemeWin.cpp.

Definition at line 85 of file nsNativeThemeWin.cpp.

Definition at line 86 of file nsNativeThemeWin.cpp.

#define THEME_COLOR   204

Definition at line 65 of file nsNativeThemeWin.cpp.

#define THEME_FONT   210

Definition at line 66 of file nsNativeThemeWin.cpp.

Definition at line 89 of file nsNativeThemeWin.cpp.

#define TS_ACTIVE   3

Definition at line 71 of file nsNativeThemeWin.cpp.

Definition at line 72 of file nsNativeThemeWin.cpp.

#define TS_FOCUSED   5

Definition at line 73 of file nsNativeThemeWin.cpp.

#define TS_HOVER   2

Definition at line 70 of file nsNativeThemeWin.cpp.

#define TS_NORMAL   1

Definition at line 69 of file nsNativeThemeWin.cpp.

Definition at line 115 of file nsNativeThemeWin.cpp.


Typedef Documentation

typedef HRESULT(WINAPI* CloseThemeDataPtr)(HANDLE hTheme)

Definition at line 123 of file nsNativeThemeWin.cpp.

typedef HRESULT(WINAPI* DrawThemeBackgroundPtr)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)

Definition at line 124 of file nsNativeThemeWin.cpp.

typedef HRESULT(WINAPI* GetThemeColorPtr)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, OUT COLORREF *pFont)

Definition at line 134 of file nsNativeThemeWin.cpp.

typedef HRESULT(WINAPI* GetThemeContentRectPtr)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, RECT *pContentRect)

Definition at line 127 of file nsNativeThemeWin.cpp.

typedef HRESULT(WINAPI* GetThemePartSizePtr)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, int ts, SIZE *psz)

Definition at line 130 of file nsNativeThemeWin.cpp.

typedef HRESULT(WINAPI* GetThemeSysFontPtr)(HANDLE hTheme, int iFontId, OUT LOGFONT *pFont)

Definition at line 133 of file nsNativeThemeWin.cpp.

typedef HANDLE(WINAPI* OpenThemeDataPtr)(HWND hwnd, LPCWSTR pszClassList)

Definition at line 122 of file nsNativeThemeWin.cpp.


Function Documentation

static void DrawTab ( HDC  hdc,
const RECT &  R,
PRInt32  aPosition,
PRBool  aSelected,
PRBool  aDrawLeft,
PRBool  aDrawRight 
) [static]

Definition at line 1400 of file nsNativeThemeWin.cpp.

{
  PRInt32 leftFlag, topFlag, rightFlag, lightFlag, shadeFlag;  
  RECT topRect, sideRect, bottomRect, lightRect, shadeRect;
  PRInt32 selectedOffset, lOffset, rOffset;

  selectedOffset = aSelected ? 1 : 0;
  lOffset = aDrawLeft ? 2 : 0;
  rOffset = aDrawRight ? 2 : 0;

  // Get info for tab orientation/position (Left, Top, Right, Bottom)
  switch (aPosition) {
    case BF_LEFT:
      leftFlag = BF_TOP; topFlag = BF_LEFT;
      rightFlag = BF_BOTTOM;
      lightFlag = BF_DIAGONAL_ENDTOPRIGHT;
      shadeFlag = BF_DIAGONAL_ENDBOTTOMRIGHT;

      ::SetRect(&topRect, R.left, R.top+lOffset, R.right, R.bottom-rOffset);
      ::SetRect(&sideRect, R.left+2, R.top, R.right-2+selectedOffset, R.bottom);
      ::SetRect(&bottomRect, R.right-2, R.top, R.right, R.bottom);
      ::SetRect(&lightRect, R.left, R.top, R.left+3, R.top+3);
      ::SetRect(&shadeRect, R.left+1, R.bottom-2, R.left+2, R.bottom-1);
      break;
    case BF_TOP:    
      leftFlag = BF_LEFT; topFlag = BF_TOP;
      rightFlag = BF_RIGHT;
      lightFlag = BF_DIAGONAL_ENDTOPRIGHT;
      shadeFlag = BF_DIAGONAL_ENDBOTTOMRIGHT;

      ::SetRect(&topRect, R.left+lOffset, R.top, R.right-rOffset, R.bottom);
      ::SetRect(&sideRect, R.left, R.top+2, R.right, R.bottom-1+selectedOffset);
      ::SetRect(&bottomRect, R.left, R.bottom-1, R.right, R.bottom);
      ::SetRect(&lightRect, R.left, R.top, R.left+3, R.top+3);      
      ::SetRect(&shadeRect, R.right-2, R.top+1, R.right-1, R.top+2);      
      break;
    case BF_RIGHT:    
      leftFlag = BF_TOP; topFlag = BF_RIGHT;
      rightFlag = BF_BOTTOM;
      lightFlag = BF_DIAGONAL_ENDTOPLEFT;
      shadeFlag = BF_DIAGONAL_ENDBOTTOMLEFT;

      ::SetRect(&topRect, R.left, R.top+lOffset, R.right, R.bottom-rOffset);
      ::SetRect(&sideRect, R.left+2-selectedOffset, R.top, R.right-2, R.bottom);
      ::SetRect(&bottomRect, R.left, R.top, R.left+2, R.bottom);
      ::SetRect(&lightRect, R.right-3, R.top, R.right-1, R.top+2);
      ::SetRect(&shadeRect, R.right-2, R.bottom-3, R.right, R.bottom-1);
      break;
    case BF_BOTTOM:    
      leftFlag = BF_LEFT; topFlag = BF_BOTTOM;
      rightFlag = BF_RIGHT;
      lightFlag = BF_DIAGONAL_ENDTOPLEFT;
      shadeFlag = BF_DIAGONAL_ENDBOTTOMLEFT;

      ::SetRect(&topRect, R.left+lOffset, R.top, R.right-rOffset, R.bottom);
      ::SetRect(&sideRect, R.left, R.top+2-selectedOffset, R.right, R.bottom-2);
      ::SetRect(&bottomRect, R.left, R.top, R.right, R.top+2);
      ::SetRect(&lightRect, R.left, R.bottom-3, R.left+2, R.bottom-1);
      ::SetRect(&shadeRect, R.right-2, R.bottom-3, R.right, R.bottom-1);
      break;
  }

  // Background
  ::FillRect(hdc, &R, (HBRUSH) (COLOR_3DFACE+1) );

  // Tab "Top"
  ::DrawEdge(hdc, &topRect, EDGE_RAISED, BF_SOFT | topFlag);

  // Tab "Bottom"
  if (!aSelected)
    ::DrawEdge(hdc, &bottomRect, EDGE_RAISED, BF_SOFT | topFlag);

  // Tab "Sides"
  if (!aDrawLeft)
    leftFlag = 0;
  if (!aDrawRight)
    rightFlag = 0;
  ::DrawEdge(hdc, &sideRect, EDGE_RAISED, BF_SOFT | leftFlag | rightFlag);

  // Tab Diagonal Corners
  if (aDrawLeft)
    ::DrawEdge(hdc, &lightRect, EDGE_RAISED, BF_SOFT | lightFlag);

  if (aDrawRight)
    ::DrawEdge(hdc, &shadeRect, EDGE_RAISED, BF_SOFT | shadeFlag);
}

Here is the caller graph for this function:

static void GetNativeRect ( const nsRect aSrc,
RECT &  aDst 
) [static]

Definition at line 192 of file nsNativeThemeWin.cpp.

{
  aDst.top = aSrc.y;
  aDst.bottom = aSrc.y + aSrc.height;
  aDst.left = aSrc.x;
  aDst.right = aSrc.x + aSrc.width;
}

Here is the caller graph for this function:

NS_METHOD NS_NewNativeTheme ( nsISupports *  aOuter,
REFNSIID  aIID,
void **  aResult 
)

Definition at line 1699 of file nsNativeThemeWin.cpp.

{
  if (aOuter)
    return NS_ERROR_NO_AGGREGATION;

  nsNativeThemeWin* theme = new nsNativeThemeWin();
  if (!theme)
    return NS_ERROR_OUT_OF_MEMORY;
  return theme->QueryInterface(aIID, aResult);
}

Variable Documentation

Definition at line 138 of file nsNativeThemeWin.cpp.

Definition at line 139 of file nsNativeThemeWin.cpp.

Definition at line 143 of file nsNativeThemeWin.cpp.

Definition at line 140 of file nsNativeThemeWin.cpp.

Definition at line 141 of file nsNativeThemeWin.cpp.

Definition at line 142 of file nsNativeThemeWin.cpp.

const char kThemeLibraryName[] = "uxtheme.dll" [static]

Definition at line 145 of file nsNativeThemeWin.cpp.

Definition at line 137 of file nsNativeThemeWin.cpp.