]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/font.cpp
Commented out Robert's SetFont change for now; changed menu handling slightly
[wxWidgets.git] / src / gtk / font.cpp
index db97e5010e76251e99294b2c4e2950c06d8995fe..2152854752a24da066716e1d87d51cafb713cf87 100644 (file)
 //-----------------------------------------------------------------------------
 
 static char *wx_font_family [] = {
-    "wxDEFAULT", "wxDECORATIVE", "wxMODERN", "wxROMAN", "wxSCRIPT",
-    "wxSWISS", "wxTELETYPE",
+    "wxDEFAULT", "wxDECORATIVE", "wxROMAN", "wxSCRIPT",
+    "wxSWISS", "wxMODERN", "wxTELETYPE",
 };
 
+/*
 static char *wx_font_style [] = {
     "wxDEFAULT", "wxNORMAL", "wxSLANT", "wxITALIC",
 };
@@ -32,6 +33,7 @@ static char *wx_font_style [] = {
 static char *wx_font_weight [] = {
     "wxDEFAULT", "wxNORMAL", "wxBOLD", "wxLIGHT",
 };
+*/
 
 extern wxFontNameDirectory *wxTheFontNameDirectory;
 
@@ -68,8 +70,8 @@ wxFontRefData::wxFontRefData(void) : m_scaled_xfonts(wxKEY_INTEGER)
   m_weight = -1;
   m_underlined = FALSE;
   m_fontId = 0;
-  m_faceName = NULL;
-  m_font = NULL;
+  m_faceName = (char *) NULL;
+  m_font = (GdkFont *) NULL;
 }
 
 wxFontRefData::~wxFontRefData(void)
@@ -85,7 +87,7 @@ wxFontRefData::~wxFontRefData(void)
   if (m_faceName) 
   {
     delete m_faceName;
-    m_faceName = NULL;
+    m_faceName = (char *) NULL;
   }
   if (m_font) gdk_font_unref( m_font );
 }
@@ -153,12 +155,16 @@ wxFont::wxFont(int PointSize, const char *Face, int Family, int Style,
 wxFont::wxFont( const wxFont& font )
 { 
   Ref( font ); 
+  
+  if (wxTheFontList) wxTheFontList->Append( this );
 }
 
 wxFont::wxFont( const wxFont* font ) 
 { 
   UnRef(); 
   if (font) Ref( *font ); 
+  
+  if (wxTheFontList) wxTheFontList->Append( this );
 }
 
 wxFont::~wxFont(void)
@@ -212,7 +218,7 @@ int wxFont::GetFamily(void) const
 
 wxString wxFont::GetFamilyString(void) const
 {
-  wxString s = wx_font_family[M_FONTDATA->m_family];
+  wxString s = wx_font_family[M_FONTDATA->m_family - wxDEFAULT];
   return s;
 }
 
@@ -228,8 +234,27 @@ int wxFont::GetStyle(void) const
 
 wxString wxFont::GetStyleString(void) const
 {
-  wxString s =  wx_font_style[M_FONTDATA->m_style];
-  return s;
+    switch (M_FONTDATA->m_style)
+    {
+        case wxNORMAL:
+        {
+            return wxString("wxNORMAL");
+        }
+        case wxSLANT:
+        {
+            return wxString("wxSLANT");
+        }
+        case wxITALIC:
+        {
+            return wxString("wxITALIC");
+        }
+        case wxDEFAULT:
+        default:
+        {
+            return wxString("wxDEFAULT");
+        }
+    }
+    return wxString("wxDEFAULT");
 }
 
 int wxFont::GetWeight(void) const
@@ -239,8 +264,27 @@ int wxFont::GetWeight(void) const
 
 wxString wxFont::GetWeightString(void) const
 {
-  wxString s = wx_font_weight[M_FONTDATA->m_weight];
-  return s;
+    switch (M_FONTDATA->m_weight)
+    {
+        case wxNORMAL:
+        {
+            return wxString("wxNORMAL");
+        }
+        case wxBOLD:
+        {
+            return wxString("wxBOLD");
+        }
+        case wxLIGHT:
+        {
+            return wxString("wxLIGHT");
+        }
+        case wxDEFAULT:
+        default:
+        {
+            return wxString("wxDEFAULT");
+        }
+    }
+    return wxString("wxDEFAULT");
 }
 
 bool wxFont::GetUnderlined(void) const
@@ -263,7 +307,7 @@ GdkFont *wxFont::GetInternalFont(float scale) const
    
   long int_scale = long(scale * 100.0 + 0.5); // key for fontlist
   int point_scale = (M_FONTDATA->m_pointSize * 10 * int_scale) / 100;
-  GdkFont *font = NULL;
+  GdkFont *font = (GdkFont *) NULL;
 
   wxNode *node = M_FONTDATA->m_scaled_xfonts.Find(int_scale);
   if (node) 
@@ -436,7 +480,7 @@ static char *font_defaults[] = {
     "-${ScreenSwissBase}${ScreenStdSuffix}",
     "ScreenScript__",
     "-${ScreenScriptBase}${ScreenStdSuffix}",
-    NULL
+    (char *) NULL
 };
 
 enum {wxWEIGHT_NORMAL, wxWEIGHT_BOLD,  wxWEIGHT_LIGHT, wxNUM_WEIGHTS};
@@ -490,8 +534,8 @@ static void SearchResource(const char *prefix, const char **names, int count, ch
 
     k = 1 << count;
     
-    *v = NULL;
-    internal = NULL;
+    *v = (char *) NULL;
+    internal = (char *) NULL;
 
     for (i = 0; i < k; i++) {
        strcpy(resource, prefix);
@@ -526,7 +570,7 @@ wxSuffixMap::~wxSuffixMap(void)
        for (j = 0; j < wxNUM_STYLES; ++j)
            if (map[k][j]) {
                delete[] map[k][j];
-               map[k][j] = NULL;
+               map[k][j] = (char *) NULL;
            }
 }
 
@@ -569,7 +613,7 @@ void wxSuffixMap::Initialize(const char *resname, const char *devresname)
                    ++i;
                } else if (v[i] == closer) {
                    int newstrlen;
-                   const char *r = NULL; bool delete_r = FALSE;
+                   const char *r = (char *) NULL; bool delete_r = FALSE;
                    char *name;
          
                    name = v + startpos + 2;
@@ -680,7 +724,7 @@ wxFontNameItem::~wxFontNameItem(void)
 {
     if (name)
        delete[] name;
-    name = NULL;
+    name = (char *) NULL;
 }
 
 #if WXDEBUG
@@ -736,7 +780,7 @@ void wxFontNameDirectory::Initialize(int fontid, int family, const char *resname
     char *fam, resource[256];
   
     sprintf(resource, "Family%s", resname);
-    SearchResource((const char *)resource, NULL, 0, (char **)&fam);
+    SearchResource((const char *)resource, (const char **) NULL, 0, (char **)&fam);
     if (fam) {
        if      (!strcmp(fam, "Default"))       family = wxDEFAULT;
        else if (!strcmp(fam, "Roman"))         family = wxROMAN;
@@ -767,7 +811,7 @@ char *wxFontNameDirectory::GetScreenName(int fontid, int weight, int style)
     if (item)
        return item->GetScreenName(weight, style);
     // font does not exist
-    return NULL;
+    return (char *) NULL;
 }
 
 char *wxFontNameDirectory::GetPostScriptName(int fontid, int weight, int style)
@@ -776,7 +820,7 @@ char *wxFontNameDirectory::GetPostScriptName(int fontid, int weight, int style)
     if (item)
        return item->GetPostScriptName(weight, style);
     // font does not exist
-    return NULL;
+    return (char *) NULL;
 }
 
 char *wxFontNameDirectory::GetAFMName(int fontid, int weight, int style)
@@ -785,7 +829,7 @@ char *wxFontNameDirectory::GetAFMName(int fontid, int weight, int style)
     if (item)
        return item->GetAFMName(weight, style);
     // font does not exist
-    return NULL;
+    return (char *) NULL;
 }
 
 char *wxFontNameDirectory::GetFontName(int fontid)
@@ -794,7 +838,7 @@ char *wxFontNameDirectory::GetFontName(int fontid)
     if (item)
        return item->GetName();
     // font does not exist
-    return NULL;
+    return (char *) NULL;
 }
 
 int wxFontNameDirectory::GetFontId(const char *name)