1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxEffects implementation
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "effects.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
23 #include "wx/gdicmn.h"
25 #include "wx/dcmemory.h"
26 #include "wx/settings.h"
27 #include "wx/effects.h"
30 * wxEffects: various 3D effects
33 IMPLEMENT_CLASS(wxEffects
, wxObject
)
35 // Assume system colours
36 wxEffects::wxEffects()
38 m_highlightColour
= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DHILIGHT
) ;
39 m_lightShadow
= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT
) ;
40 m_faceColour
= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
) ;
41 m_mediumShadow
= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DSHADOW
) ;
42 m_darkShadow
= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DDKSHADOW
) ;
45 // Going from lightest to darkest
46 wxEffects::wxEffects(const wxColour
& highlightColour
, const wxColour
& lightShadow
,
47 const wxColour
& faceColour
, const wxColour
& mediumShadow
, const wxColour
& darkShadow
)
49 m_highlightColour
= highlightColour
;
50 m_lightShadow
= lightShadow
;
51 m_faceColour
= faceColour
;
52 m_mediumShadow
= mediumShadow
;
53 m_darkShadow
= darkShadow
;
57 void wxEffects::DrawSunkenEdge(wxDC
& dc
, const wxRect
& rect
, int WXUNUSED(borderSize
))
59 wxPen
highlightPen(m_highlightColour
, 1, wxSOLID
);
60 wxPen
lightShadowPen(m_lightShadow
, 1, wxSOLID
);
61 wxPen
facePen(m_faceColour
, 1, wxSOLID
);
62 wxPen
mediumShadowPen(m_mediumShadow
, 1, wxSOLID
);
63 wxPen
darkShadowPen(m_darkShadow
, 1, wxSOLID
);
66 // Draw a medium shadow pen on left and top, followed by dark shadow line to
67 // right and below of these lines
69 dc
.SetPen(mediumShadowPen
);
70 dc
.DrawLine(rect
.x
, rect
.y
, rect
.x
+rect
.width
-1, rect
.y
); // Top
71 dc
.DrawLine(rect
.x
, rect
.y
, rect
.x
, rect
.y
+rect
.height
-1); // Left
73 dc
.SetPen(darkShadowPen
);
74 dc
.DrawLine(rect
.x
+1, rect
.y
+1, rect
.x
+rect
.width
-2, rect
.y
+1); // Top
75 dc
.DrawLine(rect
.x
+1, rect
.y
+1, rect
.x
+1, rect
.y
+rect
.height
-1); // Left
79 dc
.SetPen(highlightPen
);
80 dc
.DrawLine(rect
.x
+rect
.width
-1, rect
.y
, rect
.x
+rect
.width
-1, rect
.y
+rect
.height
-1); // Right
81 dc
.DrawLine(rect
.x
, rect
.y
+rect
.height
-1, rect
.x
+rect
.width
, rect
.y
+rect
.height
-1); // Bottom
83 dc
.SetPen(lightShadowPen
);
84 dc
.DrawLine(rect
.x
+rect
.width
-2, rect
.y
+1, rect
.x
+rect
.width
-2, rect
.y
+rect
.height
-2); // Right
85 dc
.DrawLine(rect
.x
+1, rect
.y
+rect
.height
-2, rect
.x
+rect
.width
-1, rect
.y
+rect
.height
-2); // Bottom
90 bool wxEffects::TileBitmap(const wxRect
& rect
, wxDC
& dc
, wxBitmap
& bitmap
)
92 static bool hiColour
= (wxDisplayDepth() >= 16) ;
94 int w
= bitmap
.GetWidth();
95 int h
= bitmap
.GetHeight();
99 if (bitmap
.GetPalette() && !hiColour
)
101 dc
.SetPalette(* bitmap
.GetPalette());
102 dcMem
.SetPalette(* bitmap
.GetPalette());
104 dcMem
.SelectObject(bitmap
);
107 for (i
= rect
.x
; i
< rect
.x
+ rect
.width
; i
+= w
)
109 for (j
= rect
.y
; j
< rect
.y
+ rect
.height
; j
+= h
)
110 dc
.Blit(i
, j
, bitmap
.GetWidth(), bitmap
.GetHeight(), & dcMem
, 0, 0);
112 dcMem
.SelectObject(wxNullBitmap
);
114 if (bitmap
.GetPalette() && !hiColour
)
116 dc
.SetPalette(wxNullPalette
);
117 dcMem
.SetPalette(wxNullPalette
);