ufontMetrics.hpp

00001 /* ==================================================== ======== ======= *
00002 *
00003 *  ufontMetrics.hpp
00004 *  Ubit Project
00005 *  Author: Eric Lecolinet
00006 *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00007 *  (C) 1999-2006 / EricLecolinet / ENST Paris / http://www.enst.fr/~elc/ubit
00008 *
00009 * ***********************************************************************
00010 * COPYRIGHT NOTICE : 
00011 * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 
00012 * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 
00013 * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 
00014 * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00015 * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00016 * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00017 * ***********************************************************************
00018 * ==================================================== [(c)Elc] ======= *
00019 * ==================================================== ======== ======= */
00020 
00021 #ifndef _ufontMetrics_hpp_
00022 #define _ufontMetrics_hpp_
00023 #include <ubit/uappli.hpp>
00024 //pragma ident  "@(#)ufontMetrics.hpp   ubit:05.05.00"
00025 namespace ubit {
00026 
00027 struct UFontMetrics {
00028 
00029   UFontMetrics(UContext&);
00030   UFontMetrics(const UFont&, UDisp*);
00031   UFontMetrics(const UFontDesc&, UDisp*);
00036   ~UFontMetrics();
00037   
00038   int  getCharWidth(UChar) const;
00040   
00041   int  getTextWidth(const UStr&) const;
00042   int  getTextWidth(const char* str, int str_len) const;
00043   int  getTextHeight() const;
00044   void getTextSize(const UStr&, int& width, int& height) const;
00045   void getTextSize(const char* str, int str_len, int& width, int& height) const;  
00047   
00048   int getCharPos(const char* str, int str_len, int x) const;
00049   int getXPos(const char* str, int str_len, int char_pos) const;
00051   
00052   bool getSubTextSize(const char* str, int str_len, 
00053                       int& w, int& h, int available_width, 
00054                       int& sublen, int& change_line) const;
00065   static bool getClippedText(UGraph*, float clip_x, float clip_width,
00066                              const char*, int len, float x0, float y0,
00067                              int& charpos_begin, int& charpos_end,
00068                              float& xpos_begin, float& xpos_end);
00074 protected:
00075   UDisp& disp;
00076   const UFontDesc& font;
00077   bool own_font;
00078 };
00079 
00080 }
00081 #endif
00082 /* ==================================================== [TheEnd] ======= */
00083 /* ==================================================== [(c)Elc] ======= */

Generated on Mon Jan 29 00:20:38 2007 for Ubit by  doxygen 1.4.7