mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 22:16:17 +02:00
Started the code completion.
Shane git-svn-id: trunk@162 -
This commit is contained in:
parent
3e14935439
commit
b63fd4b108
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1,5 +1,6 @@
|
||||
* text=auto !eol
|
||||
components/synedit/allunits.pp svneol=native#text/pascal
|
||||
components/synedit/syncompletion.pas svneol=native#text/pascal
|
||||
components/synedit/synedit.inc svneol=native#text/pascal
|
||||
components/synedit/synedit.pp svneol=native#text/pascal
|
||||
components/synedit/syneditautocomplete.pp svneol=native#text/pascal
|
||||
|
1175
components/synedit/syncompletion.pas
Normal file
1175
components/synedit/syncompletion.pas
Normal file
File diff suppressed because it is too large
Load Diff
@ -251,16 +251,19 @@ begin
|
||||
try
|
||||
Temp.Text := fCompletionValues[i];
|
||||
// indent lines
|
||||
if (IndentLen > 0) and (Temp.Count > 1) then begin
|
||||
if (IndentLen > 0) and (Temp.Count > 1) then
|
||||
begin
|
||||
s := StringOfChar(' ', IndentLen);
|
||||
for i := 1 to Temp.Count - 1 do
|
||||
Temp[i] := s + Temp[i];
|
||||
end;
|
||||
// find first '|' and use it as caret position
|
||||
for i := 0 to Temp.Count - 1 do begin
|
||||
for i := 0 to Temp.Count - 1 do
|
||||
begin
|
||||
s := Temp[i];
|
||||
j := Pos('|', s);
|
||||
if j > 0 then begin
|
||||
if j > 0 then
|
||||
begin
|
||||
Delete(s, j, 1);
|
||||
Temp[i] := s;
|
||||
// if j > 1 then
|
||||
|
@ -416,7 +416,6 @@ begin
|
||||
ConfFileName:=SecConfFileName;
|
||||
end;
|
||||
end;
|
||||
writeln('EditorOptionsFile=',ConfFilename);
|
||||
XMLConfig:=TXMLConfig.Create(ConfFileName);
|
||||
|
||||
// set defaults
|
||||
@ -463,7 +462,6 @@ procedure TEditorOptions.Load;
|
||||
var SynEditOpt:TSynEditorOption;
|
||||
SynEditOptName:ansistring;
|
||||
begin
|
||||
writeln('AAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
|
||||
// general options
|
||||
for SynEditOpt:=Low(TSynEditorOption) to High(TSynEditorOption) do begin
|
||||
case SynEditOpt of
|
||||
@ -496,7 +494,6 @@ writeln('AAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
|
||||
|
||||
fUndoAfterSave:=
|
||||
XMLConfig.GetValue('EditorOptions/General/Editor/UndoAfterSave',true);
|
||||
writeln('UndoAfterSave',fUndoAfterSave);
|
||||
fDoubleClickLine:=
|
||||
XMLConfig.GetValue('EditorOptions/General/Editor/DoubleClickLine',false);
|
||||
fFindTextAtCursor:=
|
||||
@ -1134,7 +1131,6 @@ begin
|
||||
with FontDialog do begin
|
||||
if Execute then begin
|
||||
EditorFontComboBox.Text:=FontName;
|
||||
writeln('[TEditorOptionsForm.EditorFontButtonClick] fontname=''',FontName,'''');
|
||||
for a:=Low(PreviewEdits) to High(PreviewEdits) do begin
|
||||
if PreviewEdits[a]<>nil then
|
||||
FontDialogNameToFont(FontName,PreviewEdits[a].Font);
|
||||
@ -1256,8 +1252,6 @@ begin
|
||||
end;
|
||||
if Old<>CurHighlightElement then
|
||||
ShowCurAttribute;
|
||||
if CurHighlightElement<>nil then
|
||||
writeln('CurHigh: '+CurHighlightElement.Name);
|
||||
end;
|
||||
|
||||
procedure TEditorOptionsForm.InvalidatePreviews;
|
||||
@ -2714,7 +2708,6 @@ begin
|
||||
EditorOpts.Save;
|
||||
|
||||
try
|
||||
writeln('SAVING ',EditorOpts.CodeTemplateFileName);
|
||||
SynAutoComplete.AutoCompleteList.SaveToFile(
|
||||
EditorOpts.CodeTemplateFileName);
|
||||
except
|
||||
@ -2730,6 +2723,7 @@ end;
|
||||
|
||||
procedure TEditorOptionsForm.CancelButtonClick(Sender:TObject);
|
||||
begin
|
||||
EditorOpts.Load;
|
||||
ModalResult:=mrCancel;
|
||||
end;
|
||||
|
||||
|
@ -45,10 +45,13 @@ type
|
||||
cbRegularExpressions : TCheckBox;
|
||||
|
||||
rgForwardBack : TRadioGroup;
|
||||
rgScope : TRadioGroup;
|
||||
rgOrigin : TRadioGroup;
|
||||
{ event handlers }
|
||||
procedure btnOKClicked(Sender : TObject);
|
||||
procedure btnCancelClicked(Sender : TObject);
|
||||
procedure btnHelpClicked(Sender : TObject);
|
||||
Procedure FindDialogOnActivate(Sender : TObject);
|
||||
private
|
||||
FFindText : String;
|
||||
FOnFind : TNotifyEvent;
|
||||
@ -101,7 +104,7 @@ begin
|
||||
begin
|
||||
parent := Self;
|
||||
Left := 10;
|
||||
Top := 35;
|
||||
Top := 30;
|
||||
Width :=(Self.Width div 2) - 10;
|
||||
Height := (Self.Height div 2) -35;
|
||||
Caption := 'Options';
|
||||
@ -117,7 +120,7 @@ begin
|
||||
begin
|
||||
parent := gbGroupBox;
|
||||
left := 5;
|
||||
top := 5;
|
||||
top := 3;
|
||||
Caption := 'Case Sensitive';
|
||||
Name := 'cbCaseSensitive';
|
||||
visible := True;
|
||||
@ -127,7 +130,7 @@ begin
|
||||
begin
|
||||
parent := gbGroupBox;
|
||||
left := 5;
|
||||
top := 25;
|
||||
top := 20;
|
||||
Caption := 'Whole Words';
|
||||
Name := 'cbWholeWords';
|
||||
visible := True;
|
||||
@ -137,7 +140,7 @@ begin
|
||||
begin
|
||||
parent := gbGroupBox;
|
||||
left := 5;
|
||||
top := 50;
|
||||
top := 37;
|
||||
Caption := 'Regular Expressions';
|
||||
Name := 'cbRegularExpressions';
|
||||
visible := True;
|
||||
@ -148,7 +151,7 @@ begin
|
||||
begin
|
||||
parent := self;
|
||||
left := (Self.Width div 2) +5;
|
||||
top := 35;
|
||||
top := 30;
|
||||
Height := (Self.Height div 2) -35;
|
||||
width := (Self.Width div 2) -10;
|
||||
Caption := 'Direction';
|
||||
@ -159,6 +162,38 @@ begin
|
||||
ItemIndex := 0;
|
||||
end;
|
||||
|
||||
rgScope := TRadioGroup.Create(self);
|
||||
with rgScope do
|
||||
begin
|
||||
parent := self;
|
||||
left := 10;
|
||||
top := (Self.Height div 2)+5;
|
||||
Height := (Self.Height div 2)-35;
|
||||
width := (Self.Width div 2) -10;
|
||||
Caption := 'Scope';
|
||||
Items.Add('Global');
|
||||
Items.Add('Selected Text');
|
||||
Name := 'rgScope';
|
||||
visible := True;
|
||||
ItemIndex := 0;
|
||||
end;
|
||||
|
||||
rgOrigin := TRadioGroup.Create(self);
|
||||
with rgOrigin do
|
||||
begin
|
||||
parent := self;
|
||||
left := (Self.Width div 2) +5;
|
||||
top := (Self.Height div 2) + 5;
|
||||
Height := (Self.Height div 2) -35;
|
||||
width := (Self.Width div 2) -10;
|
||||
Caption := 'Origin';
|
||||
Items.Add('From Cursor');
|
||||
Items.Add('Entire Scope');
|
||||
Name := 'rgOrigin';
|
||||
visible := True;
|
||||
ItemIndex := 1;
|
||||
end;
|
||||
|
||||
btnOK := TButton.create(self);
|
||||
with btnOK do
|
||||
begin
|
||||
@ -200,6 +235,7 @@ begin
|
||||
visible := True;
|
||||
OnCLick := @BTnHelpClicked;
|
||||
end;
|
||||
OnActivate := @FindDialogOnActivate;
|
||||
end;
|
||||
|
||||
procedure TFindDialog.btnOKClicked(Sender : TObject);
|
||||
@ -217,5 +253,9 @@ procedure TFindDialog.btnHelpClicked(Sender : TObject);
|
||||
Begin
|
||||
end;
|
||||
|
||||
Procedure TFindDialog.FindDialogOnActivate(Sender : TObject);
|
||||
Begin
|
||||
edtTextToFind.SetFocus;
|
||||
End;
|
||||
|
||||
end.
|
||||
|
14
ide/main.pp
14
ide/main.pp
@ -37,8 +37,7 @@ uses
|
||||
CompReg;
|
||||
|
||||
const
|
||||
STANDARDBTNCOUNT = 50;
|
||||
|
||||
Version_String = '0.7';
|
||||
type
|
||||
|
||||
|
||||
@ -258,7 +257,7 @@ var
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
|
||||
Caption := 'Lazarus Editor v 0.5';
|
||||
Caption := 'Lazarus Editor v '+Version_String;
|
||||
|
||||
Left := 0;
|
||||
Top := 0;
|
||||
@ -693,7 +692,7 @@ begin
|
||||
SpeedButton5.OnClick := @SourceNotebook.SaveClicked;
|
||||
SpeedButton6.OnClick := @SourceNotebook.SaveAllClicked;
|
||||
|
||||
|
||||
EditorOPts.Load;
|
||||
|
||||
end;
|
||||
|
||||
@ -1621,7 +1620,8 @@ end;
|
||||
|
||||
procedure TMainIDE.mnuEnvironmentOptionsClicked(Sender : TObject);
|
||||
Begin
|
||||
EditorOptionsForm.ShowModal;
|
||||
if EditorOptionsForm.ShowModal = mrOK then
|
||||
SourceNotebook.ReloadEditorOptions;
|
||||
End;
|
||||
|
||||
|
||||
@ -1643,8 +1643,8 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.53 2001/01/31 18:57:29 lazarus
|
||||
Added the ability to use the FIND feature in the editor.
|
||||
Revision 1.54 2001/02/01 16:45:19 lazarus
|
||||
Started the code completion.
|
||||
Shane
|
||||
|
||||
Revision 1.52 2001/01/31 13:03:33 lazarus
|
||||
|
@ -31,10 +31,10 @@ unit UnitEditor;
|
||||
interface
|
||||
|
||||
uses
|
||||
classes, Controls, forms,buttons,comctrls,sysutils,Dialogs,FormEditor,Find_Dlg,
|
||||
classes, Controls, forms,buttons,comctrls,sysutils,Dialogs,FormEditor,Find_Dlg,EditorOPtions,
|
||||
{$ifdef NEW_EDITOR_SYNEDIT}
|
||||
SynEdit, SynEditHighlighter, SynHighlighterPas, SynEditAutoComplete,
|
||||
SynEditKeyCmds,
|
||||
SynEdit, SynEditHighlighter, SynHighlighterPas,SynEditAutoComplete,
|
||||
SynEditKeyCmds,SynCompletion,
|
||||
{$else}
|
||||
mwcustomedit,mwPasSyn,
|
||||
{$endif}
|
||||
@ -146,6 +146,8 @@ type
|
||||
Function StartFind : Boolean;
|
||||
Function FindAgain(StartX,StartLine : Integer) : Boolean;
|
||||
|
||||
Function RefreshEditorSettings : Boolean;
|
||||
|
||||
property Editor : TmwCustomEdit read FEditor;
|
||||
property Visible : Boolean read FVisible write FVisible default False;
|
||||
FindText : String;
|
||||
@ -241,6 +243,7 @@ type
|
||||
Procedure ToggleBookmark(Value : Integer);
|
||||
Procedure GotoBookmark(Value: Integer);
|
||||
|
||||
Procedure ReloadEditorOptions;
|
||||
|
||||
property OnCloseFile : TNotifyFileEvent read FOnCloseFile write FOnCloseFile;
|
||||
property OnOpenFile : TNotifyFileEvent read FOnOPenFile write FOnOPenFile;
|
||||
@ -274,6 +277,7 @@ const
|
||||
var
|
||||
Editor_Num : Integer;
|
||||
aHighlighter: TSynPasSyn;
|
||||
aCompletion : TSynCompletion;
|
||||
|
||||
{ TSourceEditor }
|
||||
|
||||
@ -605,6 +609,8 @@ end;
|
||||
Function TSourceEditor.StartFind : Boolean;
|
||||
Begin
|
||||
Result := False;
|
||||
//setup the find dialog
|
||||
|
||||
if not Assigned(FindDialog1) then
|
||||
FindDialog1 := TFindDialog.Create(nil);
|
||||
|
||||
@ -614,7 +620,9 @@ Begin
|
||||
FindText := uppercase(FindDialog1.edtTextToFind.Text);
|
||||
Result := FindAgain(1,0);
|
||||
|
||||
end;
|
||||
end
|
||||
else
|
||||
Exit;
|
||||
|
||||
if not Result then
|
||||
Application.MessageBox('Search String not found.','Not Found',mb_OK);
|
||||
@ -802,23 +810,43 @@ Begin
|
||||
|
||||
end;
|
||||
|
||||
Function TSourceEditor.RefreshEditorSettings : Boolean;
|
||||
Begin
|
||||
Result := False;
|
||||
|
||||
if EditorOPts.UseSyntaxHighlight then
|
||||
Begin
|
||||
EditorOPts.GetHighlighterSettings(aHighlighter);
|
||||
FEditor.Highlighter:=aHighlighter;
|
||||
end
|
||||
else
|
||||
FEditor.Highlighter:=nil;
|
||||
|
||||
|
||||
|
||||
with FSynAutoComplete do begin
|
||||
if FileExists(EditorOPts.CodeTemplateFilename) then
|
||||
AutoCompleteList.LoadFromFile(EditorOPts.CodeTemplateFilename)
|
||||
else
|
||||
if FileExists('lazarus.dci') then
|
||||
AutoCompleteList.LoadFromFile('lazarus.dci');
|
||||
|
||||
end;
|
||||
|
||||
EditorOpts.GetSynEditSettings(FEditor);
|
||||
end;
|
||||
|
||||
|
||||
Procedure TSourceEditor.CreateEditor(AOwner : TComponent; AParent: TWinControl);
|
||||
Begin
|
||||
if assigned(FEditor) then
|
||||
if assigned(FEditor) then
|
||||
Begin
|
||||
FSource.Assign(FEditor.Lines);
|
||||
FEditor.Free;
|
||||
end;
|
||||
|
||||
{SynEdit}
|
||||
|
||||
FSynAutoComplete:=TSynAutoComplete.Create(FAOwner);
|
||||
with FSynAutoComplete do begin
|
||||
if FileExists(SetDirSeparators(GetPrimaryConfigPath+'/lazarus.dci')) then
|
||||
AutoCompleteList.LoadFromFile(SetDirSeparators(GetPrimaryConfigPath+'/lazarus.dci'))
|
||||
else
|
||||
AutoCompleteList.LoadFromFile('lazarus.dci');
|
||||
end;
|
||||
|
||||
FEditor:=TSynEdit.Create(FAOwner);
|
||||
with FEditor do
|
||||
@ -828,7 +856,6 @@ if assigned(FEditor) then
|
||||
Parent := AParent;
|
||||
SetBounds(0,25,TWinControl(FAOwner).ClientWidth - 10,TWinControl(FAOwner).ClientHeight -10);
|
||||
Align := alClient;
|
||||
Highlighter:=aHighlighter;
|
||||
Gutter.Color:=clBlue;
|
||||
AddKey(ecAutoCompletion, word('J'), [ssCtrl], 0, []);
|
||||
AddKey(ecFind, word('F'), [ssCtrl], 0, []);
|
||||
@ -847,10 +874,11 @@ if assigned(FEditor) then
|
||||
Show;
|
||||
end;
|
||||
FSynAutoComplete.AddEditor(FEditor);
|
||||
{SynEdit}
|
||||
RefreshEditorSettings;
|
||||
aCompletion.Editor := FEditor;
|
||||
|
||||
FEditor.Lines.Assign(FSource);
|
||||
FEditor.Setfocus
|
||||
FEditor.Lines.Assign(FSource);
|
||||
FEditor.Setfocus
|
||||
end;
|
||||
|
||||
Procedure TSourceEditor.AddControlCode(_Control : TComponent);
|
||||
@ -1249,6 +1277,16 @@ begin
|
||||
SymbolAttri.ForeGround:=clBlack;
|
||||
end;
|
||||
|
||||
|
||||
aCompletion := TSynCompletion.Create(AOwner);
|
||||
with aCompletion do
|
||||
Begin
|
||||
|
||||
|
||||
|
||||
end;
|
||||
|
||||
|
||||
StatusBar := TStatusBar.Create(self);
|
||||
with Statusbar do
|
||||
begin
|
||||
@ -1479,8 +1517,8 @@ Begin
|
||||
end;
|
||||
End;
|
||||
|
||||
//TempEditor now is the editor on the active page
|
||||
//Compare it to the editor help by the SourceEditors
|
||||
// TempEditor now is the editor on the active page
|
||||
// Compare it to the editor help by the SourceEditors
|
||||
I := 0;
|
||||
while TSourceEditor(FSourceEditorList[I]).Editor <> TempEditor do
|
||||
inc(i);
|
||||
@ -1800,6 +1838,15 @@ begin
|
||||
end; //case
|
||||
end;
|
||||
|
||||
Procedure TSourceNotebook.ReloadEditorOptions;
|
||||
var
|
||||
I : integer;
|
||||
Begin
|
||||
//this reloads the colrs for the highlighter and other settings.
|
||||
for I := 0 to FSourceEditorList.Count-1 do
|
||||
TSOurceEditor(FSourceEditorList.Items[i]).RefreshEditorSettings;
|
||||
end;
|
||||
|
||||
initialization
|
||||
Editor_Num := 0;
|
||||
|
||||
|
@ -423,6 +423,7 @@ TCMDialogKey = TLMKEY;
|
||||
FControlState: TControlState;
|
||||
Procedure AdjustSize; dynamic;
|
||||
{ events need to be protected otherwise they can't be overridden ??}
|
||||
Procedure Changed;
|
||||
procedure WMLButtonDown(Var Message: TLMLButtonDown); message LM_LBUTTONDOWN;
|
||||
procedure WMRButtonDown(Var Message: TLMRButtonDown); message LM_RBUTTONDOWN;
|
||||
procedure WMMButtonDown(Var Message: TLMMButtonDown); message LM_MBUTTONDOWN;
|
||||
@ -1124,6 +1125,10 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.11 2001/02/01 16:45:19 lazarus
|
||||
Started the code completion.
|
||||
Shane
|
||||
|
||||
Revision 1.10 2001/01/23 23:33:54 lazarus
|
||||
MWE:
|
||||
- Removed old LM_InvalidateRect
|
||||
|
@ -47,6 +47,10 @@ type
|
||||
TWindowState = (wsNormal, wsMinimized, wsMaximized);
|
||||
TCloseAction = (caNone, caHide, caFree, caMinimize);
|
||||
|
||||
TScrollBarKind = (sbHorizontal, sbVertical);
|
||||
TScrollBarInc = 1..32768;
|
||||
TScrollBarStyle = (ssRegular, ssFlat, ssHotTrack);
|
||||
|
||||
TControlScrollBar = class(TPersistent)
|
||||
end;
|
||||
|
||||
@ -78,6 +82,7 @@ type
|
||||
FModalResult : TModalResult;
|
||||
FOnActivate: TNotifyEvent;
|
||||
FOnCreate: TNotifyEvent;
|
||||
FOnDeactivate : TNotifyEvent;
|
||||
FOnDestroy: TNotifyEvent;
|
||||
FOnHide: TNotifyEvent;
|
||||
FOnShow: TNotifyEvent;
|
||||
@ -111,6 +116,7 @@ type
|
||||
function CloseQuery : boolean; virtual;
|
||||
procedure CreateParams(var Params: TCreateParams); override;
|
||||
procedure CreateWnd; override;
|
||||
Procedure DeActivate; dynamic;
|
||||
procedure DoClose(var Action: TCloseAction); dynamic;
|
||||
procedure DoHide; dynamic;
|
||||
procedure DoShow; dynamic;
|
||||
@ -129,6 +135,7 @@ type
|
||||
{events}
|
||||
property OnActivate: TNotifyEvent read FOnActivate write FOnActivate;
|
||||
property OnCreate: TNotifyEvent read FOnCreate write FOnCreate;
|
||||
property OnDeactivate: TNotifyEvent read FOnDeactivate write FOnDeactivate;
|
||||
property OnDestroy: TNotifyEvent read FOnDestroy write FOnDestroy;
|
||||
property OnHide: TNotifyEvent read FOnHide write FOnHide;
|
||||
property OnShow: TNotifyEvent read FOnShow write FOnShow;
|
||||
@ -181,6 +188,7 @@ type
|
||||
// property WindowState;
|
||||
property OnActivate;
|
||||
property OnCreate;
|
||||
property OnDeactivate;
|
||||
property OnDestroy;
|
||||
property OnShow;
|
||||
property OnHide;
|
||||
|
@ -74,6 +74,16 @@ begin
|
||||
SetZOrder(True);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TControl.Change
|
||||
}
|
||||
{------------------------------------------------------------------------------}
|
||||
Procedure TControl.Changed;
|
||||
Begin
|
||||
Perform(CM_CHANGED,0,Longint(self));
|
||||
End;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TControl.ChangeScale
|
||||
}
|
||||
@ -1273,6 +1283,10 @@ end;
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.10 2001/02/01 16:45:19 lazarus
|
||||
Started the code completion.
|
||||
Shane
|
||||
|
||||
Revision 1.9 2001/01/09 18:23:20 lazarus
|
||||
Worked on moving controls. It's just not working with the X and Y coord's I'm getting.
|
||||
Shane
|
||||
|
@ -71,6 +71,19 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCustomForm.Deactivate
|
||||
Params: None
|
||||
Returns: Nothing
|
||||
|
||||
|
||||
------------------------------------------------------------------------------}
|
||||
Procedure TCustomForm.Deactivate;
|
||||
Begin
|
||||
if Assigned(FOnDeactivate) then
|
||||
FOnDeactivate(Self);
|
||||
end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCustomForm.Notification
|
||||
@ -825,6 +838,10 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.10 2001/02/01 16:45:20 lazarus
|
||||
Started the code completion.
|
||||
Shane
|
||||
|
||||
Revision 1.9 2001/01/12 18:46:50 lazarus
|
||||
Named the speedbuttons in MAINIDE and took out some writelns.
|
||||
Shane
|
||||
|
@ -2,9 +2,191 @@
|
||||
{ function TScrollBar.Create }
|
||||
{------------------------------------------------------------------------------}
|
||||
|
||||
|
||||
{ TScrollBar }
|
||||
|
||||
constructor TScrollBar.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
// FCompStlye := csVScrollBar;
|
||||
fOwner := TControl(AOwner);
|
||||
inherited Create(AOwner);
|
||||
fCompStyle := csScrollBar;
|
||||
Width := 121;
|
||||
Height := GetSystemMetrics(SM_CYHSCROLL);
|
||||
TabStop := True;
|
||||
ControlStyle := [csFramed, csDoubleClicks, csOpaque];
|
||||
FKind := sbHorizontal;
|
||||
FPosition := 0;
|
||||
FMin := 0;
|
||||
FMax := 100;
|
||||
FSmallChange := 1;
|
||||
FLargeChange := 1;
|
||||
end;
|
||||
|
||||
procedure TScrollBar.CreateParams(var Params: TCreateParams);
|
||||
const
|
||||
Kinds: array[TScrollBarKind] of DWORD = (SBS_HORZ, SBS_VERT);
|
||||
begin
|
||||
inherited CreateParams(Params);
|
||||
CreateSubClass(Params, 'SCROLLBAR');
|
||||
Params.Style := Params.Style or Kinds[FKind];
|
||||
if FKind = sbVertical then
|
||||
Params.Style := Params.Style or SBS_LEFTALIGN;
|
||||
FRTLFactor := 1
|
||||
end;
|
||||
|
||||
procedure TScrollBar.CreateWnd;
|
||||
var
|
||||
ScrollInfo: TScrollInfo;
|
||||
begin
|
||||
inherited CreateWnd;
|
||||
SetScrollRange(Handle, SB_CTL, FMin, FMax, False);
|
||||
ScrollInfo.cbSize := SizeOf(ScrollInfo);
|
||||
ScrollInfo.nPage := FPageSize;
|
||||
ScrollInfo.fMask := SIF_PAGE;
|
||||
SetScrollInfo(Handle, SB_CTL, ScrollInfo, False);
|
||||
if NotRightToLeft then
|
||||
SetScrollPos(Handle, SB_CTL, FPosition, True)
|
||||
else
|
||||
SetScrollPos(Handle, SB_CTL, FMax - FPosition, True);
|
||||
end;
|
||||
|
||||
function TScrollBar.NotRightToLeft: Boolean;
|
||||
begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TScrollBar.SetKind(Value: TScrollBarKind);
|
||||
begin
|
||||
if FKind <> Value then
|
||||
begin
|
||||
FKind := Value;
|
||||
if not (csLoading in ComponentState) then SetBounds(Left, Top, Height, Width);
|
||||
RecreateWnd;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TScrollBar.SetParams(APosition, AMin, AMax: Integer);
|
||||
begin
|
||||
if AMax < AMin then
|
||||
raise EInvalidOperation.Create(SScrollBarRange);
|
||||
if APosition < AMin then APosition := AMin;
|
||||
if APosition > AMax then APosition := AMax;
|
||||
if (FMin <> AMin) or (FMax <> AMax) then
|
||||
begin
|
||||
FMin := AMin;
|
||||
FMax := AMax;
|
||||
if HandleAllocated then
|
||||
SetScrollRange(Handle, SB_CTL, AMin, AMax, FPosition = APosition);
|
||||
end;
|
||||
if FPosition <> APosition then
|
||||
begin
|
||||
FPosition := APosition;
|
||||
if HandleAllocated then
|
||||
if NotRightToLeft then
|
||||
SetScrollPos(Handle, SB_CTL, FPosition, True)
|
||||
else
|
||||
SetScrollPos(Handle, SB_CTL, FMax - FPosition, True);
|
||||
Change;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TScrollBar.SetPosition(Value: Integer);
|
||||
begin
|
||||
SetParams(Value, FMin, FMax);
|
||||
end;
|
||||
|
||||
procedure TScrollBar.SetPageSize(Value: Integer);
|
||||
var
|
||||
ScrollInfo: TScrollInfo;
|
||||
begin
|
||||
if (FPageSize = Value) or (FPageSize > FMax) then exit;
|
||||
FPageSize := Value;
|
||||
ScrollInfo.cbSize := SizeOf(ScrollInfo);
|
||||
ScrollInfo.nPage := Value;
|
||||
ScrollInfo.fMask := SIF_PAGE;
|
||||
if HandleAllocated then
|
||||
SetScrollInfo(Handle, SB_CTL, ScrollInfo, True);
|
||||
end;
|
||||
|
||||
procedure TScrollBar.SetMin(Value: Integer);
|
||||
begin
|
||||
SetParams(FPosition, Value, FMax);
|
||||
end;
|
||||
|
||||
procedure TScrollBar.SetMax(Value: Integer);
|
||||
begin
|
||||
SetParams(FPosition, FMin, Value);
|
||||
end;
|
||||
|
||||
procedure TScrollBar.Change;
|
||||
begin
|
||||
inherited Changed;
|
||||
if Assigned(FOnChange) then FOnChange(Self);
|
||||
end;
|
||||
|
||||
procedure TScrollBar.Scroll(ScrollCode: TScrollCode; var ScrollPos: Integer);
|
||||
begin
|
||||
if Assigned(FOnScroll) then FOnScroll(Self, ScrollCode, ScrollPos);
|
||||
end;
|
||||
|
||||
procedure TScrollBar.DoScroll(var Message: TLMScroll);
|
||||
var
|
||||
ScrollPos: Integer;
|
||||
NewPos: Longint;
|
||||
ScrollInfo: TScrollInfo;
|
||||
begin
|
||||
with Message do
|
||||
begin
|
||||
NewPos := FPosition;
|
||||
case TScrollCode(ScrollCode) of
|
||||
scLineUp:
|
||||
Dec(NewPos, FSmallChange * FRTLFactor);
|
||||
scLineDown:
|
||||
Inc(NewPos, FSmallChange * FRTLFactor);
|
||||
scPageUp:
|
||||
Dec(NewPos, FLargeChange * FRTLFactor);
|
||||
scPageDown:
|
||||
Inc(NewPos, FLargeChange * FRTLFactor);
|
||||
scPosition, scTrack:
|
||||
with ScrollInfo do
|
||||
begin
|
||||
cbSize := SizeOf(ScrollInfo);
|
||||
fMask := SIF_ALL;
|
||||
GetScrollInfo(Handle, SB_CTL, ScrollInfo);
|
||||
NewPos := nTrackPos;
|
||||
{ We need to reverse the positioning because SetPosition below
|
||||
calls SetParams that reverses the position. This acts as a
|
||||
double negative. }
|
||||
if not NotRightToLeft then NewPos := FMax - NewPos;
|
||||
end;
|
||||
scTop:
|
||||
NewPos := FMin;
|
||||
scBottom:
|
||||
NewPos := FMax;
|
||||
end;
|
||||
if NewPos < FMin then NewPos := FMin;
|
||||
if NewPos > FMax then NewPos := FMax;
|
||||
ScrollPos := NewPos;
|
||||
Scroll(TScrollCode(ScrollCode), ScrollPos);
|
||||
SetPosition(ScrollPos);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TScrollBar.CNHScroll(var Message: TLMHScroll);
|
||||
begin
|
||||
DoScroll(Message);
|
||||
end;
|
||||
|
||||
procedure TScrollBar.CNVScroll(var Message: TLMVScroll);
|
||||
begin
|
||||
DoScroll(Message);
|
||||
end;
|
||||
|
||||
procedure TScrollBar.CNCtlColorScrollBar(var Message: TLMessage);
|
||||
begin
|
||||
//CallWIndowProc is not yet created so no code is here
|
||||
end;
|
||||
|
||||
procedure TScrollBar.WMEraseBkgnd(var Message: TLMEraseBkgnd);
|
||||
begin
|
||||
DefaultHandler(Message);
|
||||
end;
|
||||
|
@ -454,6 +454,16 @@ Region_Error = Error;
|
||||
SB_RIGHT = 7;
|
||||
SB_ENDSCROLL = 8;
|
||||
|
||||
SBS_HORZ = 0;
|
||||
SBS_VERT = 1;
|
||||
SBS_TOPALIGN = 2;
|
||||
SBS_LEFTALIGN = 2;
|
||||
SBS_BOTTOMALIGN = 4;
|
||||
SBS_RIGHTALIGN = 4;
|
||||
SBS_SIZEBOXTOPLEFTALIGN = 2;
|
||||
SBS_SIZEBOXBOTTOMRIGHTALIGN = 4;
|
||||
SBS_SIZEBOX = 8;
|
||||
SBS_SIZEGRIP = $10;
|
||||
|
||||
SIF_Range = 1;
|
||||
SIF_PAGE = 2;
|
||||
@ -1361,6 +1371,10 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.5 2001/02/01 16:45:19 lazarus
|
||||
Started the code completion.
|
||||
Shane
|
||||
|
||||
Revision 1.4 2000/09/10 23:08:30 lazarus
|
||||
MWE:
|
||||
+ Added CreateCompatibeleBitamp function
|
||||
|
@ -37,13 +37,81 @@ uses vclglobals, classes, sysutils, Graphics, LMessages, Controls, forms;
|
||||
type
|
||||
TEditCharCase = (ecNormal, ecUppercase, ecLowerCase);
|
||||
TScrollStyle = (ssNone, ssHorizontal, ssVertical, ssBoth);
|
||||
TScrollBar = class(TWinControl)
|
||||
private
|
||||
fOwner: TControl;
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
end;
|
||||
TScrollCode = (scLineUp, scLineDown, scPageUp, scPageDown, scPosition,
|
||||
scTrack, scTop, scBottom, scEndScroll);
|
||||
|
||||
TScrollEvent = procedure(Sender: TObject; ScrollCode: TScrollCode;
|
||||
var ScrollPos: Integer) of object;
|
||||
|
||||
|
||||
TScrollBar = class(TWinControl)
|
||||
private
|
||||
FKind: TScrollBarKind;
|
||||
FPosition: Integer;
|
||||
FMin: Integer;
|
||||
FMax: Integer;
|
||||
FPageSize: Integer;
|
||||
FRTLFactor: Integer;
|
||||
FSmallChange: TScrollBarInc;
|
||||
FLargeChange: TScrollBarInc;
|
||||
FOnChange: TNotifyEvent;
|
||||
FOnScroll: TScrollEvent;
|
||||
procedure DoScroll(var Message: TLMScroll);
|
||||
function NotRightToLeft: Boolean;
|
||||
procedure SetKind(Value: TScrollBarKind);
|
||||
procedure SetMax(Value: Integer);
|
||||
procedure SetMin(Value: Integer);
|
||||
procedure SetPosition(Value: Integer);
|
||||
procedure SetPageSize(Value: Integer);
|
||||
procedure CNHScroll(var Message: TLMHScroll); message CN_HSCROLL;
|
||||
procedure CNVScroll(var Message: TLMVScroll); message CN_VSCROLL;
|
||||
procedure CNCtlColorScrollBar(var Message: TLMessage); message CN_CTLCOLORSCROLLBAR;
|
||||
procedure WMEraseBkgnd(var Message: TLMEraseBkgnd); message LM_ERASEBKGND;
|
||||
protected
|
||||
procedure CreateParams(var Params: TCreateParams); override;
|
||||
procedure CreateWnd; override;
|
||||
procedure Change; dynamic;
|
||||
procedure Scroll(ScrollCode: TScrollCode; var ScrollPos: Integer); dynamic;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure SetParams(APosition, AMin, AMax: Integer);
|
||||
published
|
||||
property Align;
|
||||
property Anchors;
|
||||
property Ctl3D;
|
||||
property DragCursor;
|
||||
property DragKind;
|
||||
property DragMode;
|
||||
property Enabled;
|
||||
property Kind: TScrollBarKind read FKind write SetKind default sbHorizontal;
|
||||
property LargeChange: TScrollBarInc read FLargeChange write FLargeChange default 1;
|
||||
property Max: Integer read FMax write SetMax default 100;
|
||||
property Min: Integer read FMin write SetMin default 0;
|
||||
property PageSize: Integer read FPageSize write SetPageSize;
|
||||
property ParentCtl3D;
|
||||
property ParentShowHint;
|
||||
property PopupMenu;
|
||||
property Position: Integer read FPosition write SetPosition default 0;
|
||||
property ShowHint;
|
||||
property SmallChange: TScrollBarInc read FSmallChange write FSmallChange default 1;
|
||||
property TabOrder;
|
||||
property TabStop default True;
|
||||
property Visible;
|
||||
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
||||
property OnDragDrop;
|
||||
property OnDragOver;
|
||||
property OnEndDrag;
|
||||
property OnEnter;
|
||||
property OnExit;
|
||||
property OnKeyDown;
|
||||
property OnKeyPress;
|
||||
property OnKeyUp;
|
||||
property OnScroll: TScrollEvent read FOnScroll write FOnScroll;
|
||||
property OnStartDrag;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
TCustomGroupBox = class (TWinControl) {class(TCustomControl) }
|
||||
public
|
||||
@ -432,6 +500,8 @@ type
|
||||
|
||||
implementation {*******}
|
||||
|
||||
uses LCLLinux;
|
||||
|
||||
|
||||
type
|
||||
TSelection = record
|
||||
@ -472,6 +542,10 @@ var
|
||||
aColors : Array[1..10] of TColor;
|
||||
ColorNum : Integer;
|
||||
|
||||
const
|
||||
|
||||
SScrollBarRange = 'ScrollBar property out of range';
|
||||
|
||||
{$I customgroupbox.inc}
|
||||
{$I customcombobox.inc}
|
||||
{$I customlistbox.inc}
|
||||
@ -495,6 +569,10 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.12 2001/02/01 16:45:19 lazarus
|
||||
Started the code completion.
|
||||
Shane
|
||||
|
||||
Revision 1.11 2001/01/28 21:06:07 lazarus
|
||||
Changes for TComboBox events KeyPress Focus.
|
||||
Shane
|
||||
|
@ -45,7 +45,7 @@ csEdit = 6;
|
||||
csForm= 7;
|
||||
csLabel = 8;
|
||||
csgtkTable = 9;
|
||||
csHScrollBar = 10;
|
||||
csScrollBar = 10;
|
||||
csListView = 11;
|
||||
csMainForm = 12;
|
||||
csMemo = 13;
|
||||
@ -60,7 +60,7 @@ csSpinedit = 21;
|
||||
csStatusBar = 22;
|
||||
csTable = 23;
|
||||
csToggleBox = 24;
|
||||
csVScrollBar = 25;
|
||||
//csVScrollBar = 25;
|
||||
csFrame = 26;
|
||||
csButtonBox = 27;
|
||||
csCanvas = 28;
|
||||
|
Loading…
Reference in New Issue
Block a user