Code - wxEuphoria
Our sample window as it looks using wxEuphoria. The screenshot on the left was taken from Windows; on the right is a screenshot of the same program running on RedHat Linux 8.0 with the Gnome desktop:
The sample code below came straight from Matthew Lewis, the creator and maintainer of wxEuphoria. He has liberally commented the code, so it should be easy to grasp. I'll explore his code in more detail on the following page. For now, see if you can follow along with it.
REMEMBER: The following code works on both Windows and Linux. Awesome!
without warning
-- include the files needed:
include wxEuphoria.e -- main include file for the library (also wxFrame, wxPanel)
include wxButton.e -- wxButton class
include wxText.e -- wxStaticText and wxTextCtrl classes
include wxSizer.e -- wxBoxSizer class
-- Create the controls needed:
constant
main = create( wxFrame, {0, -1, "Scramble Me", -1, -1, 250, 100}),
win = create( wxPanel, main ),
label = create( wxStaticText, {win, -1, "Enter your name:"}),
name = create( wxTextCtrl, {win, -1, "", -1, -1} ),
ScrambleButton = create( wxButton, {win, -1,"Scramble Me"}),
QuitButton = create( wxButton, {win, -1, "Quit"})
procedure setup()
atom vsizer, hsizer
-- Use sizers to dynamically resize and position controls.
-- First, create a vertical sizer, and put the label and the edit
-- field into the vertical sizer:
vsizer = create( wxBoxSizer, wxVERTICAL )
-- The label will grow horizontally (but not vertically) and will have
-- a 5 pixel space on its left and top:
add_window_to_sizer( vsizer, label, 0, wxGROW + wxTOP + wxLEFT, 5 )
-- The edit field will grow both vertically and horizontally, and has
-- borders on the top, left and right of 5 pixels:
add_window_to_sizer( vsizer, name, 1, wxGROW + wxTOP + wxLEFT + wxRIGHT, 5 )
-- The buttons will be positioned next to each other, so
-- use a horizontal sizer for them:
hsizer = create( wxBoxSizer, wxHORIZONTAL )
-- The buttons will grow horizontally only, and will have 5 pixel spaces
-- on each side.
add_window_to_sizer( hsizer, ScrambleButton, 1, wxLEFT, 5 )
add_window_to_sizer( hsizer, QuitButton, 1, wxLEFT + wxRIGHT, 5 )
-- Then we put the horizontal sizer inside of the vertical sizer, leaving
-- a 5 pixel space on the top an bottom (which will apply to all controls
-- in the spacer):
add_sizer_to_sizer( vsizer, hsizer, 0, wxGROW + wxTOP + wxBOTTOM, 5 )
-- Then we assign the vertical sizer to the panel, and the controls will
-- automatically resize and reposition themselves:
set_sizer( win, vsizer )
end procedure
setup()
-- hand control to Windows
wxMain( main )