Upstream tarball 20080414
[amule.git] / src / ColorFrameCtrl.cpp
blobd1b6a9c27545820bb9e2ae784d12ffbc921e5000
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002 Merkur ( devs@emule-project.net / http://www.emule-project.net )
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include <wx/dcclient.h>
28 #include "ColorFrameCtrl.h" // Interface declarations
30 /////////////////////////////////////////////////////////////////////////////
31 // CColorFrameCtrl
32 CColorFrameCtrl::CColorFrameCtrl( wxWindow* parent,int id, int wid,int hei )
33 : wxControl(parent,id,wxDefaultPosition,wxSize(wid,hei)),
34 m_brushBack(wxColour(0,0,0),wxSOLID),
35 m_brushFrame(wxColour(0,255,255),wxSOLID)
37 m_crBackColor = RGB( 0, 0, 0) ; // see also SetBackgroundColor
38 m_crFrameColor = RGB( 0, 255, 255) ; // see also SetFrameColor
39 SetSizeHints(wid,hei,wid,hei,0,0);
40 wxRect rc=GetClientRect();
41 m_rectClient.left=rc.x;
42 m_rectClient.top=rc.y;
43 m_rectClient.right=rc.x + wid;
44 m_rectClient.bottom=rc.y + hei;
46 } // CColorFrameCtrl
48 /////////////////////////////////////////////////////////////////////////////
49 CColorFrameCtrl::~CColorFrameCtrl()
51 } // ~CColorFrameCtrl
54 BEGIN_EVENT_TABLE(CColorFrameCtrl,wxControl)
55 EVT_PAINT(CColorFrameCtrl::OnPaint)
56 EVT_SIZE(CColorFrameCtrl::OnSize)
57 END_EVENT_TABLE()
59 /////////////////////////////////////////////////////////////////////////////
60 // CColorFrameCtrl message handlers
62 /////////////////////////////////////////////////////////////////////////////
63 void CColorFrameCtrl::SetFrameColor( COLORREF color )
65 m_crFrameColor = color;
66 m_brushFrame.SetColour(wxColour(GetRValue(m_crFrameColor),
67 GetGValue(m_crFrameColor),
68 GetBValue(m_crFrameColor)));
70 Refresh(FALSE);
72 } // SetFrameColor
75 /////////////////////////////////////////////////////////////////////////////
76 void CColorFrameCtrl::SetBackgroundColor(COLORREF color)
78 m_crBackColor = color ;
80 m_brushBack.SetColour(wxColour(GetRValue(m_crBackColor),
81 GetGValue(m_crBackColor),
82 GetBValue(m_crBackColor)));
84 // clear out the existing garbage, re-start with a clean plot
85 Refresh(FALSE);
87 } // SetBackgroundColor
90 ////////////////////////////////////////////////////////////////////////////
91 void CColorFrameCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt))
93 wxPaintDC dc(this);
95 wxRect rc;
96 rc.x=m_rectClient.left;
97 rc.y=m_rectClient.top;
98 rc.width=m_rectClient.right-m_rectClient.left;
99 rc.height=m_rectClient.bottom-m_rectClient.top;
101 dc.SetPen(*wxTRANSPARENT_PEN);
102 dc.SetBrush(m_brushBack);
103 dc.DrawRectangle(rc);
105 wxPen kyna(wxColour(0,0,0),1,wxSOLID);
106 dc.SetPen(kyna);
107 dc.DrawLine(rc.x+1,rc.y+1,rc.x+rc.width-2,rc.y+1);
108 dc.DrawLine(rc.x+rc.width-2,rc.y+1,rc.x+rc.width-2,rc.y+rc.height-2);
109 dc.DrawLine(rc.x+rc.width-2,rc.y+rc.height-2,rc.x+1,rc.y+rc.height-2);
110 dc.DrawLine(rc.x+1,rc.y+rc.height-2,rc.x+1,rc.y+1);
112 dc.SetPen(*wxWHITE_PEN);
113 dc.DrawLine(rc.x+rc.width-1,rc.y,rc.x+rc.width-1,rc.y+rc.height-1);
114 dc.DrawLine(rc.x+rc.width-1,rc.y+rc.height-1,rc.x,rc.y+rc.height-1);
115 dc.SetPen(*wxGREY_PEN);
116 dc.DrawLine(rc.x+rc.width,rc.y,rc.x,rc.y);
117 dc.DrawLine(rc.x,rc.y,rc.x,rc.y+rc.height);
119 } // OnPaint
121 /////////////////////////////////////////////////////////////////////////////
122 void CColorFrameCtrl::OnSize(wxSizeEvent& WXUNUSED(evt))
125 // NOTE: OnSize automatically gets called during the setup of the control
126 // Kry - Not on Mac.
128 wxRect rc=GetClientRect();
129 m_rectClient.left=rc.x;
130 m_rectClient.top=rc.y;
131 m_rectClient.right=rc.x + rc.width;
132 m_rectClient.bottom=rc.y + rc.height;
134 } // OnSize
135 // File_checked_for_headers