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