wxEuphoria - get_facenames() issue
- Posted by Greg Haberek <ghaberek at gm?il.com> Jan 24, 2008
- 793 views
Matt, In testing, I've found that get_facenames() returns all font faces, even when asked to only return fixed-width fonts. I've mocked up a font browser demo below. Also, is there some way to get the available point sizes? Right now I'm just hard-coding the "standard" values. -Greg
-- wxFontDemo.exw include wxeud.e without warning constant frmMain = create( wxFrame, {0, -1, "Font Demo", -1, -1, 640, 480} ), pnlMain = create( wxPanel, {frmMain} ), lblFace = create( wxStaticText, {pnlMain, -1, "&Face", 10, 14, 100, 16} ), lstFace = create( wxListBox, {pnlMain, new_id(), 10, 30, 200, 200} ), lblSize = create( wxStaticText, {pnlMain, -1, "&Size", 230, 14, 100, 16} ), txtSize = create( wxTextCtrl, {pnlMain, -1, "10", 230, 30, 60, 20} ), lstSize = create( wxListBox, {pnlMain, -1, 230, 50, 60, 180} ), grpExample = create( wxStaticBox, {pnlMain, -1, "", 40, 260, 540, 60} ), lblExample = create( wxStaticText, {grpExample, -1, "The quick brown fox jumps over the lazy dog.", 20, 24, 420, 16} ) sequence faces, sizes atom font procedure init() -- should return fixed-width fonts *only* faces = get_facenames( {wxFONTENCODING_SYSTEM, wxTrue} ) for i = 1 to length( faces ) do add_item( lstFace, faces[i] ) end for sizes = {8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72} for i = 1 to length( sizes ) do add_item( lstSize, sprint(sizes[i]) ) end for set_selection( lstFace, 0 ) set_selection( lstSize, 2 ) font = create( wxFont, {10, wxDEFAULT, wxDEFAULT, wxDEFAULT, 0, faces[1]} ) set_default_font( lblExample, font ) end procedure procedure lstFace_onSelect( atom this, atom event_type, atom id, atom event ) sequence face face = get_string_selection( this ) set_font_face_name( font, face ) set_default_font( lblExample, font ) end procedure set_event_handler( lstFace, get_id(lstFace), wxEVT_COMMAND_LISTBOX_SELECTED, routine_id("lstFace_onSelect") ) procedure lstSize_onSelect( atom this, atom event_type, atom id, atom event ) integer index, size index = get_selection( this ) size = sizes[index+1] set_label( txtSize, sprint(size) ) set_point_size( font, size ) set_default_font( lblExample, font ) end procedure set_event_handler( lstSize, get_id(lstSize), wxEVT_COMMAND_LISTBOX_SELECTED, routine_id("lstSize_onSelect") ) procedure txtSize_onUpdate( atom this, atom event_type, atom id, atom event ) sequence text object val integer size, pos text = get_label( txtSize ) val = value( text ) if val[1] = GET_SUCCESS then size = val[2] set_point_size( font, size ) set_default_font( lblExample, font ) pos = find( size, sizes ) set_selection( lstSize, pos - 1 ) end if end procedure set_event_handler( txtSize, get_id(txtSize), wxEVT_COMMAND_TEXT_UPDATED, routine_id("txtSize_onUpdate") ) init() wxMain( frmMain )