/////////////////////////////////////////////////////////////////////////////
-// Name: fontdlgg.cpp
+// Name: src/generic/fontdlgg.cpp
// Purpose: Generic font dialog
// Author: Julian Smart
// Modified by:
#include "wx/cmndata.h"
#include "wx/sizer.h"
-#include "wx/generic/fontdlgg.h"
+#include "wx/fontdlg.h"
//-----------------------------------------------------------------------------
// helper class - wxFontPreviewer
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();
}
}
* Generic wxFontDialog
*/
-wxGenericFontDialog::wxGenericFontDialog(void)
+void wxGenericFontDialog::Init()
{
m_useEvents = FALSE;
m_previewer = NULL;
- dialogParent = NULL;
+ Create( m_parent ) ;
}
-wxGenericFontDialog::wxGenericFontDialog(wxWindow *parent, const wxFontData& data):
- wxDialog(parent, -1, _("Font"), wxDefaultPosition, wxDefaultSize,
- wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL|wxRESIZE_BORDER)
-{
- m_useEvents = FALSE;
- m_previewer = NULL;
- Create(parent, data);
-}
-
-wxGenericFontDialog::~wxGenericFontDialog(void)
+wxGenericFontDialog::~wxGenericFontDialog()
{
}
EndModal(wxID_CANCEL);
}
-bool wxGenericFontDialog::Create(wxWindow *parent, const wxFontData& data)
+bool wxGenericFontDialog::DoCreate(wxWindow *parent)
{
- dialogParent = parent;
-
- fontData = data;
+ if ( !wxDialog::Create( parent , -1 , _T("Choose Font") , wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE,
+ _T("fontdialog") ) )
+ {
+ wxFAIL_MSG( wxT("wxFontDialog creation failed") );
+ return FALSE;
+ }
InitializeFont();
CreateWidgets();
+ // sets initial font in preview area
+ wxCommandEvent dummy;
+ OnChangeFont(dummy);
+
return TRUE;
}
-int wxGenericFontDialog::ShowModal(void)
+int wxGenericFontDialog::ShowModal()
{
- int ret = wxDialog::ShowModal();
+ int ret = wxDialog::ShowModal();
if (ret != wxID_CANCEL)
{
- fontData.chosenFont = dialogFont;
+ m_fontData.chosenFont = dialogFont;
}
return ret;
}
-void wxGenericFontDialog::CreateWidgets(void)
+void wxGenericFontDialog::CreateWidgets()
{
wxBusyCursor bcur;
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;
}
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(fontData.fontColour));
+ wxString name(wxTheColourDatabase->FindName(m_fontData.fontColour));
colourChoice->SetStringSelection(name);
underLineCheckBox->SetValue(dialogFont.GetUnderlined());
m_useEvents = TRUE;
}
-void wxGenericFontDialog::InitializeFont(void)
+void wxGenericFontDialog::InitializeFont()
{
int fontFamily = wxSWISS;
int fontWeight = wxNORMAL;
int fontSize = 12;
int fontUnderline = FALSE;
- if (fontData.initialFont.Ok())
+ if (m_fontData.initialFont.Ok())
{
- fontFamily = fontData.initialFont.GetFamily();
- fontWeight = fontData.initialFont.GetWeight();
- fontStyle = fontData.initialFont.GetStyle();
- fontSize = fontData.initialFont.GetPointSize();
- fontUnderline = fontData.initialFont.GetUnderlined();
+ 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();
}
dialogFont = wxFont(fontSize, fontFamily, fontStyle, fontWeight, (fontUnderline != 0));
col = wxTheColourDatabase->FindColour(colourChoice->GetStringSelection());
if (col)
{
- fontData.fontColour = *col;
+ m_fontData.fontColour = *col;
m_previewer->SetForegroundColour(*col);
}
}