Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

gfxutil.cpp

Go to the documentation of this file.
00001 /*  gfxutil.cpp
00002     Some graphic utility functions
00003 
00004     22.12.2001: tk, initial implementation.
00005 
00006     Copyright (c)2000 by Thomas Kindler, thomas.kindler@gmx.de
00007 
00008     This program is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU General Public License as
00010     published by the Free Software Foundation; either version 2 of
00011     the License, or (at your option) any later version. Read the
00012     full License at http://www.gnu.org/copyleft for more details.
00013 */
00014 
00015 // include files -----
00016 //
00017 #include <stdio.h>
00018 #include "gfxcore.h"
00019 #include "gfxutil.h"
00020 
00021 
00038 void GFX_RoundRect(Graphics *gfx, int x, int y, int w, int h,
00039                                   int r, bool shadow)
00040 {
00041   // draw frame
00042   GFX_HLine(gfx, x+r,   y,     w-r*2);  // top
00043   GFX_HLine(gfx, x+r,   y+h-1, w-r*2);  // bottom
00044   GFX_VLine(gfx, x,     y+r,   h-r*2);  // left
00045   GFX_VLine(gfx, x+w-1, y+r,   h-r*2);  // right
00046 
00047   // draw edges
00048   GFX_Line(gfx, x+1,   y+r-1, x+r-1, y+1  ); // top-left
00049   GFX_Line(gfx, x+w-r, y+1,   x+w-2, y+r-1); // top-right
00050   GFX_Line(gfx, x+1,   y+h-r, x+r-1, y+h-2); // bottom-left
00051   GFX_Line(gfx, x+w-r, y+h-2, x+w-2, y+h-r); // bottom-right
00052 
00053   // draw shadow
00054   if (shadow) {
00055     GFX_HLine(gfx, x+r+1, y+h,   w-r*2-1);  // bottom
00056     GFX_VLine(gfx, x+w  , y+r+1, h-r*2-1);  // right
00057     GFX_Line (gfx, x+w-r-1, y+h, x+w-1, y+h-r); // bottom-right
00058   }
00059 }
00060 
00061 
00070 void GFX_ProgressBar( Graphics *gfx, int x, int y, int w, int h,
00071                       float value, float min, float max )
00072 {
00073   Graphics g;
00074   GFX_Init(&g, gfx);    // work on a copy of the context..
00075 
00076   if (value>max) value = max;
00077   if (value<min) value = min;
00078   int width = ((value-min)/(max-min))*(w-4);
00079 
00080   GFX_Rectangle(&g, x, y, w, h);
00081 
00082   GFX_SetBlitMode(&g, BLT_COPY);
00083   GFX_SetFillStyle(&g, emptyFill);
00084   GFX_FillRect(&g, x+width+2, y+1, w-width-4, h-2);
00085 
00086   GFX_SetBlitMode(&g, BLT_XOR);
00087   GFX_SetFillStyle(&g, xLeaveFill);
00088   GFX_FillRect(&g, x+2, y+2, width, h-4);
00089 }

Generated on Sun Aug 4 21:47:28 2002 for k/os mp3v2 by doxygen1.2.16