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
  
     | 
    
      {
 *****************************************************************************
  See the file COPYING.modifiedLGPL.txt, included in this distribution,
  for details about the license.
 *****************************************************************************
 Authors: Michael W. Vogel
}
unit DockedTools;
{$mode objfpc}{$H+}
{ $define DEBUGDOCKEDFORMEDITORINIDE}
interface
uses
  // RTL, FCL
  Classes, SysUtils,
  // LCL
  LCLProc, Forms, Controls,
  //LazUtils
  LazLoggerBase,
  // IDEIntf
  IDEMsgIntf, SrcEditorIntf, IDEExternToolIntf,
  // DockedFormEditor
  DockedDesignForm;
{$IFDEF DEBUGDOCKEDFORMEDITORINIDE}
procedure DebugLn(s: String); overload;
procedure DebugLn(s1, s2: String); overload;
procedure DebugLn(s1, s2, s3: String); overload;
{$ENDIF}
function  EnumerationString(Str1, Str2: String): String;
function  FindSourceEditorForDesigner(ADesigner: TIDesigner): TSourceEditorInterface;
procedure IDEMessage(AString: String);
function  LinedString(Str1, Str2: String): String;
function  SourceWindowCaption(ASourceEditor: TSourceEditorInterface): String;
function  SourceWindowGet(ASourceEditor: TSourceEditorInterface): TSourceEditorWindowInterface;
implementation
{$IFDEF DEBUGDOCKEDFORMEDITORINIDE}
procedure DebugLn(s: String);
begin
  IDEMessage(s);
end;
procedure DebugLn(s1, s2: String);
begin
  IDEMessage(s1 + s2);
end;
procedure DebugLn(s1, s2, s3: String);
begin
  IDEMessage(s1 + s2 + s3);
end;
{$ENDIF}
function EnumerationString(Str1, Str2: String): String;
begin
  if Str1.IsEmpty then
    Result := Str2
  else
    Result := Str1 + ', ' + Str2;
end;
function FindSourceEditorForDesigner(ADesigner: TIDesigner): TSourceEditorInterface;
var
  i: Integer;
begin
  for i := 0 to SourceEditorManagerIntf.SourceEditorCount - 1 do
    if SourceEditorManagerIntf.SourceEditors[i].GetDesigner(False) = ADesigner then
      Exit(SourceEditorManagerIntf.SourceEditors[i]);
  Result := nil;
end;
procedure IDEMessage(AString: String);
begin
  LazLoggerBase.DebugLn(AString);
  if Assigned(IDEMessagesWindow) then
    IDEMessagesWindow.AddCustomMessage(mluNone, AString, '');
end;
function LinedString(Str1, Str2: String): String;
begin
  if Str1.IsEmpty then
    Result := Str2
  else
    Result := Str1 + LineEnding + Str2;
end;
function SourceWindowCaption(ASourceEditor: TSourceEditorInterface): String;
var
  LSourceWindowIntf: TSourceEditorWindowInterface;
begin
  LSourceWindowIntf := SourceWindowGet(ASourceEditor);
  if Assigned(LSourceWindowIntf) then
    Result := LSourceWindowIntf.Caption
  else
    Result := 'nil';
end;
function SourceWindowGet(ASourceEditor: TSourceEditorInterface): TSourceEditorWindowInterface;
var
  LWinControl: TWinControl;
begin
  Result := nil;
  if not Assigned(ASourceEditor) then Exit;
  LWinControl := ASourceEditor.EditorControl;
  while Assigned(LWinControl) do
  begin
    if LWinControl is TSourceEditorWindowInterface then
      Exit(TSourceEditorWindowInterface(LWinControl));
    LWinControl := LWinControl.Parent;
  end;
end;
end.
 
     |