Class: Fzeet::Control

Inherits:
Handle
  • Object
show all
Includes:
WindowMethods
Defined in:
lib/fzeet/windows/user/Control/Common.rb

Constant Summary

Constants included from WindowMethods

WindowMethods::EnumChildProc

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from WindowMethods

#[], #capture=, #capture?, #dialog=, #dialog?, #dlgmsg?, #drawMenuBar, #eachChild, #enabled=, #enabled?, #focus=, #focus?, #invalidate, #location, #location=, #long, #menu, #menu=, #message, #paint, #position, #position=, #postmsg, #question, #rect, #reframe, #sendmsg, #show, #size, #size=, #style, #style?, #text, #text=, #textlen, #topmost=, #topmost?, #update, #visible=, #visible?, #xstyle, #xstyle?

Methods included from Toggle

#toggle

Constructor Details

#initialize(className, parent, id, opts = {}) ⇒ Control

Returns a new instance of Control.



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
# File 'lib/fzeet/windows/user/Control/Common.rb', line 29

def initialize(className, parent, id, opts = {})
	@parent = parent
	@id = Command[id]

	handlers = {}

	opts.delete_if { |k, v|
		next false unless v.kind_of?(Proc)

		handlers[k] = v; true
	}

	_opts = {
		xstyle: [],
		caption: id.capitalize,
		style: [],
		x: 0,
		y: 0,
		width: 0,
		height: 0,
		position: [],
		anchor: nil
	}
	badopts = opts.keys - _opts.keys; raise "Bad option(s): #{badopts.join(', ')}." unless badopts.empty?
	_opts.merge!(opts)

	_opts[:xstyle] = Fzeet.flags(_opts[:xstyle], *self.class::Prefix[:xstyle])
	_opts[:caption] = _opts[:caption].to_s
	_opts[:style] = Fzeet.flags([:child, :visible, :tabstop], :ws_) | Fzeet.flags(_opts[:style], *self.class::Prefix[:style])
	_opts[:x], _opts[:y], _opts[:width], _opts[:height] = _opts[:position] unless _opts[:position].empty?

	@handle = Windows.DetonateLastError(FFI::Pointer::NULL, :CreateWindowEx,
		_opts[:xstyle], className, _opts[:caption], _opts[:style],
		_opts[:x], _opts[:y], _opts[:width], _opts[:height],
		@parent.handle, FFI::Pointer.new(@id), Windows.GetModuleHandle(nil), nil
	)

	attach

	sendmsg(:setfont, Font.handle, 1)

	handlers.each { |k, v| on(k, &v) }

	case _opts[:anchor]
	when :ltr
		@parent.on(:size) { |args|
			self.position = @parent.rect.tap { |r| r[:bottom] = _opts[:height] }.to_a

			args[:result] = nil if @parent.class == MDIChild
		}
	when :lrb
		@parent.on(:size) { |args|
			self.position = @parent.rect.tap { |r| r[:top] = r[:bottom] - _opts[:height]; r[:bottom] = _opts[:height] }.to_a

			args[:result] = nil if @parent.class == MDIChild
		}
	when :ltrb
		@parent.on(:size) { |args|
			self.position = @parent.rect.to_a

			args[:result] = nil if @parent.class == MDIChild
		}
	else raise ArgumentError, "Bad anchor spec: #{_opts[:anchor]}."
	end if _opts[:anchor]
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



95
96
97
# File 'lib/fzeet/windows/user/Control/Common.rb', line 95

def id
  @id
end

#parentObject (readonly)

Returns the value of attribute parent.



95
96
97
# File 'lib/fzeet/windows/user/Control/Common.rb', line 95

def parent
  @parent
end

Class Method Details

.crackNotification(args) ⇒ Object



27
# File 'lib/fzeet/windows/user/Control/Common.rb', line 27

def self.crackNotification(args) end

Instance Method Details

#disposeObject



97
# File 'lib/fzeet/windows/user/Control/Common.rb', line 97

def dispose; detach end