Added a TViewColumn editor to be used in the object inspector as TViewColumn's property editor.

Shane

git-svn-id: trunk@560 -
This commit is contained in:
lazarus 2001-12-31 22:43:00 +00:00
parent 5a77b46dab
commit 9620add8e6
9 changed files with 556 additions and 14 deletions

2
.gitattributes vendored
View File

@ -104,6 +104,7 @@ examples/toolbar.pp svneol=native#text/pascal
examples/trackbar.pp svneol=native#text/pascal
ide/breakpointsdlg.pp svneol=native#text/pascal
ide/codetemplatedialog.pp svneol=native#text/pascal
ide/columndlg.pp svneol=native#text/pascal
ide/compiler.pp svneol=native#text/pascal
ide/compileroptions.pp svneol=native#text/pascal
ide/compreg.pp svneol=native#text/pascal
@ -141,6 +142,7 @@ ide/projectopts.lrs svneol=native#text/pascal
ide/projectopts.pp svneol=native#text/pascal
ide/runparamsopts.pas svneol=native#text/pascal
ide/splash.pp svneol=native#text/pascal
ide/tcolumndlg1.lfm svneol=native#text/plain
ide/tinsertwatch.lfm svneol=native#text/plain
ide/transfermacros.pp svneol=native#text/pascal
ide/twatchesdlg.lfm svneol=native#text/plain

380
ide/columndlg.pp Normal file
View File

@ -0,0 +1,380 @@
unit columndlg;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, LResources, ComCtrls,
StdCtrls, Buttons, ExtCtrls, Arrow;
type
TColumnDlg1 = class(TForm)
Listbox1: TLISTBOX;
Label1: TLABEL;
Edit1: TEDIT;
Label2: TLABEL;
Edit2: TEDIT;
Button1: TBUTTON;
Button2: TBUTTON;
Radiogroup1: TRADIOGROUP;
Button3: TBUTTON;
Button4: TBUTTON;
btnOK : TBitBtn;
btnCancel : TBitBtn;
private
{ private declarations }
FItems : TList;
FSelectedIndex : Integer;
Procedure DisplayColumn(Value : Integer);
protected
procedure Button1OnClick(sender : TObject);
procedure Button2OnClick(sender : TObject);
procedure Button3OnClick(sender : TObject);
procedure Button4OnClick(sender : TObject);
procedure RadioGroup1OnClick(sender : TObject);
procedure Listbox1OnClick(sender : TObject);
Procedure Edit1OnChange(Sender : TObject);
Procedure Edit2OnChange(Sender : TObject);
Procedure FormOnShow(Sender : TObject);
public
{ public declarations }
constructor Create(AOwner : TComponent); override;
property Items : TList read FItems write FItems;
end;
var
ColumnDlg1: TColumnDlg1;
implementation
constructor TColumnDlg1.Create(AOwner : TComponent);
Begin
inherited;
// if LazarusResources.Find(Classname)=nil then
begin
Caption := 'Column Editor';
Width := 400;
Height := 345;
OnShow := @FormOnShow;
Listbox1 := TListBox.Create(self);
with Listbox1 do
Begin
Parent := Self;
left := 1;
Width := 170;
Top := 1;
Height := 300;
Visible := True;
OnClick := @Listbox1OnClick;
end;
Label1 := TLabel.Create(self);
with Label1 do
Begin
Parent := self;
Caption := 'Caption';
Left := self.width div 2;
Top := 15;
Visible := True;
end;
Edit1 := TEdit.Create(self);
with Edit1 do
Begin
Parent := Self;
Text := '';
Left := self.Width div 2;
Height := 25;
Top := Label1.Top+Label1.Height+5;
Visible := True;
OnChange := @Edit1OnChange;
end;
Label2 := TLabel.Create(self);
with Label2 do
Begin
Parent := self;
Caption := 'Width';
Left := self.width div 2;
Top := Edit1.Top+Edit1.Height+5;
Visible := True;
end;
Edit2 := TEdit.Create(self);
with Edit2 do
Begin
Parent := Self;
Text := '';
Left := self.Width div 2;
Height := 25;
Top := Label2.Top+Label2.Height+5;
Visible := True;
OnChange := @Edit2OnChange;
end;
RadioGroup1 := TRadioGroup.Create(self);
with RadioGroup1 do
Begin
Parent := Self;
Caption := 'Alignment';
Left := self.Width div 2;
Top := Edit2.Top+Edit2.Height+5;
Visible := True;
Columns := 3;
Height := 50;
Width := 200;
Items.Add('Left');
Items.Add('Center');
Items.Add('Right');
ItemIndex := 0;
OnClick := @RadioGroup1OnClick;
end;
Button1 := TButton.Create(self);
with Button1 do
Begin
Parent := self;
Caption := 'Add';
Left := self.width div 2;
Top := RadioGroup1.Top+RadioGroup1.Height+5;
Visible := True;
OnClick := @Button1OnClick;
end;
Button2 := TButton.Create(self);
with Button2 do
Begin
Parent := self;
Caption := 'Delete';
Left := Button1.Left+Button1.Width+5;
Top := Button1.Top;
Visible := True;
OnClick := @Button2OnClick;
end;
Button3 := TButton.Create(self);
with Button3 do
Begin
Parent := self;
Caption := 'Move up';
Left := 5;
Top := ListBox1.Top+Listbox1.Height+5;
Visible := True;
OnClick := @Button3OnClick;
end;
Button4 := TButton.Create(self);
with Button4 do
Begin
Parent := self;
Caption := 'Move down';
Left := Button3.Left+Button3.Width+5;
Top := Button3.Top;
Visible := True;
OnClick := @Button4OnClick;
end;
btnOK := TBitbtn.Create(self);
with btnOK do
Begin
Parent := self;
Caption := 'OK';
Left := self.Width div 2+5;
Top := Button3.Top;
Visible := True;
kind := bkOK;
end;
btnCancel := TBitbtn.Create(self);
with btnCancel do
Begin
Parent := self;
Caption := 'Cancel';
Left := btnOK.left + btnOK.Width + 5;
Top :=btnOK.top;
Visible := True;
Kind := bkCancel;
end;
end;
FItems := TList.Create;
FSelectedIndex:= -1;
end;
procedure TColumnDlg1.Button1OnClick(sender : TObject);
var
ViewColumn : TViewColumn;
Begin
//add
ViewColumn := TViewColumn.Create;
ViewColumn.Caption := 'Caption';
FSelectedIndex := FItems.Add(ViewColumn);
Listbox1.Items.Add(ViewColumn.Caption);
Listbox1.Selected[FSelectedIndex] := True;
DisplayColumn(FSelectedIndex);
end;
procedure TColumnDlg1.Listbox1OnClick(sender : TObject);
var
I : Integer;
begin
Edit1.ReadOnly := True;
FSelectedIndex := -1;
if Listbox1.SelCount = 0 then Exit;
Edit1.ReadOnly := False;
I := 0;
While not Listbox1.Selected[i] do
inc(i);
DisplayColumn(I);
end;
Procedure TColumnDlg1.Edit1OnChange(Sender : TObject);
Var
ViewColumn : TViewColumn;
begin
if FSelectedIndex = -1 then Exit;
ViewColumn := TViewColumn(FItems.Items[FSelectedIndex]);
ViewColumn.Caption := Edit1.Caption;
Listbox1.Items[FSelectedIndex] := Edit1.Caption;
Listbox1.Selected[FSelectedIndex] := True;
end;
Procedure TColumnDlg1.Edit2OnChange(Sender : TObject);
Var
ViewColumn : TViewColumn;
begin
if FSelectedIndex = -1 then Exit;
ViewColumn := TViewColumn(FItems.Items[FSelectedIndex]);
if Edit2.Caption = '' then
ViewColumn.Width := 0
else
try
ViewColumn.Width := StrtoInt(Edit2.Caption);
except
raise Exception.Create('Invalid numeric Value');
Edit2.Caption := '0';
end;
end;
procedure TColumnDlg1.Button2OnClick(sender : TObject);
var
Index : Integer;
begin
//delete
if FSelectedIndex = -1 then Exit;
Index := FSelectedIndex;
FSelectedIndex := -1;
FItems.Delete(Index);
Listbox1.Items.Delete(Index);
if Index > 0 then
Listbox1.Selected[Index-1] := True;
DisplayColumn(Index-1);
end;
procedure TColumnDlg1.Button3OnClick(sender : TObject);
Var
ViewColumn : TViewColumn;
Index : Integer;
begin
//move up
if FSelectedIndex <= 0 then Exit;
Index := FSelectedIndex;
FSelectedIndex := -1;
ViewColumn := TViewColumn(FItems.Items[Index]);
FItems.Insert(Index-1,ViewColumn);
FItems.Delete(Index+1);
Listbox1.Items.Insert(Index-1,ViewColumn.Caption);
Listbox1.Items.Delete(Index+1);
Listbox1.Selected[Index-1] := True;
DisplayColumn(Index-1);
end;
procedure TColumnDlg1.Button4OnClick(sender : TObject);
Var
ViewColumn : TViewColumn;
Index : Integer;
begin
//move down
if FSelectedIndex = -1 then Exit;
if (FSelectedIndex >= Listbox1.Items.Count-1) then Exit;
Index := FSelectedIndex;
FSelectedIndex := -1;
ViewColumn := TViewColumn(FItems.Items[Index]);
FItems.Insert(Index+2,ViewColumn);
FItems.Delete(Index);
Listbox1.Items.Insert(Index+2,ViewColumn.Caption);
Listbox1.Items.Delete(Index);
Listbox1.Selected[Index+1] := True;
DisplayColumn(Index+1);
end;
Procedure TColumnDlg1.DisplayColumn(Value : Integer);
Var
ViewColumn : TViewColumn;
begin
FSelectedIndex := -1;
if Value = -1 then exit;
ViewColumn := TViewColumn(FItems.Items[Value]);
Edit1.Caption := ViewColumn.Caption;
Edit2.Caption := Inttostr(ViewColumn.Width);
case ViewColumn.Alignment of
caLEft : RadioGroup1.ItemIndex := 0;
caCenter:RadioGroup1.ItemIndex := 1;
caRight : RadioGroup1.ItemIndex := 2;
end; //case
FSelectedIndex := Value;
end;
procedure TColumnDlg1.RadioGroup1OnClick(sender : TObject);
Var
ViewColumn : TViewColumn;
begin
if FSelectedIndex = -1 then Exit;
ViewColumn := TViewColumn(FItems.Items[FSelectedIndex]);
case RadioGroup1.ItemIndex of
0 : ViewColumn.Alignment := caLeft;
1 : ViewColumn.Alignment := caCenter;
2 : ViewColumn.Alignment := caRight;
end;
end;
Procedure TColumnDlg1.FormOnShow(Sender : TObject);
var
I : Integer;
ViewColumn : TViewColumn;
begin
//clear the listbox and display the items if any...
Listbox1.Items.Clear;
for I := 0 to FItems.Count-1 do
Begin
ViewColumn := TViewColumn(FItems.Items[I]);
Listbox1.Items.Add(ViewColumn.Caption);
end;
if Listbox1.Items.Count > 0 then
begin
Listbox1.Selected[0] := True;
DisplayColumn(0);
end;
end;
initialization
{ $I columndlg.lrs}
end.

View File

@ -40,7 +40,7 @@ uses
PropEdits, ControlSelection, UnitEditor, CompilerOptions, EditorOptions,
EnvironmentOpts, TransferMacros, KeyMapping, ProjectOpts, IDEProcs, Process,
UnitInfoDlg, Debugger, DBGWatch, RunParamsOpts, ExtToolDialog, MacroPromptDlg,
LMessages, ProjectDefs, Watchesdlg, BreakPointsdlg;
LMessages, ProjectDefs, Watchesdlg, BreakPointsdlg,ColumnDlg;
const
Version_String = '0.8.1 alpha';
@ -1919,6 +1919,10 @@ end;
Procedure TMainIDE.mnuViewMessagesClick(Sender : TObject);
Begin
MessagesView.Show;
if Not Assigned(ColumnDlg1) then
ColumnDlg1 := TColumnDlg1.Create(self);
ColumnDlg1.ShowModal;
// CreateLFM(ColumnDlg1);
End;
@ -5490,6 +5494,10 @@ end.
=======
$Log$
Revision 1.195 2001/12/31 22:42:59 lazarus
Added a TViewColumn editor to be used in the object inspector as TViewColumn's property editor.
Shane
Revision 1.194 2001/12/28 11:01:20 lazarus
MG: fixed save as with lfm and lrs files
@ -5507,6 +5515,10 @@ end.
<<<<<<< main.pp
$Log$
Revision 1.195 2001/12/31 22:42:59 lazarus
Added a TViewColumn editor to be used in the object inspector as TViewColumn's property editor.
Shane
Revision 1.194 2001/12/28 11:01:20 lazarus
MG: fixed save as with lfm and lrs files

121
ide/tcolumndlg1.lfm Normal file
View File

@ -0,0 +1,121 @@
object TCOLUMNDLG1
CAPTION = 'Column Editor'
COLOR = -2147483633
CLIENTHEIGHT = 338
CLIENTWIDTH = 401
LEFT = 207
HEIGHT = 338
TOP = 328
WIDTH = 401
object TLISTBOX
BORDERSTYLE = bssingle
ONCLICK = nil
LEFT = 1
HEIGHT = 300
TOP = 1
WIDTH = 170
end
object TLABEL
CAPTION = 'Caption'
FONT.COLOR = -2147483640
LEFT = 200
HEIGHT = 17
TOP = 15
WIDTH = 65
end
object TEDIT
ONCHANGE = nil
LEFT = 200
HEIGHT = 25
TOP = 37
WIDTH = 160
end
object TLABEL
CAPTION = 'Width'
FONT.COLOR = -2147483640
LEFT = 200
HEIGHT = 17
TOP = 67
WIDTH = 65
end
object TEDIT
ONCHANGE = nil
LEFT = 200
HEIGHT = 25
TOP = 89
WIDTH = 160
end
object TRADIOGROUP
CAPTION = 'Alignment'
ITEMINDEX = 0
ITEMS.Strings = (
'Left'
'Center'
'Right'
)
COLUMNS = 3
ONCLICK = nil
LEFT = 200
HEIGHT = 50
TOP = 119
WIDTH = 200
end
object TBUTTON
CAPTION = 'Add'
FONT.COLOR = -2147483640
ONCLICK = nil
LEFT = 200
HEIGHT = 25
TOP = 174
WIDTH = 75
end
object TBUTTON
CAPTION = 'Delete'
FONT.COLOR = -2147483640
ONCLICK = nil
LEFT = 280
HEIGHT = 25
TOP = 174
WIDTH = 75
end
object TBUTTON
CAPTION = 'Move up'
FONT.COLOR = -2147483640
ONCLICK = nil
LEFT = 5
HEIGHT = 25
TOP = 306
WIDTH = 75
end
object TBUTTON
CAPTION = 'Move down'
FONT.COLOR = -2147483640
ONCLICK = nil
LEFT = 85
HEIGHT = 25
TOP = 306
WIDTH = 75
end
object TBITBTN
KIND = bkok
SPACING = 3
MODALRESULT = 1
CAPTION = 'OK'
FONT.COLOR = -2147483640
LEFT = 205
HEIGHT = 25
TOP = 306
WIDTH = 75
end
object TBITBTN
KIND = bkcancel
SPACING = 3
MODALRESULT = 2
CAPTION = 'Cancel'
FONT.COLOR = -2147483640
LEFT = 285
HEIGHT = 25
TOP = 306
WIDTH = 75
end
end

View File

@ -428,6 +428,8 @@ type
FCaption: String;
FAlignment: TColumnAlignment;
FOnChange: TNotifyEvent;
FWidth: Integer;
procedure SetWidth(const AValue: Integer);
procedure SetCaption(const AValue: String);
procedure SetAlignment(const AValue: TColumnAlignment);
@ -435,6 +437,7 @@ type
constructor Create;
destructor Destroy; override;
Property Caption : String read FCaption write SetCaption;
Property Width : Integer read FWidth write SetWidth;
property Alignment : TColumnAlignment read FAlignment write SetAlignment;
property OnChange : TNotifyEvent read FOnChange write FOnChange;
@ -1019,6 +1022,10 @@ end.
{ =============================================================================
$Log$
Revision 1.12 2001/12/31 22:43:00 lazarus
Added a TViewColumn editor to be used in the object inspector as TViewColumn's property editor.
Shane
Revision 1.11 2001/12/21 18:16:59 lazarus
Added TImage class
Shane

View File

@ -63,15 +63,15 @@ Procedure TBitBtn.SetKind(Value : TBitBtnKind);
var
Bitmap1 : TBitmap;
Begin
HandleNeeded;
// HandleNeeded;
FKind := Value;
Assert(False, 'Trace:SETKIND');
if FKind = bkCustom then Exit;
if Glyph <> nil then Glyph.free;
Bitmap1 := TBitmap.Create;
Bitmap1.Handle :=
CreatePixmapIndirect(@BitBtnImages[FKInd], ColorToRGB(clBtnFace));
Bitmap1.Handle := CreatePixmapIndirect(@BitBtnImages[FKInd], ColorToRGB(clBtnFace));
Caption := BitBtnCaption[fKind];

View File

@ -205,17 +205,18 @@ procedure TCustomRadioGroup.SetItemIndex (Value : integer);
begin
if FReading then FItemIndex:=Value
else begin
if (Value < -1) or (Value >= FItems.Count)
then
raise Exception.Create(
'TCustomRadioGroup.SetItemIndex : Index out of bounds');
if (Value < -1) or (Value >= FItems.Count) then
raise Exception.Create('TCustomRadioGroup.SetItemIndex : Index out of bounds');
if (HandleAllocated) and (Value <> FItemIndex) then begin
if (FItemIndex <> -1)
then TRadioButton (FButtonList [FItemIndex]).Checked := false;
if (HandleAllocated) and (Value <> FItemIndex) then
begin
if (FItemIndex <> -1) then
TRadioButton (FButtonList [FItemIndex]).Checked := false;
FItemIndex := Value;
if (Value <> -1)
then TRadioButton (FButtonList [Value]).Checked := true;
if (Value <> -1) then
TRadioButton (FButtonList [Value]).Checked := true;
ItemsChanged(self);
end
else FItemIndex := Value;
end;
@ -292,6 +293,10 @@ end;
{
$Log$
Revision 1.8 2001/12/31 22:43:00 lazarus
Added a TViewColumn editor to be used in the object inspector as TViewColumn's property editor.
Shane
Revision 1.7 2001/10/19 14:27:43 lazarus
MG: fixed customradiogroup OnClick + ItemIndex

View File

@ -4,6 +4,8 @@ constructor TViewColumn.Create;
begin
inherited;
FAlignment :=caLEft;
FCaption := '';
FWidth := 50;
end;
destructor TViewColumn.Destroy;
@ -29,3 +31,12 @@ begin
OnChange(self);
end;
procedure TViewColumn.SetWidth(const AValue: Integer);
begin
if FWidth = AValue then Exit;
FWidth := AValue;
if Assigned(OnChange) then
OnChange(self);
end;

View File

@ -1792,7 +1792,7 @@ begin
Assert(False, Format('Trace:[TWinControl.HandleNeeded] Sombody set Parent := Self in %s. DONT DO THAT !!', [Classname]));
end
else begin
if (Parent <> nil)
if (Parent <> nil)
then Parent.HandleNeeded;
end;
CreateHandle;
@ -1957,6 +1957,10 @@ end;
{ =============================================================================
$Log$
Revision 1.47 2001/12/31 22:43:00 lazarus
Added a TViewColumn editor to be used in the object inspector as TViewColumn's property editor.
Shane
Revision 1.46 2001/12/28 15:12:02 lazarus
MG: LM_SIZE and LM_MOVE messages are now send directly, not queued