Class: MyTouchWindow

Inherits:
Gtk::Window
  • Object
show all
Defined in:
lib/mytouchwindow.rb

Defined Under Namespace

Classes: TouchButton

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMyTouchWindow

Returns a new instance of MyTouchWindow.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/mytouchwindow.rb', line 31

def initialize
	super()
	fullscreen
#	set_icon('e.png')
#	set_window_position(Gtk::Window::POS_CENTER_ALWAYS)
	self.title='manqod Touch'

	agg=Gtk::AccelGroup.new
	agg.connect(Gdk::Keyval.to_upper(81),nil,Gtk::ACCEL_VISIBLE){
 Gtk.main_quit
	}
	add_accel_group(agg)

 rc="
 style 'keypadbutton'
 {
bg[NORMAL]='#e09028'
bg[PRELIGHT]='#eed60b'
bg[ACTIVE]='#c1ee0b'
xthickness=10
ythickness=10
font='Helvetica'
 }

 style 'button'
 {
bg[NORMAL]='#0c6db1'
bg[PRELIGHT]='#0cb1ab'
bg[ACTIVE]='#0b41db'
xthickness=10
ythickness=10
 }

 style 'all'
 {
bg[NORMAL] = '#fff3a4'
bg[PRELIGHT] = '#ebff62'
bg[ACTIVE] = '#dcfb08'
xthickness = 10
ythickness = 10
GtkRange::stepper-size = 100
GtkRange::slider-width = 100
font_name = 'Serif 30'
 }
 
 widget '*' style 'all'
 widget '*Button*' style 'button'
 widget '*TouchButton*' style 'keypadbutton'
 "
 Gtk::RC.parse_string(rc)

	
	signal_connect("destroy") {|me|
 edebug("normal shutdown\n","touch","normal")
 Gtk.main_quit
	}
	
	signal_connect('key-press-event') {|me,key|
 edebug("key: "+key.to_s,"touch","info")
	}

	
	@holder=Gtk::Table.new(1,2,false)
	add(Gtk::Frame.new.add(@holder))
	@touchcontrol=Gtk::Table.new(5,3,true)
	@touchcontrol.set_column_spacings(10).set_row_spacings(10)
	
	@b1=TouchButton.new('1',0,1,0,1,@touchcontrol)#.set_size_request(100, 100)
	@b2=TouchButton.new('2',1,2,0,1,@touchcontrol)
	@b3=TouchButton.new('3',2,3,0,1,@touchcontrol)

	@b4=TouchButton.new('4',0,1,1,2,@touchcontrol)
	@b5=TouchButton.new('5',1,2,1,2,@touchcontrol)
	@b6=TouchButton.new('6',2,3,1,2,@touchcontrol)

	@b7=TouchButton.new('7',0,1,2,3,@touchcontrol)
	@b8=TouchButton.new('8',1,2,2,3,@touchcontrol)
	@b9=TouchButton.new('9',2,3,2,3,@touchcontrol)

	@b0=TouchButton.new('0',0,1,3,4,@touchcontrol)
	@b000=TouchButton.new('000',1,2,3,4,@touchcontrol).modify_font(Pango::FontDescription.new.set_size(24).set_family('Helvetica').set_weight(30))

	@bp=TouchButton.new('.',2,3,3,4,@touchcontrol)
	@back=TouchButton.new('<-',0,1,4,5,@touchcontrol)
	
	
	@touchcontrol.resize(5,3)
	@keypad=Gtk::Frame.new.add(@touchcontrol)
	@keypad_is_visible=false
#	@touchcontrol.set_no_show_all(true)
end

Instance Attribute Details

#keypad_is_visibleObject

Returns the value of attribute keypad_is_visible.



123
124
125
# File 'lib/mytouchwindow.rb', line 123

def keypad_is_visible
  @keypad_is_visible
end

Instance Method Details

#hide_keypadObject



157
158
159
# File 'lib/mytouchwindow.rb', line 157

def hide_keypad
	keypad(false)
end

#keypad(vis) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/mytouchwindow.rb', line 133

def keypad(vis)
	if vis
 if !keypad_is_visible
@holder.attach(@keypad,1,2,0,1,Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0)
@keypad.show_all
keypad_is_visible=true
edebug("keypad visible set: "+vis.to_s,"touch","debug")
 else
edebug("keypad allready visible","touch","debug")
 end
 else
 if keypad_is_visible
@holder.remove(@keypad)
keypad_is_visible=false
edebug("keypad visible set: "+vis.to_s,"touch","debug")
 else
edebug("keypad allready hidden","touch","debug")
 end
	end
end

#runObject



125
126
127
128
129
130
131
# File 'lib/mytouchwindow.rb', line 125

def run
	@formholder=Myform::MyFormHolder.new("touchscreen",self)
	@holder.attach(@formholder.holder,0,1,0,1,Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0)
	show_all
	@formholder.form.set_id("59")
	@formholder.form.update(self)
end

#show_keypadObject



154
155
156
# File 'lib/mytouchwindow.rb', line 154

def show_keypad
	keypad(true)
end