From: Erik B. <eb...@us...> - 2007-03-22 20:40:08
|
Update of /cvsroot/gexperts/gexperts/unstable/Src/Utils In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv6941/Utils Modified Files: GX_GenericUtils.pas GX_IdeUtils.pas Log Message: function RunningDelphi2005: Boolean; function NotEmpty(const Str: string): Boolean; function IsEmpty(const Str: string): Boolean; procedure IterateOverControls(Control: TControl; ActionProc: TForEachControlProc); procedure MakeMultiline(Control: TButtonControl); function FindTreeNode(Tree: TTreeView; const NodeText: string): TTreeNode; Index: GX_IdeUtils.pas =================================================================== RCS file: /cvsroot/gexperts/gexperts/unstable/Src/Utils/GX_IdeUtils.pas,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- GX_IdeUtils.pas 21 Jan 2006 20:13:10 -0000 1.34 +++ GX_IdeUtils.pas 22 Mar 2007 20:36:51 -0000 1.35 @@ -67,6 +67,7 @@ function RunningDelphi8OrGreater: Boolean; function RunningDelphi7OrLess: Boolean; function RunningDelphi7OrGreater: Boolean; +function RunningDelphi2005: Boolean; function RunningBDS2006OrGreater: Boolean; function RunningBDS2006: Boolean; function RunningCPPBuilder: Boolean; @@ -406,6 +407,15 @@ {$ENDIF} end; +function RunningDelphi2005: Boolean; +begin + {$IFDEF VER170} + Result := True; + {$ELSE} + Result := False; + {$ENDIF} +end; + function RunningBDS2006OrGreater: Boolean; begin {$IFDEF GX_VER180_up} Index: GX_GenericUtils.pas =================================================================== RCS file: /cvsroot/gexperts/gexperts/unstable/Src/Utils/GX_GenericUtils.pas,v retrieving revision 1.153 retrieving revision 1.154 diff -u -d -r1.153 -r1.154 --- GX_GenericUtils.pas 17 Mar 2007 07:26:30 -0000 1.153 +++ GX_GenericUtils.pas 22 Mar 2007 20:36:51 -0000 1.154 @@ -68,6 +68,8 @@ TListBoxCheckAction = (chAll, chNone, chInvert); + TForEachControlProc = procedure(Control: TControl) of object; + // System // // @@ -123,7 +125,9 @@ function StrEndsWith(const SubStr, Str: string; CaseSensitive: Boolean = True): Boolean; // See is a string contains another substring function StrContains(const SubStr, Str: string; CaseSensitive: Boolean = True): Boolean; - +// Check for empty (when trimmed) strings +function NotEmpty(const Str: string): Boolean; +function IsEmpty(const Str: string): Boolean; // Delete up to n of the rightmost characters in the string function DeleteRight(const Value: string; NumChars: Integer): string; @@ -230,6 +234,7 @@ // iterates over the Parent property of WindowContainer, // not over the Owner property. function FindChild(const WindowContainer: TWinControl; const ControlName: string): TControl; +procedure IterateOverControls(Control: TControl; ActionProc: TForEachControlProc); // See is this component owns an object of the specified class name function ComponentOwnsClass(Component: TComponent; const ClassName: string): Boolean; @@ -240,6 +245,9 @@ // Get the width of a default scrollbar function GetScrollbarWidth: Integer; +// Make a Button/CheckBox multiline (WordWrap). D6 does not have this property. +procedure MakeMultiline(Control: TButtonControl); + // Check, uncheck, or invert the checks in a TCheckListBox procedure SetListBoxChecked(CheckList: TCheckListBox; Action: TListboxCheckAction); @@ -247,6 +255,8 @@ procedure ListViewDeleteSelected(ListView: TListView); procedure ListViewSelectAll(ListView: TListView); +function FindTreeNode(Tree: TTreeView; const NodeText: string): TTreeNode; + procedure SetToolbarGradient(ToolBar: TToolBar; Enabled: Boolean = True); // Enable/disable a control and all children @@ -1353,6 +1363,16 @@ Result := CaseInsensitivePos(SubStr, Str) > 0; end; +function NotEmpty(const Str: string): Boolean; +begin + Result := Trim(Str) <> ''; +end; + +function IsEmpty(const Str: string): Boolean; +begin + Result := Trim(Str) = ''; +end; + function AddSlash(const Directory: string): string; begin Result := IncludeTrailingPathDelimiter(Directory); @@ -1647,6 +1667,22 @@ end; end; +procedure IterateOverControls(Control: TControl; ActionProc: TForEachControlProc); +var + WinControl: TWinControl; + i: Integer; +begin + Assert(Assigned(ActionProc)); + Assert(Assigned(Control)); + ActionProc(Control); + if (Control is TWinControl) then + begin + WinControl := Control as TWinControl; + for i := 0 to WinControl.ControlCount - 1 do + IterateOverControls(WinControl.Controls[i], ActionProc); + end; +end; + function ComponentOwnsClass(Component: TComponent; const ClassName: string): Boolean; var i: Integer; @@ -1688,6 +1724,11 @@ Result := GetSystemMetrics(SM_CXVSCROLL); end; +procedure MakeMultiline(Control: TButtonControl); +begin + SetWindowLong(Control.Handle, GWL_STYLE, GetWindowLong(Control.Handle, GWL_STYLE) or BS_MULTILINE); +end; + procedure SetListBoxChecked(CheckList: TCheckListBox; Action: TListBoxCheckAction); var i: Integer; @@ -1741,6 +1782,24 @@ ListView.Items[i].Selected := True; end; +function FindTreeNode(Tree: TTreeView; const NodeText: string): TTreeNode; +var + Node: TTreeNode; +begin + Assert(Assigned(Tree)); + Result := nil; + Node := Tree.Items.GetFirstNode; + while Assigned(Node) do + begin + if SameText(Node.Text, NodeText) then begin + Result := Node; + Exit; + end + else + Node := Node.GetNext; + end; +end; + procedure SetToolBarGradient(ToolBar: TToolBar; Enabled: Boolean); begin {$IFDEF GX_VER180_up} |