]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/fontdlgg.cpp
oops, more fixes needed
[wxWidgets.git] / src / generic / fontdlgg.cpp
index 1e5ecf63dd53f751fb9fd81dcba70fa31c658f12..9ac0c7dcfa4034a28728e1653ef1f27e5b0bd04c 100644 (file)
@@ -5,11 +5,11 @@
 // Modified by:
 // Created:     04/01/98
 // RCS-ID:      $Id$
-// Copyright:   (c) Julian Smart and Markus Holzem
-// Licence:     wxWindows license
+// Copyright:   (c) Julian Smart
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
 #pragma implementation "fontdlgg.h"
 #endif
 
@@ -74,14 +74,14 @@ void wxFontPreviewer::OnPaint(wxPaintEvent& WXUNUSED(event))
 
     if ( font.Ok() )
     {
-        dc.SetFont(GetFont());
+        dc.SetFont(font);
         // Calculate vertical centre
         long w, h;
-        dc.GetTextExtent("X", &w, &h);
+        dc.GetTextExtent( wxT("X"), &w, &h);
         dc.SetTextForeground(GetForegroundColour());
         dc.SetClippingRegion(2, 2, size.x-4, size.y-4);
         dc.DrawText(_("ABCDEFGabcdefg12345"), 
-                    10, h/2 + size.y/2);
+                     10, size.y/2 - h/2);
         dc.DestroyClippingRegion();
     }
 }
@@ -181,17 +181,20 @@ void wxGenericFontDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
 
 bool wxGenericFontDialog::DoCreate(wxWindow *parent)
 {
-#ifdef __WXMAC__
     if ( !wxDialog::Create( parent , -1 , _T("Choose Font") , wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE,
         _T("fontdialog") ) )
     {
         wxFAIL_MSG( wxT("wxFontDialog creation failed") );
         return FALSE;
     }
-#endif
+
   InitializeFont();
   CreateWidgets();
  
+  // sets initial font in preview area
+  wxCommandEvent dummy;
+  OnChangeFont(dummy);
+  
   return TRUE;
 }
 
@@ -201,7 +204,7 @@ int wxGenericFontDialog::ShowModal()
 
     if (ret != wxID_CANCEL)
     {
-      m_fontData.chosenFont = dialogFont;
+      m_fontData.m_chosenFont = dialogFont;
     }
 
     return ret;
@@ -238,8 +241,8 @@ void wxGenericFontDialog::CreateWidgets()
   int i;
   for ( i = 0; i < 40; i++)
   {
-    char buf[5];
-    sprintf(buf, "%d", i + 1);
+    wxChar buf[5];
+    wxSprintf(buf, wxT("%d"), i + 1);
     pointSizes[i] = buf;
   }
 
@@ -249,12 +252,12 @@ void wxGenericFontDialog::CreateWidgets()
   m_previewer = new wxFontPreviewer(this);
 
   wxButton *okButton = new wxButton(this, wxID_OK, _("OK"));
-  wxButton *cancelButton = new wxButton(this, wxID_OK, _("Cancel"));
+  wxButton *cancelButton = new wxButton(this, wxID_CANCEL, _("Cancel"));
 
   familyChoice->SetStringSelection( wxFontFamilyIntToString(dialogFont.GetFamily()) );
   styleChoice->SetStringSelection(wxFontStyleIntToString(dialogFont.GetStyle()));
   weightChoice->SetStringSelection(wxFontWeightIntToString(dialogFont.GetWeight()));
-  wxString name(wxTheColourDatabase->FindName(m_fontData.fontColour));
+  wxString name(wxTheColourDatabase->FindName(m_fontData.GetColour()));
   colourChoice->SetStringSelection(name);
 
   underLineCheckBox->SetValue(dialogFont.GetUnderlined());
@@ -307,13 +310,13 @@ void wxGenericFontDialog::InitializeFont()
   int fontSize = 12;
   int fontUnderline = FALSE;
 
-  if (m_fontData.initialFont.Ok())
+  if (m_fontData.m_initialFont.Ok())
   {
-      fontFamily = m_fontData.initialFont.GetFamily();
-      fontWeight = m_fontData.initialFont.GetWeight();
-      fontStyle = m_fontData.initialFont.GetStyle();
-      fontSize = m_fontData.initialFont.GetPointSize();
-      fontUnderline = m_fontData.initialFont.GetUnderlined();
+      fontFamily = m_fontData.m_initialFont.GetFamily();
+      fontWeight = m_fontData.m_initialFont.GetWeight();
+      fontStyle = m_fontData.m_initialFont.GetStyle();
+      fontSize = m_fontData.m_initialFont.GetPointSize();
+      fontUnderline = m_fontData.m_initialFont.GetUnderlined();
   }
 
   dialogFont = wxFont(fontSize, fontFamily, fontStyle, fontWeight, (fontUnderline != 0));
@@ -326,12 +329,9 @@ void wxGenericFontDialog::OnChangeFont(wxCommandEvent& WXUNUSED(event))
 {
   if (!m_useEvents) return;
 
-  int fontFamily = 0;  /* shut up buggy egcs warnings */
-  fontFamily = wxFontFamilyStringToInt(WXSTRINGCAST familyChoice->GetStringSelection());
-  int fontWeight = 0;
-  fontWeight = wxFontWeightStringToInt(WXSTRINGCAST weightChoice->GetStringSelection());
-  int fontStyle = 0;
-  fontStyle = wxFontStyleStringToInt(WXSTRINGCAST styleChoice->GetStringSelection());
+  int fontFamily = wxFontFamilyStringToInt(WXSTRINGCAST familyChoice->GetStringSelection());
+  int fontWeight = wxFontWeightStringToInt(WXSTRINGCAST weightChoice->GetStringSelection());
+  int fontStyle = wxFontStyleStringToInt(WXSTRINGCAST styleChoice->GetStringSelection());
   int fontSize = wxAtoi(pointSizeChoice->GetStringSelection());
   int fontUnderline = underLineCheckBox->GetValue();
 
@@ -339,12 +339,11 @@ void wxGenericFontDialog::OnChangeFont(wxCommandEvent& WXUNUSED(event))
   m_previewer->SetFont(dialogFont);
   if (colourChoice->GetStringSelection() != wxT(""))
   {
-    wxColour *col = (wxColour*) NULL;
-    col = wxTheColourDatabase->FindColour(colourChoice->GetStringSelection());
-    if (col)
+    wxColour col = wxTheColourDatabase->Find(colourChoice->GetStringSelection());
+    if (col.Ok())
     {
-      m_fontData.fontColour = *col;
-      m_previewer->SetForegroundColour(*col);
+      m_fontData.m_fontColour = col;
+      m_previewer->SetForegroundColour(col);
     }
   }
   m_previewer->Refresh();