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
144
145
146
147
148
149
#!/usr/bin/env ruby
require 'fox16'
include Fox
class HeaderWindow < FXMainWindow
def create
super
show(PLACEMENT_SCREEN)
end
def initialize(app)
# Invoke base class initializer first
super(app, "Header Control Test", :opts => DECOR_ALL, :width => 800, :height => 600)
# Menu bar stretched along the top of the main window
menubar = FXMenuBar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
# Status bar, stretched along the bottom
FXStatusBar.new(self, LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X)
# File menu
filemenu = FXMenuPane.new(self)
FXMenuCommand.new(filemenu, "&Quit\tCtl-Q\tQuit the application", nil,
getApp(), FXApp::ID_QUIT)
FXMenuTitle.new(menubar, "&File", nil, filemenu)
# Help menu
helpmenu = FXMenuPane.new(self)
FXMenuCommand.new(helpmenu, "&About Header...").connect(SEL_COMMAND) do
FXMessageBox.information(self, MBOX_OK, "About Header",
"An example of how to work with the header control.")
end
FXMenuTitle.new(menubar, "&Help", nil, helpmenu, LAYOUT_RIGHT)
# Make Main Window contents
contents = FXVerticalFrame.new(self,
FRAME_SUNKEN|FRAME_THICK|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y,
:padLeft => 0, :padRight => 0, :padTop => 0, :padBottom => 0,
:hSpacing => 0, :vSpacing => 0)
# Make header control
@header1 = FXHeader.new(contents,
:opts => HEADER_BUTTON|HEADER_RESIZE|FRAME_RAISED|FRAME_THICK|LAYOUT_FILL_X)
@header1.connect(SEL_CHANGED) do |sender, sel, which|
@lists[which].width = @header1.getItemSize(which)
end
@header1.connect(SEL_COMMAND) do |sender, sel, which|
@lists[which].numItems.times do |i|
@lists[which].selectItem(i)
end
end
# Document icon
doc = nil
File.open(File.join("icons", "minidoc.png"), "rb") do |f|
doc = FXPNGIcon.new(getApp(), f.read)
end
@header1.appendItem("Name", doc, 150)
@header1.appendItem("Type", nil, 140)
@header1.appendItem("Layout Option", doc, 230)
@header1.appendItem("Attributes", nil, 80)
# Below header
panes = FXHorizontalFrame.new(contents,
FRAME_SUNKEN|FRAME_THICK|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y,
:padLeft => 0, :padRight => 0, :padTop => 0, :padBottom => 0,
:hSpacing => 0, :vSpacing => 0)
# Make 4 lists
@lists = []
@lists.push(FXList.new(panes, :opts => LAYOUT_FILL_Y|LAYOUT_FIX_WIDTH|LIST_BROWSESELECT, :width => 150))
@lists.push(FXList.new(panes, :opts => LAYOUT_FILL_Y|LAYOUT_FIX_WIDTH|LIST_SINGLESELECT, :width => 140))
@lists.push(FXList.new(panes, :opts => LAYOUT_FILL_Y|LAYOUT_FIX_WIDTH|LIST_MULTIPLESELECT, :width => 230))
@lists.push(FXList.new(panes, :opts => LAYOUT_FILL_Y|LAYOUT_FIX_WIDTH|LIST_EXTENDEDSELECT, :width => 80))
@lists[0].backColor = FXRGB(255, 240, 240)
@lists[1].backColor = FXRGB(240, 255, 240)
@lists[2].backColor = FXRGB(240, 240, 255)
@lists[3].backColor = FXRGB(255, 255, 240)
# Add some contents
@lists[0].appendItem("Matsumoto Yukihiro")
@lists[0].appendItem("Jeroen van der Zijp")
@lists[0].appendItem("Lyle Johnson")
@lists[0].appendItem("Andy Hunt")
@lists[0].appendItem("Dave Thomas")
@lists[0].appendItem("Charles Warren")
@lists[1].appendItem("Father of Ruby")
@lists[1].appendItem("Incorrigible Hacker")
@lists[1].appendItem("Windows Hacker")
@lists[1].appendItem("Pragmatic Hacker")
@lists[1].appendItem("Ruby Hacker")
@lists[1].appendItem("Shutter Hacker")
@lists[2].appendItem("LAYOUT_FILL_X|LAYOUT_FILL_Y")
@lists[2].appendItem("LAYOUT_FILL_Y")
@lists[2].appendItem("LAYOUT_NORMAL")
@lists[2].appendItem("LAYOUT_NORMAL")
@lists[2].appendItem("LAYOUT_NORMAL")
@lists[2].appendItem("LAYOUT_NORMAL")
@lists[3].appendItem("A")
@lists[3].appendItem("B")
@lists[3].appendItem("C")
@lists[3].appendItem("D")
@lists[3].appendItem("E")
@lists[3].appendItem("F")
@header2 = FXHeader.new(panes,
:opts => HEADER_VERTICAL|HEADER_BUTTON|HEADER_RESIZE|FRAME_RAISED|FRAME_THICK|LAYOUT_FILL_Y)
@header2.appendItem("Example", nil, 30)
@header2.appendItem("Of", nil, 30)
@header2.appendItem("Vertical", nil, 30)
@header2.appendItem("Header", nil, 30)
# Group box with some controls
groupie = FXGroupBox.new(panes, "Controls",
GROUPBOX_TITLE_CENTER|LAYOUT_FILL_X|LAYOUT_FILL_Y)
check = FXCheckButton.new(groupie,
"Continuous Tracking\tContinuous\tTrack Header continuously",
:opts => ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP)
check.connect(SEL_COMMAND) do
@header1.headerStyle ^= HEADER_TRACKING
@header2.headerStyle ^= HEADER_TRACKING
end
# Whip out a tooltip control, jeez, that's hard
FXToolTip.new(getApp())
end
end
if __FILE__ == $0
# Construct a FOX application object
application = FXApp.new("Header", "FoxTest")
# Construct the main window
HeaderWindow.new(application)
# Create all the windows
application.create
# Run the application
application.run
end