mirror of https://gitlab.com/basile.b/dexed.git
messages, custom drawn, fixes
- horz scroll bar pos was not handled - reset horz scroll bar to 0 when new messages are emitted - constrain color value to make sure selected color <> background color
This commit is contained in:
parent
5e06daf09e
commit
3d74bffa3b
|
|
@ -7,7 +7,7 @@ interface
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls,
|
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls,
|
||||||
lcltype, ce_widget, ActnList, Menus, clipbrd, AnchorDocking, TreeFilterEdit,
|
lcltype, ce_widget, ActnList, Menus, clipbrd, AnchorDocking, TreeFilterEdit,
|
||||||
Buttons, ce_writableComponent, ce_common, ce_project, ce_synmemo, GraphType,
|
Buttons, math,ce_writableComponent, ce_common, ce_project, ce_synmemo, GraphType,
|
||||||
ce_dlangutils, ce_interfaces, ce_observer;
|
ce_dlangutils, ce_interfaces, ce_observer;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -48,6 +48,10 @@ type
|
||||||
procedure AssignTo(Dest: TPersistent); override;
|
procedure AssignTo(Dest: TPersistent); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// grants access to some protected fields that should be actually public (scoll position needed for custom draw !)
|
||||||
|
TTreeHack = class(TTreeView)
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCEMessagesWidget }
|
{ TCEMessagesWidget }
|
||||||
|
|
||||||
TCEMessagesWidget = class(TCEWidget, ICEEditableOptions, ICEMultiDocObserver, ICEProjectObserver, ICEMessagesDisplay)
|
TCEMessagesWidget = class(TCEWidget, ICEEditableOptions, ICEMultiDocObserver, ICEProjectObserver, ICEMessagesDisplay)
|
||||||
|
|
@ -131,6 +135,7 @@ type
|
||||||
procedure message(const aValue: string; aData: Pointer; aCtxt: TCEAppMessageCtxt; aKind: TCEAppMessageKind);
|
procedure message(const aValue: string; aData: Pointer; aCtxt: TCEAppMessageCtxt; aKind: TCEAppMessageKind);
|
||||||
procedure clearbyContext(aCtxt: TCEAppMessageCtxt);
|
procedure clearbyContext(aCtxt: TCEAppMessageCtxt);
|
||||||
procedure clearbyData(aData: Pointer);
|
procedure clearbyData(aData: Pointer);
|
||||||
|
procedure scrollToBack;
|
||||||
protected
|
protected
|
||||||
procedure updateLoop; override;
|
procedure updateLoop; override;
|
||||||
//
|
//
|
||||||
|
|
@ -138,20 +143,18 @@ type
|
||||||
function contextActionCount: integer; override;
|
function contextActionCount: integer; override;
|
||||||
function contextAction(index: integer): TAction; override;
|
function contextAction(index: integer): TAction; override;
|
||||||
//
|
//
|
||||||
property maxMessageCount: Integer read fMaxMessCnt write setMaxMessageCount;
|
property maxMessageCount: Integer read fMaxMessCnt write setMaxMessageCount;
|
||||||
property autoSelectCategory: boolean read fAutoSelect write setAutoSelectCategory;
|
property autoSelectCategory: boolean read fAutoSelect write setAutoSelectCategory;
|
||||||
property singleMessageClick: boolean read fSingleClick write setSingleMessageClick;
|
property singleMessageClick: boolean read fSingleClick write setSingleMessageClick;
|
||||||
//
|
//
|
||||||
property colorBuble: TColor read fMsgColors[amkBub] write setColorBuble;
|
property colorBuble: TColor read fMsgColors[amkBub] write setColorBuble;
|
||||||
property colorInfo: TColor read fMsgColors[amkInf] write setColorInfo;
|
property colorInfo: TColor read fMsgColors[amkInf] write setColorInfo;
|
||||||
property colorHint: TColor read fMsgColors[amkHint] write setColorHint;
|
property colorHint: TColor read fMsgColors[amkHint] write setColorHint;
|
||||||
property colorWarning: TColor read fMsgColors[amkWarn] write setColorWarning;
|
property colorWarning: TColor read fMsgColors[amkWarn] write setColorWarning;
|
||||||
property colorError: TColor read fMsgColors[amkErr] write setColorError;
|
property colorError: TColor read fMsgColors[amkErr] write setColorError;
|
||||||
public
|
public
|
||||||
constructor create(aOwner: TComponent); override;
|
constructor create(aOwner: TComponent); override;
|
||||||
destructor destroy; override;
|
destructor destroy; override;
|
||||||
//
|
|
||||||
procedure scrollToBack;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function guessMessageKind(const aMessg: string): TCEAppMessageKind;
|
function guessMessageKind(const aMessg: string): TCEAppMessageKind;
|
||||||
|
|
@ -163,6 +166,7 @@ implementation
|
||||||
|
|
||||||
const
|
const
|
||||||
optname = 'messages.txt';
|
optname = 'messages.txt';
|
||||||
|
minColor = $232323;
|
||||||
|
|
||||||
{$REGION TCEMessagesOptions ----------------------------------------------------}
|
{$REGION TCEMessagesOptions ----------------------------------------------------}
|
||||||
constructor TCEMessagesOptions.Create(AOwner: TComponent);
|
constructor TCEMessagesOptions.Create(AOwner: TComponent);
|
||||||
|
|
@ -400,25 +404,25 @@ end;
|
||||||
|
|
||||||
procedure TCEMessagesWidget.setColorError(aValue: TColor);
|
procedure TCEMessagesWidget.setColorError(aValue: TColor);
|
||||||
begin
|
begin
|
||||||
fMsgColors[amkErr] := aValue;
|
fMsgColors[amkErr] := max(aValue, minColor);
|
||||||
List.Invalidate;
|
List.Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEMessagesWidget.setColorInfo(aValue: TColor);
|
procedure TCEMessagesWidget.setColorInfo(aValue: TColor);
|
||||||
begin
|
begin
|
||||||
fMsgColors[amkInf] := aValue;
|
fMsgColors[amkInf] := max(aValue, minColor);
|
||||||
List.Invalidate;
|
List.Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEMessagesWidget.setColorHint(aValue: TColor);
|
procedure TCEMessagesWidget.setColorHint(aValue: TColor);
|
||||||
begin
|
begin
|
||||||
fMsgColors[amkHint] := aValue;
|
fMsgColors[amkHint] := max(aValue, minColor);
|
||||||
List.Invalidate;
|
List.Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEMessagesWidget.setColorBuble(aValue: TColor);
|
procedure TCEMessagesWidget.setColorBuble(aValue: TColor);
|
||||||
begin
|
begin
|
||||||
fMsgColors[amkBub] := aValue;
|
fMsgColors[amkBub] := max(aValue, minColor);
|
||||||
List.Invalidate;
|
List.Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
@ -431,25 +435,24 @@ end;
|
||||||
procedure TCEMessagesWidget.ListCustomDrawItem(Sender: TCustomTreeView;
|
procedure TCEMessagesWidget.ListCustomDrawItem(Sender: TCustomTreeView;
|
||||||
Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
|
Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
|
||||||
var
|
var
|
||||||
|
x: integer;
|
||||||
rc: TRect;
|
rc: TRect;
|
||||||
customdraw: Boolean;
|
|
||||||
begin
|
begin
|
||||||
customdraw := fMsgColors[TCEAppMessageKind(node.ImageIndex + 1)] <> clDefault;
|
rc := node.DisplayRect(false);
|
||||||
if customdraw then
|
x := rc.Left + 2 - TTreeHack(list).ScrolledLeft;
|
||||||
|
// warning: the cast may become wrong if the enum is modified.
|
||||||
|
Sender.Canvas.Brush.Color := fMsgColors[TCEAppMessageKind(node.ImageIndex + 1)];
|
||||||
|
if node.Selected then
|
||||||
begin
|
begin
|
||||||
rc := node.DisplayRect(false);
|
Sender.Canvas.DrawFocusRect(rc);
|
||||||
Sender.Canvas.Brush.Color := fMsgColors[TCEAppMessageKind(node.ImageIndex + 1)];
|
Sender.Canvas.Brush.Color := Sender.Canvas.Brush.Color - minColor;
|
||||||
if node.Selected then
|
|
||||||
begin
|
|
||||||
Sender.Canvas.DrawFocusRect(rc);
|
|
||||||
Sender.Canvas.Brush.Color := Sender.Canvas.Brush.Color - $232323;
|
|
||||||
end;
|
|
||||||
Sender.Canvas.FillRect(rc);
|
|
||||||
Sender.Canvas.TextOut(rc.Left + 30, rc.Top, node.Text);
|
|
||||||
list.Images.Draw(sender.Canvas, rc.Left + 1, (rc.Top + rc.Bottom - list.Images.Height) div 2,
|
|
||||||
node.ImageIndex, Node.NodeEffect);
|
|
||||||
end;
|
end;
|
||||||
DefaultDraw := not customdraw;
|
Sender.Canvas.FillRect(rc);
|
||||||
|
list.Images.Draw(sender.Canvas, x, (rc.Top + rc.Bottom - list.Images.Height) div 2,
|
||||||
|
node.ImageIndex, Node.NodeEffect);
|
||||||
|
x += list.Images.Width + 5;
|
||||||
|
Sender.Canvas.TextOut(x, rc.Top, node.Text);
|
||||||
|
DefaultDraw := false;
|
||||||
end;
|
end;
|
||||||
{$ENDREGION}
|
{$ENDREGION}
|
||||||
|
|
||||||
|
|
@ -669,9 +672,9 @@ begin
|
||||||
item.SelectedIndex := item.ImageIndex;
|
item.SelectedIndex := item.ImageIndex;
|
||||||
if not fastDisplay then
|
if not fastDisplay then
|
||||||
begin
|
begin
|
||||||
//TODO-cfeature: reset horz scroll bar to the left
|
|
||||||
clearOutOfRangeMessg;
|
clearOutOfRangeMessg;
|
||||||
scrollToBack;
|
scrollToBack;
|
||||||
|
TTreeHack(list).scrolledLeft := 0;
|
||||||
Application.ProcessMessages;
|
Application.ProcessMessages;
|
||||||
filterMessages(fCtxt);
|
filterMessages(fCtxt);
|
||||||
end;
|
end;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue