Class: FileSelector

Inherits:
Object
  • Object
show all
Defined in:
lib/libGUIb16.rb,
lib/libGUIb16.rb,
lib/libGUIb14.rb,
lib/libGUIb14.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ FileSelector

Returns a new instance of FileSelector.



1122
1123
1124
1125
# File 'lib/libGUIb16.rb', line 1122

def initialize(parent)
  construct_widget_tree(parent)
  init if respond_to? :init
end

Instance Attribute Details

#__foxGUIb__last__Object

Returns the value of attribute __foxGUIb__last__.



1161
1162
1163
# File 'lib/libGUIb16.rb', line 1161

def __foxGUIb__last__
  @__foxGUIb__last__
end

#browseObject

Returns the value of attribute browse.



1161
1162
1163
# File 'lib/libGUIb16.rb', line 1161

def browse
  @browse
end

#currentPatternObject

Returns the value of attribute currentPattern.



1180
1181
1182
# File 'lib/libGUIb16.rb', line 1180

def currentPattern
  @currentPattern
end

#directoryObject

Returns the value of attribute directory.



1180
1181
1182
# File 'lib/libGUIb16.rb', line 1180

def directory
  @directory
end

#filenameObject

Returns the value of attribute filename.



1180
1181
1182
# File 'lib/libGUIb16.rb', line 1180

def filename
  @filename
end

#FileSelectorObject

Returns the value of attribute FileSelector.



1161
1162
1163
# File 'lib/libGUIb16.rb', line 1161

def FileSelector
  @FileSelector
end

#labelObject

Returns the value of attribute label.



1161
1162
1163
# File 'lib/libGUIb16.rb', line 1161

def label
  @label
end

#onNewFilenameBlockObject

Returns the value of attribute onNewFilenameBlock.



1181
1182
1183
# File 'lib/libGUIb16.rb', line 1181

def onNewFilenameBlock
  @onNewFilenameBlock
end

#patternsObject

Returns the value of attribute patterns.



1180
1181
1182
# File 'lib/libGUIb16.rb', line 1180

def patterns
  @patterns
end

#relative_pathObject

Returns the value of attribute relative_path.



1180
1181
1182
# File 'lib/libGUIb16.rb', line 1180

def relative_path
  @relative_path
end

#textfieldObject

Returns the value of attribute textfield.



1161
1162
1163
# File 'lib/libGUIb16.rb', line 1161

def textfield
  @textfield
end

#titleObject

Returns the value of attribute title.



1180
1181
1182
# File 'lib/libGUIb16.rb', line 1180

def title
  @title
end

#topwinObject

Returns the value of attribute topwin.



1161
1162
1163
# File 'lib/libGUIb16.rb', line 1161

def topwin
  @topwin
end

Instance Method Details

#construct_widget_tree(parent) ⇒ Object



1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
# File 'lib/libGUIb16.rb', line 1127

def construct_widget_tree(parent)
  @topwin =
    FX::HorizontalFrame.new(parent) { |w|
      @FileSelector = w
      w.padLeft = 0
      w.frameStyle = 0
      w.padRight = 0
      w.hSpacing = 2
      w.height = 21
      w.layoutHints = 1024
      FX::Label.new(@FileSelector) { |w|
        @label = w
        w.text = "File:"
        w.width = 24
        w.x = 0
      }
      FX::TextField.new(@FileSelector) { |w|
        @textfield = w
        w.width = 297
        w.y = 0
        w.layoutHints = 1024
        w.x = 26
      }
      FX::Button.new(@FileSelector) { |w|
        @browse = w
        w.text = "Browse..."
        w.padLeft = 4
        w.width = 59
        w.padRight = 4
        w.y = 0
        w.x = 325
      }
    }
end

#descriptionObject



1186
1187
1188
# File 'lib/libGUIb16.rb', line 1186

def description
  @label.text
end

#description=(text) ⇒ Object



1182
1183
1184
# File 'lib/libGUIb16.rb', line 1182

def description=text
  @label.text = text
end

#initObject



1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
# File 'lib/libGUIb16.rb', line 1170

def init
  @title = "File Dialog"
  @relative_path = false
  @filename = ""
  @directory = Dir.getwd
  @dialog = Fox::FXFileDialog.new(@topwin, @title)
  @patterns = ["All Files (*)"]
  @currentPattern = 0
  @browse.connect(Fox::SEL_COMMAND, method(:onBrowse))
end

#onBrowse(*args) ⇒ Object



1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
# File 'lib/libGUIb16.rb', line 1190

def onBrowse(*args)
  @dialog.title = @title
  @dialog.directory = @directory
  @dialog.patternList = @patterns
  @currentPattern = 0 if @currentPattern >= @patterns.size
  @dialog.currentPattern = @currentPattern
  @dialog.filename = filename.to_s
  if @dialog.execute != 0
    @filename = @textfield.text = if @relative_path
                  rel_path(Dir.getwd, @dialog.filename)
                else
                  @dialog.filename
                end
    @onNewFilenameBlock.call if @onNewFilenameBlock.respond_to? :call
  end
end