class BorderLayout
Constants
- Center
- East
- ItemWrapper
- MinimumSize
- North
- SizeHint
- South
- West
Public Class Methods
new(parent = nil, margin = 0, spacing = -1)
click to toggle source
Calls superclass method
# File examples/layouts/borderlayout/borderlayout.rb, line 39 def initialize(parent = nil, margin = 0, spacing = -1) @list = [] super(parent) setMargin(margin) setSpacing(spacing) end
Public Instance Methods
add(item, position)
click to toggle source
# File examples/layouts/borderlayout/borderlayout.rb, line 163 def add(item, position) @list << ItemWrapper.new(item, position) end
addItem(item)
click to toggle source
def initialize(spacing)
setSpacing(spacing)
end
# File examples/layouts/borderlayout/borderlayout.rb, line 50 def addItem(item) add(item, West) end
addWidget(widget, position)
click to toggle source
# File examples/layouts/borderlayout/borderlayout.rb, line 54 def addWidget(widget, position) add(Qt::WidgetItem.new(widget), position) end
calculateSize(sizeType)
click to toggle source
# File examples/layouts/borderlayout/borderlayout.rb, line 167 def calculateSize(sizeType) totalSize = Qt::Size.new (0...@list.length).each do |i| wrapper = @list[i] position = wrapper.position if sizeType == MinimumSize itemSize = wrapper.item.minimumSize else # (sizeType == SizeHint) itemSize = wrapper.item.sizeHint end if position == North || position == South || position == Center totalSize.height += itemSize.height end if position == West || position == East || position == Center totalSize.width += itemSize.width end end return totalSize end
count()
click to toggle source
# File examples/layouts/borderlayout/borderlayout.rb, line 66 def count() return @list.length() end
expandingDirections()
click to toggle source
# File examples/layouts/borderlayout/borderlayout.rb, line 58 def expandingDirections() return Qt::Horizontal | Qt::Vertical end
hasHeightForWidth()
click to toggle source
# File examples/layouts/borderlayout/borderlayout.rb, line 62 def hasHeightForWidth() return false end
itemAt(index)
click to toggle source
# File examples/layouts/borderlayout/borderlayout.rb, line 70 def itemAt(index) wrapper = @list[index] if !wrapper.nil? return wrapper.item else return nil end end
minimumSize()
click to toggle source
# File examples/layouts/borderlayout/borderlayout.rb, line 79 def minimumSize() return calculateSize(MinimumSize) end
setGeometry(rect)
click to toggle source
Calls superclass method
# File examples/layouts/borderlayout/borderlayout.rb, line 83 def setGeometry(rect) center = 0 eastWidth = 0 westWidth = 0 northHeight = 0 southHeight = 0 centerHeight = 0 super(rect) (0...@list.length).each do |i| wrapper = @list[i] item = wrapper.item position = wrapper.position if position == North item.geometry = Qt::Rect.new(rect.x, northHeight, rect.width, item.sizeHint.height) northHeight += item.geometry.height + spacing() elsif position == South item.geometry = Qt::Rect.new(item.geometry.x, item.geometry.y, rect.width, item.sizeHint.height) southHeight += item.geometry().height() + spacing() item.geometry = Qt::Rect.new(rect.x, rect.y + rect.height - southHeight + spacing(), item.geometry.width, item.geometry.height) elsif position == Center center = wrapper end end centerHeight = rect.height() - northHeight - southHeight (0...@list.length).each do |i| wrapper = @list[i] item = wrapper.item position = wrapper.position if position == West item.geometry = Qt::Rect.new(rect.x + westWidth, northHeight, item.sizeHint.width, centerHeight) westWidth += item.geometry.width + spacing() elsif position == East item.geometry = Qt::Rect.new(item.geometry.x, item.geometry.y, item.sizeHint.width, centerHeight) eastWidth += item.geometry.width + spacing() item.geometry = Qt::Rect.new( rect.x + rect.width - eastWidth + spacing, northHeight, item.geometry.width, item.geometry.height) end end if !center.nil? center.item.geometry = Qt::Rect.new(westWidth, northHeight, rect.width - eastWidth - westWidth, centerHeight) end end
sizeHint()
click to toggle source
# File examples/layouts/borderlayout/borderlayout.rb, line 151 def sizeHint() return calculateSize(SizeHint) end
takeAt(index)
click to toggle source
# File examples/layouts/borderlayout/borderlayout.rb, line 155 def takeAt(index) if index >= 0 && index < @list.length() layoutStruct = @list.delete_at(index) return layoutStruct.item end return nil end