Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/env ruby
require 'fox16'
include Fox
# A little dialog box to use in our tests
class FXTestDialog < FXDialogBox
def initialize(owner)
# Invoke base class initialize function first
super(owner, "Test of Dialog Box", DECOR_TITLE|DECOR_BORDER)
# Bottom buttons
buttons = FXHorizontalFrame.new(self,
LAYOUT_SIDE_BOTTOM|FRAME_NONE|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH,
:padLeft => 40, :padRight => 40, :padTop => 20, :padBottom => 20)
# Separator
FXHorizontalSeparator.new(self,
LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|SEPARATOR_GROOVE)
# Contents
contents = FXHorizontalFrame.new(self,
LAYOUT_SIDE_TOP|FRAME_NONE|LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH)
submenu = FXMenuPane.new(self)
FXMenuCommand.new(submenu, "One")
FXMenuCommand.new(submenu, "Two")
FXMenuCommand.new(submenu, "Three")
# Menu
menu = FXMenuPane.new(self)
FXMenuCommand.new(menu, "&Accept", nil, self, ID_ACCEPT)
FXMenuCommand.new(menu, "&Cancel", nil, self, ID_CANCEL)
FXMenuCascade.new(menu, "Submenu", nil, submenu)
FXMenuCommand.new(menu, "&Quit\tCtl-Q", nil, getApp(), FXApp::ID_QUIT)
# Popup menu
pane = FXPopup.new(self)
%w{One Two Three Four Five Six Seven Eight Nine Ten}.each do |s|
FXOption.new(pane, s, :opts => JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
end
# Option menu
FXOptionMenu.new(contents, pane, (FRAME_RAISED|FRAME_THICK|
JUSTIFY_HZ_APART|ICON_AFTER_TEXT|LAYOUT_CENTER_X|LAYOUT_CENTER_Y))
# Button to pop menu
FXMenuButton.new(contents, "&Menu", nil, menu, (MENUBUTTON_DOWN|
JUSTIFY_LEFT|LAYOUT_TOP|FRAME_RAISED|FRAME_THICK|ICON_AFTER_TEXT|
LAYOUT_CENTER_X|LAYOUT_CENTER_Y))
# Accept
accept = FXButton.new(buttons, "&Accept", 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
end
end
# Subclassed main window
class DialogTester < FXMainWindow
def initialize(app)
# Invoke base class initialize first
super(app, "Dialog Test", :opts => DECOR_ALL, :width => 400, :height => 200)
# Tooltip
FXToolTip.new(getApp())
# Menubar
menubar = FXMenuBar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
# Separator
FXHorizontalSeparator.new(self,
LAYOUT_SIDE_TOP|LAYOUT_FILL_X|SEPARATOR_GROOVE)
# File Menu
filemenu = FXMenuPane.new(self)
FXMenuCommand.new(filemenu, "&Quit", nil, getApp(), FXApp::ID_QUIT, 0)
FXMenuTitle.new(menubar, "&File", nil, filemenu)
# Contents
contents = FXHorizontalFrame.new(self,
LAYOUT_SIDE_TOP|FRAME_NONE|LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH)
# Button to pop normal dialog
nonModalButton = FXButton.new(contents,
"&Non-Modal Dialog...\tDisplay normal dialog",
:opts => FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_X|LAYOUT_CENTER_Y)
nonModalButton.connect(SEL_COMMAND, method(:onCmdShowDialog))
# Button to pop modal dialog
modalButton = FXButton.new(contents,
"&Modal Dialog...\tDisplay modal dialog",
:opts => FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_X|LAYOUT_CENTER_Y)
modalButton.connect(SEL_COMMAND, method(:onCmdShowDialogModal))
# Build a dialog box
@dialog = FXTestDialog.new(self)
end
# Show the non-modal dialog
def onCmdShowDialog(sender, sel, ptr)
@dialog.show
end
# Show a modal dialog
def onCmdShowDialogModal(sender, sel, ptr)
FXTestDialog.new(self).execute
return 1
end
# Start
def create
super
show(PLACEMENT_SCREEN)
end
end
def run
# Make an application
application = FXApp.new("Dialog", "FoxTest")
# Construct the application's main window
DialogTester.new(application)
# Create the application
application.create
# Run the application
application.run
end
run