indexing description : "Command that can be added in a toolbar." legal: "See notice at end of class." status: "See notice at end of class." date : "$Date$" revision : "$Revision$" deferred class EB_TOOLBARABLE_COMMAND inherit EB_GRAPHICAL_COMMAND redefine update end EB_TOOLBARABLE redefine new_toolbar_item end feature -- Access pixmap: EV_PIXMAP is -- Pixmap representing the command. deferred end pixel_buffer: EV_PIXEL_BUFFER is -- Pixel buffer which representing the command. deferred end mini_pixmap: EV_PIXMAP is -- Pixmap representing the command for mini toolbars. do end mini_pixel_buffer: EV_PIXEL_BUFFER is -- Pixel buffer representing the command for mini toolbars. do end tooltip: STRING_GENERAL is -- Tooltip for the toolbar button. deferred ensure valid_result: Result /= Void end tooltext: STRING_GENERAL is -- Text displayed on the toolbar button. do Result := "" ensure valid_result: Result /= Void end has_text: BOOLEAN is -- Does `Current' show text when displayed do Result := tooltext /= Void and then not tooltext.is_empty end is_tooltext_important: BOOLEAN is -- Is the tooltext important shown when view is 'Selective Text' do Result := False end feature -- Status Report is_displayed: BOOLEAN -- Is the toolbar button currently displayed? feature -- Status setting enable_displayed is -- Set `is_displayed' to True. do is_displayed := True end disable_displayed is -- Set `is_displayed' to False. do is_displayed := False end enable_sensitive is -- Set `is_sensitive' to True. local toolbar_items: like internal_managed_toolbar_items sd_toolbar_items: like internal_managed_sd_toolbar_items do if not is_sensitive then is_sensitive := True toolbar_items := internal_managed_toolbar_items if toolbar_items /= Void then from toolbar_items.start until toolbar_items.after loop toolbar_items.item.enable_sensitive toolbar_items.forth end end sd_toolbar_items := internal_managed_sd_toolbar_items if sd_toolbar_items /= Void then from sd_toolbar_items.start until sd_toolbar_items.after loop sd_toolbar_items.item.enable_sensitive sd_toolbar_items.forth end end end end disable_sensitive is -- Set `is_sensitive' to True. local toolbar_items: like internal_managed_toolbar_items sd_toolbar_items: like internal_managed_sd_toolbar_items do if is_sensitive then toolbar_items := internal_managed_toolbar_items if toolbar_items /= Void then from toolbar_items.start until toolbar_items.after loop toolbar_items.item.disable_sensitive toolbar_items.forth end end sd_toolbar_items := internal_managed_sd_toolbar_items if sd_toolbar_items /= Void then from sd_toolbar_items.start until sd_toolbar_items.after loop sd_toolbar_items.item.disable_sensitive sd_toolbar_items.forth end end is_sensitive := False end end update (a_window: EV_WINDOW) is -- Update `accelerator' and interfaces according to `referred_shortcut'. do Precursor {EB_GRAPHICAL_COMMAND} (a_window) update_tooltips end feature -- Basic operations new_toolbar_item (display_text: BOOLEAN): EB_COMMAND_TOOL_BAR_BUTTON is -- Create a new toolbar button for this command. -- Call `recycle' on the result when you don't need it anymore otherwise -- it will never be garbage collected. do create Result.make (Current) initialize_toolbar_item (Result, display_text) Result.select_actions.extend (agent execute) end new_sd_toolbar_item (display_text: BOOLEAN): EB_SD_COMMAND_TOOL_BAR_BUTTON is -- Create a new docking tool bar button for this command. do create Result.make (Current) initialize_sd_toolbar_item (Result, display_text) Result.select_actions.extend (agent execute) end new_mini_toolbar_item: EB_COMMAND_TOOL_BAR_BUTTON is -- Create a new mini toolbar button for this command. require mini_pixmap_not_void: mini_pixmap /= Void local l_tt: like tooltip do create Result.make (Current) Result.set_pixmap (mini_pixmap) if is_sensitive then Result.enable_sensitive else Result.disable_sensitive end l_tt := tooltip.twin if shortcut_available then l_tt.append (opening_parenthesis) l_tt.append (shortcut_string) l_tt.append (closing_parenthesis) end Result.set_tooltip (l_tt) Result.select_actions.extend (agent execute) end new_mini_sd_toolbar_item: EB_SD_COMMAND_TOOL_BAR_BUTTON is -- Create a new mini toolbar button for this command. require mini_pixmap_not_void: mini_pixmap /= Void local l_tt: like tooltip do create Result.make (Current) Result.set_pixmap (mini_pixmap) Result.set_pixel_buffer (mini_pixel_buffer) if is_sensitive then Result.enable_sensitive else Result.disable_sensitive end l_tt := tooltip.twin if shortcut_available then l_tt.append (opening_parenthesis) l_tt.append (shortcut_string) l_tt.append (closing_parenthesis) end Result.set_tooltip (l_tt) Result.select_actions.extend (agent execute) end feature {NONE} -- Implementation initialize_toolbar_item (a_item: EB_COMMAND_TOOL_BAR_BUTTON; display_text: BOOLEAN) is -- Initialize `a_item' local l_tt: STRING_GENERAL do if display_text and then has_text then a_item.set_text (tooltext) end a_item.set_pixmap (pixmap) if is_sensitive then a_item.enable_sensitive else a_item.disable_sensitive end l_tt := tooltip.twin if shortcut_available then l_tt.append (opening_parenthesis) l_tt.append (shortcut_string) l_tt.append (closing_parenthesis) end a_item.set_tooltip (l_tt) end feature {EB_COMMAND_TOOL_BAR_BUTTON} -- Implementation add_toolbar_item (a_toolbar_item: like new_toolbar_item) is -- Add `a_toolbar_item' to `managed_toolbar_items'. do managed_toolbar_items.extend (a_toolbar_item) ensure managed_toolbar_items_has_item: managed_toolbar_items.has (a_toolbar_item) end initialize_sd_toolbar_item (a_item: EB_SD_COMMAND_TOOL_BAR_BUTTON; display_text: BOOLEAN) is -- Initialize `a_item' local l_tt: STRING_GENERAL do if display_text and then has_text then a_item.set_text (tooltext) end a_item.set_pixmap (pixmap) if pixel_buffer /= Void then a_item.set_pixel_buffer (pixel_buffer) end a_item.set_description (description) if is_sensitive then a_item.enable_sensitive else a_item.disable_sensitive end if shortcut_available then l_tt := tooltip.twin l_tt.append (opening_parenthesis) l_tt.append (shortcut_string) l_tt.append (closing_parenthesis) a_item.set_tooltip (l_tt) else a_item.set_tooltip (tooltip) end end remove_toolbar_item (a_toolbar_item: like new_toolbar_item) is -- Remove `a_toolbar_item' from `managed_toolbar_items'. require managed_toolbar_items_not_empty: not managed_toolbar_items.is_empty managed_toolbar_items_has_item: managed_toolbar_items.has (a_toolbar_item) do managed_toolbar_items.prune_all (a_toolbar_item) ensure managed_toolbar_items_not_has_item: not managed_toolbar_items.has (a_toolbar_item) end feature {EB_COMMAND_TOOL_BAR_BUTTON, EB_SD_COMMAND_TOOL_BAR_BUTTON} -- Implementation internal_managed_sd_toolbar_items: ARRAYED_LIST [like new_sd_toolbar_item] managed_toolbar_items: ARRAYED_LIST [like new_toolbar_item] is -- Toolbar items associated with this command. do if internal_managed_toolbar_items = Void then create internal_managed_toolbar_items.make (1) end Result := internal_managed_toolbar_items ensure managed_toolbar_items_not_void: Result /= Void end feature {EB_SD_COMMAND_TOOL_BAR_BUTTON} -- Implementaiton managed_sd_toolbar_items: ARRAYED_LIST [like new_sd_toolbar_item] is -- do if internal_managed_sd_toolbar_items = Void then create internal_managed_sd_toolbar_items.make (1) end Result := internal_managed_sd_toolbar_items end feature {NONE} -- Implementation update_tooltips is -- Update tooltips when shortcut is changed. local l_items: like managed_toolbar_items l_sd_items: like managed_sd_toolbar_items l_tt: STRING_GENERAL do if tooltip /= Void then l_tt := tooltip.twin if shortcut_available then l_tt.append (opening_parenthesis) l_tt.append (shortcut_string) l_tt.append (closing_parenthesis) end from l_items := managed_toolbar_items l_items.start until l_items.after loop l_items.item.set_tooltip (l_tt) l_items.forth end from l_sd_items := managed_sd_toolbar_items l_sd_items.start until l_sd_items.after loop l_sd_items.item.set_description (description) l_sd_items.item.set_tooltip (l_tt) l_sd_items.forth end end end internal_managed_toolbar_items: ARRAYED_LIST [like new_toolbar_item] Opening_parenthesis: STRING is " (" Closing_parenthesis: STRING is ")"; indexing copyright: "Copyright (c) 1984-2006, Eiffel Software" license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" licensing_options: "http://www.eiffel.com/licensing" copying: "[ This file is part of Eiffel Software's Eiffel Development Environment. Eiffel Software's Eiffel Development Environment is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2 of the License (available at the URL listed under "license" above). Eiffel Software's Eiffel Development Environment is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Eiffel Software's Eiffel Development Environment; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ]" source: "[ Eiffel Software 356 Storke Road, Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end -- class EB_TOOLBARABLE_COMMAND