OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / include / lib / Net_UserAgent_Mobile-1.0.0 / Net / UserAgent / Mobile / Display.php
1 <?php
2 /* vim: set expandtab tabstop=4 shiftwidth=4: */
3
4 /**
5  * PHP versions 4 and 5
6  *
7  * Copyright (c) 2003-2009 KUBO Atsuhiro <kubo@iteman.jp>,
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are met:
12  *
13  *     * Redistributions of source code must retain the above copyright
14  *       notice, this list of conditions and the following disclaimer.
15  *     * Redistributions in binary form must reproduce the above copyright
16  *       notice, this list of conditions and the following disclaimer in the
17  *       documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  *
31  * @category   Networking
32  * @package    Net_UserAgent_Mobile
33  * @author     KUBO Atsuhiro <kubo@iteman.jp>
34  * @copyright  2003-2009 KUBO Atsuhiro <kubo@iteman.jp>
35  * @license    http://www.opensource.org/licenses/bsd-license.php  New BSD License
36  * @version    CVS: $Id: Display.php 2043 2009-07-03 09:36:18Z fishbone $
37  * @since      File available since Release 0.1
38  *
39  * @modified-for        adjust for magic3 framework
40  * @modified-by         naoki hirata(naoki@aplo.co.jp)
41  * @modified-date       2009.7.3
42  */
43
44 // {{{ Net_UserAgent_Mobile_Display
45
46 /**
47  * Display information for Net_UserAgent_Mobile
48  *
49  * Net_UserAgent_Mobile_Display is a class for display information on
50  * {@link Net_UserAgent_Mobile}. Handy for image resizing or dispatching.
51  *
52  * SYNOPSIS:
53  * <code>
54  * require_once 'Net/UserAgent/Mobile.php';
55  *
56  * $agent = &Net_UserAgent_Mobile::factory();
57  * $display = $agent->getDisplay();
58  *
59  * $width  = $display->getWidth();
60  * $height = $display->getHeight();
61  * list($width, $height) = $display->getSize();
62  *
63  * if ($display->isColor()) {
64  *     $depth = $display->getDepth();
65  * }
66  *
67  * // only available in DoCoMo 505i
68  * $width_bytes  = $display->getWidthBytes();
69  * $height_bytes = $display->getHeightBytes();
70  * </code>
71  *
72  * USING EXTERNAL MAP FILE:
73  * If the environment variable DOCOMO_MAP exists, the specified XML data will be used
74  * for DoCoMo display information.
75  *
76  * ex) Please add the following code.
77  * $_SERVER['DOCOMO_MAP'] = '/path/to/DoCoMoMap.xml';
78  *
79  * @category   Networking
80  * @package    Net_UserAgent_Mobile
81  * @author     KUBO Atsuhiro <kubo@iteman.jp>
82  * @copyright  2003-2009 KUBO Atsuhiro <kubo@iteman.jp>
83  * @license    http://www.opensource.org/licenses/bsd-license.php  New BSD License
84  * @version    Release: 1.0.0
85  * @since      Class available since Release 0.1
86  */
87 class Net_UserAgent_Mobile_Display
88 {
89
90     // {{{ properties
91
92     /**#@+
93      * @access public
94      */
95
96     /**#@-*/
97
98     /**#@+
99      * @access private
100      */
101
102     /**
103      * width of the display
104      * @var integer
105      */
106     var $_width;
107
108     /**
109      * height of the display
110      * @var integer
111      */
112     var $_height;
113
114     /**
115      * depth of the display
116      * @var integer
117      */
118     var $_depth;
119
120     /**
121      * color capability of the display
122      * @var boolean
123      */
124     var $_color;
125
126     /**
127      * width (bytes) of the display
128      * @var integer
129      */
130     var $_widthBytes;
131
132     /**
133      * height (bytes) of the display
134      * @var integer
135      */
136     var $_heightBytes;
137
138     /**#@-*/
139
140     /**#@+
141      * @access public
142      */
143
144     // }}}
145     // {{{ constructor
146
147     /**
148      * constructor
149      *
150      * @param array $data display infomation
151      */
152     function Net_UserAgent_Mobile_Display($data)
153     {
154         $this->_width  = (integer)@$data['width'];
155         $this->_height = (integer)@$data['height'];
156         $this->_depth  = (integer)@$data['depth'];
157         $this->_color  = (boolean)@$data['color'];
158
159         $this->_widthBytes  = (integer)@$data['width_bytes'];
160         $this->_heightBytes = (integer)@$data['height_bytes'];
161     }
162
163     // }}}
164     // {{{ calcSize()
165
166     /**
167      * returns width * height of the display
168      *
169      * @return integer
170      */
171     function calcSize()
172     {
173         return $this->_width * $this->_height;
174     }
175
176     // }}}
177     // {{{ getSize()
178
179     /**
180      * returns width with height of the display
181      *
182      * @return array
183      */
184     function getSize()
185     {
186         return array($this->_width, $this->_height);
187     }
188
189     // }}}
190     // {{{ getWidth()
191
192     /**
193      * returns width of the display
194      *
195      * @return integer
196      */
197     function getWidth()
198     {
199         return $this->_width;
200     }
201
202     // }}}
203     // {{{ getHeight()
204
205     /**
206      * returns height of the display
207      *
208      * @return integer
209      */
210     function getHeight()
211     {
212         return $this->_height;
213     }
214
215     // }}}
216     // {{{ getDepth()
217
218     /**
219      * returns depth of the display
220      *
221      * @return integer
222      */
223     function getDepth()
224     {
225         return $this->_depth;
226     }
227
228     // }}}
229     // {{{ isColor()
230
231     /**
232      * returns true if the display has color capability
233      *
234      * @return boolean
235      */
236     function isColor()
237     {
238         return $this->_color;
239     }
240
241     // }}}
242     // {{{ getWidthBytes()
243
244     /**
245      * returns width (bytes) of the display
246      *
247      * @return integer
248      */
249     function getWidthBytes()
250     {
251         return $this->_widthBytes;
252     }
253
254     // }}}
255     // {{{ getHeightBytes()
256
257     /**
258      * returns height (bytes) of the display
259      *
260      * @return integer
261      */
262     function getHeightBytes()
263     {
264         return $this->_heightBytes;
265     }
266
267     /**#@-*/
268
269     /**#@+
270      * @access private
271      */
272
273     /**#@-*/
274
275     // }}}
276 }
277
278 // }}}
279
280 /*
281  * Local Variables:
282  * mode: php
283  * coding: iso-8859-1
284  * tab-width: 4
285  * c-basic-offset: 4
286  * c-hanging-comment-ender-p: nil
287  * indent-tabs-mode: nil
288  * End:
289  */