Upstream tarball 20080901
[amule.git] / src / ColorFrameCtrl.cpp
blob9408da278f09701ec00ec81996138eedce3456ef
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-2008 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
29 #include "MuleColour.h"
31 /////////////////////////////////////////////////////////////////////////////
32 // CColorFrameCtrl
33 CColorFrameCtrl::CColorFrameCtrl( wxWindow* parent,int id, int wid,int hei )
34 : wxControl(parent,id,wxDefaultPosition,wxSize(wid,hei)),
35 m_brushBack(*wxBLACK_BRUSH),
36 m_brushFrame(CMuleColour(0,255,255).GetBrush())
38 SetSizeHints(wid,hei,wid,hei,0,0);
39 wxRect rc=GetClientRect();
40 m_rectClient.left=rc.x;
41 m_rectClient.top=rc.y;
42 m_rectClient.right=rc.x + wid;
43 m_rectClient.bottom=rc.y + hei;
45 } // CColorFrameCtrl
47 /////////////////////////////////////////////////////////////////////////////
48 CColorFrameCtrl::~CColorFrameCtrl()
50 } // ~CColorFrameCtrl
53 BEGIN_EVENT_TABLE(CColorFrameCtrl,wxControl)
54 EVT_PAINT(CColorFrameCtrl::OnPaint)
55 EVT_SIZE(CColorFrameCtrl::OnSize)
56 END_EVENT_TABLE()
58 /////////////////////////////////////////////////////////////////////////////
59 // CColorFrameCtrl message handlers
61 /////////////////////////////////////////////////////////////////////////////
62 void CColorFrameCtrl::SetFrameBrushColour(const wxColour& colour)
64 m_brushFrame = *(wxTheBrushList->FindOrCreateBrush(colour, wxSOLID));
66 Refresh(FALSE);
67 } // SetFrameColor
70 /////////////////////////////////////////////////////////////////////////////
71 void CColorFrameCtrl::SetBackgroundBrushColour(const wxColour& colour)
73 m_brushBack = *(wxTheBrushList->FindOrCreateBrush(colour, wxSOLID));
75 // clear out the existing garbage, re-start with a clean plot
76 Refresh(FALSE);
77 } // SetBackgroundColor
80 ////////////////////////////////////////////////////////////////////////////
81 void CColorFrameCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt))
83 wxPaintDC dc(this);
85 wxRect rc;
86 rc.x=m_rectClient.left;
87 rc.y=m_rectClient.top;
88 rc.width=m_rectClient.right-m_rectClient.left;
89 rc.height=m_rectClient.bottom-m_rectClient.top;
91 dc.SetPen(*wxTRANSPARENT_PEN);
92 dc.SetBrush(m_brushBack);
93 dc.DrawRectangle(rc);
95 dc.SetPen(*wxBLACK_PEN);
96 dc.DrawLine(rc.x+1,rc.y+1,rc.x+rc.width-2,rc.y+1);
97 dc.DrawLine(rc.x+rc.width-2,rc.y+1,rc.x+rc.width-2,rc.y+rc.height-2);
98 dc.DrawLine(rc.x+rc.width-2,rc.y+rc.height-2,rc.x+1,rc.y+rc.height-2);
99 dc.DrawLine(rc.x+1,rc.y+rc.height-2,rc.x+1,rc.y+1);
101 dc.SetPen(*wxWHITE_PEN);
102 dc.DrawLine(rc.x+rc.width-1,rc.y,rc.x+rc.width-1,rc.y+rc.height-1);
103 dc.DrawLine(rc.x+rc.width-1,rc.y+rc.height-1,rc.x,rc.y+rc.height-1);
105 dc.SetPen(*wxGREY_PEN);
106 dc.DrawLine(rc.x+rc.width,rc.y,rc.x,rc.y);
107 dc.DrawLine(rc.x,rc.y,rc.x,rc.y+rc.height);
109 } // OnPaint
111 /////////////////////////////////////////////////////////////////////////////
112 void CColorFrameCtrl::OnSize(wxSizeEvent& WXUNUSED(evt))
115 // NOTE: OnSize automatically gets called during the setup of the control
116 // Kry - Not on Mac.
118 wxRect rc=GetClientRect();
119 m_rectClient.left=rc.x;
120 m_rectClient.top=rc.y;
121 m_rectClient.right=rc.x + rc.width;
122 m_rectClient.bottom=rc.y + rc.height;
124 } // OnSize
125 // File_checked_for_headers