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