IDE: desktopmanager: simplify associated debug desktops. Issue #32083

git-svn-id: trunk@55425 -
This commit is contained in:
ondrej 2017-07-02 10:45:54 +00:00
parent c552f9e5c7
commit f2bb18cf26
2 changed files with 39 additions and 50 deletions

View File

@ -206,8 +206,7 @@ object DesktopForm: TDesktopForm
BorderSpacing.Left = 10 BorderSpacing.Left = 10
ItemHeight = 15 ItemHeight = 15
OnChange = AssociatedDebugDesktopComboBoxChange OnChange = AssociatedDebugDesktopComboBoxChange
OnDrawItem = AssociatedDebugDesktopComboBoxDrawItem Style = csDropDownList
Style = csOwnerDrawFixed
TabOrder = 1 TabOrder = 1
end end
object AssociatedDebugDesktopLabel: TLabel object AssociatedDebugDesktopLabel: TLabel

View File

@ -54,8 +54,6 @@ type
ToolButton2: TToolButton; ToolButton2: TToolButton;
ToolButton3: TToolButton; ToolButton3: TToolButton;
procedure AssociatedDebugDesktopComboBoxChange(Sender: TObject); procedure AssociatedDebugDesktopComboBoxChange(Sender: TObject);
procedure AssociatedDebugDesktopComboBoxDrawItem(Control: TWinControl;
Index: Integer; ARect: TRect; State: TOwnerDrawState);
procedure DeleteActionClick(Sender: TObject); procedure DeleteActionClick(Sender: TObject);
procedure DesktopListBoxDrawItem(Control: TWinControl; Index: Integer; procedure DesktopListBoxDrawItem(Control: TWinControl; Index: Integer;
ARect: TRect; {%H-}State: TOwnerDrawState); ARect: TRect; {%H-}State: TOwnerDrawState);
@ -77,6 +75,7 @@ type
FActiveDesktopChanged: Boolean; FActiveDesktopChanged: Boolean;
procedure RefreshList(SelectName: string = ''); procedure RefreshList(SelectName: string = '');
procedure RefreshAssociatedDebugList(SelectedDesktop: TCustomDesktopOpt);
procedure ExportDesktops(const aDesktops: array of TCustomDesktopOpt); procedure ExportDesktops(const aDesktops: array of TCustomDesktopOpt);
end; end;
@ -394,16 +393,18 @@ begin
HasNonCompatible := False; HasNonCompatible := False;
DesktopListBox.Clear; DesktopListBox.Clear;
AssociatedDebugDesktopComboBox.Clear;
AssociatedDebugDesktopComboBox.Items.AddObject(dlgPOIconDescNone, nil);
// Saved desktops // Saved desktops
for i:=0 to EnvironmentOptions.Desktops.Count-1 do DesktopListBox.Items.BeginUpdate;
begin try
DskTop := EnvironmentOptions.Desktops[i]; for i:=0 to EnvironmentOptions.Desktops.Count-1 do
DesktopListBox.Items.AddObject(DskTop.Name, DskTop); begin
AssociatedDebugDesktopComboBox.Items.AddObject(DskTop.Name, DskTop); DskTop := EnvironmentOptions.Desktops[i];
if not DskTop.Compatible then DesktopListBox.Items.AddObject(DskTop.Name, DskTop);
HasNonCompatible := True; if not DskTop.Compatible then
HasNonCompatible := True;
end;
finally
DesktopListBox.Items.EndUpdate;
end; end;
if HasNonCompatible then if HasNonCompatible then
begin begin
@ -473,42 +474,6 @@ begin
EnvironmentOptions.Desktop.AssociatedDebugDesktopName := SelDesktop.AssociatedDebugDesktopName; EnvironmentOptions.Desktop.AssociatedDebugDesktopName := SelDesktop.AssociatedDebugDesktopName;
end; end;
procedure TDesktopForm.AssociatedDebugDesktopComboBoxDrawItem(
Control: TWinControl; Index: Integer; ARect: TRect; State: TOwnerDrawState);
var
ACB: TComboBox;
ACanvas: TCanvas;
ADesktop: TCustomDesktopOpt;
ATextSyle: TTextStyle;
begin
ACB := Control as TComboBox;
ACanvas := ACB.Canvas;
if not (odBackgroundPainted in State) then
ACanvas.FillRect(ARect);
ACanvas.Brush.Style := bsClear;
ATextSyle := ACanvas.TextStyle;
ATextSyle.Layout := tlCenter;
ATextSyle.RightToLeft := ACB.UseRightToLeftReading;
if ACB.UseRightToLeftAlignment then
begin
ATextSyle.Alignment := taRightJustify;
ARect.Right := ARect.Right - 2;
end
else
begin
ATextSyle.Alignment := taLeftJustify;
ARect.Left := ARect.Left + 2;
end;
ADesktop := TCustomDesktopOpt(ACB.Items.Objects[Index]);
if Assigned(ADesktop) and not ADesktop.Compatible then
ACanvas.Font.Color := LblGrayedInfo.Font.Color;
ACanvas.TextStyle := ATextSyle;
ACanvas.TextRect(ARect, ARect.Left, ARect.Top, ACB.Items[Index]);
end;
procedure TDesktopForm.DeleteActionClick(Sender: TObject); procedure TDesktopForm.DeleteActionClick(Sender: TObject);
var var
dskName: String; dskName: String;
@ -727,6 +692,30 @@ begin
RefreshList(xOldName); RefreshList(xOldName);
end; end;
procedure TDesktopForm.RefreshAssociatedDebugList(SelectedDesktop: TCustomDesktopOpt);
var
DskTop: TCustomDesktopOpt;
i: Integer;
begin
AssociatedDebugDesktopComboBox.Items.BeginUpdate;
try
AssociatedDebugDesktopComboBox.Clear;
AssociatedDebugDesktopComboBox.Enabled := SelectedDesktop<>nil;
if not AssociatedDebugDesktopComboBox.Enabled then
Exit;
AssociatedDebugDesktopComboBox.Items.AddObject(dlgPOIconDescNone, nil);
// Saved desktops
for i:=0 to EnvironmentOptions.Desktops.Count-1 do
begin
DskTop := EnvironmentOptions.Desktops[i];
if DskTop.Compatible = SelectedDesktop.Compatible then
AssociatedDebugDesktopComboBox.Items.AddObject(DskTop.Name, DskTop);
end;
finally
AssociatedDebugDesktopComboBox.Items.EndUpdate;
end;
end;
procedure TDesktopForm.DesktopListBoxDrawItem(Control: TWinControl; procedure TDesktopForm.DesktopListBoxDrawItem(Control: TWinControl;
Index: Integer; ARect: TRect; State: TOwnerDrawState); Index: Integer; ARect: TRect; State: TOwnerDrawState);
var var
@ -828,6 +817,7 @@ begin
if HasSel then if HasSel then
begin begin
SelDesktop := DesktopListBox.Items.Objects[DesktopListBox.ItemIndex] as TCustomDesktopOpt; SelDesktop := DesktopListBox.Items.Objects[DesktopListBox.ItemIndex] as TCustomDesktopOpt;
RefreshAssociatedDebugList(SelDesktop);
if (SelDesktop.AssociatedDebugDesktopName<>'') then if (SelDesktop.AssociatedDebugDesktopName<>'') then
begin begin
AssociatedDebugDesktopComboBox.ItemIndex := AssociatedDebugDesktopComboBox.ItemIndex :=
@ -843,8 +833,8 @@ begin
else begin else begin
IsActive := False; IsActive := False;
IsDebug := False; IsDebug := False;
RefreshAssociatedDebugList(nil);
end; end;
AssociatedDebugDesktopComboBox.Enabled:=HasSel;
SetActiveDesktopAction.Enabled := HasSel and not IsActive; SetActiveDesktopAction.Enabled := HasSel and not IsActive;
SetDebugDesktopAction.Enabled := HasSel and not IsDebug; SetDebugDesktopAction.Enabled := HasSel and not IsDebug;
RenameAction.Enabled := HasSel; RenameAction.Enabled := HasSel;