]> git.vomp.tv Git - vompclient.git/blob - src/tbboxx.cc
Switch to cmake
[vompclient.git] / src / tbboxx.cc
1 /*
2     Copyright 2007-2021 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP 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 2 of the License, or
9     (at your option) any later version.
10
11     VOMP 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 VOMP.  If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #include "tbboxx.h"
21
22 TBBoxx::TBBoxx()
23 {
24   titleBarOn = 0;
25   borderOn = 0;
26   titleText = NULL;
27   titleBarTextWidth = 0;
28 }
29
30 TBBoxx::~TBBoxx()
31 {
32   if (titleText) delete[] titleText;
33 }
34
35 void TBBoxx::setTitleText(const char* takeText, int width)
36 {
37   int length = strlen(takeText);
38   titleText = new char[length + 1];
39   strcpy(titleText, takeText);
40   titleBarTextWidth = width;
41 }
42
43 void TBBoxx::draw()
44 {
45   //Log::getInstance()->log("TBBoxx", Log::DEBUG, "Draw: %d",this);
46
47   fillColour(DrawStyle::VIEWBACKGROUND);
48
49   if (borderOn)
50   {
51     rectangle(0, 0, area.w, area.h, titleBarColour);
52     rectangle(5, 5, area.w-10, area.h-10, DrawStyle::VIEWBACKGROUND);
53   }
54
55   if (titleBarOn)
56   {
57     rectangle(0, 0, area.w, 30, titleBarColour);
58     int xpos = 5;
59 #ifdef GRADIENT_DRAWING
60     if (tbIcon)
61     {
62       drawImage(tbIcon, static_cast<float>(xpos), 0, 30, 30, TopLeftLimited);
63       xpos += 5 + 30;
64     }
65 #endif
66     if (titleText)
67     {
68       if (titleBarTextWidth) drawText(titleText, xpos, 5, titleBarTextWidth+5-xpos, DrawStyle::LIGHTTEXT);
69       else drawText(titleText, xpos, 5, DrawStyle::LIGHTTEXT);
70     }
71   }
72
73   Boxx::draw();  
74 }
75
76 void TBBoxx::setTitleBarColour(const DrawStyle& Tcolour)
77 {
78   titleBarColour = Tcolour;
79 }
80
81 void TBBoxx::setTitleBarIcon(Image& ticon)
82 {
83   tbIcon = ticon;
84 }
85
86 void TBBoxx::setTitleBarOn(UCHAR on)
87 {
88   titleBarOn = on;
89 }
90
91 void TBBoxx::setBorderOn(UCHAR on)
92 {
93   borderOn = on;
94 }