[fxruby-users] Help widget: suggestion?

Joel VanderWerf vjoel at PATH.Berkeley.EDU
Mon Jan 10 23:47:14 EST 2005


Riccardo Giannitrapani wrote:
> Dear all FXRuby users
> 
> I'm writing to ask for a suggestion; I need to display some 
> documentation  in my FXRuby application for the user, nothing 
> particularly complicate ..  till now my solution was to generate HTML 
> pages and than, from the GUI, to  start a browser to load that HTML 
> pages .. on windows this is quite easy  ('start doc\\index.html' or 
> something like this), while on Linux I've  found around some code (in 
> the FOX community page) to guess the browser  installed (Mozilla, 
> Firefox, whatever) .. now, althought this is working,  I'm wondering if 
> I really need to start an external application for my  user help .. I've 
> seen in the examples of FXruby (the texteditor) that  help is shown as a 
> simple dialog with text inside .. just wondering is  someone has worked 
> on this and end up with some nice widgets and/or  suggestions ..

In the app I'm currently working on, there are two things for help. 
There is a quick "tip" window (attached) for short info. It's just 
FXText in tabs, run as a non-modal dlg.

For more details, I have buttons and menus that link to web pages. On 
non-windows platforms, I make the user select a browser the first time, 
and store that in preferences.

It would be nice to have a polished bunch of FXRuby widgets for help.
-------------- next part --------------
class TipWindow < FXDialogBox

  TIP_DATA = [
    [ "&General", "\
      * These tips cover the operation of the program rather
        than the significance of the simulation objects. See
        the detailed model documents for that information.
      
      * You can copy text out of this tip window, and you can
        leave the window open while you work.
      "
    ],
    [ "Getting &Help", "\
      * Hover the mouse over certain widgets (such as buttons,
        menu items, and fields) for short help messages. The
        help messages appear as text in the status line at the
        bottom of the current window and, in some cases, as
        floating windows near the mouse pointer.
      
      * Dialog boxes have help buttons for more detailed help.

      * The Help menu and buttons link to the HTML documents
        included with EvalTool.
      "
    ],
    [ "&Editing", "\
      "
    ],
    [ "&Files", "\
      "
    ],
    [ "&Mouse", "\
      "
    ],
    [ "&Keyboard", "\
      "
    ],
    [ "&Dialogs", "\
      "
    ],
    [ "&Plot", "\
      "
    ],
    [ "&Advanced", "\
      "
    ],
  ]

  class TipItem
    def initialize(tabbook, caption, icon = nil, text = "", font = nil)
      tab = FXTabItem.new(tabbook, caption, icon, TAB_LEFT_NORMAL)
      body = FXHorizontalFrame.new(tabbook, FRAME_THICK|FRAME_RAISED)
      @textbox = FXText.new(body, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y)
      @textbox.editable = false
      @textbox.font = font if font
      @textbox.text = text
    end
  end

  ## should centralize fonts and have font prefs
  def tip_font
    @tip_font ||= FXFont.new(getApp(), "courier", 9) ##, FONTWEIGHT_BOLD)
  end

  def initialize(owner)
    super(owner, "EvalTool Tips", DECOR_ALL)
    
    register_pref_key "dialogs/tips"
    register_pref_var :x => 100, :y => 100, :height => 200, :width => 550
    
    self.padLeft = self.padTop = self.padBottom = self.padRight = 2
    
    tabbook = FXTabBook.new(self, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y)
      
    tabbook.tabStyle = TABBOOK_LEFTTABS
    TIP_DATA.each do |caption, text|
      TipItem.new(tabbook, caption, nil, text.tabto(0), tip_font)
    end
  end
end


More information about the fxruby-users mailing list