Changeset 515


Ignore:
Timestamp:
Nov 21, 2005, 6:24:33 PM (15 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Added caca_set_width, set_height_, set_size
Location:
libcaca/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/examples/cacaball.c

    r514 r515  
    6060    int p, frame = 0, pause = 0;
    6161
     62    caca_set_size(40,40);
    6263    if(caca_init())
    6364        return 1;
  • libcaca/trunk/src/caca.h

    r508 r515  
    251251unsigned int caca_get_width(void);
    252252unsigned int caca_get_height(void);
     253void caca_set_size(unsigned int width, unsigned int height);
     254void caca_set_width(unsigned int width);
     255void caca_set_height(unsigned int height);
    253256int caca_set_window_title(char const *);
    254257unsigned int caca_get_window_width(void);
  • libcaca/trunk/src/graphics.c

    r513 r515  
    673673int _caca_init_graphics(void)
    674674{
     675
     676
    675677#if defined(HAVE_SIGNAL) && (defined(USE_NCURSES) || defined(USE_SLANG))
    676678    signal(SIGWINCH, sigwinch_handler);
     
    806808        int i;
    807809
     810        if(!_caca_width && !_caca_height)
    808811        if(getenv("CACA_GEOMETRY") && *(getenv("CACA_GEOMETRY")))
    809812            sscanf(getenv("CACA_GEOMETRY"),
     
    932935        /* Sample code to get the biggest possible window */
    933936        //size = GetLargestConsoleWindowSize(win32_hout);
    934 
    935         _caca_width = csbi.srWindow.Right - csbi.srWindow.Left + 1;
    936         _caca_height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
    937 
     937        if(!_caca_width && !_caca_height)
     938          {
     939            _caca_width = csbi.srWindow.Right - csbi.srWindow.Left + 1;
     940            _caca_height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
     941          }
    938942        size.X = _caca_width;
    939943        size.Y = _caca_height;
     
    965969        int i;
    966970        char *empty;
    967 
    968         if(getenv("CACA_GEOMETRY") && *(getenv("CACA_GEOMETRY")))
     971       
     972        if(!_caca_width && !_caca_height)
     973          if(getenv("CACA_GEOMETRY") && *(getenv("CACA_GEOMETRY")))
    969974            sscanf(getenv("CACA_GEOMETRY"),
    970975                   "%ux%u", &_caca_width, &_caca_height);
     
    10541059    if(_caca_driver == CACA_DRIVER_NULL)
    10551060    {
     1061      if(!_caca_width && !_caca_height)
    10561062        if(getenv("CACA_GEOMETRY") && *(getenv("CACA_GEOMETRY")))
    1057             sscanf(getenv("CACA_GEOMETRY"),
    1058                   "%ux%u", &_caca_width, &_caca_height);
    1059         if(!_caca_width)
    1060             _caca_width = 80;
    1061         if(!_caca_height)
    1062             _caca_height = 32;
     1063          sscanf(getenv("CACA_GEOMETRY"),
     1064                "%ux%u", &_caca_width, &_caca_height);
     1065      if(!_caca_width)
     1066        _caca_width = 80;
     1067      if(!_caca_height)
     1068        _caca_height = 32;
    10631069    }
    10641070    else
     
    12801286    return _caca_height * 10;
    12811287}
     1288
     1289
     1290/** \brief Set the size of the display on devices that permit it
     1291 *
     1292 *  This function sets the display width and height, on devices
     1293 *  that permit it. We're talking here about the size in
     1294 *  CHARACTERS fo the window, NOT in pixels.
     1295 *  \param width The width of the window, in CHARACTERS.
     1296 *  \param heigth The height of the window, in CHARACTERS.
     1297 */
     1298void caca_set_size(unsigned int width, unsigned int height)
     1299{
     1300  _caca_width = width;
     1301  _caca_height = height;
     1302}
     1303
     1304
     1305
     1306/** \brief Set the width of the window, in characters, if device permits it.
     1307 *
     1308 *  This function sets the width of displayable image, in characters.
     1309 *  \param width The width of the window, in CHARACTERS.
     1310 */
     1311void caca_set_width(unsigned int width)
     1312{
     1313   _caca_width = width;
     1314}
     1315/** \brief Set the height of the window, in characters, if device permits it.
     1316 *
     1317 *  This function sets the height of displayable image, in characters.
     1318 *  \param width The width of the window, in CHARACTERS.
     1319 */
     1320void caca_set_height(unsigned int height)
     1321{
     1322   _caca_height = height;
     1323}
     1324
     1325
    12821326
    12831327/** \brief Set the refresh delay.
Note: See TracChangeset for help on using the changeset viewer.