1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
|
{
***************************************************************************
* *
* This source 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 code 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. *
* *
* A copy of the GNU General Public License is available on the World *
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
* obtain it by writing to the Free Software Foundation, *
* Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. *
* *
***************************************************************************
Author: Mattias Gaertner
Abstract:
IDE option frame for Messages window.
}
unit MsgWnd_Options;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,
// LazUtils
LazLoggerBase,
// LCL
Forms, Controls, Graphics, Dialogs, StdCtrls, ColorBox, ExtCtrls, Spin, Buttons,
// IdeIntf
IDEOptionsIntf, IDEOptEditorIntf, IDEExternToolIntf, IDEImagesIntf,
// IDE
LazarusIDEStrConsts, EnvironmentOpts, editor_general_options;
type
{ TMsgWndOptionsFrame }
TMsgWndOptionsFrame = class(TAbstractIDEOptionsEditor)
MsgColorBox: TColorBox;
MsgColorListBox: TColorListBox;
MsgColorGroupBox: TGroupBox;
MWAlwaysDrawFocusedCheckBox: TCheckBox;
MWFocusCheckBox: TCheckBox;
MWSetPastelColorsButton: TButton;
MWShowFPCMsgLinesCompiledCheckBox: TCheckBox;
MWShowIconsCheckBox: TCheckBox;
MWMaxProcsLabel: TLabel;
MWMaxProcsSpinEdit: TSpinEdit;
MWOptsLeftBevel: TBevel;
MWColorBox: TColorBox;
MWColorListBox: TColorListBox;
MWColorsGroupBox: TGroupBox;
MWOptionsLabel: TLabel;
MWOptsRightBevel: TBevel;
MWSetDefaultColorsButton: TBitBtn;
MWSetEditorColorsButton: TButton;
MWSpeedSetColorsGroupBox: TGroupBox;
procedure MsgColorBoxChange(Sender: TObject);
procedure MsgColorListBoxGetColors(Sender: TCustomColorListBox; Items: TStrings);
procedure MsgColorListBoxSelectionChange(Sender: TObject; User: boolean);
procedure MWColorBoxChange(Sender: TObject);
procedure MWColorListBoxGetColors(Sender: TCustomColorListBox;
Items: TStrings);
procedure MWColorListBoxSelectionChange(Sender: TObject; User: boolean);
procedure MWSetDefaultColorsButtonClick(Sender: TObject);
procedure MWSetEditorColorsButtonClick(Sender: TObject);
procedure MWSetPastelColorsButtonClick(Sender: TObject);
private
fReady: boolean;
FDialog: TAbstractOptionsEditorDialog;
function GeneralPage: TEditorGeneralOptionsFrame;
public
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;
var
MsgWndOptionsFrame: TMsgWndOptionsFrame;
implementation
{$R *.lfm}
{ TMsgWndOptionsFrame }
procedure TMsgWndOptionsFrame.MWColorListBoxGetColors(
Sender: TCustomColorListBox; Items: TStrings);
begin
Items.Add(dlgBackColor);
Items.Add(lisToolHeaderRunning);
Items.Add(lisToolHeaderSuccess);
Items.Add(lisToolHeaderFailed);
Items.Add(lisToolHeaderScrolledUp);
Items.Add(dlfMouseSimpleTextSect);
end;
procedure TMsgWndOptionsFrame.MWColorBoxChange(Sender: TObject);
var
i: Integer;
begin
i:=MWColorListBox.ItemIndex;
if not fReady or (i < 0) then
exit;
MWColorListBox.Colors[i]:=MWColorBox.Selected;
end;
procedure TMsgWndOptionsFrame.MsgColorBoxChange(Sender: TObject);
var
i: Integer;
begin
i:=MsgColorListBox.ItemIndex;
if not fReady or (i < 0) then
exit;
MsgColorListBox.Colors[i]:=MsgColorBox.Selected;
end;
procedure TMsgWndOptionsFrame.MsgColorListBoxGetColors(Sender: TCustomColorListBox;
Items: TStrings);
begin
(*
mluNone,
mluProgress, // time and statistics about the run
mluDebug, // extreme verbosity, only useful for tool authors
mluVerbose3, // all infos
mluVerbose2, // almost all infos
mluVerbose, // extra infos
mluHint, // tool found something unusual
mluNote, // maybe wrong or unnecessary
mluWarning, // probably something is wrong
mluImportant, // message has no urgency level, but should be shown
mluError, // tool could not finish, some tools can still continue
mluFatal, // critical error in input, tool had to abort
mluPanic // bug in tool
*)
Items.Add(dlgMsgWinColorUrgentNone);
Items.Add(dlgMsgWinColorUrgentProgress);
Items.Add(dlgMsgWinColorUrgentDebug);
Items.Add(dlgMsgWinColorUrgentVerbose3);
Items.Add(dlgMsgWinColorUrgentVerbose2);
Items.Add(dlgMsgWinColorUrgentVerbose);
Items.Add(dlgMsgWinColorUrgentHint);
Items.Add(dlgMsgWinColorUrgentNote);
Items.Add(dlgMsgWinColorUrgentWarning);
Items.Add(dlgMsgWinColorUrgentImportant);
Items.Add(dlgMsgWinColorUrgentError);
Items.Add(dlgMsgWinColorUrgentFatal);
Items.Add(dlgMsgWinColorUrgentPanic);
end;
procedure TMsgWndOptionsFrame.MsgColorListBoxSelectionChange(Sender: TObject; User: boolean);
begin
if not (fReady and User) then
Exit;
MsgColorBox.Selected := MsgColorListBox.Selected;
end;
procedure TMsgWndOptionsFrame.MWColorListBoxSelectionChange(Sender: TObject;
User: boolean);
begin
if not (fReady and User) then
Exit;
MWColorBox.Selected := MWColorListBox.Selected;
end;
procedure TMsgWndOptionsFrame.MWSetDefaultColorsButtonClick(Sender: TObject);
var
c: TMsgWndColor;
begin
for c in TMsgWndColor do
MWColorListBox.Colors[ord(c)]:=MsgWndDefaultColors[c];
MWColorBox.Selected := MWColorListBox.Selected;
end;
procedure TMsgWndOptionsFrame.MWSetEditorColorsButtonClick(Sender: TObject);
var
Page: TEditorGeneralOptionsFrame;
begin
Page:=GeneralPage;
if Page=nil then exit;
{MWColorListBox.Colors[mwBackground]:=aSynEdit.Color;
MWColorListBox.Colors[mwRunning]:=aSynEdit.
MWColorListBox.Colors[mwSuccess]:=aSynEdit.
MWColorListBox.Colors[mwFailed]:=aSynEdit.
MWColorListBox.Colors[mwAutoHeader]:=aSynEdit.}
MWColorBox.Selected := MWColorListBox.Selected;
end;
procedure TMsgWndOptionsFrame.MWSetPastelColorsButtonClick(Sender: TObject);
begin
MWColorListBox.Colors[ord(mwBackground)]:=clWindow;
MWColorListBox.Colors[ord(mwRunning)] :=TColor($00CBF3FF); // harmonic pastel yellow
MWColorListBox.Colors[ord(mwSuccess)] :=TColor($00BEEFC3); // harmonic pastel green
MWColorListBox.Colors[ord(mwFailed)] :=TColor($00CCCBFF); // harmonic pastel rose
MWColorListBox.Colors[ord(mwAutoHeader)]:=TColor($00EEC3BD); // harmonic pastel blue
MWColorBox.Selected := MWColorListBox.Selected;
end;
function TMsgWndOptionsFrame.GeneralPage: TEditorGeneralOptionsFrame;
begin
Result:=nil;
if FDialog<>nil then
Result := TEditorGeneralOptionsFrame(FDialog.FindEditor(TEditorGeneralOptionsFrame));
end;
constructor TMsgWndOptionsFrame.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
MWOptionsLabel.Caption:=lisOptions;
MWColorsGroupBox.Caption:= lisHeaderColors;
MsgColorGroupBox.Caption:= lisMsgColors;
MWSpeedSetColorsGroupBox.Caption:=lisSetAllColors;
MWSetDefaultColorsButton.Caption:=lisLazarusDefault;
IDEImages.AssignImage(MWSetDefaultColorsButton, 'restore_defaults');
MWSetPastelColorsButton.Caption:=lisPastelColors;
MWSetEditorColorsButton.Caption:=lisEditorColors;
MWShowIconsCheckBox.Caption:=dlgShowMessagesIcons;
MWShowIconsCheckBox.Hint:=dlgAnIconForErrorWarningHintIsShown;
MWAlwaysDrawFocusedCheckBox.Caption:=lisAlwaysDrawSelectedItemsFocused;
MWAlwaysDrawFocusedCheckBox.Hint:=lisDrawTheSelectionFocusedEvenIfTheMessagesWindowHasN;
MWFocusCheckBox.Caption:=dlgEOFocusMessagesAtCompilation;
MWMaxProcsLabel.Caption:=Format(lisMaximumParallelProcesses0MeansDefault,
[IntToStr(DefaultMaxProcessCount)]);
MWShowFPCMsgLinesCompiledCheckBox.Caption:=lisShowFPCMessageLinesCompiled;
MWShowFPCMsgLinesCompiledCheckBox.Hint:=
lisElevateTheMessagePriorityToAlwaysShowItByDefaultIt;
end;
function TMsgWndOptionsFrame.GetTitle: String;
begin
Result:=lisMessagesWindow;
end;
procedure TMsgWndOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
begin
fReady:=false;
FDialog := ADialog;
MWSetEditorColorsButton.Visible:=false;
end;
procedure TMsgWndOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
var
o: TEnvironmentOptions;
c: TMsgWndColor;
u: TMessageLineUrgency;
begin
o:=(AOptions as TEnvironmentOptions);
for c in TMsgWndColor do
MWColorListBox.Colors[ord(c)] := o.MsgViewColors[c];
for u in TMessageLineUrgency do
MsgColorListBox.Colors[ord(u)] := o.MsgColors[u];
MWShowIconsCheckBox.Checked := o.ShowMessagesIcons;
MWAlwaysDrawFocusedCheckBox.Checked := o.MsgViewAlwaysDrawFocused;
MWFocusCheckBox.Checked := o.MsgViewFocus;
MWMaxProcsSpinEdit.Value := o.MaxExtToolsInParallel;
MWShowFPCMsgLinesCompiledCheckBox.Checked := o.MsgViewShowFPCMsgLinesCompiled;
fReady:=true;
end;
procedure TMsgWndOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
var
o: TEnvironmentOptions;
c: TMsgWndColor;
u: TMessageLineUrgency;
begin
o:=(AOptions as TEnvironmentOptions);
for c in TMsgWndColor do
o.MsgViewColors[c] := MWColorListBox.Colors[ord(c)];
for u in TMessageLineUrgency do
o.MsgColors[u] := MsgColorListBox.Colors[ord(u)];
o.ShowMessagesIcons := MWShowIconsCheckBox.Checked;
o.MsgViewAlwaysDrawFocused := MWAlwaysDrawFocusedCheckBox.Checked;
o.MsgViewFocus := MWFocusCheckBox.Checked;
o.MaxExtToolsInParallel := MWMaxProcsSpinEdit.Value;
o.MsgViewShowFPCMsgLinesCompiled := MWShowFPCMsgLinesCompiledCheckBox.Checked;
end;
class function TMsgWndOptionsFrame.
SupportedOptionsClass: TAbstractIDEOptionsClass;
begin
Result := TEnvironmentOptions;
end;
initialization
RegisterIDEOptionsEditor(GroupEnvironment, TMsgWndOptionsFrame, EnvOptionsMessages);
end.
|