1 /////////////////////////////////////////////////////////////////////////////// 
   2 // Name:        msw/renderer.cpp 
   3 // Purpose:     implementation of wxRendererNative for Windows 
   4 // Author:      Vadim Zeitlin 
   8 // Copyright:   (c) 2003 Vadim Zeitlin <vadim@wxwindows.org> 
   9 // License:     wxWindows licence 
  10 /////////////////////////////////////////////////////////////////////////////// 
  12 // ============================================================================ 
  14 // ============================================================================ 
  16 // ---------------------------------------------------------------------------- 
  18 // ---------------------------------------------------------------------------- 
  20 // for compilers that support precompilation, includes "wx.h". 
  21 #include "wx/wxprec.h" 
  28     #include "wx/string.h" 
  29     #include "wx/window.h" 
  33 #include "wx/splitter.h" 
  34 #include "wx/renderer.h" 
  35 #include "wx/msw/uxtheme.h" 
  36 #include "wx/msw/private.h" 
  38 // ---------------------------------------------------------------------------- 
  39 // wxRendererMSW: wxRendererNative implementation for "old" Win32 systems 
  40 // ---------------------------------------------------------------------------- 
  42 class WXDLLEXPORT wxRendererMSW 
: public wxDelegateRendererNative
 
  47     static wxRendererNative
& Get(); 
  49     virtual void DrawComboBoxDropButton(wxWindow 
*win
, 
  55     DECLARE_NO_COPY_CLASS(wxRendererMSW
) 
  58 // ---------------------------------------------------------------------------- 
  59 // wxRendererXP: wxRendererNative implementation for Windows XP and later 
  60 // ---------------------------------------------------------------------------- 
  62 class WXDLLEXPORT wxRendererXP 
: public wxDelegateRendererNative
 
  65     wxRendererXP() : wxDelegateRendererNative(wxRendererMSW::Get()) { } 
  67     static wxRendererNative
& Get(); 
  69     virtual void DrawSplitterBorder(wxWindow 
*win
, 
  73     virtual void DrawSplitterSash(wxWindow 
*win
, 
  80     virtual wxSplitterRenderParams 
GetSplitterParams(const wxWindow 
*win
); 
  83     DECLARE_NO_COPY_CLASS(wxRendererXP
) 
  86 // ============================================================================ 
  87 // wxRendererNative and wxRendererMSW implementation 
  88 // ============================================================================ 
  91 wxRendererNative
& wxRendererNative::GetDefault() 
  93     wxUxThemeEngine 
*themeEngine 
= wxUxThemeEngine::Get(); 
  94     return themeEngine 
&& themeEngine
->IsAppThemed() ? wxRendererXP::Get() 
  95                                                      : wxRendererMSW::Get(); 
  99 wxRendererNative
& wxRendererMSW::Get() 
 101     static wxRendererMSW s_rendererMSW
; 
 103     return s_rendererMSW
; 
 107 wxRendererMSW::DrawComboBoxDropButton(wxWindow 
* WXUNUSED(win
), 
 113     r
.left 
= rect
.GetLeft(); 
 114     r
.top 
= rect
.GetTop(); 
 115     r
.bottom 
= rect
.GetBottom(); 
 116     r
.right 
= rect
.GetRight(); 
 118     int style 
= DFCS_SCROLLCOMBOBOX
; 
 119     if ( flags 
& wxCONTROL_DISABLED 
) 
 120         style 
|= DFCS_INACTIVE
; 
 121     if ( flags 
& wxCONTROL_PRESSED 
) 
 122         style 
|= DFCS_PUSHED
; 
 124     ::DrawFrameControl(GetHdcOf(dc
), &r
, DFC_SCROLL
, style
); 
 127 // ============================================================================ 
 128 // wxRendererXP implementation 
 129 // ============================================================================ 
 132 wxRendererNative
& wxRendererXP::Get() 
 134     static wxRendererXP s_rendererXP
; 
 139 // ---------------------------------------------------------------------------- 
 141 // ---------------------------------------------------------------------------- 
 143 // the width of the sash: this is the same as used by Explorer... 
 144 static const wxCoord SASH_WIDTH 
= 4; 
 146 wxSplitterRenderParams
 
 147 wxRendererXP::GetSplitterParams(const wxWindow 
* win
) 
 149     if (win
->GetWindowStyle() & wxSP_NO_XP_THEME
) 
 150         return m_rendererNative
.GetSplitterParams(win
); 
 152         return wxSplitterRenderParams(SASH_WIDTH
, 0, false); 
 156 wxRendererXP::DrawSplitterBorder(wxWindow 
* win
, 
 161     if (win
->GetWindowStyle() & wxSP_NO_XP_THEME
) 
 163         m_rendererNative
.DrawSplitterBorder(win
, dc
, rect
, flags
); 
 168 wxRendererXP::DrawSplitterSash(wxWindow 
*win
, 
 172                                wxOrientation orient
, 
 175     if ( !win
->HasFlag(wxSP_NO_XP_THEME
) ) 
 177         wxUxThemeHandle 
hTheme(win
, L
"WINDOW"); 
 181             if ( orient 
== wxVERTICAL 
) 
 183                 rect
.left 
= position
; 
 184                 rect
.right 
= position 
+ SASH_WIDTH
; 
 186                 rect
.bottom 
= size
.y
; 
 193                 rect
.bottom 
= position 
+ SASH_WIDTH
; 
 196             wxUxThemeEngine::Get()->DrawThemeBackground
 
 200                                         29, // WP_DIALOG: dlg background 
 201                                         0, // no particular state 
 209     m_rendererNative
.DrawSplitterSash(win
, dc
, size
, position
, orient
, flags
);