1 /* 2 Copyright (C) 2010-2014 Kristian Duske 3 4 This file is part of TrenchBroom. 5 6 TrenchBroom is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 TrenchBroom is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #include "BorderLine.h" 21 22 #include "View/ViewConstants.h" 23 24 #include <wx/dcclient.h> 25 26 namespace TrenchBroom { 27 namespace View { BorderLine(wxWindow * parent,Direction direction,const int thickness)28 BorderLine::BorderLine(wxWindow* parent, Direction direction, const int thickness) : 29 wxWindow(parent, wxID_ANY) { 30 SetForegroundColour(Colors::borderColor()); 31 SetBackgroundStyle(wxBG_STYLE_PAINT); 32 Bind(wxEVT_PAINT, &BorderLine::OnPaint, this); 33 if (direction == Direction_Horizontal) { 34 const wxSize size(wxSize(wxDefaultSize.x, thickness)); 35 SetMinSize(size); 36 SetMaxSize(size); 37 } else { 38 const wxSize size(wxSize(thickness, wxDefaultSize.y)); 39 SetMinSize(size); 40 SetMaxSize(size); 41 } 42 } 43 OnPaint(wxPaintEvent & event)44 void BorderLine::OnPaint(wxPaintEvent& event) { 45 if (IsBeingDeleted()) return; 46 47 wxPaintDC dc(this); 48 dc.SetPen(wxPen(GetForegroundColour())); 49 dc.SetBrush(wxBrush(GetForegroundColour())); 50 51 dc.DrawRectangle(GetClientRect()); 52 event.Skip(); 53 } 54 } 55 } 56