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

Linux Cross Reference
Tina4/src/tv/tv_size.c

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

  1 /**@(#)
  2 **/
  3 #include <stdio.h>
  4 #include <tina/sys.h>
  5 #include <tina/math.h>
  6 #include <tina/tv.h>
  7 #include <tina/tvfuncs.h>
  8 #include <tina/tw_Xfuncs.h>
  9 
 10 /* EXTERNS */
 11 extern void tv_screen_set_width();
 12 extern void tv_screen_set_height();
 13 
 14 int     tv_get_width(Tv * tv)
 15 {
 16     return (tv->width);
 17 }
 18 
 19 int     tv_get_height(Tv * tv)
 20 {
 21     return (tv->height);
 22 }
 23 
 24 void    tv_rescale(Tv * tv)
 25 {
 26     if (tv && tv->tv_screen)
 27     {
 28         double  scalex, scaley, x, y;
 29         double  width = (double) tv_screen_get_width(tv->tv_screen);
 30         double  height = (double) tv_screen_get_height(tv->tv_screen);
 31 
 32         if (width != tv->width || height != tv->height)
 33         {
 34             scalex = width / tv->width;
 35             scaley = height / tv->height;
 36             if (tv->zoomlevel != ZOOMAF)
 37                 scalex = scaley = MIN(scalex, scaley);
 38 
 39             x = (tv->width / 2 - tv->cx) / tv->scalex;
 40             tv->width = (int)width;
 41             tv->scalex *= (float)scalex;
 42             tv->cx = (float)(tv->width / 2 - x * tv->scalex);
 43 
 44             y = (tv->height / 2 - tv->cy) / tv->scaley;
 45             tv->height = (int)height;
 46             tv->scaley *= (float)scaley;
 47             tv->cy = (float)(tv->height / 2 - y * tv->scaley);
 48 
 49             tv_free_background(tv);
 50         }
 51     }
 52 }
 53 
 54 void    tv_resize(Tv * tv, int repaint)
 55 {
 56     int     width, height;
 57     int     new_width, new_height;
 58     Bool    smaller;
 59 
 60     if (tv == NULL)
 61         return;
 62 
 63     /* let tv_screen know about resize */
 64     width = tv_screen_get_width(tv->tv_screen);
 65     height = tv_screen_get_height(tv->tv_screen);
 66     new_width = tv_screen_check_width(tv->tv_screen);
 67     new_height = tv_screen_check_height(tv->tv_screen);
 68     smaller = (Bool) ((new_width < width) && (new_height < height));
 69     tv_screen_set_width(tv->tv_screen, new_width);
 70     tv_screen_set_height(tv->tv_screen, new_height);
 71 
 72     /* let tv know about resize */
 73     tv_rescale(tv);
 74 
 75     /* re-allocate zbuffer */
 76     if (tv->zbuff != NULL)
 77         tv_set_zbuff(tv, tv->zbuff->zmin, tv->zbuff->zmax);
 78 
 79     switch (repaint)
 80     {
 81     case TV_SCREEN_REPAINT:
 82         tv_repaint(tv);
 83         break;
 84     case TV_SCREEN_REPAINT_IF_SMALLER:
 85         if (smaller)
 86             tv_repaint(tv);
 87         break;
 88     case TV_SCREEN_NO_REPAINT:
 89         break;
 90     default:
 91         break;
 92     }
 93 }
 94 

~ [ 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.