]>
git.saurik.com Git - wxWidgets.git/blob - src/common/effects.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/effects.cpp
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/effects.h"
22 #include "wx/dcmemory.h"
24 #include "wx/settings.h"
25 #include "wx/gdicmn.h"
29 * wxEffects: various 3D effects
32 IMPLEMENT_CLASS(wxEffects
, wxObject
)
34 // Assume system colours
35 wxEffects::wxEffects()
37 m_highlightColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DHILIGHT
) ;
38 m_lightShadow
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT
) ;
39 m_faceColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
) ;
40 m_mediumShadow
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW
) ;
41 m_darkShadow
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW
) ;
44 // Going from lightest to darkest
45 wxEffects::wxEffects(const wxColour
& highlightColour
, const wxColour
& lightShadow
,
46 const wxColour
& faceColour
, const wxColour
& mediumShadow
, const wxColour
& darkShadow
)
48 m_highlightColour
= highlightColour
;
49 m_lightShadow
= lightShadow
;
50 m_faceColour
= faceColour
;
51 m_mediumShadow
= mediumShadow
;
52 m_darkShadow
= darkShadow
;
56 void wxEffects::DrawSunkenEdge(wxDC
& dc
, const wxRect
& rect
, int WXUNUSED(borderSize
))
58 wxPen
highlightPen(m_highlightColour
, 1, wxSOLID
);
59 wxPen
lightShadowPen(m_lightShadow
, 1, wxSOLID
);
60 wxPen
facePen(m_faceColour
, 1, wxSOLID
);
61 wxPen
mediumShadowPen(m_mediumShadow
, 1, wxSOLID
);
62 wxPen
darkShadowPen(m_darkShadow
, 1, wxSOLID
);
65 // Draw a medium shadow pen on left and top, followed by dark shadow line to
66 // right and below of these lines
68 dc
.SetPen(mediumShadowPen
);
69 dc
.DrawLine(rect
.x
, rect
.y
, rect
.x
+rect
.width
-1, rect
.y
); // Top
70 dc
.DrawLine(rect
.x
, rect
.y
, rect
.x
, rect
.y
+rect
.height
-1); // Left
72 dc
.SetPen(darkShadowPen
);
73 dc
.DrawLine(rect
.x
+1, rect
.y
+1, rect
.x
+rect
.width
-2, rect
.y
+1); // Top
74 dc
.DrawLine(rect
.x
+1, rect
.y
+1, rect
.x
+1, rect
.y
+rect
.height
-1); // Left
78 dc
.SetPen(highlightPen
);
79 dc
.DrawLine(rect
.x
+rect
.width
-1, rect
.y
, rect
.x
+rect
.width
-1, rect
.y
+rect
.height
-1); // Right
80 dc
.DrawLine(rect
.x
, rect
.y
+rect
.height
-1, rect
.x
+rect
.width
, rect
.y
+rect
.height
-1); // Bottom
82 dc
.SetPen(lightShadowPen
);
83 dc
.DrawLine(rect
.x
+rect
.width
-2, rect
.y
+1, rect
.x
+rect
.width
-2, rect
.y
+rect
.height
-2); // Right
84 dc
.DrawLine(rect
.x
+1, rect
.y
+rect
.height
-2, rect
.x
+rect
.width
-1, rect
.y
+rect
.height
-2); // Bottom
89 bool wxEffects::TileBitmap(const wxRect
& rect
, wxDC
& dc
, const wxBitmap
& bitmap
)
91 static bool hiColour
= (wxDisplayDepth() >= 16) ;
93 int w
= bitmap
.GetWidth();
94 int h
= bitmap
.GetHeight();
99 if (bitmap
.GetPalette() && !hiColour
)
101 dc
.SetPalette(* bitmap
.GetPalette());
102 dcMem
.SetPalette(* bitmap
.GetPalette());
104 #endif // wxUSE_PALETTE
106 dcMem
.SelectObject(bitmap
);
109 for (i
= rect
.x
; i
< rect
.x
+ rect
.width
; i
+= w
)
111 for (j
= rect
.y
; j
< rect
.y
+ rect
.height
; j
+= h
)
112 dc
.Blit(i
, j
, bitmap
.GetWidth(), bitmap
.GetHeight(), & dcMem
, 0, 0);
114 dcMem
.SelectObject(wxNullBitmap
);
117 if (bitmap
.GetPalette() && !hiColour
)
119 dc
.SetPalette(wxNullPalette
);
120 dcMem
.SetPalette(wxNullPalette
);
122 #endif // wxUSE_PALETTE