Class: Fzeet::FontDialog

Inherits:
CommonDialog show all
Defined in:
lib/fzeet/windows/comdlg/FontDialog.rb

Constant Summary collapse

DialogStruct =
Windows::CHOOSEFONT
HookProc =
-> *args { CommonDialog::HookProc.(*args.unshift(DialogStruct)) }

Constants included from WindowMethods

WindowMethods::EnumChildProc

Instance Attribute Summary

Attributes inherited from CommonDialog

#struct

Instance Method Summary collapse

Methods inherited from CommonDialog

crackMessage, #hookProc, #on

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, #size, #size=, #style, #style?, #text, #text=, #textlen, #topmost=, #topmost?, #update, #visible=, #visible?, #xstyle, #xstyle?

Methods included from Toggle

#toggle

Constructor Details

#initialize(opts = {}) ⇒ FontDialog

Returns a new instance of FontDialog.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/fzeet/windows/comdlg/FontDialog.rb', line 84

def initialize(opts = {})
	_opts = {
		font: Control::Font,
		color: 0
	}
	badopts = opts.keys - _opts.keys; raise "Bad option(s): #{badopts.join(', ')}." unless badopts.empty?
	_opts.merge!(opts)

	@struct = DialogStruct.new

	@struct[:lStructSize] = @struct.size
	@struct[:hInstance] = Windows.GetModuleHandle(nil)
	@struct[:lpLogFont] = _opts[:font].logfont.pointer
	@struct[:Flags] = Fzeet.flags([:enablehook, :both, :inittologfontstruct, :effects], :cf_)
	@struct[:rgbColors] = _opts[:color]
	@struct[:lCustData] = object_id
	@struct[:lpfnHook] = HookProc

	super()
end

Instance Method Details

#colorObject



112
# File 'lib/fzeet/windows/comdlg/FontDialog.rb', line 112

def color; @struct[:rgbColors] end

#fontObject



111
# File 'lib/fzeet/windows/comdlg/FontDialog.rb', line 111

def font; IndirectFont.new(Windows::LOGFONT.new(@struct[:lpLogFont])) end

#show(window = Application.window) ⇒ Object



105
106
107
108
109
# File 'lib/fzeet/windows/comdlg/FontDialog.rb', line 105

def show(window = Application.window)
	@struct[:hwndOwner] = window.handle

	DialogResult.new((Windows.ChooseFont(@struct) == 0) ? Windows::IDCANCEL : Windows::IDOK)
end