1 /* $Id: MenuItemView.cpp,v 1.8 2002/02/15 14:14:35 yotsuya Exp $ */
2
3 // Copyright (C) 2000, 2001, 2002 ���� �ȹ�(Kanna Yoshihiro)
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 #include "ttinc.h"
20 #include "MenuItemView.h"
21 #include "MenuItem.h"
22 #include "LoadImage.h"
23 #include "BaseView.h"
24 #include "RCFile.h"
25
26 extern RCFile *theRC;
27
MenuItemView()28 MenuItemView::MenuItemView() {
29 m_image = NULL;
30 }
31
~MenuItemView()32 MenuItemView::~MenuItemView() {
33 if ( m_image )
34 delete m_image;
35 }
36
37 bool
Init(MenuItem * menu,char * fileName)38 MenuItemView::Init( MenuItem *menu, char *fileName ) {
39 char fname[256];
40
41 sprintf( fname, _("%s.pbm"), fileName );
42
43 m_menuItem = menu;
44
45 m_image = new ImageData();
46 m_image->LoadFile( fname );
47 return true;
48 }
49
50 bool
Redraw()51 MenuItemView::Redraw() {
52 return true;
53 }
54
55 bool
RedrawAlpha()56 MenuItemView::RedrawAlpha() {
57 glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
58
59 glPushMatrix();
60 glMatrixMode(GL_PROJECTION);
61 glPushMatrix();
62 glLoadIdentity();
63 gluOrtho2D( 0.0F, (GLfloat)BaseView::GetWinWidth(),
64 0.0F, (GLfloat)BaseView::GetWinHeight() );
65 glMatrixMode(GL_MODELVIEW);
66 glLoadIdentity();
67
68 GLboolean depthtestenabled = glIsEnabled(GL_DEPTH_TEST);
69 glDisable(GL_DEPTH_TEST);
70
71 glDepthMask(0);
72
73 if ( m_menuItem->GetSelected() )
74 glColor4f( 1.0F, 1.0F, 0.0F, 1.0F );
75 else
76 glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
77
78 glRasterPos2i( m_menuItem->GetX(), m_menuItem->GetY() );
79 glBitmap( m_menuItem->GetWidth(), m_menuItem->GetHeight(),
80 0.0F, 0.0F, 0.0F, 0, m_image->GetImage() );
81
82 glDepthMask(1);
83 if (depthtestenabled) glEnable(GL_DEPTH_TEST);
84
85 glMatrixMode(GL_PROJECTION);
86 glPopMatrix();
87 glMatrixMode(GL_MODELVIEW);
88 glPopMatrix();
89
90 return true;
91 }
92