Class: FXMapDialogBox
- Inherits:
-
FXDialogBox
- Object
- FXDialogBox
- FXMapDialogBox
- Defined in:
- lib/IFMapper/FXMapDialogBox.rb
Instance Method Summary collapse
- #copy_from(map) ⇒ Object
- #copy_to ⇒ Object
-
#initialize(parent) ⇒ FXMapDialogBox
constructor
A new instance of FXMapDialogBox.
Constructor Details
#initialize(parent) ⇒ FXMapDialogBox
Returns a new instance of FXMapDialogBox.
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 |
# File 'lib/IFMapper/FXMapDialogBox.rb', line 77 def initialize(parent) decor = DECOR_TITLE|DECOR_BORDER|DECOR_CLOSE super( parent, BOX_MAP_INFORMATION, decor, 40, 40, 0, 0 ) mainFrame = FXVerticalFrame.new(self, FRAME_SUNKEN|FRAME_THICK| LAYOUT_FILL_X|LAYOUT_FILL_Y) @read = FXCheckButton.new(mainFrame, BOX_MAP_READ_ONLY, nil, 0, ICON_BEFORE_TEXT|LAYOUT_LEFT|LAYOUT_SIDE_TOP| LAYOUT_SIDE_RIGHT) frame = FXHorizontalFrame.new(mainFrame, LAYOUT_SIDE_TOP|LAYOUT_FILL_X) FXLabel.new(frame, "#{BOX_NAME}:", nil, 0, LAYOUT_FILL_X) @name = FXTextField.new(frame, 42, nil, 0, LAYOUT_FILL_ROW) frame = FXHorizontalFrame.new(mainFrame, LAYOUT_FILL_X|LAYOUT_FILL_Y) FXLabel.new(frame, BOX_MAP_CREATOR, nil, 0, LAYOUT_FILL_X) @creator = FXTextField.new(frame, 40, nil, 0, LAYOUT_FILL_ROW) frame = FXHorizontalFrame.new(mainFrame, LAYOUT_SIDE_TOP|FRAME_SUNKEN| LAYOUT_FILL_X|LAYOUT_FILL_Y) frame2 = FXVerticalFrame.new(frame, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y ) FXLabel.new(frame2, BOX_MAP_WIDTH, nil, 0, LAYOUT_FILL_X) @width = FXTextField.new( frame2, 6, nil, 0, TEXTFIELD_INTEGER|LAYOUT_FILL_ROW) frame2 = FXVerticalFrame.new(frame, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y ) FXLabel.new(frame2, BOX_MAP_HEIGHT, nil, 0, LAYOUT_FILL_X) @height = FXTextField.new( frame2, 6, nil, 0, TEXTFIELD_INTEGER|LAYOUT_FILL_ROW) @name.connect(SEL_CHANGED) { copy_to() } @creator.connect(SEL_CHANGED) { copy_to() } @read.connect(SEL_COMMAND) { copy_to() } @width.connect(SEL_COMMAND) { copy_to() } @height.connect(SEL_COMMAND) { copy_to() } @parent = parent # We need to create the dialog box first, so we can use select text. create end |
Instance Method Details
#copy_from(map) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/IFMapper/FXMapDialogBox.rb', line 57 def copy_from(map) @name.text = map.name @creator.text = map.creator @read.checkState = map. @width.text = map.width.to_s @height.text = map.height.to_s if map. @name.disable @creator.disable @width.disable @height.disable else @name.enable @creator.enable @width.enable @height.enable end @map = map end |
#copy_to ⇒ Object
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 |
# File 'lib/IFMapper/FXMapDialogBox.rb', line 5 def copy_to() @map.name = @name.text @map.creator = @creator.text @map. = (@read.checkState == 1) if @map. @name.disable @creator.disable @width.disable @height.disable else @name.enable @creator.enable @width.enable @height.enable end w = @width.text.to_i h = @height.text.to_i @map.update_title if w != @map.width or h != @map.height if w < @map.width or h < @map.height rooms = [] @map.sections.each { |s| s.rooms.each { |r| if r.x >= w or r.y >= h rooms << [s, r] end } } if not rooms.empty? d = FXWarningBox.new(@map.window, WARN_MAP_SMALL) if d.execute == 0 copy_from(@map) return end rooms.each { |p| p[0].delete_room(p[1]) } end end @map.width = w @map.height = h @map.zoom = @map.zoom @map.create_pathmap @map.draw end end |