-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbox.radiobutton.php
More file actions
139 lines (108 loc) · 3.5 KB
/
box.radiobutton.php
File metadata and controls
139 lines (108 loc) · 3.5 KB
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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
// $Header: /cvsroot/html2ps/box.radiobutton.php,v 1.20 2006/11/11 13:43:51 Konstantin Exp $
require_once(HTML2PS_DIR.'box.inline.simple.php');
class RadioBox extends SimpleInlineBox {
var $_checked;
/**
* @var String name of radio button group
* @access private
*/
var $_group_name;
/**
* @var String value to be posted as this radio button value
* @access private
*/
var $_value;
function &create(&$root, &$pipeline) {
$checked = $root->has_attribute('checked');
$value = $root->get_attribute('value');
if (trim($value) == "") {
error_log("Radiobutton with empty 'value' attribute");
$value = sprintf("___Value%s",md5(time().rand()));
};
$css_state = $pipeline->get_current_css_state();
$box =& new RadioBox($checked, $value,
$css_state->get_property(CSS_HTML2PS_FORM_RADIOGROUP));
$box->readCSS($css_state);
return $box;
}
function RadioBox($checked, $value, $group_name) {
// Call parent constructor
$this->GenericBox();
// Check the box state
$this->_checked = $checked;
/**
* Store the form value for this radio button
*/
$this->_value = trim($value);
$this->_group_name = $group_name;
// Setup box size:
$this->default_baseline = units2pt(RADIOBUTTON_SIZE);
$this->height = units2pt(RADIOBUTTON_SIZE);
$this->width = units2pt(RADIOBUTTON_SIZE);
$this->setCSSProperty(CSS_DISPLAY,'-radio');
}
// Inherited from GenericFormattedBox
function get_min_width(&$context) {
return $this->get_full_width($context);
}
function get_max_width(&$context) {
return $this->get_full_width($context);
}
function get_max_width_natural(&$context) {
return $this->get_full_width($context);
}
function reflow(&$parent, &$context) {
GenericFormattedBox::reflow($parent, $context);
// set default baseline
$this->baseline = $this->default_baseline;
// append to parent line box
$parent->append_line($this);
// Determine coordinates of upper-left _margin_ corner
$this->guess_corner($parent);
// Offset parent current X coordinate
$parent->_current_x += $this->get_full_width();
// Extends parents height
$parent->extend_height($this->get_bottom_margin());
}
function show(&$driver) {
// Cet check center
$x = ($this->get_left() + $this->get_right()) / 2;
$y = ($this->get_top() + $this->get_bottom()) / 2;
// Calculate checkbox size
$size = $this->get_width() / 3;
// Draw checkbox
$driver->setlinewidth(0.25);
$driver->circle($x, $y, $size);
$driver->stroke();
/**
* Render the interactive button (if requested and possible)
* Also, if no value were specified, then this radio button should not be interactive
*/
global $g_config;
if ($g_config['renderforms'] && $this->_value != "") {
$driver->field_radio($x - $size,
$y + $size,
2*$size,
2*$size,
$this->_group_name,
$this->_value,
$this->_checked);
} else {
// Draw checkmark if needed
if ($this->_checked) {
$check_size = $this->get_width() / 6;
$driver->circle($x, $y, $check_size);
$driver->fill();
}
};
return true;
}
function get_ascender() {
return $this->get_height();
}
function get_descender() {
return 0;
}
}
?>