]> git.vomp.tv Git - vompclient.git/blob - vpicturebanner.cc
0.2.7 readiness patches for Windows
[vompclient.git] / vpicturebanner.cc
1 /*
2     Copyright 2004-2005 Chris Tallon, Andreas Vogel
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 "vpicturebanner.h"
22
23 #include "vpicture.h"
24 #include "wsymbol.h"
25 #include "remote.h"
26 #include "colour.h"
27 #include "video.h"
28 #include "vinfo.h"
29 #include "boxstack.h"
30 #include "i18n.h"
31
32 VPictureBanner::VPictureBanner(VPicture *p, bool ld, bool sl)
33 {
34   loading=ld;
35   slideshow=sl;
36   parent=p;
37   Video *v=Video::getInstance();
38   setSize(v->getScreenWidth()-100, 36);
39   createBuffer();
40   setPosition(50, v->getScreenHeight()-50);
41   setTitleBarOn(0);
42   info=NULL;
43   Log::getInstance()->log("VPictureBanner",Log::DEBUG,"created %p",this);
44   //TODO compute sizes from text
45   rotsize=70;
46   infsize=50;
47 }
48
49 VPictureBanner::~VPictureBanner()
50 {
51   Log::getInstance()->log("VPictureBanner",Log::DEBUG,"deleted %p",this);
52 }
53
54
55
56 void VPictureBanner::draw()
57 {
58 //  View::draw();
59   if (loading) {
60     if (info) {
61       char *buf=new char[strlen(info)+100];
62       sprintf(buf,"%s %s",tr("Loading"),info);
63       drawText(buf,5,area.h-25,Colour::LIGHTTEXT);
64       delete buf;
65       }
66     else drawText(tr("Loading"),5,3,Colour::LIGHTTEXT);
67     }
68   else {
69     int x=5;
70     rectangle(x, area.h - 24, 18, 16, Colour::RED);
71     x+=18+3;
72     drawText(tr("rotate"), x, area.h - 25, Colour::LIGHTTEXT);
73     x+=rotsize+3;
74     rectangle(x, area.h - 24, 18, 16, Colour::GREEN);
75     x+=18+3;
76     drawText(tr("info"), 5+18+3+rotsize+3+18+3, area.h - 25, Colour::LIGHTTEXT);
77     x+=infsize+3;
78     WSymbol w;
79     TEMPADD(&w);
80     if (slideshow) {
81       w.nextSymbol = WSymbol::PAUSE;
82       }
83     else {
84       w.nextSymbol = WSymbol::PLAY;
85     }
86     w.setPosition(x, area.h-24);
87     w.draw();
88     x+=20+3;
89     if (info) {
90       drawText(info,x,area.h - 25,Colour::LIGHTTEXT);
91     }
92   }
93 }
94
95 int VPictureBanner::handleCommand(int command)
96 {
97   //don not handle commands - leave this to the picture viewer
98   return 0;
99 }
100
101
102
103 void VPictureBanner::processMessage(Message* m)
104 {
105   if (m->message == Message::MOUSE_MOVE)
106   {
107     
108   }
109   else if (m->message == Message::MOUSE_LBDOWN)
110   {
111     //check if press is outside this view! then simulate cancel
112     int x=(m->parameter>>16)-getScreenX();
113     int y=(m->parameter&0xFFFF)-getScreenY();
114     if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
115     {
116       BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
117     }
118     else if (y>=(int)area.h-24 && y<=(int)area.h-6)
119     {
120       //y coordinate is right!
121       if (x>=7 &&x<=25)
122       {
123         BoxStack::getInstance()->handleCommand(Remote::RED); //simulate red press
124       }
125       else if (x>=110 &&x<=128)
126       {
127         BoxStack::getInstance()->handleCommand(Remote::GREEN); //simulate red press
128       }
129     }
130   }
131 }
132
133 void VPictureBanner::setText(const char * text) {
134   if (info) delete info;
135   info=NULL;
136   if(!text) return;
137   info=new char[strlen(text)+1];
138   strcpy(info,text);
139 }
140
141
142
143
144