📄 targetedit.tcl
字号:
# Copyright (c) 2000, 2001, Red Hat, Inc.# # This file is part of Source-Navigator.# # Source-Navigator 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, or (at your option)# any later version.# # Source-Navigator 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 Source-Navigator; see the file COPYING. If not, write to# the Free Software Foundation, 59 Temple Place - Suite 330, Boston,# MA 02111-1307, USA.# #################################################### Target Editor Dialog for SN-IDE.## Copyright (c) 1999 Cygnus Solutions, Inc.## Written by Ian Roxborough <irox@cygnus.com>##################################################itcl::class snEditTarget { inherit sourcenav::Dialog # Public variables public variable TargetName "" # Target Name as store in db. public variable NewTarget "" # Set to one if it's a new target. # FIXME: this does not seem to get used anywhere, should be removed! # list of source files protected variable src_file_list "" # Table of rules. protected variable rulesindex # Build target object public variable b_target # Variable used to track the debug toggle button state private variable rb_debug_state 0 # Var used to store linker location/command. private variable linkerlocal "" constructor {target_name args} { #TODO: check target_name is valid set TargetName ${target_name} CreateDialog InitalizeData eval itk_initialize $args # Make the dialog modal $this configure -modality application } destructor { DestroyDialog } ################################################## # snEditTarget::InitalizeData # # This create a build target object and load the # target data from the db to the object which is # used to supply the settings for the dialog. # public method InitalizeData {} { set b_target [snBuildTarget .te_target_data] ${b_target} LoadData ${TargetName} SetTargetType SetToolChain SetBuildDirectory SetLibraryFiles SetSourceFiles # Linker rule SetOutputFilename SetLinkerEntryPoint SetUserLinkFlags SetLinkerExecutable SetLaunchDebugerInfo SetLaunchCommandLine #SetLibraryFiles HandleLibsTabState SetBuildRules UpdateCmdLine # Add custom GUI parts (if any). AddCustomGUI } method AddCustomGUI {} { set tool_chain [$itk_component(tchaincbx) get] set tchain_obj [GetToolChainObject ${tool_chain}] # Check if any custom code is there. if {[$tchain_obj GetUserTargetEditGUI] != ""} { # Add custom GUI tab. itk_component add custompage { $itk_component(notebook) add custom \ -label "Custom" } [$tchain_obj GetUserTargetEditGUI] $itk_component(custompage) "[itcl::code $b_target]" } } method RemoveCustomGUI {} { set tool_chain [$itk_component(tchaincbx) get] set tchain_obj [GetToolChainObject ${tool_chain}] # Check if any custom code is there. if {[info exists itk_component(custompage)] && [winfo exists $itk_component(custompage)]} { if {[$tchain_obj GetRemoveUserTargetEditGUI] != ""} { [$tchain_obj GetRemoveUserTargetEditGUI] $itk_component(custompage) [itcl::code $b_target] } # Remove custom GUI tab. $itk_component(notebook) delete custom } } ################################################## # snEditTarget::CreateDialog # # This deals with the drawing and layout of the # Edit Target dialog box. # public method CreateDialog {} { $this title "[get_indep String IDETargetEdTitle] ${TargetName}" # Create notebook widget itk_component add notebook { tixNoteBook $itk_component(hull).notebook \ -width 200 -height 200 } {} # Add the leafs AddSrcPage AddLibPage AddRulesPage AddLinkPage # Add Build Directory Widget itk_component add bdirlbl { label $itk_component(hull).bdirlbl \ -text [get_indep String IDETEBuildDir] \ -under [get_indep Pos IDETEBuildDir] } itk_component add bdirleb { LabelEntryButton& $itk_component(hull).bdirleb } {} $itk_component(bdirleb) configure \ -command [list sn_choose_dir [$itk_component(bdirleb) component entry]] # Add Target Type combobox itk_component add ttypelbl { label $itk_component(hull).ttypelbl \ -text [get_indep String IDETETargetType] \ -under [get_indep Pos IDETETargetType] } itk_component add ttypecbx { combobox::combobox $itk_component(hull).ttypecbx } {} # FIXME : We should check the tool chain to see what types # of builds are supported, but for now lets just # assume it's Executable, Library, DLL (Shared Library). $itk_component(ttypecbx) listinsert end "Executable" $itk_component(ttypecbx) listinsert end "Library" $itk_component(ttypecbx) configure -editable 0 # Add Tool Chain combobox itk_component add tchainlbl { label $itk_component(hull).tchainlbl \ -text [get_indep String IDETEToolChain] \ -under [get_indep Pos IDETEToolChain] } itk_component add tchaincbx { combobox::combobox $itk_component(hull).tchaincbx \ -command "${this} ToolChainChanged ${this}" } {} # Get list of installed tool chains. set ToolChainList [GetActiveToolChains] foreach toolchain $ToolChainList { $itk_component(tchaincbx) listinsert end [$toolchain GetLongName] } # Add OK/Cancel Buttons itk_component add ok { button $itk_component(hull).ok \ -width 11 \ -command "${this} ok_cb" \ -text [get_indep String IDETEOK] } itk_component add cancel { button $itk_component(hull).cancel \ -width 11 \ -command "${this} cancel_cb" \ -text [get_indep String IDETECancel] } # Bind Escape and close window button to Cancel $this protocol WM_DELETE_WINDOW "$itk_component(cancel) invoke" bind $itk_component(hull) <Escape> "$itk_component(cancel) invoke" # Bind Return to the OK button. bind $itk_component(hull) <Return> "$itk_component(ok) invoke" # Put a 10 pixel border around the frame $this configure -borderwidth 10 grid columnconfigure $itk_component(hull) 0 -weight 1 grid rowconfigure $itk_component(hull) 6 -weight 1 grid $itk_component(notebook) -row 0 -column 0 -sticky news -rowspan 7 \ -padx 5 -pady 5 grid $itk_component(bdirlbl) -row 0 -column 1 -columnspan 2 -sticky w grid $itk_component(bdirleb) -row 1 -column 1 -columnspan 2 -sticky ew grid $itk_component(ttypelbl) -row 2 -column 1 -columnspan 2 -sticky w grid $itk_component(ttypecbx) -row 3 -column 1 -columnspan 2 -sticky ew grid $itk_component(tchainlbl) -row 4 -column 1 -columnspan 2 -sticky w grid $itk_component(tchaincbx) -row 5 -column 1 -columnspan 2 -sticky ew grid $itk_component(ok) -row 8 -column 1 grid $itk_component(cancel) -row 8 -column 2 # This seems about right, might need some adjusting though configure -geometry 800x500 # FIXME : we can not use reqwidth and reqheight because of tabnotebook! minsize 650 300 } public method ToolChainChanged {my_this {dummy1 ""} {tool_chain ""}} { RemoveCustomGUI # Set the new toolchain. ${b_target} SetToolChain ${tool_chain} # Set the linker to reflect the new toolchain. SetLinkerExecutable # Update Build rules list (list may vary from toolchain to # toolchain). $my_this SetBuildRules # Update the command lines in build rules and link rules. ${my_this} UpdateCmdLine AddCustomGUI } private method AddSrcPage {} { global sn_options # Add leafs for source files. itk_component add sourcepage { $itk_component(notebook) add src \ -label [get_indep String IDETESourceFilesTab] \ -under [get_indep Pos IDETESourceFilesTab] } itk_component add trfr1 { frame $itk_component(sourcepage).trfr1 \ -relief sunken -borderwidth 2 } itk_component add srctree { sn_treetable $itk_component(trfr1) \ -selectmode extended \ -height 10 -width 1 -indent 20 -bw 2 -relief sunken \ -font $sn_options(def,default-font) \ -selectforeground $sn_options(def,select-fg) \ -selectbackground $sn_options(def,select-bg) } {} grid $itk_component(srctree) -row 0 -column 0 -sticky news grid $itk_component(trfr1).x -row 1 -column 0 -sticky ew grid $itk_component(trfr1).y -row 0 -column 1 -sticky ns grid columnconfigure $itk_component(trfr1) 0 -weight 1 grid rowconfigure $itk_component(trfr1) 0 -weight 1 itk_component add trfr2 { frame $itk_component(sourcepage).trfr2 \ -relief sunken -borderwidth 2 } itk_component add srctree2 { sn_treetable $itk_component(trfr2) \ -selectmode extended \ -height 10 -width 1 -indent 20 -bw 2 -relief sunken \ -font $sn_options(def,default-font) \ -selectforeground $sn_options(def,select-fg) \ -selectbackground $sn_options(def,select-bg) } {} grid $itk_component(srctree2) -row 0 -column 0 -sticky news grid $itk_component(trfr2).x -row 1 -column 0 -sticky ew grid $itk_component(trfr2).y -row 0 -column 1 -sticky ns grid columnconfigure $itk_component(trfr2) 0 -weight 1 grid rowconfigure $itk_component(trfr2) 0 -weight 1 set AllProjectFiles [sn_project_file_list 0] $itk_component(srctree2) delete 0 end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -