]> git.saurik.com Git - wxWidgets.git/blame - src/common/effects.cpp
PCH-less compilation fix
[wxWidgets.git] / src / common / effects.cpp
CommitLineData
3f4fc796 1/////////////////////////////////////////////////////////////////////////////
f38924e8 2// Name: src/common/effects.cpp
fe1efe6a 3// Purpose: wxEffectsImpl implementation
3f4fc796
JS
4// Author: Julian Smart
5// Modified by:
6// Created: 25/4/2000
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
3f4fc796
JS
10/////////////////////////////////////////////////////////////////////////////
11
3f4fc796
JS
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
f38924e8 16 #pragma hdrstop
3f4fc796
JS
17#endif
18
f38924e8
WS
19#include "wx/effects.h"
20
21#ifndef WX_PRECOMP
22 #include "wx/dcmemory.h"
f5590243 23 #include "wx/pen.h"
9eddec69 24 #include "wx/settings.h"
dd05139a 25 #include "wx/gdicmn.h"
f38924e8
WS
26#endif //WX_PRECOMP
27
831b64f3
VZ
28#if WXWIN_COMPATIBILITY_2_8
29
3f4fc796 30/*
fe1efe6a 31 * wxEffectsImpl: various 3D effects
3f4fc796
JS
32 */
33
fe1efe6a 34IMPLEMENT_CLASS(wxEffectsImpl, wxObject)
3f4fc796
JS
35
36// Assume system colours
fe1efe6a 37wxEffectsImpl::wxEffectsImpl()
3f4fc796 38{
a756f210
VS
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) ;
3f4fc796
JS
44}
45
46// Going from lightest to darkest
fe1efe6a 47wxEffectsImpl::wxEffectsImpl(const wxColour& highlightColour, const wxColour& lightShadow,
3f4fc796
JS
48 const wxColour& faceColour, const wxColour& mediumShadow, const wxColour& darkShadow)
49{
50 m_highlightColour = highlightColour;
51 m_lightShadow = lightShadow;
52 m_faceColour = faceColour;
53 m_mediumShadow = mediumShadow;
54 m_darkShadow = darkShadow;
55}
56
57// Draw a sunken edge
fe1efe6a 58void wxEffectsImpl::DrawSunkenEdge(wxDC& dc, const wxRect& rect, int WXUNUSED(borderSize))
3f4fc796 59{
04ee05f9
PC
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);
3f4fc796
JS
65
66 //// LEFT AND TOP
67 // Draw a medium shadow pen on left and top, followed by dark shadow line to
68 // right and below of these lines
69
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
73
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
77
78 //// RIGHT AND BOTTOM
79
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
83
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
87
88 dc.SetPen(wxNullPen);
89}
90
fe1efe6a 91bool wxEffectsImpl::TileBitmap(const wxRect& rect, wxDC& dc, const wxBitmap& bitmap)
3f4fc796 92{
3f4fc796
JS
93 int w = bitmap.GetWidth();
94 int h = bitmap.GetHeight();
33ac7e6f 95
3f4fc796 96 wxMemoryDC dcMem;
33ac7e6f 97
d275c7eb 98#if wxUSE_PALETTE
0055a7a4 99 static bool hiColour = (wxDisplayDepth() >= 16) ;
3f4fc796
JS
100 if (bitmap.GetPalette() && !hiColour)
101 {
102 dc.SetPalette(* bitmap.GetPalette());
103 dcMem.SetPalette(* bitmap.GetPalette());
104 }
d275c7eb
VZ
105#endif // wxUSE_PALETTE
106
fea35690 107 dcMem.SelectObjectAsSource(bitmap);
3f4fc796
JS
108
109 int i, j;
110 for (i = rect.x; i < rect.x + rect.width; i += w)
111 {
112 for (j = rect.y; j < rect.y + rect.height; j+= h)
113 dc.Blit(i, j, bitmap.GetWidth(), bitmap.GetHeight(), & dcMem, 0, 0);
114 }
115 dcMem.SelectObject(wxNullBitmap);
116
d275c7eb 117#if wxUSE_PALETTE
3f4fc796
JS
118 if (bitmap.GetPalette() && !hiColour)
119 {
120 dc.SetPalette(wxNullPalette);
121 dcMem.SetPalette(wxNullPalette);
122 }
d275c7eb 123#endif // wxUSE_PALETTE
3f4fc796 124
1a18887b 125 return true;
3f4fc796 126}
831b64f3
VZ
127
128#endif // WXWIN_COMPATIBILITY_2_8
129