[Fxruby-users] How to show stuff created at run time (not the easy question)
Status: Inactive
Brought to you by:
lyle
|
From: Will M. <wi...@co...> - 2003-12-10 00:08:34
|
Hi, I am using FXRuby to test out some ideas for an app that I am thinking
about writing. FXRuby is proving to be good for quickly trying out ideas to
see what will work well.
One of my questions is how to add gui elements at run time. Now I know all
about needing to call create and all of that, and if you check out the
included code below, you'll see that I am doing so. The problem is that when
I do what I think is proper, the added elemnts do not show up. The weird
part is that if I resize the dialog, then they suddenly show up working
fine. In fact if I add two lines to programatically resize it (as shown in
the code,) then the dialog works exactly as it should. But that seems like a
really hokie hack job, and I can't believe it is the proper way to do it.
So, what is?
PS. I am running this on a windows XP machine using a recent (within the
last month or two) version of the windows Ruby install from Dave and Andy's
site. I have not tried this on any other machine yet.
Any help would be appreciated.
--Will
==================== begin include =================
#!/usr/bin/env ruby
require 'fox'
require 'fox/responder'
require 'observable'
require 'foxtails'
include Fox
include Observable
include FoxTails
class ObjectInspector
include Responder
extend Observable
def initialize(app, proj)
@targetObject = nil
createWindow(app, proj)
end
def createWindow(app, proj)
@app = app
@project = proj
@inspectordlg = FXDialogBox.new(app, "Inspector",
DECOR_BORDER|DECOR_RESIZE|DECOR_TITLE, 0, 0, 150, 300)
@matrix = FXMatrix.new(@inspectordlg, 2,
MATRIX_BY_COLUMNS|LAYOUT_FILL_X)
end
def clear()
@matrix.hide
end
def set(newobj)
@targetObject = newobj
@matrix = FXMatrix.new(@propertyFrame, 2,
MATRIX_BY_COLUMNS|LAYOUT_FILL_X)
# First row
FXLabel.new(@matrix, "Property", nil, LAYOUT_FILL_COLUMN)
FXLabel.new(@matrix, "Value", nil, LAYOUT_FILL_COLUMN)
# First row
FXLabel.new(@matrix, "Type", nil, LAYOUT_FILL_COLUMN)
FXLabel.new(@matrix, @targetObject.name, nil, LAYOUT_FILL_COLUMN)
FXLabel.new(@matrix, "Left", nil, LAYOUT_FILL_COLUMN)
FTTextField.new(@matrix, 17, @targetObject, :left,
FRAME_SUNKEN|LAYOUT_FILL_COLUMN)
FXLabel.new(@matrix, "Right", nil, LAYOUT_FILL_COLUMN)
FTTextField.new(@matrix, 17, @targetObject, :right,
FRAME_SUNKEN|LAYOUT_FILL_COLUMN)
FXLabel.new(@matrix, "Top", nil, LAYOUT_FILL_COLUMN)
FTTextField.new(@matrix, 17, @targetObject, :top,
FRAME_SUNKEN|LAYOUT_FILL_COLUMN)
FXLabel.new(@matrix, "Bottom", nil, LAYOUT_FILL_COLUMN)
FTTextField.new(@matrix, 17, @targetObject, :bottom,
FRAME_SUNKEN|LAYOUT_FILL_COLUMN)
@inspectordlg.create
@inspectordlg.show
# @inspectordlg.update
# @inspectordlg.repaint
@inspectordlg.resize(@inspectordlg.width + 1, @inspectordlg.height)
@inspectordlg.resize(@inspectordlg.width - 1, @inspectordlg.height)
end
# Close the Inspector Windows
def close
@inspectordlg.hide
end
# Create and show the main window
def create
# Create the windows
@inspectordlg.create
@inspectordlg.show(PLACEMENT_DEFAULT)
end
end
===================== end include ==================
|