File: form1.kvs

package info (click to toggle)
kvirc2 2.1.3-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 16,308 kB
  • ctags: 9,533
  • sloc: cpp: 86,257; sh: 10,532; makefile: 631; perl: 419; ansic: 315; sed: 16
file content (77 lines) | stat: -rw-r--r-- 2,526 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
# A simple input form dialog example

# Create the needed class
# We're using the -o switch (safely , because we're out of the object scope)
# Another good solution could be to define the class only if it was not already defined

class -o (myform,widget)
{
	# Constructor
	# Create all the necessary controls here
	function(constructor)
	{
		# The main layout. It will manage all the children
		# It will be 5 rows and 4 columns
		# The first column will host the labels
		# The remaining columns will be occupied by the line editors
		# The last row will be occupied by the cancel and ok buttons
		%l = $new(layout,$this,mylayout)
		# The name label
		%label = $new(label,$this,name_label,Name:)
		%l->$add(%label,0,0)
		# And the name edit fileld
		$this->%name = $new(lineedit,$this,name_lineedit,Your name here)
		%l->$addMultiCell($this->%name,0,0,1,3)
		# Street label
		%label = $new(label,$this,street_label,Street:)
		%l->$add(%label,1,0)
		# Street edit field
		$this->%street = $new(lineedit,$this,street_lineedit,Your street here)
		%l->$addMultiCell($this->%street,1,1,1,3)
		# Same as above for the city and country
		%label = $new(label,$this,street_label,City:)
		%l->$add(%label,2,0)
		$this->%city = $new(lineedit,$this,city_lineedit,Your city here)
		%l->$addMultiCell($this->%city,2,2,1,3)
		%label = $new(label,$this,street_label,Country:)
		%l->$add(%label,3,0)
		$this->%country = $new(lineedit,$this,country_lineedit,Your country here)
		%l->$addMultiCell($this->%country,3,3,1,3)
		# Create the cancel button and connect it to the relevant slot
		%button = $new(button,$this,cancel_button,Cancel)
		%button->$setMinimumWidth(100)
		connect %button clicked $this cancelClicked
		%l->$add(%button,4,2)
		# Create the OK button and connect it to the relevant slot
		%button = $new(button,$this,ok_button,Ok)
		%button->$setMinimumWidth(100)
		connect %button clicked $this okClicked
		%l->$add(%button,4,3)
		# Adjust the layout...
		%l->$setColStretch(1,1)
		$this->$setCaption(User form:)
		# And automatically show up
		$this->$show(1)
	}

	# Slot connected to the cancel button clicked signal
	function(cancelClicked)
	{
		echo Input form cancelled
		destroy $this
	}
	# Slot connected to the ok button signal
	function(okClicked)
	{
		echo User data:
		echo Name:    $this->%name->$text()
		echo Street:  $this->%street->$text()
		echo City:    $this->%city->$text()
		echo Country: $this->%country->$text()
		destroy $this
	}
}

# Then just create the dialog

%obj = $new(myform,$root,mymagicform)