|
Revision 28895, 1.4 kB
(checked in by isaisstillalive, 4 years ago)
|
- parent_resizedで正しくリサイズできるように設定。
|
| Rev | Line | |
|---|
| [28574] | 1 | module Ruwin
|
|---|
| 2 | class Control < Component
|
|---|
| [28843] | 3 | STYLE = WS_VISIBLE | WS_CHILD
|
|---|
| 4 | EXSTYLE = 0
|
|---|
| [28574] | 5 |
|
|---|
| [28891] | 6 | property_accessor \
|
|---|
| 7 | :left => 0,
|
|---|
| 8 | :top => 0,
|
|---|
| 9 | :right => nil,
|
|---|
| 10 | :bottom => nil,
|
|---|
| 11 | :width => 10,
|
|---|
| 12 | :height => 10
|
|---|
| 13 |
|
|---|
| 14 | def initialize
|
|---|
| 15 | super
|
|---|
| [28895] | 16 | move @proparty[:left]||0, @proparty[:top]||0, @proparty[:width]||0, @proparty[:height]||0
|
|---|
| [28891] | 17 | end
|
|---|
| 18 |
|
|---|
| [28895] | 19 | def parent_resized parent_width, parent_height
|
|---|
| 20 | return unless @proparty[:right] || @proparty[:bottom]
|
|---|
| 21 |
|
|---|
| 22 | size = Array.new(4)
|
|---|
| 23 |
|
|---|
| 24 | [
|
|---|
| 25 | [0, 2, parent_width, :left, :right, :width],
|
|---|
| 26 | [1, 3, parent_height, :top, :bottom, :height],
|
|---|
| 27 | ].each do |(low_index, interval_index, parent, low, high, interval)|
|
|---|
| 28 | if @proparty[interval]
|
|---|
| 29 | size[interval_index] = @proparty[interval]
|
|---|
| 30 | if @proparty[low]
|
|---|
| 31 | size[low_index] = @proparty[low]
|
|---|
| 32 | else
|
|---|
| 33 | size[low_index] = parent - @proparty[high] - @proparty[interval]
|
|---|
| 34 | end
|
|---|
| 35 | else
|
|---|
| 36 | size[low_index] = @proparty[low]
|
|---|
| 37 | size[interval_index] = parent - @proparty[high] - @proparty[low]
|
|---|
| 38 | end
|
|---|
| 39 | end
|
|---|
| 40 |
|
|---|
| 41 | move *size
|
|---|
| 42 | end
|
|---|
| 43 |
|
|---|
| [28748] | 44 | class << self
|
|---|
| [28816] | 45 | def new parent
|
|---|
| [28884] | 46 | super
|
|---|
| [28816] | 47 | end
|
|---|
| 48 |
|
|---|
| [28748] | 49 | def inherit name, &block
|
|---|
| 50 | klass = Class.new(self)
|
|---|
| [28816] | 51 | klass.class_eval &block
|
|---|
| [28748] | 52 | klass
|
|---|
| 53 | end
|
|---|
| [28574] | 54 | end
|
|---|
| 55 | end
|
|---|
| 56 | end
|
|---|