]>
git.saurik.com Git - wxWidgets.git/blob - src/common/effects.cpp
5a7ac476e0b12c903a001c9e126c43c99a7364ba
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxEffects 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/gdicmn.h"
21 #include "wx/dcmemory.h"
22 #include "wx/settings.h"
23 #include "wx/effects.h"
26 * wxEffects: various 3D effects
29 IMPLEMENT_CLASS(wxEffects
, wxObject
)
31 // Assume system colours
32 wxEffects::wxEffects()
34 m_highlightColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DHILIGHT
) ;
35 m_lightShadow
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT
) ;
36 m_faceColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
) ;
37 m_mediumShadow
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW
) ;
38 m_darkShadow
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW
) ;
41 // Going from lightest to darkest
42 wxEffects::wxEffects(const wxColour
& highlightColour
, const wxColour
& lightShadow
,
43 const wxColour
& faceColour
, const wxColour
& mediumShadow
, const wxColour
& darkShadow
)
45 m_highlightColour
= highlightColour
;
46 m_lightShadow
= lightShadow
;
47 m_faceColour
= faceColour
;
48 m_mediumShadow
= mediumShadow
;
49 m_darkShadow
= darkShadow
;
53 void wxEffects::DrawSunkenEdge(wxDC
& dc
, const wxRect
& rect
, int WXUNUSED(borderSize
))
55 wxPen
highlightPen(m_highlightColour
, 1, wxSOLID
);
56 wxPen
lightShadowPen(m_lightShadow
, 1, wxSOLID
);
57 wxPen
facePen(m_faceColour
, 1, wxSOLID
);
58 wxPen
mediumShadowPen(m_mediumShadow
, 1, wxSOLID
);
59 wxPen
darkShadowPen(m_darkShadow
, 1, wxSOLID
);
62 // Draw a medium shadow pen on left and top, followed by dark shadow line to
63 // right and below of these lines
65 dc
.SetPen(mediumShadowPen
);
66 dc
.DrawLine(rect
.x
, rect
.y
, rect
.x
+rect
.width
-1, rect
.y
); // Top
67 dc
.DrawLine(rect
.x
, rect
.y
, rect
.x
, rect
.y
+rect
.height
-1); // Left
69 dc
.SetPen(darkShadowPen
);
70 dc
.DrawLine(rect
.x
+1, rect
.y
+1, rect
.x
+rect
.width
-2, rect
.y
+1); // Top
71 dc
.DrawLine(rect
.x
+1, rect
.y
+1, rect
.x
+1, rect
.y
+rect
.height
-1); // Left
75 dc
.SetPen(highlightPen
);
76 dc
.DrawLine(rect
.x
+rect
.width
-1, rect
.y
, rect
.x
+rect
.width
-1, rect
.y
+rect
.height
-1); // Right
77 dc
.DrawLine(rect
.x
, rect
.y
+rect
.height
-1, rect
.x
+rect
.width
, rect
.y
+rect
.height
-1); // Bottom
79 dc
.SetPen(lightShadowPen
);
80 dc
.DrawLine(rect
.x
+rect
.width
-2, rect
.y
+1, rect
.x
+rect
.width
-2, rect
.y
+rect
.height
-2); // Right
81 dc
.DrawLine(rect
.x
+1, rect
.y
+rect
.height
-2, rect
.x
+rect
.width
-1, rect
.y
+rect
.height
-2); // Bottom
86 bool wxEffects::TileBitmap(const wxRect
& rect
, wxDC
& dc
, const wxBitmap
& bitmap
)
88 static bool hiColour
= (wxDisplayDepth() >= 16) ;
90 int w
= bitmap
.GetWidth();
91 int h
= bitmap
.GetHeight();
96 if (bitmap
.GetPalette() && !hiColour
)
98 dc
.SetPalette(* bitmap
.GetPalette());
99 dcMem
.SetPalette(* bitmap
.GetPalette());
101 #endif // wxUSE_PALETTE
103 dcMem
.SelectObject(bitmap
);
106 for (i
= rect
.x
; i
< rect
.x
+ rect
.width
; i
+= w
)
108 for (j
= rect
.y
; j
< rect
.y
+ rect
.height
; j
+= h
)
109 dc
.Blit(i
, j
, bitmap
.GetWidth(), bitmap
.GetHeight(), & dcMem
, 0, 0);
111 dcMem
.SelectObject(wxNullBitmap
);
114 if (bitmap
.GetPalette() && !hiColour
)
116 dc
.SetPalette(wxNullPalette
);
117 dcMem
.SetPalette(wxNullPalette
);
119 #endif // wxUSE_PALETTE