#!/usr/bin/tclsh # Part of MCU 8051 IDE ( http://https://sourceforge.net/projects/mcu8051ide/ ) ############################################################################ # Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by Martin Ošmera # # martin.osmera@gmail.com # # # # Copyright (C) 2014 by Moravia Microsystems, s.r.o. # # martin.osmera@gmail.com # # # # This program 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; either version 2 of the License, or # # (at your option) any later version. # # # # This program 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 this program; if not, write to the # # Free Software Foundation, Inc., # # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################ # >>> File inclusion guard if { ! [ info exists _RIGHTPANEL_TCL ] } { set _RIGHTPANEL_TCL _ # <<< File inclusion guard # -------------------------------------------------------------------------- # DESCRIPTION # Implements Right Panel # Right Panel Notebook consist of: # - List of bookmarks # - List of breakpoints # - List of register watches # - Instruction details # - List of active subprograms # -------------------------------------------------------------------------- # Import nesesary sources source "${::LIB_DIRNAME}/rightpanel/regwatches.tcl" ;# Register watches source "${::LIB_DIRNAME}/rightpanel/instructiondetails.tcl" ;# Instruction details source "${::LIB_DIRNAME}/rightpanel/subprograms.tcl" ;# List of active subprograms source "${::LIB_DIRNAME}/rightpanel/hwmanager.tcl" ;# Hardware tools manager class RightPanel { inherit RegWatches InstructionDetails SubPrograms HwManager ## COMMON # Background color for selected rows -- light public common selection_color {#EEFFDD} # Background color for selected rows -- dark public common selection_color_dark {#DDDDFF} # Default font size for text widgets public common fontSize ${Editor::fontSize} # Default font family for text widgets public common fontFamily ${Editor::fontFamily} # Font used in Editor public common editor_font [font create -size -$fontSize -family $fontFamily] # Definition of popup menu for bookmark list public common BOOKMARKMENU { {command {Remove} {$edit:bookmark} 0 "editor_procedure {} Bookmark {}" {button_cancel} "Add/Remove editor bookmark to/from current line"} {separator} {command {Previous} {} 0 "rightPanel_bm_up" {1uparrow} "Go to previous bookmark"} {command {Next} {} 0 "rightPanel_bm_up" {1downarrow} "Go to next bookmark"} {separator} {command {Remove all} {} 0 "editor_procedure {} clear_all_bookmarks {}" {editdelete} "Remove all bookmarks from the editor"} } # Definition of popup menu for breakpoint list public common BREAKPOINTMENU { {command {Remove} {$edit:breakpoint} 0 "editor_procedure {} Breakpoint {}" {button_cancel} "Add/Remove editor breakpoint to/from current line"} {separator} {command {Previous} {} 0 "rightPanel_bp_up" {1uparrow} "Go to previous breakpoint"} {command {Next} {} 0 "rightPanel_bp_up" {1downarrow} "Go to next breakpoint"} {separator} {command {Remove all} {} 0 "editor_procedure {} clear_all_breakpoints {}" {editdelete} "Remove all breakpoints from the editor"} } # Definition of popup menu for symbols list public common SYMBOLSKMENU {} ## PRIVATE private variable notebook_frame ;# ID of panel main frame private variable notebook ;# ID of panel NoteBook private variable bookmarks ;# ID of tab "Bookmarks" private variable breakpoints ;# ID of tab "Breakpoints" private variable watches ;# ID of tab "Register watches" private variable instruction ;# ID of tab "Instruction details" private variable subprograms ;# ID of tab "Active subprograms" private variable hwmanager ;# ID of tab "Hardware manager" private variable table_of_symbols ;# ID of tab "Table of symbols" private variable obj_idx ;# Number of this object private variable bookmarks_menu {} ;# ID of popup menu for "Bookmarks" private variable breakpoints_menu {} ;# ID of popup menu for "Breakpoints" private variable symbols_menu ;# ID of popup menu for "Symbol list" private variable bm_pagesManager ;# ID of pages manager for tab "Bookmarks" private variable bp_pagesManager ;# ID of pages manager for tab "Breakpoints" private variable sm_pagesManager ;# ID of pages manager for tab "Symbol list" private variable bookmarks_lineNumbers ;# ID of text widget showing line numbers - tab "Bookmarks" private variable breakpoints_lineNumbers ;# ID of text widget showing line numbers - tab "Breakpoints" private variable bookmarks_text ;# ID of list of bookmarks (text widget) - tab "Bookmarks" private variable breakpoints_text ;# ID of list of breakpoints (text widget) - tab "Breakpoints" private variable bm_up_button ;# ID of button "Up" - tab "Bookmarks" private variable bm_down_button ;# ID of button "Down" - tab "Bookmarks" private variable bm_clear_button ;# ID of button "Clear all" - tab "Bookmarks" private variable bp_up_button ;# ID of button "Up" - tab "Breakpoints" private variable bp_down_button ;# ID of button "Down" - tab "Breakpoints" private variable bp_clear_button ;# ID of button "Clear all" - tab "Breakpoints" private variable sm_text ;# ID of symbol list text widget - tab "Symbols" private variable sm_lineNumbers ;# ID of text widget showing line numbers - tab "Symbols" private variable LIST_bookmarks_lineNumbers {} ;# List of $bookmarks_lineNumbers (for each editor) private variable LIST_breakpoints_lineNumbers {} ;# List of $breakpoints_lineNumbers (for each editor) private variable LIST_bookmarks_text {} ;# List of $bookmarks_text (for each editor) private variable LIST_breakpoints_text {} ;# List of $breakpoints_text (for each editor) private variable LIST_bm_up_button {} ;# List of $bm_up_button (for each editor) private variable LIST_bm_down_button {} ;# List of $bm_down_button (for each editor) private variable LIST_bm_clear_button {} ;# List of $bm_clear_button (for each editor) private variable LIST_bp_up_button {} ;# List of $bp_up_button (for each editor) private variable LIST_bp_down_button {} ;# List of $bp_down_button (for each editor) private variable LIST_bp_clear_button {} ;# List of $bp_clear_button (for each editor) private variable LIST_sm_text {} ;# List of $sm_text (for each editor) private variable LIST_sm_lineNumbers {} ;# List of $sm_lineNumbers (for each editor) private variable bm_bp_pages_list {} ;# List of editor numbers present in the panel private variable editors_count 0 ;# Counter of added editors private variable current_editor_idx 0 ;# Int: Index of currently active editor private variable block_select 0 ;# Bool: Block selection of an item for certain procedures private variable search_val_in_progress 0 ;# Bool: Search procedure is in progress private variable button_bar ;# ID of button bar which replaces notebook on hide private variable redraw_pane_in_progress 0 ;# (see procedure right_panel_redraw_pane) private variable parentPane ;# ID of parent container (some frame) private variable last_PanelSize ;# Last panel widgth private variable PanelSize $::CONFIG(RIGHT_PANEL_SIZE) ;# Current panel width private variable active_page $::CONFIG(RIGHT_PANEL_ACTIVE_PAGE) ;# ID of the active page private variable PanelVisible $::CONFIG(RIGHT_PANEL) ;# Bool: is panel visible private variable enabled 0 ;# Bool: enable procedures which are needless while loading project ## Object constructor constructor {} { } ## Object destructor destructor { # Clean up GUI destroy $notebook_frame # Remove status bar tips for popup menus menu_Sbar_remove $bookmarks_menu menu_Sbar_remove $breakpoints_menu } ## Create right panel # @parm Widget notebookframe - frame where to pack NoteBook # @parm Widget ParentPane - parent paned window # @parm String watches_file - definition file for register watches # @return void public method initialize_rightPanel {notebookframe ParentPane watches_file} { # Object variables set parentPane $ParentPane ;# Parent container (some frame) # Main frame of this panel set notebook_frame $notebookframe ## Create NoteBook set notebook [ModernNoteBook $notebook_frame.ntb_rightPanel] # Register notebook status bar tips notebook_Sbar_set {rightpanel} [list \ Bookmarks [mc "List of bookmarks in the current editor"] \ Breakpoints [mc "List of breakpoints in the current editor"] \ Instruction [mc "Details for instruction on the current line"] \ Watches [mc "Register watches (for internal data memory, external data memory, expanded data memory and bits)"] \ Subprograms [mc "List of active subprograms"] \ Symbols [mc "Symbol list"] \ Hardware [mc "Hardware manager"] \ Hide [mc "Hide the panel"] \ ] $notebook bindtabs "notebook_Sbar rightpanel" $notebook bindtabs "Sbar {} ;#" # # Create tabs # if {!${::Editor::editor_to_use}} { # Tab "Bookmarks" set bookmarks [$notebook insert end {Bookmarks} \ -image ::ICONS::16::bookmark_toolbar \ -raisecmd [list $this rightPanel_set_active_page Bookmarks] \ -helptext [mc "List of bookmarks in editor (Ctrl+6)"] \ ] # Tab "Breakpoints" set breakpoints [$notebook insert end {Breakpoints} \ -image ::ICONS::16::flag \ -raisecmd [list $this rightPanel_set_active_page Breakpoints] \ -helptext [mc "List of breakpoints in editor (Ctrl+7)"] \ ] # Tab "Symbols" set table_of_symbols [$notebook insert end {Symbols} \ -image ::ICONS::16::_blockdevice \ -raisecmd [list $this rightPanel_set_active_page Symbols] \ -helptext [mc "Symbol List"] \ ] # Tab "Instruction" set instruction [$notebook insert end {Instruction} \ -image ::ICONS::16::info \ -raisecmd [list $this rightPanel_set_active_page Instruction] \ -helptext [mc "Instruction details (Ctrl+8)"] \ -createcmd [list $this CreateInstructionDetailsGUI] \ ] } # Tab "Watches" set watches [$notebook insert end {Watches} \ -image ::ICONS::16::player_playlist \ -raisecmd [list $this rightPanel_set_active_page Watches] \ -helptext [mc "Register watches (Ctrl+9)"] \ -createcmd [list $this CreateRegWatchesGUI] \ ] # Tab "Subprograms" set subprograms [$notebook insert end {Subprograms} \ -image ::ICONS::16::queue \ -raisecmd [list $this rightPanel_set_active_page Subprograms] \ -helptext [mc "Active subprograms (Ctrl+0)"] \ -createcmd [list $this CreateSubProgramsGUI] \ ] # Tab "Hardware manager" set hwmanager [$notebook insert end {Hardware} \ -image ::ICONS::16::kcmpci \ -raisecmd [list $this rightPanel_set_active_page Hardware] \ -helptext [mc "Hardware manager"] \ -createcmd [list $this CreateHwManagerGUI] \ ] # Tab "Hide" $notebook insert end {Hide} \ -image ::ICONS::16::2rightarrow \ -raisecmd [list $this right_panel_show_hide] \ -helptext [mc "Hide the panel"] # Prepare panel componenets but do not create GUI elements PrepareRegWatches $watches $watches_file PrepareSubPrograms $subprograms PrepareHwManager $hwmanager if {!${::Editor::editor_to_use}} { PrepareInstructionDetails $instruction } ## Create Button bar # Button "Show" set button_bar [frame $notebook_frame.button_bar] pack [ttk::button $button_bar.but_show \ -image ::ICONS::16::2leftarrow \ -style ToolButton.TButton \ -command "$this right_panel_show_hide" \ ] DynamicHelp::add $button_bar.but_show -text [mc "Show the panel"] setStatusTip -widget $button_bar.but_show -text [mc "Show the panel"] # Separator pack [ttk::separator $button_bar.sep -orient horizontal] -fill x -pady 2 # Button "Hardware manager" pack [ttk::button $button_bar.but_hwman \ -image ::ICONS::16::kcmpci \ -style ToolButton.TButton \ -command "$this rightPanel_show_up Hardware" \ ] DynamicHelp::add $button_bar.but_hwman -text [mc "Hardware tools"] setStatusTip -widget $button_bar.but_hwman \ -text [mc "Hardware tools manager"] # Button "Active Subprograms" pack [ttk::button $button_bar.but_subprog \ -image ::ICONS::16::queue \ -style ToolButton.TButton \ -command "$this rightPanel_show_up Subprograms" \ ] DynamicHelp::add $button_bar.but_subprog -text [mc "Active subprograms (Ctrl+0)"] setStatusTip -widget $button_bar.but_subprog \ -text [mc "List of active subprograms"] # Button "Register watches" pack [ttk::button $button_bar.but_reg_watch \ -image ::ICONS::16::player_playlist \ -style ToolButton.TButton \ -command "$this rightPanel_show_up Watches" \ ] DynamicHelp::add $button_bar.but_reg_watch -text [mc "MCU register watches (Ctrl+9)"] setStatusTip -widget $button_bar.but_reg_watch \ -text [mc "Register watches for internal data memory, external data memory and expanded data memory"] if {!${::Editor::editor_to_use}} { # Button "Instruction details" pack [ttk::button $button_bar.but_ins_det \ -image ::ICONS::16::info \ -style ToolButton.TButton \ -command "$this rightPanel_show_up Instruction" \ -state [expr {${::Editor::editor_to_use} ? {disabled} : {!disabled}}] \ ] DynamicHelp::add $button_bar.but_ins_det -text [mc "Instruction details (Ctrl+8)"] setStatusTip -widget $button_bar.but_ins_det \ -text [mc "Details for instruction on the current line"] # Button "Symbol List" pack [ttk::button $button_bar.but_symbols \ -image ::ICONS::16::_blockdevice \ -style ToolButton.TButton \ -command "$this rightPanel_show_up Symbols" \ -state [expr {${::Editor::editor_to_use} ? {disabled} : {!disabled}}] \ ] DynamicHelp::add $button_bar.but_symbols -text [mc "Symbol List"] setStatusTip -widget $button_bar.but_symbols \ -text [mc "Symbol List"] # Button "Breakpoints" pack [ttk::button $button_bar.but_breakpoints \ -image ::ICONS::16::flag \ -style ToolButton.TButton \ -command "$this rightPanel_show_up Breakpoints" \ -state [expr {${::Editor::editor_to_use} ? {disabled} : {!disabled}}] \ ] DynamicHelp::add $button_bar.but_breakpoints -text [mc "List of breakpoints in editor (Ctrl+7)"] setStatusTip -widget $button_bar.but_breakpoints \ -text [mc "List of breakpoints in the current editor"] # Button "Bookmarks" pack [ttk::button $button_bar.but_bookmarks \ -image ::ICONS::16::bookmark_toolbar \ -style ToolButton.TButton \ -command "$this rightPanel_show_up Bookmarks" \ -state [expr {${::Editor::editor_to_use} ? {disabled} : {!disabled}}] \ ] DynamicHelp::add $button_bar.but_bookmarks -text [mc "List of bookmarks in editor (Ctrl+6)"] setStatusTip -widget $button_bar.but_bookmarks \ -text [mc "List of bookmarks in the current editor"] } if {!${::Editor::editor_to_use}} { # Pack pages managers set bm_pagesManager [PagesManager $bookmarks.pgm_rightPanel_bm -background ${::COMMON_BG_COLOR}] pack $bm_pagesManager -expand 1 -fill both $bm_pagesManager compute_size set bp_pagesManager [PagesManager $breakpoints.pgm_rightPanel_pm -background ${::COMMON_BG_COLOR}] pack $bp_pagesManager -expand 1 -fill both $bp_pagesManager compute_size set sm_pagesManager [PagesManager $table_of_symbols.sm_pagesManager -background ${::COMMON_BG_COLOR}] pack $sm_pagesManager -expand 1 -fill both $sm_pagesManager compute_size # Create popup menus set bookmarks_menu $notebook_frame.menu_rightPanel_bookmarks set breakpoints_menu $notebook_frame.menu_rightPanel_breakpoints set symbols_menu $notebook_frame.menu_rightPanel_symbols menuFactory $BREAKPOINTMENU $breakpoints_menu 0 "$this " 0 {} [namespace current] menuFactory $BOOKMARKMENU $bookmarks_menu 0 "$this " 0 {} [namespace current] menuFactory $SYMBOLSKMENU $symbols_menu 0 "$this " 0 {} [namespace current] } # # Post-initialization # bind $parentPane "$this right_panel_set_size" # Show panel GUI components if {$PanelVisible} { # Show NoteBook $parentPane paneconfigure $notebook_frame -minsize 295 pack [$notebook get_nb] -expand 1 -fill both -padx 5 -pady 5 $parentPane configure -sashwidth 2 if {[catch { $notebook raise $active_page if { ${::Editor::editor_to_use} && ([lsearch {Bookmarks Breakpoints Instruction Symbols} $active_page] != -1) } then { set active_page {Watches} $notebook raise {Watches} } }]} then { set active_page {Watches} $notebook raise {Watches} } } else { # Show button bar $parentPane paneconfigure $notebook_frame -minsize 0 pack $button_bar -anchor nw $parentPane configure -sashwidth 0 bind $parentPane