Ignore:
Timestamp:
Jul 12, 2012, 9:15:02 AM (12 years ago)
Author:
chronos
Message:
  • Added: Tool button with drop down menu of available targets.
  • Added Target list have icons.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r47 r48  
    4444    ActionList1: TActionList;
    4545    CoolTranslator1: TCoolTranslator;
    46     ImageList1: TImageList;
     46    ImageListMain: TImageList;
    4747    MainMenu1: TMainMenu;
    4848    MenuItem1: TMenuItem;
     
    8686    PanelOutput: TPanel;
    8787    PanelInput: TPanel;
     88    PopupMenuTargets: TPopupMenu;
     89    PopupMenuRecentFiles: TPopupMenu;
    8890    SaveDialog1: TSaveDialog;
    8991    Splitter1: TSplitter;
     
    106108    ToolButton14: TToolButton;
    107109    ToolButton15: TToolButton;
     110    ToolButtonTarget: TToolButton;
    108111    ToolButton2: TToolButton;
    109112    ToolButton3: TToolButton;
     
    223226  I: Integer;
    224227begin
     228  if Sender is TMenuItem then
    225229  with TMenuItem(Sender) do begin
    226230    CurrentTarget := TTarget(Targets[MenuIndex]);
     
    252256  FCurrentTarget.OnChangeState := TargetStateChanged;
    253257  FCurrentTarget.Messages.OnChange := MessagesChanged;
     258  UpdateTargetList;
    254259  UpdateInterface;
    255260end;
     
    293298begin
    294299  LastOpenedList.LoadToMenuItem(MenuItemOpenRecent, AProjectOpenRecentExecute);
     300  LastOpenedList.LoadToMenuItem(PopupMenuRecentFiles.Items, AProjectOpenRecentExecute);
    295301end;
    296302
     
    378384var
    379385  I: Integer;
    380   NewMenuItem: TMenuItem;
    381 begin
    382   MenuItemTarget.Clear;
    383   for I := 0 to Targets.Count - 1 do begin
    384     NewMenuItem := TMenuItem.Create(MenuItemTarget);
    385     NewMenuItem.Caption := TTarget(Targets[I]).Name;
    386     NewMenuItem.OnClick := MenuItemTargetClick;
    387     if TTarget(Targets[I]) = CurrentTarget then NewMenuItem.Checked := True;
    388     MenuItemTarget.Add(NewMenuItem);
     386begin
     387  Targets.LoadToMenuItem(MenuItemTarget, MenuItemTargetClick, CurrentTarget);
     388  Targets.LoadToMenuItem(PopupMenuTargets.Items, MenuItemTargetClick, CurrentTarget);
     389
     390  // Update toolbutton
     391  I := Targets.IndexOf(CurrentTarget);
     392  if I <> -1 then
     393  with TTarget(Targets[I]) do begin
     394    ToolButtonTarget.ImageIndex := ImageIndex;
     395    ToolButtonTarget.Caption := Name;
     396    ToolButtonTarget.OnClick := MenuItemTargetClick();
    389397  end;
    390398end;
Note: See TracChangeset for help on using the changeset viewer.