Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 130 lines (103 sloc) 4.041 kb
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
1 /////////////////////////////////////////////////////////////////////////////
8838fc5 Include wx/dcmemory.h according to precompiled headers of wx/wx.h (with ...
Włodzimierz Skiba authored
2 // Name: src/common/effects.cpp
792bd64 VZ deprecate wxEffects
vadz authored
3 // Purpose: wxEffectsImpl implementation
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 25/4/2000
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
c668316 JulianSmart Use old licence name
JulianSmart authored
9 // Licence: wxWindows licence
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
8838fc5 Include wx/dcmemory.h according to precompiled headers of wx/wx.h (with ...
Włodzimierz Skiba authored
16 #pragma hdrstop
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
17 #endif
18
8838fc5 Include wx/dcmemory.h according to precompiled headers of wx/wx.h (with ...
Włodzimierz Skiba authored
19 #include "wx/effects.h"
20
21 #ifndef WX_PRECOMP
22 #include "wx/dcmemory.h"
726a0df Include wx/pen.h according to precompiled headers of wx/wx.h (with other...
Włodzimierz Skiba authored
23 #include "wx/pen.h"
b928eb6 Include wx/settings.h according to precompiled headers of wx/wx.h (with ...
Włodzimierz Skiba authored
24 #include "wx/settings.h"
f7f59c5 Include wx/gdicmn.h according to precompiled headers of wx/wx.h (with ot...
Włodzimierz Skiba authored
25 #include "wx/gdicmn.h"
8838fc5 Include wx/dcmemory.h according to precompiled headers of wx/wx.h (with ...
Włodzimierz Skiba authored
26 #endif //WX_PRECOMP
27
885792e VZ fix the wrong #ifdef WXWIN_COMPATIBILITY_2_8 checks, #if should be used ...
vadz authored
28 #if WXWIN_COMPATIBILITY_2_8
29
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
30 /*
792bd64 VZ deprecate wxEffects
vadz authored
31 * wxEffectsImpl: various 3D effects
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
32 */
33
792bd64 VZ deprecate wxEffects
vadz authored
34 IMPLEMENT_CLASS(wxEffectsImpl, wxObject)
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
35
36 // Assume system colours
792bd64 VZ deprecate wxEffects
vadz authored
37 wxEffectsImpl::wxEffectsImpl()
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
38 {
048f358 Václav Slavík use the new wxSystemSettings API everywhere
vslavik authored
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) ;
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
44 }
45
46 // Going from lightest to darkest
792bd64 VZ deprecate wxEffects
vadz authored
47 wxEffectsImpl::wxEffectsImpl(const wxColour& highlightColour, const wxColour& lightShadow,
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
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
792bd64 VZ deprecate wxEffects
vadz authored
58 void wxEffectsImpl::DrawSunkenEdge(wxDC& dc, const wxRect& rect, int WXUNUSED(borderSize))
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
59 {
466133d fix a huge number of build errors
Paul Cornett authored
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);
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
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
792bd64 VZ deprecate wxEffects
vadz authored
91 bool wxEffectsImpl::TileBitmap(const wxRect& rect, wxDC& dc, const wxBitmap& bitmap)
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
92 {
93 int w = bitmap.GetWidth();
94 int h = bitmap.GetHeight();
883c71c Updates to fix Watcom C/C++ 11.0 compiler warning problems. Now compiles
Kendall Bennett authored
95
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
96 wxMemoryDC dcMem;
883c71c Updates to fix Watcom C/C++ 11.0 compiler warning problems. Now compiles
Kendall Bennett authored
97
5646328 VZ added wxUSE_PALETTE and fixed compilation with it set to 0
vadz authored
98 #if wxUSE_PALETTE
4dfdade VZ fix unused variable warning when wxUSE_PALETTE==0
vadz authored
99 static bool hiColour = (wxDisplayDepth() >= 16) ;
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
100 if (bitmap.GetPalette() && !hiColour)
101 {
102 dc.SetPalette(* bitmap.GetPalette());
103 dcMem.SetPalette(* bitmap.GetPalette());
104 }
5646328 VZ added wxUSE_PALETTE and fixed compilation with it set to 0
vadz authored
105 #endif // wxUSE_PALETTE
106
d5e7486 VZ Added wxMemoryDC::SelectObjectAsSource() and make SelectObject() unshare
vadz authored
107 dcMem.SelectObjectAsSource(bitmap);
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
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
5646328 VZ added wxUSE_PALETTE and fixed compilation with it set to 0
vadz authored
117 #if wxUSE_PALETTE
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
118 if (bitmap.GetPalette() && !hiColour)
119 {
120 dc.SetPalette(wxNullPalette);
121 dcMem.SetPalette(wxNullPalette);
122 }
5646328 VZ added wxUSE_PALETTE and fixed compilation with it set to 0
vadz authored
123 #endif // wxUSE_PALETTE
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
124
bd2c0e3 Source cleaning: tabs, whitespaces, -1/wxID_ANY, TRUE/true, FALSE/false.
Włodzimierz Skiba authored
125 return true;
f88237e JulianSmart Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
JulianSmart authored
126 }
885792e VZ fix the wrong #ifdef WXWIN_COMPATIBILITY_2_8 checks, #if should be used ...
vadz authored
127
128 #endif // WXWIN_COMPATIBILITY_2_8
129
Something went wrong with that request. Please try again.