=begin
I am trying to understand how FlexGridSizer works and I have written a small
test application using the latest wxRuby 0.4.0 on Win XP (Home).
I cannot get static text ''Week'', ''Day'' and
''Date'' line up above the OK button.
I have tried all combinations of ALIGN flags, but I either got the text sticking
far too close to the left edge of the dialog or come very close to the Text
Controls on the right.
Any suggestions ?
TIA,
-- shanko
=end
require ''wxruby''
ROMAN_10B = Wx::Font.new(10, Wx::ROMAN, Wx::NORMAL, Wx::BOLD)
ROMAN_12 = Wx::Font.new(12, Wx::ROMAN, Wx::NORMAL, Wx::NORMAL)
class MyDialog < Wx::Dialog
def initialize(parent)
super( parent, -1, ''FlexGridSizer'')
sizer = Wx::FlexGridSizer.new(4,2,0,5)
week = Wx::StaticText.new(self, -1, ''Week'')
week.set_font(ROMAN_10B)
sizer.add(week,0, Wx::ALIGN_CENTRE_VERTICAL|Wx::ALIGN_RIGHT, 10)
@week = Wx::TextCtrl.new(self, -1, ''week'')
@week.set_font(ROMAN_12)
sizer.add(@week, 0, Wx::ALL, 5)
day = Wx::StaticText.new(self, -1, ''Day'')
day.set_font(ROMAN_10B)
sizer.add(day, 0, Wx::ALIGN_CENTRE_VERTICAL|Wx::ALIGN_RIGHT, 5)
@day = Wx::TextCtrl.new(self, -1, ''day'')
@day.set_font(ROMAN_12)
sizer.add(@day, 0, Wx::ALL, 5)
date = Wx::StaticText.new(self, -1, ''Date'')
date.set_font(ROMAN_10B)
sizer.add(date, 0, Wx::ALIGN_CENTRE_VERTICAL|Wx::ALIGN_RIGHT, 5)
@date = Wx::TextCtrl.new(self, -1, ''6/28/2004'')
@date.set_font(ROMAN_12)
sizer.add(@date, 0, Wx::ALL, 5)
button = Wx::Button.new(self, Wx::ID_OK, ''OK'',
Wx::Point.new(0,0),Wx::Size.new(70,25))
button.evt_button(Wx::ID_OK){|event| onDoOK()}
sizer.add(button, 0, Wx::SOUTH|Wx::WEST|Wx::EAST, 10)
button = Wx::Button.new(self, Wx::ID_CANCEL, ''Cancel'',
Wx::Point.new(0,0),Wx::Size.new(70,25))
button.evt_button(Wx::ID_CANCEL){|event| onDoCancel()}
sizer.add(button, 0, Wx::SOUTH|Wx::EAST, 10)
self.set_sizer(sizer)
sizer.set_size_hints(self)
sizer.fit(self)
end
def onDoOK()
end_modal(Wx::ID_OK)
end
def onDoCancel()
end_modal(Wx::ID_CANCEL)
end
end
class MyApp < Wx::App
def on_init
frame = Wx::Frame.new(nil, -1, "Test",
Wx::Point.new(10, 100),
Wx::Size.new(170,100))
frame.show(TRUE)
btn = Wx::Button.new(frame,:btn.id,"OK",
Wx::Point.new(10,10),Wx::DEFAULT_SIZE)
btn.evt_button(:btn.id){|event| onOK()}
end
def onOK()
begin
dialog = MyDialog.new(nil)
ret = dialog.show_modal()
rescue
Wx::message_box($!.to_s,"Error")
end
end
end
app = MyApp.new
app.main_loop()
__END__
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/wxruby-users/attachments/20040619/f3047616/attachment.htm
Have you tried without any ALIGN flags? works beautifully on wxRuby 0.3
:-)
e.g. change: sizer.add(week,0,
Wx::ALIGN_CENTRE_VERTICAL|Wx::ALIGN_RIGHT, 10)
to: sizer.add(week,0, Wx::ALL, 10)
HTH,
Assaph
ps. the ''10'' above has no meaning, as you forgot to add
|Wx::ALL.
-----Original Message-----
From: wxruby-users-bounces@rubyforge.org
[mailto:wxruby-users-bounces@rubyforge.org] On Behalf Of Shashank Date
Sent: Saturday, 19 June 2004 3:45 PM
To: General discussion of wxRuby
Subject: [Wxruby-users] FlexGridSizer question
=begin
I am trying to understand how FlexGridSizer works and I have
written a small
test application using the latest wxRuby 0.4.0 on Win XP (Home).
I cannot get static text ''Week'', ''Day'' and
''Date'' line up above
the OK button.
I have tried all combinations of ALIGN flags, but I either got
the text sticking
far too close to the left edge of the dialog or come very close
to the Text
Controls on the right.
Any suggestions ?
TIA,
-- shanko
=end
require ''wxruby''
ROMAN_10B = Wx::Font.new(10, Wx::ROMAN, Wx::NORMAL, Wx::BOLD)
ROMAN_12 = Wx::Font.new(12, Wx::ROMAN, Wx::NORMAL, Wx::NORMAL)
class MyDialog < Wx::Dialog
def initialize(parent)
super( parent, -1, ''FlexGridSizer'')
sizer = Wx::FlexGridSizer.new(4,2,0,5)
week = Wx::StaticText.new(self, -1, ''Week'')
week.set_font(ROMAN_10B)
sizer.add(week,0, Wx::ALIGN_CENTRE_VERTICAL|Wx::ALIGN_RIGHT,
10)
@week = Wx::TextCtrl.new(self, -1, ''week'')
@week.set_font(ROMAN_12)
sizer.add(@week, 0, Wx::ALL, 5)
day = Wx::StaticText.new(self, -1, ''Day'')
day.set_font(ROMAN_10B)
sizer.add(day, 0, Wx::ALIGN_CENTRE_VERTICAL|Wx::ALIGN_RIGHT,
5)
@day = Wx::TextCtrl.new(self, -1, ''day'')
@day.set_font(ROMAN_12)
sizer.add(@day, 0, Wx::ALL, 5)
date = Wx::StaticText.new(self, -1, ''Date'')
date.set_font(ROMAN_10B)
sizer.add(date, 0,
Wx::ALIGN_CENTRE_VERTICAL|Wx::ALIGN_RIGHT, 5)
@date = Wx::TextCtrl.new(self, -1, ''6/28/2004'')
@date.set_font(ROMAN_12)
sizer.add(@date, 0, Wx::ALL, 5)
button = Wx::Button.new(self, Wx::ID_OK, ''OK'',
Wx::Point.new(0,0),Wx::Size.new(70,25))
button.evt_button(Wx::ID_OK){|event| onDoOK()}
sizer.add(button, 0, Wx::SOUTH|Wx::WEST|Wx::EAST, 10)
button = Wx::Button.new(self, Wx::ID_CANCEL, ''Cancel'',
Wx::Point.new(0,0),Wx::Size.new(70,25))
button.evt_button(Wx::ID_CANCEL){|event| onDoCancel()}
sizer.add(button, 0, Wx::SOUTH|Wx::EAST, 10)
self.set_sizer(sizer)
sizer.set_size_hints(self)
sizer.fit(self)
end
def onDoOK()
end_modal(Wx::ID_OK)
end
def onDoCancel()
end_modal(Wx::ID_CANCEL)
end
end
class MyApp < Wx::App
def on_init
frame = Wx::Frame.new(nil, -1, "Test",
Wx::Point.new(10, 100),
Wx::Size.new(170,100))
frame.show(TRUE)
btn = Wx::Button.new(frame,:btn.id,"OK",
Wx::Point.new(10,10),Wx::DEFAULT_SIZE)
btn.evt_button(:btn.id){|event| onOK()}
end
def onOK()
begin
dialog = MyDialog.new(nil)
ret = dialog.show_modal()
rescue
Wx::message_box($!.to_s,"Error")
end
end
end
app = MyApp.new
app.main_loop()
__END__
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/wxruby-users/attachments/20040622/670e45c9/attachment.htm
MessageAssaph Yes, (Wx:ALL,10) worked the best. What I was really looking for is to be able to specify a border of 20 on the LEFT and a border of 5 on the remaining three sides. I guess, that is not possible. Anyway, thanks for looking. -- shanko e.g. change: sizer.add(week,0, Wx::ALIGN_CENTRE_VERTICAL|Wx::ALIGN_RIGHT, 10) to: sizer.add(week,0, Wx::ALL, 10) HTH, Assaph ps. the ''10'' above has no meaning, as you forgot to add |Wx::ALL. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20040622/e64a2e0c/attachment.htm
Would this help:
sizer.add(week,0, Wx::WEST|Wx::ALIGN_CENTER_VERTICAL, 15) # label
sizer.add(@week, 0, Wx::WEST|Wx::SOUTH|Wx::NORTH, 5) #
widget
Remember that when you add borders around bordering widgets, you only
need to add on one side (i.e. the border-padding is cumulative from both
neighbouring widgets).
A combination of specific borders and ALIGN_CENTER_* will keep
everything aligned nicely.
Something else that may work is embedding the controls in panels. Make
the top level sizer a vertical box sizer and then add panels, each with
it''s own horizontal sizer. You can then set the horizontal border
between each widgets in a panel, and the vertical borders between
panels.
HTH,
Assaph
-----Original Message-----
From: Shashank Date [mailto:sdate@everestkc.net]
Sent: Tuesday, 22 June 2004 10:39 PM
To: General discussion of wxRuby
Cc: Mehr, Assaph (Assaph)
Subject: Re: [Wxruby-users] FlexGridSizer question
Assaph
Yes, (Wx:ALL,10) worked the best. What I was really looking for
is to be able to specify a border of 20 on the LEFT and a border of 5 on
the remaining three sides. I guess, that is not possible.
Anyway, thanks for looking.
-- shanko
e.g. change: sizer.add(week,0,
Wx::ALIGN_CENTRE_VERTICAL|Wx::ALIGN_RIGHT, 10)
to: sizer.add(week,0, Wx::ALL, 10)
HTH,
Assaph
ps. the ''10'' above has no meaning, as you forgot to add
|Wx::ALL.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/wxruby-users/attachments/20040623/3cd03aae/attachment.htm
MessageYes, that is even better !
The option of using hierarchy of sizers is always there... I was hoping that
FlexGrid will make it less verbose.
-- shanko
----- Original Message -----
From: Mehr, Assaph (Assaph)
To: Shashank Date ; General discussion of wxRuby
Sent: Tuesday, June 22, 2004 6:24 PM
Subject: RE: [Wxruby-users] FlexGridSizer question
Would this help:
sizer.add(week,0, Wx::WEST|Wx::ALIGN_CENTER_VERTICAL, 15) # label
sizer.add(@week, 0, Wx::WEST|Wx::SOUTH|Wx::NORTH, 5) # widget
Remember that when you add borders around bordering widgets, you only need to
add on one side (i.e. the border-padding is cumulative from both neighbouring
widgets).
A combination of specific borders and ALIGN_CENTER_* will keep everything
aligned nicely.
Something else that may work is embedding the controls in panels. Make the top
level sizer a vertical box sizer and then add panels, each with it''s
own horizontal sizer. You can then set the horizontal border between each
widgets in a panel, and the vertical borders between panels.
HTH,
Assaph
-----Original Message-----
From: Shashank Date [mailto:sdate@everestkc.net]
Sent: Tuesday, 22 June 2004 10:39 PM
To: General discussion of wxRuby
Cc: Mehr, Assaph (Assaph)
Subject: Re: [Wxruby-users] FlexGridSizer question
Assaph
Yes, (Wx:ALL,10) worked the best. What I was really looking for is to be
able to specify a border of 20 on the LEFT and a border of 5 on the remaining
three sides. I guess, that is not possible.
Anyway, thanks for looking.
-- shanko
e.g. change: sizer.add(week,0, Wx::ALIGN_CENTRE_VERTICAL|Wx::ALIGN_RIGHT,
10)
to: sizer.add(week,0, Wx::ALL, 10)
HTH,
Assaph
ps. the ''10'' above has no meaning, as you forgot to add
|Wx::ALL.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/wxruby-users/attachments/20040622/fd7968e7/attachment.htm