// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWidgets licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#include "wx/cmndata.h"
#include "wx/sizer.h"
#include "wx/fontdlg.h"
+#include "wx/generic/fontdlgg.h"
#include "wx/settings.h"
//-----------------------------------------------------------------------------
class WXDLLEXPORT wxFontPreviewer : public wxWindow
{
public:
- wxFontPreviewer(wxWindow *parent) : wxWindow(parent, -1) {}
+ wxFontPreviewer(wxWindow *parent) : wxWindow(parent, wxID_ANY) {}
private:
void OnPaint(wxPaintEvent& event);
dc.GetTextExtent( wxT("X"), &w, &h);
dc.SetTextForeground(GetForegroundColour());
dc.SetClippingRegion(2, 2, size.x-4, size.y-4);
- dc.DrawText(_("ABCDEFGabcdefg12345"),
+ dc.DrawText(_("ABCDEFGabcdefg12345"),
10, size.y/2 - h/2);
dc.DestroyClippingRegion();
}
void wxGenericFontDialog::Init()
{
- m_useEvents = FALSE;
+ m_useEvents = false;
m_previewer = NULL;
Create( m_parent ) ;
}
bool wxGenericFontDialog::DoCreate(wxWindow *parent)
{
- if ( !wxDialog::Create( parent , -1 , _T("Choose Font") , wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE,
+ if ( !wxDialog::Create( parent , wxID_ANY , _T("Choose Font") , wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE,
_T("fontdialog") ) )
{
wxFAIL_MSG( wxT("wxFontDialog creation failed") );
- return FALSE;
+ return false;
}
InitializeFont();
CreateWidgets();
-
+
// sets initial font in preview area
wxCommandEvent dummy;
OnChangeFont(dummy);
-
- return TRUE;
+
+ return true;
}
int wxGenericFontDialog::ShowModal()
styleChoice->SetStringSelection(wxFontStyleIntToString(dialogFont.GetStyle()));
weightChoice->SetStringSelection(wxFontWeightIntToString(dialogFont.GetWeight()));
wxString name(wxTheColourDatabase->FindName(m_fontData.GetColour()));
- colourChoice->SetStringSelection(name);
-
+ if (name.length())
+ colourChoice->SetStringSelection(name);
+ else
+ colourChoice->SetStringSelection(wxT("BLACK"));
+
underLineCheckBox->SetValue(dialogFont.GetUnderlined());
pointSizeChoice->SetSelection(dialogFont.GetPointSize()-1);
sizer->Add(weightChoice, 0, wxALIGN_CENTER | wxLEFT, 10);
sizer->Add(colourChoice, 0, wxALIGN_CENTER | wxLEFT, 10);
topsizer->Add(sizer, 0, wxLEFT| wxTOP| wxRIGHT, 10);
-
+
sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(pointSizeChoice, 0, wxALIGN_CENTER | wxLEFT, 10);
sizer->Add(underLineCheckBox, 0, wxALIGN_CENTER | wxLEFT, 10);
topsizer->Add(sizer, 0, wxLEFT| wxTOP| wxRIGHT, 10);
}
-
+
topsizer->Add(m_previewer, 1, wxALL | wxEXPAND, 10);
topsizer->SetItemMinSize(m_previewer, 430, 100);
sizer->Add(cancelButton, 0, wxRIGHT, 10);
topsizer->Add(sizer, 0, wxALIGN_RIGHT | wxBOTTOM, 10);
- SetAutoLayout(TRUE);
SetSizer(topsizer);
topsizer->SetSizeHints(this);
topsizer->Fit(this);
delete[] styles;
delete[] weights;
delete[] pointSizes;
-
+
// Don't block events any more
- m_useEvents = TRUE;
+ m_useEvents = true;
}
void wxGenericFontDialog::InitializeFont()
int fontWeight = wxNORMAL;
int fontStyle = wxNORMAL;
int fontSize = 12;
- int fontUnderline = FALSE;
+ bool fontUnderline = false;
if (m_fontData.m_initialFont.Ok())
{
fontUnderline = m_fontData.m_initialFont.GetUnderlined();
}
- dialogFont = wxFont(fontSize, fontFamily, fontStyle, fontWeight, (fontUnderline != 0));
+ dialogFont = wxFont(fontSize, fontFamily, fontStyle,
+ fontWeight, fontUnderline);
if (m_previewer)
m_previewer->SetFont(dialogFont);
dialogFont = wxFont(fontSize, fontFamily, fontStyle, fontWeight, (fontUnderline != 0));
m_previewer->SetFont(dialogFont);
- if (colourChoice->GetStringSelection() != wxT(""))
+ if ( !colourChoice->GetStringSelection().empty() )
{
wxColour col = wxTheColourDatabase->Find(colourChoice->GetStringSelection());
if (col.Ok())