WxFontDialog-WxBasic

From WxWiki
Jump to: navigation, search
  'wxBasic tutorial by Luca Cassioli 2004
  'http://www.geocities.com/lcassioli/wxbasic/
  'FONT DIALOG
  frame=new wxFrame(Null,-1,"wxFontDialog",wxPoint(10,10),wxSize(320,200),wxCAPTION <nowiki>|</nowiki> wxSYSTEM_MENU)
  panel=new wxPanel(frame,-1)
  button=new wxButton(panel,-1,"change",wxPoint(120,50))
  'testo=new wxTextCtrl(panel,-1,"Text text etext",wxPoint(20,100),wxSize(250,20))
  etic=new wxStaticText(panel,-1,"text ",wxPoint(10,10))
  test=wxFont(20, wxDEFAULT,wxNORMAL,wxNORMAL,0,"Times New Roman")
  etic.SetFont(test)
  frame.Show(True)
 
  fontDataIN= new wxFontData()   ' Allocate two wxFontData variables: first one for dialog input,
  fontDataOUT = new wxFontData() ' second one for dialog output.
 
  'Set default parameters of Font Dialog:
  fontDataIN.EnableEffects(True)
  fontDataIN.SetAllowSymbols(True)
  fontDataIN.SetChosenFont(test)
  fontDataIN.SetColour(wxBLUE)
  fontDataIN.SetInitialFont(test)
  fontDataIN.SetRange(8,30)
  fontDataIN.SetShowHelp(True) ' I don't know how to use the help button, sorry.
 
  sub change(event)
    dialog = new wxFontDialog(frame, fontDataIN) ' Prepare dialog.
    result=dialog.ShowModal() 
    print "Dialog result: ",result
    if result= 5101 then: exit sub : end if ' Show it.
    fontDataOUT=dialog.GetFontData() 'Get "font data" from dialog.
 
    print "Data resulting from Font Dialog (if not printable, the data type is printed instead):"
    print "GetAllowSymbols:",fontDataOUT.GetAllowSymbols()
    print "GetColour:",fontDataOUT.GetColour()  color=fontDataOUT.GetColour()
  
    print "--=>>GetChosenFont:",fontDataOUT.GetChosenFont(),"<<=--"
    print "GetEnableEffects:",fontDataOUT.GetEnableEffects()
    print "GetInitialFont:",fontDataOUT.GetInitialFont()
    print "GetShowHelp:",fontDataOUT.GetShowHelp()
 
    font=fontDataOUT.GetChosenFont() 'Get font from "font data".
    dialog.Finalize() '???
    etic.SetLabel(font.GetFaceName())  'Print selected font
    etic.SetFont(font) 'Apply selected font
    etic.SetForegroundColor(color)
    print
    print "Data resulting from FontData (GetChosenFont):"
    print "GetPointSize:",font.GetPointSize()
    print "GetFamily:",font.GetFamily()
    print "GetStyle:",font.GetStyle()
    print "GetWeight:",font.GetWeight()
    print "GetUnderlined:",font.GetUnderlined()
    print "GetFaceName:",font.GetFaceName()
    <nowiki>print"------"</nowiki>
    print
  end sub
  connect(button,wxEVT_COMMAND_BUTTON_CLICKED,"change")


Back to WxBasic Tutorial