1 /*
2 * ppui/Seperator.cpp
3 *
4 * Copyright 2009 Peter Barth
5 *
6 * This file is part of Milkytracker.
7 *
8 * Milkytracker is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Milkytracker is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Milkytracker. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23 /*
24 * PPSeperator.cpp
25 * MilkyTracker
26 *
27 * Created by Peter Barth on 16.03.05.
28 *
29 */
30
31 #include "Seperator.h"
32 #include "GraphicsAbstract.h"
33
PPSeperator(pp_int32 id,PPScreen * parentScreen,const PPPoint & location,pp_uint32 size,const PPColor & theColor,bool horizontal)34 PPSeperator::PPSeperator(pp_int32 id, PPScreen* parentScreen,
35 const PPPoint& location, pp_uint32 size,
36 const PPColor& theColor, bool horizontal/* = true*/) :
37 PPControl(id, parentScreen, NULL, location, PPSize(0,0)),
38 horizontal(horizontal),
39 color(&theColor)
40 {
41 if (horizontal)
42 {
43 this->size.width = size;
44 this->size.height = 2;
45 }
46 else
47 {
48 this->size.height = size;
49 this->size.width = 2;
50 }
51 }
52
paint(PPGraphicsAbstract * g)53 void PPSeperator::paint(PPGraphicsAbstract* g)
54 {
55 if (!isVisible())
56 return;
57
58 g->setRect(location.x, location.y, location.x + size.width+1, location.y + size.height+1);
59
60 //g->setColor(color);
61
62 PPColor bColor = *color, dColor = *color;
63
64 // adjust dark color
65 dColor.scaleFixed(20000);
66
67 // adjust bright color
68 bColor.scaleFixed(87163);
69
70 if (horizontal)
71 {
72 g->setColor(dColor);
73 g->drawHLine(location.x, location.x + size.width, location.y);
74 }
75 else
76 {
77 g->setColor(dColor);
78 g->drawVLine(location.y, location.y + size.height, location.x);
79 }
80
81 if (horizontal)
82 {
83 g->setColor(bColor);
84 g->drawHLine(location.x+1, location.x +1+ size.width, location.y+1);
85 }
86 else
87 {
88 g->setColor(bColor);
89 g->drawVLine(location.y+1, location.y +1+ size.height, location.x+1);
90 }
91 }
92