~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina6/tina-tools/tinatool/gphx/gdk2/gphxGdk_size.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**********
  2  * 
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  * 
 35  * Program :  TINA
 36  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/gphx/gdk2/gphxGdk_size.c,v $
 37  * Date    :  $Date: 2005/06/01 20:06:26 $
 38  * Version :  $Revision: 1.1 $
 39  * CVS Id  :  $Id: gphxGdk_size.c,v 1.1 2005/06/01 20:06:26 paul Exp $
 40  *
 41  * Author  :  giob@man.ac.uk, paul.bromiley@manchester.ac.uk
 42  *
 43  *********
 44 */
 45 /** 
 46  *  @file  gphxGdk_size.c
 47  *  @brief Set and check the stored and allocated screen sizes and colour depths.
 48  *
 49  *  Tina stores the width, height and colour depth of a GDK drawable in a Tv_screen struct
 50  *  associated with the drawable.  However, GDK does not set absolute dimensions for its
 51  *  windows - it requests dimensions from the window manager, which may elect to allocate
 52  *  different values (especially if the user has done some resizing).
 53  *
 54  *  The functions in this file query the dimensions and colour depth stored in the Tv_screen
 55  *  struct and those allocated by the window manager.  They allow the stored values to be
 56  *  updated to match the allocated ones. 
 57  *
 58  *  Note: the functions in this file are duplicated for each graphics lib (x11, GDK, etc ...).
 59  *
 60  */
 61 
 62 
 63 #include "gphxGdk_size.h"
 64 
 65 #if HAVE_CONFIG_H
 66   #include <config.h>
 67 #endif
 68 
 69 #include <gtk/gtk.h>
 70 
 71 
 72 /**
 73  * @brief  Get the width the Tv_screen thinks it is.  
 74  * @param  tv_screen   Pointer to the Tv_screen to be queried.
 75  * @return int   Width stored in Tv_screen struct.
 76  *
 77  * Note that this may not be the width allocated to the screen by 
 78  * the window manager.
 79  */
 80 int   tv_screen_get_width(Tv_screen *tv_screen)
 81 {
 82   return (tv_screen->width);
 83 }
 84 
 85 /**
 86  * @brief  Set the width the Tv_screen thinks it should be.  
 87  * @param  tv_screen  Pointer to the Tv_screen to be modified.
 88  * @param  width      Integer width to be stored in Tv_screen struct.
 89  *
 90  * Note that this may not be the width allocated to the screen by 
 91  * the window manager.
 92  */
 93 void   tv_screen_set_width(Tv_screen *tv_screen, int width)
 94 {
 95   tv_screen->width = width;
 96 }
 97 
 98 /**
 99  * @brief  Get the width allocated to a screen.  
100  * @param  tv_screen   Pointer to the Tv_screen to be queried.
101  * @return int   Width allocated to tv_screen.
102  *
103  * Note that this may not be the same width stored in the
104  * associated Tv_screen struct.
105  */
106 int   tv_screen_check_width(Tv_screen *tv_screen)
107 {
108   int  width = 0;
109 
110   if(tv_screen)
111     width = (int) (GTK_WIDGET(tv_screen->canvas)->allocation.width);
112 
113   return width;
114 }
115 
116 /**
117  * @brief  Get the height the Tv_screen thinks it is.  
118  * @param  tv_screen   Pointer to the Tv_screen to be queried.
119  * @return int   Height stored in Tv_screen struct.
120  *
121  * Note that this may not be the height allocated to the screen by 
122  * the window manager.
123  */
124 int   tv_screen_get_height(Tv_screen *tv_screen)
125 {
126   return (tv_screen->height);
127 }
128 
129 /**
130  * @brief  Set the height the Tv_screen thinks it should be.  
131  * @param  tv_screen  Pointer to the Tv_screen to be modified.
132  * @param  width      Integer height to be stored in Tv_screen struct.
133  *
134  * Note that this may not be the height allocated to the screen by 
135  * the window manager.
136  */
137 void   tv_screen_set_height(Tv_screen *tv_screen, int height)
138 {
139   tv_screen->height = height;
140 }
141 
142 /**
143  * @brief  Get the height allocated to a screen.  
144  * @param  tv_screen   Pointer to the Tv_screen to be queried.
145  * @return int   Height allocated to tv_screen.
146  *
147  * Note that this may not be the same height stored in the
148  * associated Tv_screen struct.
149  */
150 int   tv_screen_check_height(Tv_screen *tv_screen)
151 {
152   int  height = 0;
153 
154   if(tv_screen)
155     height = (int) (GTK_WIDGET(tv_screen->canvas)->allocation.height);
156 
157   return height;
158 }
159 
160 /**
161  * @brief  Get the colour depth the Tv_screen thinks it has.  
162  * @param  tv_screen   Pointer to the Tv_screen to be queried.
163  * @return int   Colour depth stored in Tv_screen struct.
164  *
165  * Note that this may not be the actual colour depth of the current visual.
166  */
167 int   tv_screen_get_depth(Tv_screen *tv_screen)
168 {
169   return (tv_screen->depth);
170 }
171 
172 /**
173  * @brief  Get the best colour depth of a screen.  
174  * @param  tv_screen   Pointer to the Tv_screen to be queried.
175  * @return int   Best colour depth of the tv_screen visual.
176  *
177  * Note that this may not be the colour depth stored in the
178  * associated Tv_screen struct.
179  */
180 int   tv_screen_check_depth(Tv_screen *tv_screen)
181 {
182   int  depth = 0;
183 
184   if(tv_screen)
185     depth = (int) gdk_visual_get_best_depth();
186 
187   return depth;
188 }
189 
190 /**
191  * @brief  Match stored and allocated screen size and colour depth.  
192  * @param  tv_screen  Pointer to the Tv_screen to be queried/set.
193  * 
194  * Allocated sizes may not match requisition sizes, so check them and
195  * reset if necessary to match them.
196  */
197 void   tv_screen_save_size(Tv_screen *tv_screen)
198 {
199   if (tv_screen == NULL)
200     return;
201 
202   tv_screen->width  = tv_screen_check_width(tv_screen);
203   tv_screen->height = tv_screen_check_height(tv_screen);
204   tv_screen->depth  = tv_screen_check_depth(tv_screen);
205 }
206 
207 /**
208  * @brief  Print stored and allocated screen sizes and colour depth.  
209  * @param  tv_screen  Pointer to the Tv_screen to be queried.
210  *
211  * Debugging aid.
212  */
213 void   size_format(Tv_screen *tv_screen)
214 {
215   int     width, height, depth;
216 
217   width  = tv_screen->width;
218   height = tv_screen->height;
219   depth  = tv_screen->depth;
220   format("tv_screen get size   :  %d x %d x %d\n", width, height, depth);
221 
222   width  = tv_screen_check_width(tv_screen);
223   height = tv_screen_check_height(tv_screen);
224   depth  = tv_screen_check_depth(tv_screen);
225   format("tv_screen check size :  %d x %d x %d\n", width, height, depth);
226 }
227 
228 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.