]>
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
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #include "wx/effects.h"
21 #include "wx/dcmemory.h"
23 #include "wx/settings.h"
24 #include "wx/gdicmn.h"
27 #if WXWIN_COMPATIBILITY_2_8
30 * wxEffectsImpl: various 3D effects
33 IMPLEMENT_CLASS(wxEffectsImpl
, wxObject
)
35 // Assume system colours
36 wxEffectsImpl::wxEffectsImpl()
38 m_highlightColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DHILIGHT
) ;
39 m_lightShadow
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT
) ;
40 m_faceColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
) ;
41 m_mediumShadow
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW
) ;
42 m_darkShadow
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW
) ;
45 // Going from lightest to darkest
46 wxEffectsImpl::wxEffectsImpl(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 wxEffectsImpl::DrawSunkenEdge(wxDC
& dc
, const wxRect
& rect
, int WXUNUSED(borderSize
))
59 wxPen
highlightPen(m_highlightColour
, 1, wxPENSTYLE_SOLID
);
60 wxPen
lightShadowPen(m_lightShadow
, 1, wxPENSTYLE_SOLID
);
61 wxPen
facePen(m_faceColour
, 1, wxPENSTYLE_SOLID
);
62 wxPen
mediumShadowPen(m_mediumShadow
, 1, wxPENSTYLE_SOLID
);
63 wxPen
darkShadowPen(m_darkShadow
, 1, wxPENSTYLE_SOLID
);
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 wxEffectsImpl::TileBitmap(const wxRect
& rect
, wxDC
& dc
, const wxBitmap
& bitmap
)
92 int w
= bitmap
.GetWidth();
93 int h
= bitmap
.GetHeight();
98 static bool hiColour
= (wxDisplayDepth() >= 16) ;
99 if (bitmap
.GetPalette() && !hiColour
)
101 dc
.SetPalette(* bitmap
.GetPalette());
102 dcMem
.SetPalette(* bitmap
.GetPalette());
104 #endif // wxUSE_PALETTE
106 dcMem
.SelectObjectAsSource(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
127 #endif // WXWIN_COMPATIBILITY_2_8