Brutyn Nick hotmail
2006-Feb-02 08:51 UTC
[fxruby-users] 2 Problems: Multi main windows, and text is not displayed
hey,
Problem 1
I have this progam:
-it has a login screen, when logging in (through webservices) u get a second
screen
-the second screen is dialog with optionmenus, here u can select options and
submit them
-after submit u get another dialog with a confirmation
the problem i have,
when i drag the dialog i automatically shrinks to fit it own components, and u
cant set a icon
The solution i want
I want 3 main windows, when logging in, it disappears and the second window is
shown,same for the third one.
Is that possible? Or make the dialog not dragable? ....
Problem 2
When logging in it should say "Connecting..." and a sandmile is
running , but that isnt showing, but after the login the "Login
succesfull." and the "Wrong username or password." are shown.
See code (bottom)
My code:
------------------
require ''rubygems''
require_gem ''fxruby''
require ''soap/wsdlDriver''
include Fox
@@wsdl = "xxxxx"
@@twa = "xxxx"
@@login = ""
@@pass = ""
@@employee_id = 0
@@geotag_id = 0
def initializeMenu(popup=false)
#Make menu bar
menubar = FXMenuBar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
# Help menu
helpmenu = FXMenuPane.new(self)
FXMenuTitle.new(menubar, "&Help", nil, helpmenu, LAYOUT_RIGHT)
# Help Menu entries
FXMenuCommand.new(helpmenu, "&About...").connect(SEL_COMMAND) {
FXMessageBox.new(self, "About Twodecode",
"Twodecode for Mobile Users.\n\n" +
"Using the FOX C++ GUI Library (http://www.fox-toolkit.org)\n\n" +
"Copyright (C) 2006 Twodecode (support at twodecode.com)", nil,
MBOX_OK|DECOR_TITLE|DECOR_BORDER).execute
}
if !popup
FXMenuCommand.new(helpmenu, "&Quit\tCtl-Q", nil, getApp(),
FXApp::ID_QUIT)
end
# Separator
FXHorizontalSeparator.new(self)
end
# A little dialog box to use in our tests
class FXResultDialog < FXDialogBox
def initialize(owner)
# Invoke base class initialize function first
super(owner, "Twodecode", DECOR_TITLE|DECOR_BORDER, 0, 0, 400, 300,0
,0 ,0 ,0 ,0)
initializeMenu(true)
mainFrame = FXVerticalFrame.new(self, LAYOUT_CENTER_X|LAYOUT_CENTER_Y)
# Arrange nicely
matrix = FXMatrix.new(mainFrame, 1,
MATRIX_BY_COLUMNS|LAYOUT_SIDE_TOP|LAYOUT_FILL_X| LAYOUT_FILL_Y)
@user_text = FXLabel.new(matrix, "Sending...")
btn = FXButton.new(matrix, "&OK", nil, @@application,
FXApp::ID_QUIT,FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_X|LAYOUT_CENTER_Y)
if @@employee_id != 0 && @@geotag_id != 0
#Connect to webservice (register_time_entry)
factory = SOAP::WSDLDriverFactory.new(@@wsdl)
@driver = factory.create_rpc_driver
result = @driver.RegisterTimeEntry(@@twa, @@employee_id, @@geotag_id)
responsecode = result[0]
local_time = result[1]
if responsecode == "TIMER_SUCCESS"
@user_text.text = "Thank You!\nYour registration was received on "
+ local_time
else
@user_text.text = "Error in the URL conversion\nThe location code
and/or license was not found"
end
else
@user_text.text = "Invalid data. \nPlease select an employee and a
geotag."
end
end
end
# A little dialog box to use in our tests
class FXTimeDialog < FXDialogBox
def initialize(owner)
# Invoke base class initialize function first
super(owner, "Twodecode", DECOR_TITLE|DECOR_BORDER, 0, 0, 400, 300,0
,0 ,0 ,0 ,0)
initializeMenu(true)
getApp().beginWaitCursor() do
#Showing user details
# First row
#Connect to webservice (fetchUser)
factory = SOAP::WSDLDriverFactory.new(@@wsdl)
@driver = factory.create_rpc_driver
@user = @driver.fetchUser(@@twa, @@login, @@pass)
@user_text = FXLabel.new(self, "Welcome " + @user.last_name +
" " + @user.first_name + ".")
#Main frame (select lists)
mainFrame = FXVerticalFrame.new(self, LAYOUT_CENTER_X | LAYOUT_CENTER_Y |
LAYOUT_FILL_X )
# Arrange nicely
matrix = FXMatrix.new(mainFrame, 2,
MATRIX_BY_COLUMNS|LAYOUT_SIDE_TOP|LAYOUT_FILL_X| LAYOUT_FILL_Y)
# First row
FXLabel.new(matrix, "Employee")
# Popup menu
employeePane = FXPopup.new(self)
#Connect to webservice (FetchEmployees)
@employees = @driver.FetchEmployees(@@twa, @user.id)
for employee in @employees
FXOption.new(employeePane, employee.last_name + " " +
employee.first_name , nil, nil, 0, JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
end
# Option menu
@employeeMenu = FXOptionMenu.new(matrix, employeePane,
(FRAME_RAISED|FRAME_THICK|
JUSTIFY_HZ_APART|ICON_AFTER_TEXT|LAYOUT_RIGHT|LAYOUT_CENTER_Y))
# Second row
FXLabel.new(matrix, "Client")
# Popup menu
clientPane = FXPopup.new(self)
#Connect to webservice (FetchClients)
@clients = @driver.FetchClients(@@twa, @user.id)
for client in @clients
FXOption.new(clientPane, client.name , nil, nil, 0,
JUSTIFY_HZ_APART|ICON_AFTER_TEXT).connect(SEL_COMMAND) { getGeotagsByClient() }
end
# Option menu
@clientMenu = FXOptionMenu.new(matrix, clientPane, (FRAME_RAISED|FRAME_THICK|
JUSTIFY_HZ_APART|ICON_AFTER_TEXT|LAYOUT_RIGHT|LAYOUT_CENTER_Y))
# Third row
FXLabel.new(matrix, "Geotag")
# Popup menu
geotagPane = FXPopup.new(self)
#Connect to webservice (FetchGeotagsByClient)
@geotags = @driver.FetchGeotagsByClient(@@twa, @user.id, @clients[0].id)
for geotag in @geotags
FXOption.new(geotagPane, geotag.address1 + ", " + geotag.address2
+ ", " + geotag.floor, nil, nil, 0, JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
end
# Option menu
@geotagMenu = FXOptionMenu.new(matrix, geotagPane, (FRAME_RAISED|FRAME_THICK|
JUSTIFY_HZ_APART|ICON_AFTER_TEXT|LAYOUT_RIGHT|LAYOUT_CENTER_Y))
# Bottom buttons
buttons = FXHorizontalFrame.new(self,
LAYOUT_SIDE_BOTTOM|FRAME_NONE|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH)
# Separator
FXHorizontalSeparator.new(self,
LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|SEPARATOR_GROOVE)
# Accept
accept = FXButton.new(buttons, "&Send", nil, self, ID_ACCEPT,
FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
# Cancel
FXButton.new(buttons, "&Cancel", nil, self, ID_CANCEL,
FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
accept.setDefault
accept.setFocus
accept.connect(SEL_COMMAND, method(:onCmdSendButton))
end
def self.getGeotagsByClient()
getApp().beginWaitCursor() do
current_option = @clientMenu.getCurrentNo()
current_client_id = @clients[current_option].id
pane = FXPopup.new(self, (FRAME_RAISED|FRAME_THICK|
JUSTIFY_HZ_APART|ICON_AFTER_TEXT|LAYOUT_RIGHT|LAYOUT_CENTER_Y))
#Connect to webservice (FetchGeotagsByClient)
@geotags = @driver.FetchGeotagsByClient(@@twa, @user.id, current_client_id)
test = ""
for geotag in @geotags
FXOption.new(pane, geotag.address1 + ", " + geotag.address2 +
", " + geotag.floor, nil, nil, 0, JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
test += geotag.address1 + "\n "
end
@user_text.text = test
@geotagMenu.menu = pane
@geotagMenu.setCurrentNo(2)
end
end
end
# Show a modal dialog
def onCmdSendButton(sender, sel, ptr)
current_employee = @employees[@employeeMenu.getCurrentNo()]
current_client = @clients[@clientMenu.getCurrentNo()]
current_geotag = @geotags[@geotagMenu.getCurrentNo()]
@user_text.text = "Employee:" + current_employee.last_name + "
" + current_employee.first_name + "\n" +
"Client:" + current_client.name + "\n" +
"Geotag:" + current_geotag.address1 + " " +
current_geotag.address2 + " " + current_geotag.floor + "\n"
@@employee_id = current_employee.id
@@geotag_id = current_geotag.id
#popup 2nd window
FXResultDialog.new(self).execute
return 1
end
end
class LoginWindow < FXMainWindow
def initialize(theApp)
# Initialize base class first
super(theApp, "Twodecode", nil, nil, DECOR_ALL, 0, 0, 400, 300)
begin
iconFileName = "icons/Twodecode.ico"
iconFile = File.open(iconFileName, "rb")
self.icon = FXICOIcon.new(theApp, iconFile.read)
rescue
puts "Error reading icon file #{iconFileName}"
end
initializeMenu()
mainFrame = FXVerticalFrame.new(self, LAYOUT_CENTER_X|LAYOUT_CENTER_Y)
# Arrange nicely
matrix = FXMatrix.new(mainFrame, 2,
MATRIX_BY_COLUMNS|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y)
# First row
FXLabel.new(matrix, "Login")
@loginText = FXTextField.new(matrix, 20, @stringLogin, FXDataTarget::ID_VALUE)
# Second row
FXLabel.new(matrix, "Password")
@passText = FXTextField.new(matrix, 21, @stringPass, FXDataTarget::ID_VALUE,
TEXTFIELD_PASSWD)
# Third row
FXLabel.new(matrix, " ")
# Button to pop modal dialog
loginButton = FXButton.new(matrix,
"&Login...\tLogin in the Twodecode", nil, nil, 0,
FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
loginButton.connect(SEL_COMMAND, method(:onCmdLoginButton))
@resultLabel = FXLabel.new(mainFrame, " ")
end
# Show a modal dialog
def onCmdLoginButton(sender, sel, ptr)
login_succesfull = false
getApp().beginWaitCursor() do
@resultLabel.text = "Connecting..."
#Connect to webservices
@@login = @loginText.text
@@pass = @passText.text
factory = SOAP::WSDLDriverFactory.new(@@wsdl)
@driver = factory.create_rpc_driver
responsecode = @driver.authenticate(@@twa, @@login, @@pass)
#p responsecode
if responsecode == "USER_FOUND"
login_succesfull = true
else
login_succesfull = false
end
end
if login_succesfull
@resultLabel.text = "Login succesfull."
#popup 2nd window
FXTimeDialog.new(self).execute
return 1
else
#User doesnt exist, or wrong password
@resultLabel.text = "Wrong username or password."
end
end
def create
super
show(PLACEMENT_SCREEN)
end
end
if __FILE__ == $0
@@application = FXApp.new("Twodecode", "FXRuby")
LoginWindow.new(@@application)
@@application.create
@@application.run
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/fxruby-users/attachments/20060202/29879196/attachment-0001.htm