Class: Wx::SimpleHelpProvider

Inherits:
HelpProvider show all
Defined in:
lib/wx/classes/simplehelpprovider.rb

Overview

Pure-ruby implementation of the corresponding Wx class. Simply shows the Window’s help text in a tooltip.

Direct Known Subclasses

HelpControllerHelpProvider

Instance Method Summary collapse

Constructor Details

#initializeSimpleHelpProvider

Returns a new instance of SimpleHelpProvider.



4
5
6
7
8
9
10
# File 'lib/wx/classes/simplehelpprovider.rb', line 4

def initialize
  super
  # Store for mapping windows -> help strings
  @help_wins = {} 
  # Store for mapping ids -> help strings
  @help_ids  = {}
end

Instance Method Details

#add_help(identifier, text) ⇒ Object

This is what is called by Wx::Window#set_help_text



13
14
15
16
17
18
19
# File 'lib/wx/classes/simplehelpprovider.rb', line 13

def add_help(identifier, text)
  if identifier.kind_of? Wx::Window
    @help_wins[identifier.object_id] = text
  else
    @help_ids[identifier] = text
  end
end

#get_help(win) ⇒ Object

Retrieve help text for the given window win



22
23
24
# File 'lib/wx/classes/simplehelpprovider.rb', line 22

def get_help(win)
  @help_wins[win.object_id] || @help_ids[win.wx_id] || ""
end

#remove_help(win) ⇒ Object

Remove the help text for win



27
28
29
# File 'lib/wx/classes/simplehelpprovider.rb', line 27

def remove_help(win)
  @help_wins.delete(win.object_id)
end

#show_help(win) ⇒ Object

Show help for win



32
33
34
35
36
37
# File 'lib/wx/classes/simplehelpprovider.rb', line 32

def show_help(win)
  help_text = get_help(win)
  return false if help_text.empty?
  tip = Wx::TipWindow.new(win, help_text, 100)
  true
end