]> git.vomp.tv Git - vompclient.git/blob - view.cc
New GUI code
[vompclient.git] / view.cc
1 /*
2     Copyright 2004-2005 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, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #include "view.h"
22
23 char View::numViews = 0;
24
25 View::View()
26 {
27   delSec = 0;
28   delNSec = 0;
29   seconds = 0;
30
31   titleBarOn = 0;
32   borderOn = 0;
33
34   titleText = NULL;
35
36   surface = NULL;
37
38   numViews++;
39   Log::getInstance()->log("View", Log::DEBUG, "Construct %p, now %u", this, numViews);
40 }
41
42 View::~View()
43 {
44   if (titleText) delete[] titleText;
45
46   delete surface;
47
48   numViews--;
49   Log::getInstance()->log("View", Log::DEBUG, "Destruct, now %u", numViews);
50 }
51
52 bool View::create(UINT w, UINT h)
53 {
54   area.w = w;
55   area.h = h;
56
57   surface = new Surface();
58   return surface->create(area.w, area.h);
59 }
60
61 void View::setTitleText(char* takeText)
62 {
63   int length = strlen(takeText);
64   titleText = new char[length + 1];
65   strcpy(titleText, takeText);
66 }
67
68 void View::draw()
69 {
70
71   if (borderOn)
72   {
73     rectangle(0, 0, area.w, area.h, titleBarColour);
74     rectangle(5, 5, area.w-10, area.h-10, backgroundColour);
75   }
76   else
77   {
78     fillColour(backgroundColour);
79   }
80
81   if (titleBarOn)
82   {
83     rectangle(0, 0, area.w, 30, titleBarColour);
84     if (titleText) drawText(titleText, 5, 5, Colour::LIGHTTEXT);
85   }
86 }
87
88 int View::handleCommand(int command)
89 {
90   return 0;
91 }
92
93 void View::processMessage(Message* m)
94 {
95 }
96
97 void View::setBackgroundColour(Colour& Tcolour)
98 {
99   backgroundColour = Tcolour;
100 }
101
102 void View::setTitleBarColour(Colour& Tcolour)
103 {
104   titleBarColour = Tcolour;
105 }
106
107 void View::setTitleBarOn(UCHAR on)
108 {
109   titleBarOn = on;
110 }
111
112 void View::setBorderOn(UCHAR on)
113 {
114   borderOn = on;
115 }
116
117 void View::setParent(View* tParent)
118 {
119   parent = tParent;
120 }