~extremepopcorn/dhlib/dhlib_ep

« back to all changes in this revision

Viewing changes to lib/ui/MenuItemString.mhx

  • Committer: edA-qa mort-ora-y
  • Date: 2010-02-16 05:36:32 UTC
  • Revision ID: eda-qa@disemia.com-20100216053632-60lt7fndfi3fgblw
first

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* <license>
 
2
 * This file is part of the dis-Emi-A HaXe Library. Copyright (c) edA-qa mort-ora-y
 
3
 * For full copyright and license information please refer to doc/license.txt.
 
4
 * </license> 
 
5
 */
 
6
package ui;
 
7
 
 
8
#if neash
 
9
import neash.text.TextField;
 
10
import neash.text.TextFieldAutoSize;
 
11
#elseif flash
 
12
import flash.text.TextField;
 
13
import flash.text.TextFieldAutoSize;
 
14
#end
 
15
 
 
16
class MenuItemString extends MenuItem
 
17
{
 
18
        private var text : String;
 
19
        
 
20
        public function new( pop : Menu, atext : String, evt )
 
21
        {
 
22
                super( pop, evt );
 
23
                text = atext;
 
24
                
 
25
                //setup text
 
26
                textF = new TextField( );
 
27
                textF.selectable = false;
 
28
                textF.textColor = Theme.current.textColor.asInt();
 
29
                textF.text = text;
 
30
                textF.autoSize = TextFieldAutoSize.LEFT;
 
31
                addChild( textF );
 
32
                
 
33
                draw( false, textF.width );
 
34
        }
 
35
        
 
36
        private var textF : TextField;
 
37
        override private function draw( highlight : Bool, w : Float )
 
38
        {
 
39
                graphics.clear();
 
40
                        
 
41
                textF.textColor = (highlight 
 
42
                        ? Theme.current.highTextColor
 
43
                        : Theme.current.textColor).asInt();
 
44
                
 
45
                graphics.beginFill( 
 
46
                        (highlight 
 
47
                                ? Theme.current.highBackColor
 
48
                                : Theme.current.menuColor ).asInt()
 
49
                         );
 
50
                graphics.moveTo( 0, 0 );
 
51
                graphics.lineTo( w, 0 );
 
52
                graphics.lineTo( w, height );
 
53
                graphics.lineTo( 0, height );
 
54
                graphics.endFill();
 
55
        }
 
56
}