]>
git.saurik.com Git - wxWidgets.git/blob - src/common/effects.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/effects.cpp
3 // Purpose: wxEffectsImpl implementation
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
19 #include "wx/effects.h"
22 #include "wx/dcmemory.h"
24 #include "wx/settings.h"
25 #include "wx/gdicmn.h"
28 #if WXWIN_COMPATIBILITY_2_8
31 * wxEffectsImpl: various 3D effects
34 IMPLEMENT_CLASS(wxEffectsImpl
, wxObject
)
36 // Assume system colours
37 wxEffectsImpl::wxEffectsImpl()
39 m_highlightColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DHILIGHT
) ;
40 m_lightShadow
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT
) ;
41 m_faceColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
) ;
42 m_mediumShadow
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW
) ;
43 m_darkShadow
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW
) ;
46 // Going from lightest to darkest
47 wxEffectsImpl::wxEffectsImpl(const wxColour
& highlightColour
, const wxColour
& lightShadow
,
48 const wxColour
& faceColour
, const wxColour
& mediumShadow
, const wxColour
& darkShadow
)
50 m_highlightColour
= highlightColour
;
51 m_lightShadow
= lightShadow
;
52 m_faceColour
= faceColour
;
53 m_mediumShadow
= mediumShadow
;
54 m_darkShadow
= darkShadow
;
58 void wxEffectsImpl::DrawSunkenEdge(wxDC
& dc
, const wxRect
& rect
, int WXUNUSED(borderSize
))
60 wxPen
highlightPen(m_highlightColour
, 1, wxPENSTYLE_SOLID
);
61 wxPen
lightShadowPen(m_lightShadow
, 1, wxPENSTYLE_SOLID
);
62 wxPen
facePen(m_faceColour
, 1, wxPENSTYLE_SOLID
);
63 wxPen
mediumShadowPen(m_mediumShadow
, 1, wxPENSTYLE_SOLID
);
64 wxPen
darkShadowPen(m_darkShadow
, 1, wxPENSTYLE_SOLID
);
67 // Draw a medium shadow pen on left and top, followed by dark shadow line to
68 // right and below of these lines
70 dc
.SetPen(mediumShadowPen
);
71 dc
.DrawLine(rect
.x
, rect
.y
, rect
.x
+rect
.width
-1, rect
.y
); // Top
72 dc
.DrawLine(rect
.x
, rect
.y
, rect
.x
, rect
.y
+rect
.height
-1); // Left
74 dc
.SetPen(darkShadowPen
);
75 dc
.DrawLine(rect
.x
+1, rect
.y
+1, rect
.x
+rect
.width
-2, rect
.y
+1); // Top
76 dc
.DrawLine(rect
.x
+1, rect
.y
+1, rect
.x
+1, rect
.y
+rect
.height
-1); // Left
80 dc
.SetPen(highlightPen
);
81 dc
.DrawLine(rect
.x
+rect
.width
-1, rect
.y
, rect
.x
+rect
.width
-1, rect
.y
+rect
.height
-1); // Right
82 dc
.DrawLine(rect
.x
, rect
.y
+rect
.height
-1, rect
.x
+rect
.width
, rect
.y
+rect
.height
-1); // Bottom
84 dc
.SetPen(lightShadowPen
);
85 dc
.DrawLine(rect
.x
+rect
.width
-2, rect
.y
+1, rect
.x
+rect
.width
-2, rect
.y
+rect
.height
-2); // Right
86 dc
.DrawLine(rect
.x
+1, rect
.y
+rect
.height
-2, rect
.x
+rect
.width
-1, rect
.y
+rect
.height
-2); // Bottom
91 bool wxEffectsImpl::TileBitmap(const wxRect
& rect
, wxDC
& dc
, const wxBitmap
& bitmap
)
93 int w
= bitmap
.GetWidth();
94 int h
= bitmap
.GetHeight();
99 static bool hiColour
= (wxDisplayDepth() >= 16) ;
100 if (bitmap
.GetPalette() && !hiColour
)
102 dc
.SetPalette(* bitmap
.GetPalette());
103 dcMem
.SetPalette(* bitmap
.GetPalette());
105 #endif // wxUSE_PALETTE
107 dcMem
.SelectObjectAsSource(bitmap
);
110 for (i
= rect
.x
; i
< rect
.x
+ rect
.width
; i
+= w
)
112 for (j
= rect
.y
; j
< rect
.y
+ rect
.height
; j
+= h
)
113 dc
.Blit(i
, j
, bitmap
.GetWidth(), bitmap
.GetHeight(), & dcMem
, 0, 0);
115 dcMem
.SelectObject(wxNullBitmap
);
118 if (bitmap
.GetPalette() && !hiColour
)
120 dc
.SetPalette(wxNullPalette
);
121 dcMem
.SetPalette(wxNullPalette
);
123 #endif // wxUSE_PALETTE
128 #endif // WXWIN_COMPATIBILITY_2_8