wxFontEnumerator class for Motif/X
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3781 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -395,6 +395,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
|
||||
|
||||
panel = new wxPanel(m_notebook);
|
||||
m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 5, choices );
|
||||
m_choice->SetSelection(2);
|
||||
m_choice->SetBackgroundColour( "red" );
|
||||
(void)new wxButton( panel, ID_CHOICE_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
|
||||
(void)new wxButton( panel, ID_CHOICE_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#endif
|
||||
|
||||
#include <wx/fontdlg.h>
|
||||
#include <wx/fontenum.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// private classes
|
||||
@@ -81,8 +82,14 @@ public:
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
void OnSelectFont(wxCommandEvent& event);
|
||||
void OnCreateFont(wxCommandEvent& event);
|
||||
void OnEnumerateFamilies(wxCommandEvent& WXUNUSED(event))
|
||||
{ DoEnumerateFamilies(FALSE); }
|
||||
void OnEnumerateFixedFamilies(wxCommandEvent& WXUNUSED(event))
|
||||
{ DoEnumerateFamilies(TRUE); }
|
||||
|
||||
protected:
|
||||
void DoEnumerateFamilies(bool fixedWidthOnly);
|
||||
|
||||
MyCanvas *m_canvas;
|
||||
|
||||
private:
|
||||
@@ -119,7 +126,10 @@ enum
|
||||
Font_Quit = 1,
|
||||
Font_About,
|
||||
Font_Choose = 100,
|
||||
Font_Create
|
||||
Font_Create,
|
||||
Font_EnumFamilies,
|
||||
Font_EnumFixedFamilies,
|
||||
Font_Max
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -134,6 +144,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(Font_About, MyFrame::OnAbout)
|
||||
EVT_MENU(Font_Choose, MyFrame::OnSelectFont)
|
||||
EVT_MENU(Font_Create, MyFrame::OnCreateFont)
|
||||
EVT_MENU(Font_EnumFamilies, MyFrame::OnEnumerateFamilies)
|
||||
EVT_MENU(Font_EnumFixedFamilies, MyFrame::OnEnumerateFixedFamilies)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// Create a new application object: this macro will allow wxWindows to create
|
||||
@@ -155,7 +167,7 @@ IMPLEMENT_APP(MyApp)
|
||||
bool MyApp::OnInit()
|
||||
{
|
||||
// Create the main application window
|
||||
MyFrame *frame = new MyFrame("Minimal wxWindows App",
|
||||
MyFrame *frame = new MyFrame("Font wxWindows demo",
|
||||
wxPoint(50, 50), wxSize(450, 340));
|
||||
|
||||
// Show it and tell the application that it's our main window
|
||||
@@ -176,9 +188,6 @@ bool MyApp::OnInit()
|
||||
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
|
||||
{
|
||||
// set the frame icon
|
||||
SetIcon(wxICON(mondrian));
|
||||
|
||||
// create a menu bar
|
||||
wxMenu *menuFile = new wxMenu;
|
||||
|
||||
@@ -187,10 +196,14 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
menuFile->Append(Font_Quit, "E&xit\tAlt-X", "Quit this program");
|
||||
|
||||
wxMenu *menuFont = new wxMenu;
|
||||
menuFont->Append(Font_Choose, "&Select font...\tCtrl-F",
|
||||
menuFont->Append(Font_Choose, "&Select font...\tCtrl-S",
|
||||
"Select a standard font");
|
||||
menuFont->Append(Font_Create, "&Create font...\tCtrl-C",
|
||||
"Create a custom font");
|
||||
menuFont->AppendSeparator();
|
||||
menuFont->Append(Font_EnumFamilies, "&Enumerate font families\tCtrl-E");
|
||||
menuFont->Append(Font_EnumFixedFamilies,
|
||||
"&Enumerate fixed font families\tCtrl-F");
|
||||
|
||||
// now append the freshly created menu to the menu bar...
|
||||
wxMenuBar *menuBar = new wxMenuBar;
|
||||
@@ -210,6 +223,30 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
|
||||
// event handlers
|
||||
|
||||
void MyFrame::DoEnumerateFamilies(bool fixedWidthOnly)
|
||||
{
|
||||
class MyFontEnumerator : public wxFontEnumerator
|
||||
{
|
||||
public:
|
||||
MyFontEnumerator() { m_n = 0; }
|
||||
|
||||
protected:
|
||||
virtual bool OnFontFamily(const wxString& family)
|
||||
{
|
||||
wxLogMessage("Font family %d: %s\n", ++m_n, family.c_str());
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
private:
|
||||
size_t m_n;
|
||||
} fontEnumerator;
|
||||
|
||||
wxLogMessage("Enumerating %s font families:",
|
||||
fixedWidthOnly ? "fixed width" : "all");
|
||||
fontEnumerator.EnumerateFamilies(fixedWidthOnly);
|
||||
}
|
||||
|
||||
void MyFrame::OnCreateFont(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
MyFontDialog dialog(this);
|
||||
|
@@ -13,7 +13,7 @@ top_srcdir = @top_srcdir@
|
||||
top_builddir = ../..
|
||||
program_dir = samples/text
|
||||
|
||||
DATAFILES = text.cpp
|
||||
DATAFILES = text.rc
|
||||
|
||||
PROGRAM=text
|
||||
|
||||
|
@@ -32,10 +32,6 @@
|
||||
#include "wx/tooltip.h"
|
||||
#endif
|
||||
|
||||
#if defined(__WXGTK__) || defined(__WXMOTIF__)
|
||||
#include "mondrian.xpm"
|
||||
#endif
|
||||
|
||||
// We test for wxUSE_DRAG_AND_DROP also, because data objects may not be
|
||||
// implemented for compilers that can't cope with the OLE parts in
|
||||
// wxUSE_DRAG_AND_DROP.
|
||||
@@ -171,8 +167,7 @@ bool MyApp::OnInit()
|
||||
{
|
||||
// Create the main frame window
|
||||
MyFrame *frame = new MyFrame((wxFrame *) NULL,
|
||||
"Text wxWindows App",
|
||||
50, 50, 640, 420);
|
||||
"Text wxWindows sample", 50, 50, 640, 420);
|
||||
frame->SetSizeHints( 500, 400 );
|
||||
|
||||
wxMenu *file_menu = new wxMenu;
|
||||
@@ -454,7 +449,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
|
||||
|
||||
m_horizontal = new MyTextCtrl( this, -1, "Multiline text control with a horizontal scrollbar.",
|
||||
wxPoint(10,170), wxSize(140,70), wxTE_MULTILINE | wxHSCROLL );
|
||||
m_horizontal->SetFont(wxFont(18, wxSWISS, wxNORMAL, wxBOLD));
|
||||
m_horizontal->SetFont(wxFont(18, wxSWISS, wxNORMAL, wxNORMAL,
|
||||
FALSE, "", wxFONTENCODING_KOI8));
|
||||
|
||||
m_multitext = new MyTextCtrl( this, -1, "Multi line.",
|
||||
wxPoint(180,10), wxSize(240,70), wxTE_MULTILINE );
|
||||
@@ -668,7 +664,7 @@ void MyFrame::OnToggleTooltips(wxCommandEvent& event)
|
||||
|
||||
void MyFrame::OnFileLoad(wxCommandEvent& event)
|
||||
{
|
||||
if ( m_panel->m_multitext->LoadFile("text.cpp") )
|
||||
if ( m_panel->m_multitext->LoadFile("text.rc") )
|
||||
wxLogStatus(this, _T("Successfully loaded file"));
|
||||
else
|
||||
wxLogStatus(this, _T("Couldn't load the file"));
|
||||
|
Reference in New Issue
Block a user