Upstream tarball 20080708
[amule.git] / src / ColorFrameCtrl.cpp
blobd1221152d1b711d3faeb48239c6559b7a1a2b64e
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(*wxBLACK_BRUSH),
35 m_brushFrame(*(wxTheBrushList->FindOrCreateBrush(wxColour(0,255,255),wxSOLID)))
37 SetSizeHints(wid,hei,wid,hei,0,0);
38 wxRect rc=GetClientRect();
39 m_rectClient.left=rc.x;
40 m_rectClient.top=rc.y;
41 m_rectClient.right=rc.x + wid;
42 m_rectClient.bottom=rc.y + hei;
44 } // CColorFrameCtrl
46 /////////////////////////////////////////////////////////////////////////////
47 CColorFrameCtrl::~CColorFrameCtrl()
49 } // ~CColorFrameCtrl
52 BEGIN_EVENT_TABLE(CColorFrameCtrl,wxControl)
53 EVT_PAINT(CColorFrameCtrl::OnPaint)
54 EVT_SIZE(CColorFrameCtrl::OnSize)
55 END_EVENT_TABLE()
57 /////////////////////////////////////////////////////////////////////////////
58 // CColorFrameCtrl message handlers
60 /////////////////////////////////////////////////////////////////////////////
61 void CColorFrameCtrl::SetFrameBrushColour(const wxColour& colour)
63 m_brushFrame = *(wxTheBrushList->FindOrCreateBrush(colour, wxSOLID));
65 Refresh(FALSE);
66 } // SetFrameColor
69 /////////////////////////////////////////////////////////////////////////////
70 void CColorFrameCtrl::SetBackgroundBrushColour(const wxColour& colour)
72 m_brushBack = *(wxTheBrushList->FindOrCreateBrush(colour, wxSOLID));
74 // clear out the existing garbage, re-start with a clean plot
75 Refresh(FALSE);
76 } // SetBackgroundColor
79 ////////////////////////////////////////////////////////////////////////////
80 void CColorFrameCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt))
82 wxPaintDC dc(this);
84 wxRect rc;
85 rc.x=m_rectClient.left;
86 rc.y=m_rectClient.top;
87 rc.width=m_rectClient.right-m_rectClient.left;
88 rc.height=m_rectClient.bottom-m_rectClient.top;
90 dc.SetPen(*wxTRANSPARENT_PEN);
91 dc.SetBrush(m_brushBack);
92 dc.DrawRectangle(rc);
94 dc.SetPen(*wxBLACK_PEN);
95 dc.DrawLine(rc.x+1,rc.y+1,rc.x+rc.width-2,rc.y+1);
96 dc.DrawLine(rc.x+rc.width-2,rc.y+1,rc.x+rc.width-2,rc.y+rc.height-2);
97 dc.DrawLine(rc.x+rc.width-2,rc.y+rc.height-2,rc.x+1,rc.y+rc.height-2);
98 dc.DrawLine(rc.x+1,rc.y+rc.height-2,rc.x+1,rc.y+1);
100 dc.SetPen(*wxWHITE_PEN);
101 dc.DrawLine(rc.x+rc.width-1,rc.y,rc.x+rc.width-1,rc.y+rc.height-1);
102 dc.DrawLine(rc.x+rc.width-1,rc.y+rc.height-1,rc.x,rc.y+rc.height-1);
104 dc.SetPen(*wxGREY_PEN);
105 dc.DrawLine(rc.x+rc.width,rc.y,rc.x,rc.y);
106 dc.DrawLine(rc.x,rc.y,rc.x,rc.y+rc.height);
108 } // OnPaint
110 /////////////////////////////////////////////////////////////////////////////
111 void CColorFrameCtrl::OnSize(wxSizeEvent& WXUNUSED(evt))
114 // NOTE: OnSize automatically gets called during the setup of the control
115 // Kry - Not on Mac.
117 wxRect rc=GetClientRect();
118 m_rectClient.left=rc.x;
119 m_rectClient.top=rc.y;
120 m_rectClient.right=rc.x + rc.width;
121 m_rectClient.bottom=rc.y + rc.height;
123 } // OnSize
124 // File_checked_for_headers