Sha256: 414d464602463ad1cceb35f8d96f36f2e855d2d6dd6881891212e2788ac74b0e

Contents?: true

Size: 1.73 KB

Versions: 13

Compression:

Stored size: 1.73 KB

Contents

module Bowline
  module Desktop
    module Dialog
      # Display a dialog box from the main window.
      # You can ask for a confirmation, or just display some information.
      # 
      # Supported options are:
      #   :yes_no           - Puts Yes and No buttons on the message box *
      #   :ok               - Puts an Ok button on the message box *
      #   :cancel           - Puts a Cancel button on the message box
      #   :icon_exclamation - Displays an exclamation mark symbol
      #   :icon_error       - Displays an error symbol
      #   :question         - Displays a question mark symbol
      #   :information      - Displays an information symbol
      #   :caption          - Title for the message box
      #                       * may be combined with :cancel
      # 
      # Return values are:
      #   :yes    - User clicked yes
      #   :no     - User clicked no
      #   :ok     - User clicked ok
      #   :cancel - User clicked cancel, or closed the box
      def message(msg, options = {})
        style = 0
        style |= YES_NO if options[:yes_no]
        style |= OK     if options[:ok]
        style |= CANCEL if options[:cancel]
        style |= ICON_EXCLAMATION if options[:icon_exclamation]
        style |= ICON_HAND   if options[:icon_hand]
        style |= ICON_ERROR  if options[:icon_error]
        style |= QUESTION    if options[:question]
        style |= INFORMATION if options[:information]
        caption = options[:caption] || "Message"
        
        result = _message(msg, caption, style)
        
        case result
        when YES then :yes
        when NO  then :no
        when OK  then :ok
        when CANCEL then :cancel
        end
      end
      module_function :message
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
bowline-0.9.4 lib/bowline/desktop/dialog.rb
bowline-0.9.3 lib/bowline/desktop/dialog.rb
bowline-0.9.2 lib/bowline/desktop/dialog.rb
bowline-0.9.1 lib/bowline/desktop/dialog.rb
bowline-0.6.3 lib/bowline/desktop/dialog.rb
bowline-0.6.2 lib/bowline/desktop/dialog.rb
bowline-0.6.1 lib/bowline/desktop/dialog.rb
bowline-0.6.0 lib/bowline/desktop/dialog.rb
bowline-0.5.8 lib/bowline/desktop/dialog.rb
bowline-0.5.7 lib/bowline/desktop/dialog.rb
bowline-0.5.6 lib/bowline/desktop/dialog.rb
bowline-0.5.5 lib/bowline/desktop/dialog.rb
bowline-0.5.4 lib/bowline/desktop/dialog.rb