Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 173 lines (163 sloc) 5.94 kb
f6b0e85 Initial check in of Gtk_Styled package.
Scott Mattocks authored
1 <?php
2 /* vim: set expandtab tabstop=4 shiftwidth=4: */
3 // +----------------------------------------------------------------------+
4 // | PHP Version 4 |
5 // +----------------------------------------------------------------------+
6d51367 DocBlock and header comment fixes.
Scott Mattocks authored
6 // | Copyright (c) 2005 Scott Mattocks |
f6b0e85 Initial check in of Gtk_Styled package.
Scott Mattocks authored
7 // +----------------------------------------------------------------------+
8 // | This source file is subject to version 3.0 of the PHP license, |
9 // | that is bundled with this package in the file LICENSE, and is |
10 // | available through the world-wide-web at the following url: |
11 // | http://www.php.net/license/3_0.txt. |
12 // | If you did not receive a copy of the PHP license and are unable to |
13 // | obtain it through the world-wide-web, please send a note to |
14 // | license@php.net so we can mail you a copy immediately. |
15 // +----------------------------------------------------------------------+
16 // | Author: Scott Mattocks <scottmattocks@php.net> |
17 // +----------------------------------------------------------------------+
18 //
19 // $Id$
20 /**
21 * A horizontal styleable adjustment pseudo widget.
22 *
23 * This adjustments bar moves from left to right when the value
24 * is changed. All components are packed into an hBox.
25 *
26 * This class inherits from Gtk_Styled_Adjustment.
27 *
28 * @author Scott Mattocks <scottmattocks@php.net>
29 * @version @VER@
30 * @category Gtk
6d51367 DocBlock and header comment fixes.
Scott Mattocks authored
31 * @package Gtk_Styled
f6b0e85 Initial check in of Gtk_Styled package.
Scott Mattocks authored
32 * @subpackage Adjustment
33 * @license PHP version 3.0
6d51367 DocBlock and header comment fixes.
Scott Mattocks authored
34 * @copyright Copyright &copy; 2005 Scott Mattocks
f6b0e85 Initial check in of Gtk_Styled package.
Scott Mattocks authored
35 * @see Gtk_Styled_Adjustment
36 */
37 require_once 'Gtk/Styled/Adjustment.php';
38 class Gtk_Styled_HAdjustment extends Gtk_Styled_Adjustment {
39
40 function &_getTrackContainer()
41 {
42 $container =& new GtkHBox;
43 $container->set_usize($this->pageSize, $this->width);
44
45 return $container;
46 }
47
48 /**
49 * Set the size of the bar.
50 *
51 * The bar size is configurable. Depending on how the adjustment is
52 * used, the bar size may depend entirely on its value or it may
53 * change with respect to its environment. If the adjustment is used
54 * as a progress bar, the size of the bar is directly related to the
55 * percentage of the task that is complete. If the adjustment is used
56 * as a scroll bar, the size of the bar is related to the amount of
57 * the scrolling widget that is currently show compared to its total
58 * size.
59 *
60 * @access private
61 * @param none
62 * @return void
63 */
64 function _setBarSize()
65 {
66 if ($this->pageSize >= $this->upper) {
67 $this->bar->set_usize($this->widget->allocation->width, -1);
68 $this->postTrack->set_usize(0, -1);
69 } else {
70 $ts = $this->widget->allocation->width;
71 $this->bar->set_usize($ts * ($this->pageSize / $this->upper), -1);
72 }
73 }
74
75 /**
76 * Set the bars position within the track.
77 *
78 * Set the starting position of the bar with in the track. The bar
79 * cannot start (length of track) - (length of bar). The position
80 * of the bar is mostly only relavent when the adjustment is being
81 * used as a scroll bar or when being used as an activity progress
82 * indicator.
83 *
84 * The bar position is determined by the width/height of the event
85 * box that preceeds the bar.
86 *
87 * @access private
88 * @param none
89 * @return void
90 */
91 function _setBarPosition()
92 {
93 // tb = Top of Bar
94 $tb = ceil($this->value * (($this->widget->allocation->width) / $this->upper));
95 $this->preTrack->set_usize($tb, -1);
96 }
97
98 /**
99 * Get the adjustment value based on a new bar position.
100 *
101 * Sometimes it is necessary to first set the position of the bar
102 * and then the value of the adjustment. This method calculates the
103 * value based on the current bar position and a change in the bar's
104 * position. This method is mostly used for dragging the bar within
105 * the track while scrolling.
106 *
107 * @access public
108 * @param double $changeInPosition The amount the position should change
109 * @return double
110 */
111 function getValueFromPosition($changeInPosition)
112 {
113 // tbc = Top of Bar Current
114 $tbc = $this->preTrack->allocation->width;
115 $value = ($tbc + $changeInPosition) / (($this->widget->allocation->width) / $this->upper);
116
117 return $value;
118 }
119
120 /**
121 * Set the size of the entire track.
122 *
123 * Sets the size of the entire track. The track contains the preTrack
124 * the bar and the postTrack.
125 *
126 * @access private
127 * @param none
128 * @return void
129 */
130 function _setTrackSize()
131 {
132 if (isset($this->widget->allocation->width)) {
133 $this->track->set_usize($this->widget->allocation->width, $this->width);
134 }
135 }
136
137 /**
138 * Check to see that the mouse is within the boundries of the
139 * bar.
140 *
141 * Check the current mouse position to see if it is within
142 * the bounds of the adjustment bar. It is only necessary to
143 * check if the mouse is with in one direction of the bar's
144 * alloted space. For example, we only care if the mouse is
145 * within the y-range of a vertical adjustment.
146 *
147 * @abstract
148 * @access public
149 * @param none
150 * @return boolean
151 */
152 function checkMouseBounds()
153 {
154 $pointer = $this->widget->window->pointer;
155 $bar = $this->widget->allocation;
156
157 if ($pointer[0] > $bar->x + $bar->width) {
158 return false;
159 } elseif ($pointer[0] < $bar->x) {
160 return false;
161 } else {
162 return true;
163 }
164 }
165
166 }
167 /*
168 * Local variables:
169 * tab-width: 4
170 * c-basic-offset: 4
171 * End:
172 */
173 ?>
Something went wrong with that request. Please try again.