Back to index

plt-scheme  4.2.1
Font.h
Go to the documentation of this file.
00001 /*                                                      -*- C++ -*-
00002  *
00003  * Purpose: wxWindows font handling
00004  *
00005  * Authors: Markus Holzem and Julian Smart
00006  *
00007  * Copyright: (C) 2004-2009 PLT Scheme Inc.
00008  * Copyright: (C) 1995, AIAI, University of Edinburgh (Julian)
00009  * Copyright: (C) 1995, GNU (Markus)
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00024  * 02110-1301 USA.
00025  */
00026 
00027 #ifndef Font_h
00028 #define Font_h
00029 
00030 #ifdef __GNUG__
00031 #pragma interface
00032 #endif
00033 
00034 extern char *wx_font_spec[];
00035 
00036 #ifdef WX_USE_XFT
00037 # define wxFontStruct XftFont
00038 #else
00039 # define wxFontStruct XFontStruct
00040 #endif
00041 
00042 class wxFont : public wxObject {
00043 public:
00044     wxFont(void);
00045     wxFont(int PointSize, int FontIdOrFamily, int Style, int Weight,
00046           Bool underlined = FALSE, int smoothing = wxSMOOTHING_DEFAULT, 
00047           Bool sip = FALSE, double Rotation = 0.0);
00048     wxFont(int PointSize, const char *Face, int Family, int Style, int Weight, 
00049           Bool underlined = FALSE, int smoothing = wxSMOOTHING_DEFAULT, 
00050           Bool sip = FALSE);
00051     ~wxFont(void);
00052 
00053     void InitFont(void);
00054 
00055     int   GetPointSize(void)     { return point_size; }
00056     int   GetFamily(void)        { return family; }
00057     char  *GetFamilyString(void) { return wx_font_spec[family]; }
00058     int   GetFontId(void)        { return font_id; }
00059     char  *GetFaceString(void);
00060     int   GetStyle(void)         { return style; }
00061     char  *GetStyleString(void)  { return wx_font_spec[style]; }
00062     int   GetWeight(void)    { return weight==wxNORMAL_WEIGHT ? wxNORMAL : weight; }
00063     char  *GetWeightString(void) { return wx_font_spec[weight]; }
00064     Bool  GetUnderlined(void)    { return underlined; }
00065     int   GetSmoothing(void)     { return smoothing; }
00066     int   GetSizeInPixels(void)  { return size_in_pixels; }
00067 
00068     Bool  ScreenGlyphAvailable(int c, Bool for_label = FALSE);
00069 
00070     wxFont *GetRotated(double angle);
00071     int CanRotate();
00072 
00073     void  *GetInternalFont(double scale_x = 1.0, double scale_y = 1.0, double angle = 0.0); // return type XFontStruct*
00074     void  *GetInternalAAFont(double scale_x = 1.0, double scale_y = 1.0, double angle = 0.0); // return type wxFontStruct*
00075 
00076 #ifdef WX_USE_XFT
00077     int HasAASubstitutions(void);
00078     void *GetNextAASubstitution(int index, int cval, double scale_x, double scale_y, double angle);
00079 #endif
00080 
00081 private:
00082     wxList *scaled_xfonts;
00083 #ifdef WX_USE_XFT
00084     wxList *scaled_xft_fonts;
00085     wxList *substitute_xft_fonts;
00086 #endif
00087     wxList *rotated_fonts;
00088     short  point_size;
00089     short  family, style, weight;
00090     Bool   underlined, size_in_pixels;
00091     int    font_id;
00092     int    smoothing;
00093     double  rotation;
00094     char   *main_screen_name;
00095 };
00096 
00097 class wxFontList : public wxObject {
00098    wxChildList *list;
00099 public:
00100     wxFontList(void);
00101     ~wxFontList(void);
00102 
00103     void AddFont(wxFont *font);
00104 
00105     wxFont *FindOrCreateFont(int PointSize, int FontIdOrFamily, int Style, 
00106                           int Weight, Bool underline = FALSE,
00107                           int smoothing = wxSMOOTHING_DEFAULT, 
00108                           Bool sip = FALSE);
00109     wxFont *FindOrCreateFont(int PointSize, const char *Face, int Family, 
00110                           int Style, int Weight,
00111                           Bool underline = FALSE,
00112                           int smoothing = wxSMOOTHING_DEFAULT, 
00113                           Bool sip = FALSE);
00114 };
00115 
00116 extern int wxGetControlFontSize();
00117 
00118 #endif // Font_h