]> git.vomp.tv Git - vompclient.git/blob - vpicturebanner.cc
Switch trunk code to new boxes
[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[strlen(info)+100];
62       sprintf(buf,"%s %s",tr("Loading"),info);
63       drawText(buf,5,area.h-25,Colour::LIGHTTEXT);
64       }
65     else drawText(tr("Loading"),5,3,Colour::LIGHTTEXT);
66     }
67   else {
68     int x=5;
69     rectangle(x, area.h - 24, 18, 16, Colour::RED);
70     x+=18+3;
71     drawText(tr("rotate"), x, area.h - 25, Colour::LIGHTTEXT);
72     x+=rotsize+3;
73     rectangle(x, area.h - 24, 18, 16, Colour::GREEN);
74     x+=18+3;
75     drawText(tr("info"), 5+18+3+rotsize+3+18+3, area.h - 25, Colour::LIGHTTEXT);
76     x+=infsize+3;
77     WSymbol w;
78     TEMPADD(&w);
79     if (slideshow) {
80       w.nextSymbol = WSymbol::PAUSE;
81       }
82     else {
83       w.nextSymbol = WSymbol::PLAY;
84     }
85     w.setPosition(x, area.h-24);
86     w.draw();
87     x+=20+3;
88     if (info) {
89       drawText(info,x,area.h - 25,Colour::LIGHTTEXT);
90     }
91   }
92 }
93
94 int VPictureBanner::handleCommand(int command)
95 {
96   //don not handle commands - leave this to the picture viewer
97   return 0;
98 }
99
100
101
102 void VPictureBanner::processMessage(Message* m)
103 {
104   if (m->message == Message::MOUSE_MOVE)
105   {
106     
107   }
108   else if (m->message == Message::MOUSE_LBDOWN)
109   {
110     //check if press is outside this view! then simulate cancel
111     int x=(m->parameter>>16)-getScreenX();
112     int y=(m->parameter&0xFFFF)-getScreenY();
113     if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
114     {
115       BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
116     }
117     else if (y>=(int)area.h-24 && y<=(int)area.h-6)
118     {
119       //y coordinate is right!
120       if (x>=7 &&x<=25)
121       {
122         BoxStack::getInstance()->handleCommand(Remote::RED); //simulate red press
123       }
124       else if (x>=110 &&x<=128)
125       {
126         BoxStack::getInstance()->handleCommand(Remote::GREEN); //simulate red press
127       }
128     }
129   }
130 }
131
132 void VPictureBanner::setText(const char * text) {
133   if (info) delete info;
134   info=NULL;
135   if(!text) return;
136   info=new char[strlen(text)+1];
137   strcpy(info,text);
138 }
139
140
141
142
143