-
- Following conditional symbols can be used in a project (Project-Options-Directories/Conditional Defines)
+ Following conditional symbols can be used in a (Project-Options-Directories/Conditional Defines)
to change code generated a bit. There are following:
-
+
EXTERNAL_KOLDEFS - since there are a lot of such symbols, it may be not
possible to include all the desired optional symbols
in the Project Options (Delphi has a restriction to 256
@@ -133,55 +57,8 @@ unit KOL;
only). This option should be included only in MCK package
options and never in options of the KOL/MCK application.
PAS_VERSION - to use Pascal version of the code.
- USE_CMOV - force using CMOV machine instruction in asm code (not recommended,
- still on some machines your application will not work).
- SMALLEST_CODE - to create minimal code application (affected:
- (o) SimpleGetCtlBrushHandle - returns solid silver brush
- always;
- (o) _NewWindowed
- - only default system font used by default;
- font of the parent control is not applied to its
- children automatically (but see SMALLEST_CODE_PARENTFONT);
- - fBrush always set to NIL by default (parent Brush
- is not applied);
- (o) WndProcDoEraseBkgnd
- - child controls windows are not created in WM_ERASEBKGND
- if were not created earlier (in most case, all OK
- with this - controls are created BTW);
- - SetBkColor, SetBkMode, SetBrushOrgEx are not
- called (all OK therefore)
- (o) by default, NOT_UNLOAD_RICHEDITLIB is defined if
- UNLOAD_RICHEDITLIB is not defined in project options
- (this minimizes finalization section).
- (o) _NewControl
- - BoundsRect initialized with a rectangle
- (aParent.fMarginLeft, aParent.fMarginTop,
- aParent.fMarginLeft+64, aParent.fMargin+64)
- rather then with (aParent.fMargin+aParent.fMarginLeft,
- aParent.fMargin+aParent.fMarginTop,
- aParent.fMargin+aParent.fMarginLeft+64,
- aParent.fMargin+aParent.fMarginTop+64).
- In most cases this is enough.
- (o) Int2Hex
- there are no check for second parameter > 15
- (o) .... other see in code
- SMALLER_CODE - like smallest code, but functionality is the same. The speed can be lower therefore.
- SMALLEST_CODE_PARENTFONT - Parent font therefore is applied for child controls, but initially only.
- SPEED_FASTER - by default (but off when SMALLEST_CODE on) - sorting of
- TStrList.AnsiSort and comparing using AnsiCompareStrA,
- AnsiCompareStrNoCaseA is much faster (about 5-6 times).
- Also, sorting of lists and strlists is redirected to
- SortArray which is faster about 5-15% (vs SortData).
- To turn off, add a symbol SPEED_NORMAL.
REGKEYGETSTREX_ALWAYS - If you use already RegKeyGetStrEx, add this option to
redirect RegKeyGetStr to it.
- NOT_USE_EXCEPTIONS - to prevent referencing unit ERR.PAS in uses even when KOLmath is listed there.
- REDEFINE_ABS - usual Abs works as a macro which is better in most cases. But who knows...
- CUSTOM_APPICON - when this option is defined, the resource name for the
- application icon is extracted from a file
- CusomAppIconRsrcName_PAS.inc (place it in your project
- folder and type there name of the resource in quotes).
- By default, string 'MAIN' is used like in usual Delphi application.
USE_NAMES - to use property Name with any TObj. This makes also
available method TObj.FindObj( name ): PObj.
UNIQUE_NAMES - provide Name property to be unique among all siblings.
@@ -195,30 +72,21 @@ unit KOL;
DFLT_TLIST_NOUSE_BLOCKS - for TLIST_FAST: by default, do not make all TList
objects using new (fast) algorithms, but only those of
TList objects, which property UseBlocks was set to TRUE after creating it.
- OLD_REGKEYGETSUBKEYS - to use elder version of RegKeyGetSubKeys functions
- (new version is faster).
- OLD_REGKEYGETVALUENAMES - to use elder version of RegKeyGetValueNames
- (newer version is faster).
USE_CUSTOMEXTENSIONS - to extend TControl with custom additions.
DATE0_0001 - to correct correctly TDateTime to TSystemTime and vice
versa even for dates earlier then 1-Jan-1601.
UNICODE_CTRLS - to use Unicode versions of controls (WM_XXXXW messages,
etc.)
- SAFE_CODE - use more safe code in some algorithms (but more slowly
- and taking more code a bit).
USE_OnIdle - to use OnIdle event
- SNAPMOUSE2DFLTBTN - for all MessageBox-based functions, snap mouse to
- default button is provided if such option is on in
- mouse driver settings.
- BUTTON_DBLCLICK - to prevent clicking buttons with double click (separate
- event OnMouseDblClk is fired in such case), this takes
- smaller code but buttons can not be pressed with mouse
- fast. When SMALLEST_CODE on, this option also is on.
- ALL_BUTTONS_RESPOND_TO_ENTER - obvious (by default, buttons respond to key
- SPACE, since those are working this way in Windows).
- CLICK_DEFAULT_CANCEL_BTN_DIRECTLY - to prevent visual effect of default/cancel
- button pressing with Enter/Escape keys. Also, button
- don't become focused in such case.
+ SNAPMOUSE2DFLTBTN - for all MessageBox-based functions, snap mouse to default button is
+ provided if such option is on in mouse driver settings.
+ BUTTON_DBLCLICK - to prevent clicking buttons with double click (separate event
+ OnMouseDblClk is fired in such case), this takes smaller code but buttons
+ can not be pressed with mouse fast.
+ ALL_BUTTONS_RESPOND_TO_ENTER - obvious (by default, buttons respond to key SPACE, since those are
+ working this way in Windows).
+ CLICK_DEFAULT_CANCEL_BTN_DIRECTLY - to prevent visual effect of default/cancel button pressing
+ with Enter/Escape keys. Also, button don't become focused in such case.
DEFAULT_CANCEL_BTN_EXCLUSIVE - to disable assigning to a button properties
DefaultBtn and CancelBtn simultaneously.
NO_DEFAULT_BUTTON_BOLD - to prevent DefaultBtn to be visually with a bold border.
@@ -231,11 +99,6 @@ unit KOL;
KEY_PREVIEW - form also receive WM_KEYDOWN (OnKeyDown event fired)
SUPPORT_ONDEADCHAR - to support OnKeyDeadChar event in response to WM_DEADCHAR, WM_SYSDEADCHAR
AUTO_CONTEXT_HELP - to use automatic respond to WM_CONTEXTMENU to call context help.
- NOT_FIX_MODAL - not to fix modal (if fixed, click on any window
- activates the application. If not fixed, code is
- smaller very a little, but only click on modal form
- activates the application). This does not fix calling
- MsgBox though.
MODAL_ACTIVATE_FIX - if this option is set, all the windows of clicked app
with active modal form are brought to foreground, not
only modal form itself. This option is not necessary if
@@ -245,13 +108,10 @@ unit KOL;
USE_SETMODALRESULT - to guarantee ModalResult property assigning handling.
USE_SHOWMODALPARENTED_ALWAYS - to use TControl.ShowModalParented( Applet )
instead of TControl.ShowModal always.
- USE_MENU_CURCTL - to use CurCtl property in popup menu to detect which
- control initiated a pop-up.
+ USE_MENU_CURCTL - to use CurCtl property in popup menu to detect which control initiated a pop-up.
NEW_MENU_ACCELL - to use new menu accelerators handling, without
AcceleratorTable (not tested for all cases)
USE_DROPDOWNCOUNT - to force setting combobox dropdown count.
- NOT_UNLOAD_RICHEDITLIB - to stop unload Rich Edit library in finalization
- section (to economy several byte of code).
NOT_USE_RICHEDIT - not use richedit (it will not be possible to create richedit)
TV_DRAG_RBUTTON - to allow dragging tree view items with right mouse button too.
TOOLBAR_FORCE_CHILDALIGN - this option provides Align working for child
@@ -270,11 +130,6 @@ unit KOL;
CANRESIZE_THICKFRAME - to use elder version of CanResize, changing border
style of the window (this cause incorrect form view in
Vista Aero theme (due a bug in Vista?)).
- ANCHORS_WM_SIZE - to check WM_SIZE message in Anchor handling window
- procedure. By default, now used WM_WINDOWPOSCHANGED.
- USE_PROP - to use GetProp / SetProp (old style) in place of
- Get / SetWindowLong( wnd, GWL_USERDATA... ) (slower?)
- PROVIDE_EXITCODE - PostQuitMessage( value ) assigns value to ExitCode
INITIALFORMSIZE_FIXMENU - form size initially is really the same as defined at
design time even for forms having main menu bar
USE_GRAPHCTLS - to use graphic (non-windowed) controls
@@ -315,25 +170,11 @@ unit KOL;
paths (принудительное использование альтернативного имени
пути и имени файла для юникод путей)
NEW_GRADIENT - to use new gradient painting by homm (fast).
- OLD_ALIGN - to prevent using new Align by Galkov.
- NEW_ALIGN - (default) - to use new Align implementation (faster).
- OLD_TRANSPARENT - to prevent using NEW_TRANSPARENT
- NEW_TRANSPARENT - created by Alexander Karpinsky a.k.a. homm (faster)
- OLD_REFCOUNT - to prevent using new RefInc/RefDec behavior (new style works better).
- OLD_FREE - to declare Free as a method as in earlier versions of KOL.
- In new versions, Free is declared as a property, and
- "calling" it just redirects call to RefDec. OLD_FREE
- can be used for compatibility with compilers not
- understanding "calling" a property without assigning
- something to or from it (Turbo Delphi?).
FILE_EXISTS_EX - to use more correct (but a bit large code in FileExists function)
- USE_AUTOFREE4CONTROLS - (default) - from 2.40, most of control sub-objects are
- destroying using Add2AutoFree (smaller code).
ENDSESSION_HALT - to halt the process when WM_ENDSESSION comes.
FILESTREAM_POSITION - in PAS_VERSION, Stream..fData.fPosition always show
current position (for debug purposes)
PSEUDO_THREADS - to use pseudo-threads instead of normal threads.
- WAIT_SLEEP - for PSEUDO_THREADS: sleep 10 ms in a WaitForMultipleObjects loop.
ENUM_DYN_HANDLERS_AFTER_RUN - to allow all the events handling even when AppletTerminated become TRUE.
STOP_WNDPROCTRANSPARENT_AFTER_APPLETTERMINATED - use this long-named option to
prevent any functionality of WndProcTransparent after
@@ -345,7 +186,6 @@ unit KOL;
to handle such events).
DEBUG_MENU - to debug menu.
DEBUG_GDIOBJECTS - to allow counting all the GDI objects used.
- CHK_BITBLT - to check BitBlt operations.
DEBUG_ENDSESSION - to allow debugging WM_ENDSESSION handling.
DEBUG_CREATEWINDOW - to debug CreateWindow.
CRASH_DEBUG - to fill object memory with $DD before freeing it
@@ -372,9 +212,8 @@ unit KOL;
more then 50 flags occupying earlies 1 byte for each
flag). This option is turned on by default. To turn off,
define a symbol USE_OLD_FLAGS !
- EVENTS_DYNAMIC - to create events record (about 600 bytes) only for
- controls having assigned events. To turn off, define a
- symbol EVENTS_STATIC.
+ EVENTS_DYNAMIC - to create events record (about 600 bytes) only for controls having
+ assigned events. To turn off, define a symbol EVENTS_STATIC.
NIL_EVENTS - by default, is off. This option returns back again checking
TControl's events if it is assigned before calling. By
default, now this option is off, all events are assigned
@@ -382,15 +221,9 @@ unit KOL;
is assigned is not necessary. But it is not allowed to
assign NIL to the event, instead call ResetEvent method
with the correspondent index (e.g. idx_fOnMessage).
- COMMANDACTIONS_OBJ - to store command actions certain for different control
- kinds in shared objects, separately from TControl object
- instances. To turn off, define a symbol COMMANDACTIONS_RECORD.
- PACK_COMMANDACTIONS - this option must be defined together with COMMANDACTIONS_OBJ
- and must not with COMMANDACTIONS_RECORD (just do nothing
- and this is applied automatically).
+ PACK_COMMANDACTIONS - use packed version of COMMANDACTIONSOBJ
|
}
-// = K.O.L - ключевая библиотека объектов. (C) Кладов Владимир, 2000-2007.
{$IFNDEF WIN64}
{$A-} // align off, otherwise code is not good
{$Q-} // no overflow check: this option makes code wrong
@@ -398,7 +231,6 @@ unit KOL;
{$Z-}
{$ENDIF}
{$T-} // not typed @-operator
-//{$D+}
{$IFDEF PUREPASCAL}
{$DEFINE PAS_VERSION}
@@ -422,54 +254,9 @@ unit KOL;
{$ENDIF}
interface
-{$IFnDEF CREATE_VISIBLE}
- {$DEFINE CREATE_HIDDEN}
-{$ENDIF}
-{$IFDEF NEW_ALIGN}
- {$UNDEF OLD_ALIGN}
-{$ELSE}
- {$IFNDEF OLD_ALIGN}
- {$DEFINE NEW_ALIGN}
- {$ENDIF}
-{$ENDIF}
-{$IFDEF OLD_ALIGN}
- {$UNDEF NEW_ALIGN}
-{$ELSE}
- {$IFNDEF NEW_ALIGN}
- {$DEFINE NEW_ALIGN}
- {$ENDIF}
-{$ENDIF}
-{$IFNDEF OLD_TRANSPARENT}
- {$DEFINE NEW_TRANSPARENT}
-{$ENDIF}
-{$DEFINE USE_AUTOFREE4CONTROLS}
-{$DEFINE USE_AUTOFREE4CHILDREN}
-{$IFDEF SMALLEST_CODE}
- {$DEFINE NOT_UNLOAD_RICHEDITLIB}
- {$DEFINE SMALLER_CODE}
- {$DEFINE CREATE_VISIBLE}
-{$ELSE}
- {$IFnDEF SPEED_NORMAL}
- {$DEFINE SPEED_FASTER}
- {$ENDIF}
-{$ENDIF}
-{$IFDEF SAFE_CODE}
- {$UNDEF NO_SAFE_CODE}
-{$ENDIF}
-{$IFDEF NO_SAFE_CODE}
- {$UNDEF SAFE_CODE}
-{$ENDIF}
-{$IFnDEF NO_SAFE_CODE}
-{$IFnDEF SMALLER_CODE}
- {$DEFINE SAFE_CODE}
-{$ENDIF}
-{$ENDIF}
-{$IFDEF NOT_USE_RICHEDIT}
- {$DEFINE NOT_UNLOAD_RICHEDITLIB}
-{$ENDIF}
uses
- Messages, Windows{$IFNDEF NOT_USE_RICHEDIT}, RichEdit{$ENDIF}{$IFDEF CHK_GDI}, ChkGdi {$ENDIF};
+ Windows, Messages {$IFNDEF NOT_USE_RICHEDIT}, RichEdit{$ENDIF};
var
AppTheming: Boolean;
@@ -531,6 +318,8 @@ type
{$ENDIF}
{$ENDIF FPC}
+PKOLString = ^KOLString;
+
{$IFNDEF ASM_VERSION}
{$DEFINE PAS_VERSION}
{$ENDIF ASM_VERSION}
@@ -546,7 +335,7 @@ type
{$I delphicommctrl.inc}
{$ELSE}
{$I delphicommctrl.inc}
- {$I KOL_API.inc.pas}
+ {$I KOL_API.inc}
{$ENDIF FPC}
type
@@ -593,9 +382,6 @@ type
{$ENDIF}
fRefCount: Integer;
fOnDestroy: TOnEvent;
- {$IFDEF OLD_REFCOUNT}
- procedure DoDestroy;
- {$ENDIF}
protected
fAutoFree: PList;
{* Is called from a constructor to initialize created object instance
@@ -659,17 +445,13 @@ type
вызов Free немедленно ПЕРЕД последним RefDec. }
property RefCount: Integer read fRefCount;
{* }
- {$IFDEF OLD_FREE}
- procedure Free;
- {$ELSE NEW_FREE}
- property Free: Integer read RefDec;
+ procedure Free; inline;
{* Before calling destructor of object, checks if passed pointer is not
nil - similar what is done in VCL for TObject. It is ALWAYS recommended
to use Free instead of Destroy - see also comments to RefInc, RefDec. }
{= До вызова деструктора, проверяет, не передан ли nil в качестве параметра.
ВСЕГДА рекомендуется использовать Free вместо Destroy - см. так же RefInc,
RefDec. }
- {$ENDIF NEW_FREE}
// By Vyacheslav Gavrik:
function InstanceSize: Integer;
{* Returns a size of object instance. }
@@ -698,6 +480,8 @@ type
{* Adds an event handler to the list of events, called in destructor.
This method is mainly for internal use, and allows to auto-destroy
VCL components, located on KOL form at design time (in MCK project). }
+ procedure Add2AutoFreeStr(var S: String);
+ {* dufa: like Add2AutoFree, but for string *}
procedure RemoveFromAutoFree( Obj: PObj );
{* Removes an object from auto-free list }
procedure RemoveFromAutoFreeEx( Proc: TObjectMethod );
@@ -805,6 +589,10 @@ type
procedure ReleaseItems; //dufa
{* Especially for lists of pointers to dynamically allocated memory.
Releases all pointed memory blocks only. }
+ procedure ReleaseObjectsOnly;
+ {* Especially for a list of objects derived from TObj.
+ Calls Free for every of the object in the list, and then calls
+ Clear }
procedure ReleaseObjects;
{* Especially for a list of objects derived from TObj.
Calls Free for every of the object in the list, and then calls
@@ -1356,18 +1144,22 @@ RT_VERSION Version resource
{ ------------------------- string list objects ------------------------------ }
type
- TCompareStrListFun = function( const S1, S2: PAnsiChar ): Integer;
- TSwapEvent = procedure (const Data : Pointer; const e1,e2 : Dword);
+ TCompareStrListFun = function(const S1, S2: PAnsiChar): Integer;
+ { * TODO DESC }
+ TSwapEvent = procedure(const Data : Pointer; const e1, e2: DWORD);
{* Event type to define swap procedure which is swapping two elements of the
sorting data. }
- TCompareArrayEvent = function(e1,e2 : DWord_PTR) : PtrInt;
+ TCompareArrayEvent = function(e1, e2: DWORD_PTR): PtrInt;
{* Event type to define comparison function between two elements of an array.
Like in TCompareEvent, but e1 and e2 are not indexes in the array but items
themselves. }
- PStrList = ^TStrList;
+ // TStrList options. dufa
+ TStrListOption = (sloCaseSensitive, sloAnsi, sloNames);
+ TStrListOptions = set of TStrListOption;
{ ---------------------------------------------------------------------
TStrList - string list
---------------------------------------------------------------------- }
+ PStrList = ^TStrList;
TStrList = object(TObj)
{* Easy string list implementation (non-visual, just to store string data).
It is well improved and has very high performance allowing to work fast with huge text files
@@ -1376,18 +1168,6 @@ type
the rest of a line. Be careful, if your data contain such characters. }
protected
procedure Init; virtual;
- protected
- fList: PList;
- fCount: Integer;
- FItemIndex: Integer; //dufa
- fTextBuf: PAnsiChar;
- fTextSiz: DWORD;
- fCompareStrListFun: TCompareStrListFun;
- fCaseSensitiveSort: Boolean;
- fAnsiSort: Boolean;
- function GetPChars(Idx: Integer): PAnsiChar;
- //procedure AddTextBuf( Src: PAnsiChar; Len: DWORD );
- protected
{$IFDEF TLIST_FAST}
function GetUseBlocks: Boolean;
procedure SetUseBlocks(const Value: Boolean);
@@ -1401,21 +1181,47 @@ type
function GetValueNoCase(const AName: AnsiString): AnsiString;
procedure SetValue(const AName, Value: Ansistring);
procedure SetValueNoCase(const AName, Value: AnsiString);
+ function GetPChars(Idx: Integer): PAnsiChar;
+ procedure UpdateCompare; // dufa
+ // by Alexander Pravdin:
+ function GetLineName( Idx: Integer ): AnsiString;
+ procedure SetLineName( Idx: Integer; const NV: AnsiString );
+ function GetLineValue(Idx: Integer): Ansistring;
+ procedure SetLineValue(Idx: Integer; const Value: Ansistring);
+ procedure SetOptions(const Value: TStrListOptions);
+ function GetValueSorted(const AName: AnsiString): AnsiString;
+ procedure SetValueSorted(const AName, Value: AnsiString);
+ protected
+ fList: PList;
+ fCount: Integer;
+ fTextBuf: PAnsiChar;
+ fTextSiz: DWORD;
+ FColsCount: Integer; // dufa
+ FItemIndex: Integer; // dufa
+ FCompare: TCompareStrListFun; // dufa
+ FOptions: TStrListOptions; // dufa
+ fNameDelim: AnsiChar; // by Alexander Pravdin:
public
function IndexOfName(const AName: AnsiString): Integer;
{* Returns index of line starting like Name=... }
function IndexOfName_NoCase(const AName: AnsiString): Integer;
{* Returns index of line starting like Name=... (case insensitive) }
property Values[const AName: Ansistring]: AnsiString read GetValue write SetValue;
- {* Returns right side of a line starting like Name=... }
+ {* Returns right side of a line starting like Name=..., Name case insensitive }
property Values_Nocase[const AName: AnsiString]: AnsiString read GetValueNocase write SetValueNoCase;
+ {* Returns right side of a line starting like Name=..., when list options is [sloNames] }
+ property Values_Sorted[const AName: AnsiString]: AnsiString read GetValueSorted write SetValueSorted;
{* Returns right side of a line starting like Name=... (case insensitive) }
function Add(const S: Ansistring): Integer;
{* Adds a string to list. }
- function AddSorted(const S: Ansistring): Integer;
- {* Adds a string to sorted list. }
+ function AddValue(const AName, AValue: AnsiString): Integer;
+ {* Adds a name=value to list. dufa}
+ function AddSorted(const S: AnsiString; const Uniq: Boolean = False): Integer;
+ {* Adds a string to sorted list. With uniq option - no duplicates. dufa}
procedure AddStrings(Strings: PStrList);
{* Merges string list with given one. Very fast - more preferable to use than any loop with calling Add method. }
+ procedure AddStrings_Fast(src: PStrList);
+ {* dufa }
procedure Assign(Strings: PStrList);
{* Fills string list with strings from other one. The same as AddStrings, but Clear is called first. }
procedure Clear;
@@ -1428,10 +1234,14 @@ type
{* Removes first entry of a Value in the list. }
procedure RemoveByName(AName: Ansistring);
{* Removes first entry of a line starting like "AName=" in the list. }
+ procedure RemoveByNameNoCase(AName: Ansistring);
+ {* Removes first entry of a line starting like "AName=" in the list (while comparing it
+ without case sensitivity). }
procedure DeleteLast;
{* Deletes the last string (it *must* exist). }
function IndexOf(const S: AnsiString): Integer;
function IndexOf_Fast(const S: AnsiString): Integer;
+ function IndexOf_New(const S: AnsiString): Integer;
{* Returns index of first string, equal to given one. }
function IndexOf_NoCase(const S: Ansistring): Integer;
function IndexOf_Fast_NoCase(const S: AnsiString): Integer;
@@ -1445,14 +1255,19 @@ type
works only for sorted TStrList object. Returns TRUE if exact string found,
otherwise nearest (greater then a pattern) string index is returned,
and the result is FALSE. And in such _case Index is returned negated
- when the S string is less then the string found. }
+ when the S string is less then the string found.
+ Use [sloNames] - for find by LineName (LiveValue ignored) dufa }
function FindFirst(const S: AnsiString; var Index: Integer): Boolean;
{* Like above but always returns Index of the first string, equal or greater
to given pattern. Also works only for sorted TStrList object. Returns TRUE
if exact string found, otherwise nearest (greater then a pattern) string
index is returned, and the result is FALSE. }
+ function FindVCL_(const S: string; var Index: Integer): Boolean;
+ {* TODO DESC. dufa}
procedure Insert(Idx: integer; const S: Ansistring);
{* Inserts string before one with given index. }
+ procedure InsertValue(Idx: Integer; const AName, AValue: AnsiString);
+ {* Inserts name=value before one with given index. dufa }
procedure Move(CurIndex, NewIndex: integer);
{* Moves string to another location. }
procedure SetText(const S: Ansistring; Append2List: Boolean);
@@ -1463,7 +1278,7 @@ type
Assign, AddStrings). }
procedure SetUnixText( const S: AnsiString; Append2List: Boolean );
{* Allows to assign UNIX-style text (with #10 as string separator). }
- property Count: integer read fCount;
+ property Count: Integer read fCount;
{* Number of strings in a string list. }
property Items[Idx: integer]: Ansistring read Get write Put; default;
{* Strings array items. If item does not exist, empty string is returned.
@@ -1472,38 +1287,34 @@ type
{* Fast access to item strings as PChars. }
function Last: AnsiString;
{* Last item (or '', if string list is empty). }
+ function First: AnsiString;
+ {* First item (or '', if string list is empty). dufa}
property Text: Ansistring read GetTextStr write SetTextStr;
{* Content of string list as a single string (where strings are separated by chars $0D,$0A) }
- procedure Swap( Idx1, Idx2 : Integer );
+ procedure Swap(Idx1, Idx2 : Integer);
{* Swaps to strings with given indexes. }
- procedure Sort( CaseSensitive: Boolean );
- {* Call it to sort string list. }
- procedure AnsiSort( CaseSensitive: Boolean );
- {* Call it to sort ANSI string list. }
- procedure SortEx(const CompareFun: TCompareEvent);
+ procedure Sort(AOptions: TStrListOptions);
+ {* Call it to sort string list. Use [sloNames] - for sort by LineName (LiveValue ignored). Dufa }
+ procedure SortEx(const CompareFun: TCompareEvent; const SwapProc: TSwapEvent); overload;
+ {* Call it to sort via your own compare procedure + swap proc. Dufa }
+ procedure SortEx(const CompareFun: TCompareEvent); overload;
{* Call it to sort via your own compare procedure. Dufa }
- property IsAnsiSorted: Boolean read fAnsiSort write fAnsiSort;
- {* TODO DESC }
- property IsCaseSensitiveSorted: Boolean read fCaseSensitiveSort write fCaseSensitiveSort;
- {* TODO DESC }
- protected // by Alexander Pravdin:
- fNameDelim: AnsiChar;
- function GetLineName( Idx: Integer ): AnsiString;
- procedure SetLineName( Idx: Integer; const NV: AnsiString );
- function GetLineValue(Idx: Integer): Ansistring;
- procedure SetLineValue(Idx: Integer; const Value: Ansistring);
- public
+ property Options: TStrListOptions read FOptions write SetOptions;
+ {* TODO DESC. Dufa }
+ property Compare: TCompareStrListFun read FCompare write FCompare;
+ {* TODO DESC. Dufa }
property LineName[ Idx: Integer ]: Ansistring read GetLineName write SetLineName;
+ {* TODO DESC }
property LineValue[ Idx: Integer ]: Ansistring read GetLineValue write SetLineValue;
+ {* TODO DESC }
property NameDelimiter: AnsiChar read fNameDelim write fNameDelim;
- function Join( const sep: AnsiString ): AnsiString;
+ {* TODO DESC }
+ function Join(const sep: AnsiString; const AddLastSep: Boolean = True): AnsiString;
{* by Sergey Shishmintzev }
function LoadFromFile(const FileName: KOLString): Boolean;
- {* Loads string list from a file. (If file does not exist, nothing
- happens). Very fast even for huge text files. }
+ {* Loads string list from a file. (If file does not exist - nothing happens). Very fast even for huge text files. }
procedure LoadFromStream(Stream: PStream; Append2List: Boolean);
- {* Loads string list from a stream (from current position to the end of
- a stream). Very fast even for huge text. }
+ {* Loads string list from a stream (from current position to the end of a stream). Very fast even for huge text. }
procedure MergeFromFile(const FileName: KOLString);
{* Merges string list with strings in a file. Fast. }
function SaveToFile(const FileName: KOLString): Boolean;
@@ -1513,12 +1324,10 @@ type
function AppendToFile(const FileName: KOLString): Boolean;
{* Appends strings of string list to the end of a file. }
procedure OptimizeForRead;
- {* }
+ {* TODO DESC }
{$IFDEF TLIST_FAST}
property UseBlocks: Boolean read GetUseBlocks write SetUseBlocks;
{$ENDIF TLIST_FAST}
- public
- ColsCount: Integer;
{* For Matrix-Items access, Cols count. dufa }
procedure DeleteRange(Idx, Len: Integer);
{* Like TList.DeleteRange. dufa }
@@ -1539,12 +1348,18 @@ type
But for assign to property, string with given index *must* exist. }
procedure Swap2(Idx1, Idx2: Integer);
{* For Matrix-Items access, like Swap. dufa}
- function IndexOf2(const S2: array of AnsiString): Integer;
+ function IndexOf2(const S: array of AnsiString; const FullMatch: Boolean): Integer; overload;
+ function IndexOf2(const S: AnsiString; const Col: Integer): Integer; overload;
+ function IndexOf2_NoCase(const S: AnsiString; const Col: Integer): Integer;
{* For Matrix-Items access, like IndexOf. dufa}
+ function Last2(Col: Integer): AnsiString;
+ {* For Matrix-Items access, like Last. dufa}
function IsEmpty: Boolean;
{* Is list empty? dufa }
function GetRandomItem: AnsiString;
{* Get random item. dufa }
+ procedure Shuffle;
+ {* Randomize list items. dufa }
procedure ItemFirst;
{* Select first item - ItemIndex = 0, Dufa }
procedure ItemLast;
@@ -1555,8 +1370,10 @@ type
{* Select next item and return False if End Of List. Dufa }
function ItemPrev(var Item: AnsiString): Boolean;
{* Select prev item and return False if Start Of List. Dufa }
- property ItemIndex: Integer read FItemIndex;
+ property ItemIndex: Integer read FItemIndex write FItemIndex;
{* Current ItemIndex. Dufa }
+ property ColsCount: Integer read FColsCount write FColsCount;
+ {* For Matrix-Items access: columns count. Dufa }
end;
var DefaultNameDelimiter: AnsiChar = '=';
@@ -1618,17 +1435,14 @@ type
{* Moves string to another location. }
procedure Swap( Idx1, Idx2 : Integer );
{* Swaps to strings with given indexes. }
- procedure Sort( CaseSensitive: Boolean );
+ procedure Sort(AOptions: TStrListOptions); // dufa
{* Call it to sort string list. }
procedure SortEx(const CompareFun: TCompareEvent);
- {* Call it to sort string list by CompareFun.dufa }
- procedure AnsiSort( CaseSensitive: Boolean );
- {* Call it to sort ANSI string list. }
+ {* Call it to sort string list by CompareFun. dufa }
function LastObj: PtrUInt;
{* Object associated with the last string. }
function AddObject( const S: AnsiString; Obj: PtrUInt ): Integer;
- {* Adds a string and associates given number with it. Index of the item added
- is returned. }
+ {* Adds a string and associates given number with it. Index of the item added is returned. }
procedure InsertObject( Before: Integer; const S: AnsiString; Obj: PtrUInt );
{* Inserts a string together with object associated. }
function IndexOfObj( Obj: Pointer ): Integer;
@@ -3492,8 +3306,7 @@ type
At the same time, to use pointer to object in 'WITH' operator,
it is necessary to apply suffix '^' to pointer to get know
to compiler, what do You want. }
- TWindowFunc = function( Sender: PControl; var Msg: TMsg; var Rslt: LRESULT )
- : Boolean;
+ TWindowFunc = function( Sender: PControl; var Msg: TMsg; var Rslt: LRESULT ): Boolean;
{* Event type to define custom extended message handlers (as pointers to
procedure entry points). Such handlers are usually defined like add-ons,
extending behavior of certain controls and attached using AttachProc
@@ -3620,7 +3433,6 @@ type
aItem2XY: Word;
end;
- {$IFDEF COMMANDACTIONS_OBJ}
PCommandActionsObj = ^TCommandActionsObj;
TCommandActionsObj = object(TObj)
aClear: procedure( Sender: PControl );
@@ -3645,7 +3457,6 @@ type
fIndexInActions: Integer;
destructor Destroy; virtual;
end;
- {$ENDIF}
TTextAlign = ( taLeft, taRight, taCenter );
{* Text alignments available. }
@@ -4153,7 +3964,7 @@ type
fTBBtMinWidth: Integer;
fTBBtMaxWidth: Integer;
fTBttCmd: PList;
- fTBttTxt: {$IFDEF UNICODE_CTRLS} PWStrList {$ELSE} PStrList {$ENDIF};
+ fTBttTxt: {$IFDEF UNICODE_CTRLS} PWStrList {$ELSE} PStrList {$ENDIF}; // TODO: to TKOLStrList
fTBCurItem: Integer;
fDefaultTBBtnStyle: Byte; // for Toolbars
fTBDropped: Boolean;
@@ -4458,21 +4269,6 @@ type
function Get_SizeRedraw: Boolean;
procedure Set_SizeRedraw(const Value: Boolean);
{$ENDIF USE_FLAGS}
- public //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- FormString: KOLString;
- {* строка текущего параметра. Очищается после каждого вызова
- FormExecuteCommands, так что специальная очистка не требуется. }
- function FormGetIntParam: PtrInt;
- {* извлекает очередной целочисленный параметр до ',' или до ';' }
- function FormGetColorParam: Integer;
- {* извлекает очередной целочисленный параметр до ',' или до ';' }
- procedure FormGetStrParam;
- {* извлекает очередной строковый параметр до ',' или до ';' -> FormString }
- procedure FormCreateParameters( alphabet: PFormInitFuncArray; params: PAnsiChar );
- {* задает первоначальный алфавит и параметры с командами }
- procedure FormExecuteCommands(AForm: PControl; ControlPtrOffsets: PSmallIntArray);
- {* выполняет команды (с параметрами) до конца или до ';' }
-
protected
function GetDate: TDateTime;
function GetTime: TDateTime;
@@ -4588,7 +4384,7 @@ type
function TBGetBtnWidth(BtnID: Integer): Integer;
procedure TBSetBtnWidth(BtnID: Integer; const Value: Integer);
- procedure TBSetBtMinMaxWidth(const Idx: Integer; const Value: Integer);
+ procedure TBSetBtMinMaxWidth(const Idx, Value: Integer);
procedure TBFreeTBevents;
function TBGetButtonLParam(const Idx: Integer): PtrUInt;
procedure TBSetButtonLParam(const Idx: Integer; const Value: PtrUInt);
@@ -4893,11 +4689,7 @@ type
{$ENDIF}
{ }
public
- {$IFDEF COMMANDACTIONS_OBJ}
fCommandActions: PCommandActionsObj;
- {$ELSE}
- fCommandActions: TCommandActions;
- {$ENDIF}
{$IFDEF EVENTS_DYNAMIC}
EV: PEvents;
protected
@@ -4915,10 +4707,8 @@ type
fMenuObj: PObj;
{* PMenu pointer to TMenu object. Freed automatically with entire
chain of menu objects attached to a control (or form). }
-{$IFNDEF NEW_MENU_ACCELL}
fAccelTable: HAccel;
procedure DoDestroyAccelTable;
-{$ENDIF}
protected
{* Handle of accelerator table created by menu(s). }
fImageList: PImageList;
@@ -5441,8 +5231,7 @@ type
also ScreenCursor. }
procedure CursorLoad( Inst: HINST; ResName: PKOLChar );
{* Loads Cursor from the resource. See also comments for Icon property. }
- property Icon: HIcon read {$IFDEF SMALLEST_CODE} DF.fIcon {$ELSE} GetIcon {$ENDIF}
- write SetIcon;
+ property Icon: HIcon read GetIcon write SetIcon;
{* |<#appbutton>
|<#form>
Icon. By default, icon of the Applet is used. To load icon from the
@@ -5524,100 +5313,68 @@ type
selection. For rich edit, use RE_Text[ reText, TRUE ], if you want to
read correctly characters from another locale then ANSI only. }
procedure SelectAll;
- {* |<#edit>
- |<#memo>
- |<#richedit>
- Makes all the text in editbox or RichEdit, or all items in listbox
- selected. }
+ {* |<#edit> <#memo> <#richedit>
+ Makes all the text in editbox or RichEdit, or all items in listbox selected. }
procedure ReplaceSelection( const Value: KOLString; aCanUndo: Boolean );
- {* |<#edit>
- |<#memo>
- |<#richedit>
+ {* |<#edit> <#memo> <#richedit>
Replaces selection (in edit, RichEdit). Unlike assigning new value
to Selection property, it is possible to specify, if operation can
be undone.
- |