1 /* $Id: MenuItem.cpp,v 1.6 2002/09/07 05:06:29 nan Exp $ */
2
3 // Copyright (C) 2000, 2001, 2002 $B?@Fn(B $B5H9((B(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 "MenuItem.h"
21 #include "MenuItemView.h"
22 #include "MenuItemView2D.h"
23 #include "BaseView.h"
24 #include "Title.h"
25 #include "RCFile.h"
26
27 extern RCFile *theRC;
28
MenuItem()29 MenuItem::MenuItem() {
30 m_View = NULL;
31 m_selected = false;
32 m_x = 0;
33 m_y = 0;
34 m_width = 0;
35 m_height = 0;
36 }
37
~MenuItem()38 MenuItem::~MenuItem() {
39 if ( m_View ){
40 if ( m_parent )
41 ((TitleView *)m_parent->GetView())->RemoveView( m_View );
42 delete m_View;
43 }
44 }
45
46 bool
Init(long x,long y,long width,long height,char * fileName,Title * parent)47 MenuItem::Init( long x, long y, long width, long height, char *fileName,
48 Title *parent ) {
49 m_x = x;
50 if ( theRC->gmode == GMODE_2D )
51 m_y = BaseView::GetWinHeight()-y-height;
52 else
53 m_y = y;
54 m_width = width;
55 m_height = height;
56
57 m_parent = parent;
58
59 m_View = (MenuItemView *)View::CreateView( VIEW_MENUITEM );
60
61 m_View->Init( this, fileName );
62
63 if ( m_parent )
64 ((TitleView *)m_parent->GetView())->AddView( m_View );
65
66 return true;
67 }
68
69 bool
SetSelected(bool select)70 MenuItem::SetSelected( bool select ) {
71 m_selected = select;
72 return m_selected;
73 }
74