mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 14:18:17 +02:00
The Speedbutton now has a numglyphs setting.
I started the TStringPropertyEditor git-svn-id: trunk@91 -
This commit is contained in:
parent
4187ae3f25
commit
2f4f81f07e
@ -286,6 +286,7 @@ begin
|
||||
Visible:=false;
|
||||
Enabled:=false;
|
||||
OnClick:=@ValueButtonClick;
|
||||
Caption := '...';
|
||||
Parent:=Self;
|
||||
end;
|
||||
|
||||
|
@ -583,6 +583,19 @@ type
|
||||
function GetAttributes: TPropertyAttributes; override;
|
||||
end;
|
||||
|
||||
{ TStringsPropertyEditor
|
||||
PropertyEditor editor for the TStrings property. Brings up the dialog for entering test. }
|
||||
|
||||
TStringsPropertyEditor = class(TClassPropertyEditor)
|
||||
public
|
||||
procedure Edit; override;
|
||||
function GetValue: string; override;
|
||||
function GetAttributes: TPropertyAttributes; override;
|
||||
|
||||
procedure GetValues(Proc: TGetStringProc);
|
||||
procedure SetValue(const NewValue: string); override;
|
||||
|
||||
end;
|
||||
|
||||
//==============================================================================
|
||||
|
||||
@ -802,6 +815,7 @@ type
|
||||
FPenStyle:TPenStyle;
|
||||
FTabOrder:integer;
|
||||
FCaption:TCaption;
|
||||
FLines:TStrings;
|
||||
function PTypeInfos(const PropName:string):PTypeInfo;
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
@ -814,6 +828,7 @@ type
|
||||
property PenStyle:TPenStyle read FPenStyle;
|
||||
property TabOrder:integer read FTabOrder;
|
||||
property Caption:TCaption read FCaption;
|
||||
property Lines:TStrings read FLines;
|
||||
end;
|
||||
|
||||
//==============================================================================
|
||||
@ -920,10 +935,8 @@ const
|
||||
TBoolPropertyEditor, // tkBool
|
||||
TInt64PropertyEditor, // tkInt64
|
||||
nil // tkQWord
|
||||
{$IFDEF VER1_1_0}
|
||||
,nil // tkDynArray
|
||||
,nil // tkInterfaceRaw
|
||||
{$ENDIF}
|
||||
);
|
||||
|
||||
// XXX ToDo: There are bugs in the typinfo.pp. Thus this workaround -------
|
||||
@ -2894,6 +2907,137 @@ begin
|
||||
Result := [paMultiSelect, paAutoUpdate, paRevertable];
|
||||
end;
|
||||
|
||||
{ TStringsPropertyEditor }
|
||||
|
||||
type
|
||||
TStringsPropEditor = class(TForm)
|
||||
public
|
||||
Memo1 : TMemo;
|
||||
OKButton : TButton;
|
||||
CancelButton : TButton;
|
||||
constructor Create(AOwner : TComponent); override;
|
||||
end;
|
||||
|
||||
constructor TStringsPropEditor.Create(AOwner : TComponent);
|
||||
Begin
|
||||
inherited;
|
||||
position := poScreenCenter;
|
||||
Height := 200;
|
||||
Width := 300;
|
||||
Memo1 := TMemo.Create(self);
|
||||
Memo1.Parent := Self;
|
||||
Memo1.Left := 0;
|
||||
Memo1.Top := 0;
|
||||
memo1.Height := Height-50;
|
||||
Memo1.Width := Width -1;
|
||||
memo1.Visible := true;
|
||||
|
||||
OKButton := TButton.Create(self);
|
||||
with OKButton do
|
||||
Begin
|
||||
Parent := self;
|
||||
Caption := '&OK';
|
||||
ModalResult := mrOK;
|
||||
Left := self.width div 2;
|
||||
top := self.height -45;
|
||||
Visible := true;
|
||||
end;
|
||||
|
||||
CancelButton := TButton.Create(self);
|
||||
with CancelButton do
|
||||
Begin
|
||||
Parent := self;
|
||||
Caption := '&Cancel';
|
||||
ModalResult := mrCancel;
|
||||
Left := (self.width div 2) + 75;
|
||||
top := self.height -45;
|
||||
Visible := true;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
procedure TStringsPropertyEditor.Edit;
|
||||
type
|
||||
TGetStrFunc=function(const StrValue:string):Integer of object;
|
||||
var
|
||||
TheDialog: TStringsPropEditor;
|
||||
|
||||
I:Integer;
|
||||
Values:TStringList;
|
||||
AddValue:TGetStrFunc;
|
||||
|
||||
StringsType: PTypeInfo;
|
||||
Count : Integer;
|
||||
begin
|
||||
Writeln('edit');
|
||||
Count := 0;
|
||||
Values:=TStringList.Create;
|
||||
try
|
||||
AddValue:=@Values.Add;
|
||||
GetValues(TGetStringProc(AddValue));
|
||||
writeln('Create the TheDialog');
|
||||
TheDialog:=TStringsPropEditor.Create(Application);
|
||||
writeln('Created the TheDialog');
|
||||
TheDialog.Memo1.Lines.Assign(Values);
|
||||
TheDialog.Caption:='Strings Editor Dialog';
|
||||
try
|
||||
if (TheDialog.ShowModal = mrOK) then
|
||||
begin
|
||||
//what do I do here?
|
||||
end;
|
||||
finally
|
||||
TheDialog.Free;
|
||||
end;
|
||||
|
||||
finally
|
||||
Values.Free;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
end;
|
||||
|
||||
|
||||
procedure TStringsPropertyEditor.GetValues(Proc: TGetStringProc);
|
||||
var
|
||||
I: Integer;
|
||||
StringsType: PTypeInfo;
|
||||
begin
|
||||
Writeln('GETVALUES');
|
||||
//what do I do here?
|
||||
StringsType := GetPropType;
|
||||
with GetTypeData(StringsType)^ do
|
||||
for I := MinValue to MaxValue do Proc(GetStrValueAt(I));
|
||||
end;
|
||||
|
||||
function TStringsPropertyEditor.GetAttributes: TPropertyAttributes;
|
||||
begin
|
||||
Result := [paMultiSelect,paDialog, paRevertable];
|
||||
end;
|
||||
|
||||
|
||||
function TStringsPropertyEditor.GetValue: string;
|
||||
Begin
|
||||
Writeln('GETVALUE');
|
||||
Result := '(TStrings)';
|
||||
end;
|
||||
|
||||
procedure TStringsPropertyEditor.SetValue(const NewValue: string);
|
||||
var
|
||||
I: Integer;
|
||||
begin
|
||||
Writeln('SETVALUES');
|
||||
{ I := GetStrValueA(GetPropType, NewValue);
|
||||
if I < 0 then begin
|
||||
{raise EPropertyError.CreateRes(@SInvalidPropertyValue)};
|
||||
exit;
|
||||
end;
|
||||
SetStrValue(I);
|
||||
}
|
||||
end;
|
||||
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
||||
@ -3188,6 +3332,8 @@ initialization
|
||||
nil,'',TTabOrderPropertyEditor);
|
||||
RegisterPropertyEditor(DummyClassForPropTypes.PTypeInfos('shortstring'),
|
||||
nil,'',TCaptionPropertyEditor);
|
||||
RegisterPropertyEditor(DummyClassForPropTypes.PTypeInfos('TStrings'),
|
||||
nil,'Lines',TStringsPropertyEditor);
|
||||
|
||||
finalization
|
||||
PropertyEditorMapperList.Free; PropertyEditorMapperList:=nil;
|
||||
|
@ -33,42 +33,69 @@ uses
|
||||
|
||||
type
|
||||
{--------------------------------------------
|
||||
Created by Shane Miller
|
||||
This class is used for adding controls to the toolbar to be
|
||||
dropped onto a form
|
||||
---------------------------------------------}
|
||||
TIDEComponent = class(TObject)
|
||||
private
|
||||
{The speedbutton that's displayed on the IDE control bar}
|
||||
FSpeedButton : TSpeedButton;
|
||||
{This is the @link(TRegisteredComponent) from compreg.pp.}
|
||||
FRegisteredComponent : TRegisteredComponent;
|
||||
protected
|
||||
{Loads the image (from a resource) into a @link(TPixMap)}
|
||||
Function LoadImageintoPixmap : TPixmap;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
Function _Speedbutton(AOwner : TComponent; nParent: TWinControl): TSpeedButton; Virtual;
|
||||
{Public access to create the Speedbutton.}
|
||||
Function _Speedbutton(AOwner : TComponent; nParent: TWinControl): TSpeedButton;
|
||||
{Public access to @link(FSpeedbutton)}
|
||||
property SpeedButton : TSpeedButton read FSpeedButton write FSPeedbutton;
|
||||
{Public access to @link(FRegisteredComponent)}
|
||||
property RegisteredComponent : TRegisteredComponent read FRegisteredComponent write FRegisteredComponent;
|
||||
|
||||
end;
|
||||
|
||||
{-------------------------------------------
|
||||
Created by Shane Miller
|
||||
This class keeps a list of TIDeComponents
|
||||
--------------------------------------------}
|
||||
TIdeCompList = Class(TObject)
|
||||
private
|
||||
{The list of @link(TIdeComponent)s used in the IDE.}
|
||||
FItems : TList;
|
||||
{The count of @link(TIdeComponent)s used in the IDE.}
|
||||
FCount : Integer;
|
||||
{Used to count the @link(TIdeComponent)s used in the IDE. Checks FItems.Count}
|
||||
Function GetCount : Integer;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
|
||||
{You can pass the Speedbutton and find the @link(TIdeComponent).
|
||||
This can be used when the Speedbutton is clicked and you want to find out
|
||||
what the @link(TRegisteredComponent) is.}
|
||||
function FindCompbySpeedbutton(Value : TSpeedButton) : TIDEComponent;
|
||||
|
||||
{You can pass the index and find the @link(TIdeComponent).
|
||||
This is used because the tag of the speedbutton stores it's index
|
||||
in this list}
|
||||
function FindCompbyIndex(Value : Integer) : TIDEComponent;
|
||||
|
||||
{You can pass the @link(TRegisteredComponent) and it'll return the @link(TIdeComponent).
|
||||
This can be used if you are running through the list of RegisteredComponents and
|
||||
want to find the speedbutton associated with it.}
|
||||
function FindCompbyRegComponent(Value : TRegisteredComponent) : TIDEComponent;
|
||||
|
||||
{This is used to add a @link(TIdeComponent) to the @link(FItems).}
|
||||
function Add(Value : TObject) : Integer;
|
||||
|
||||
{This is used to delete a @link(TIdeComponent) from the @link(FItems).}
|
||||
function Delete(Value : TObject) : Boolean;
|
||||
|
||||
{Calls @link(GetCount)}
|
||||
property Count : Integer read GetCount;
|
||||
end;
|
||||
|
||||
|
10
ide/main.pp
10
ide/main.pp
@ -276,7 +276,6 @@ begin
|
||||
LoadMainMenu;
|
||||
|
||||
MouseDownControl:=nil;
|
||||
|
||||
Bitmap1 := TBitmap.Create;
|
||||
Bitmap1.Handle := CreatePixmapIndirect(@IMGOK_Check, ColorToRGB(clBtnFace));
|
||||
|
||||
@ -315,7 +314,6 @@ begin
|
||||
|
||||
For I := 0 to RegCompList.PageCount-1 do
|
||||
Begin
|
||||
Writeln('I = '+inttostr(i));
|
||||
RegCompPage := RegCompList.Pages[i];
|
||||
if I = 0 then
|
||||
Notebook1.Pages.Strings[i] := RegCompPage.Name
|
||||
@ -339,6 +337,7 @@ begin
|
||||
|
||||
for x := 0 to RegCompPage.Count-1 do //for every component on the page....
|
||||
begin
|
||||
writeln('X = '+inttostr(x));
|
||||
RegComp := RegCompPage.Items[x];
|
||||
IDEComponent := TIDEComponent.Create;
|
||||
IdeComponent.RegisteredComponent := RegComp;
|
||||
@ -489,6 +488,7 @@ begin
|
||||
Left := Speedbutton4_2.Left + 13;
|
||||
OnClick := @mnuSaveCLicked;
|
||||
Glyph := Pixmap1;
|
||||
NumGlyphs := 2;
|
||||
Visible := True;
|
||||
Flat := true;
|
||||
Name := 'Speedbutton5';
|
||||
@ -510,6 +510,7 @@ begin
|
||||
Left := Speedbutton5.left + 26;
|
||||
OnClick := @mnuSaveAllCLicked;
|
||||
Glyph := Pixmap1;
|
||||
NumGlyphs := 2;
|
||||
Visible := True;
|
||||
Flat := true;
|
||||
Name := 'Speedbutton6';
|
||||
@ -573,6 +574,7 @@ begin
|
||||
Left := Speedbutton8.Left + 26;
|
||||
//OnClick := @mnuNewFormCLicked;
|
||||
Glyph := Pixmap1;
|
||||
NumGlyphs := 2;
|
||||
Visible := True;
|
||||
Flat := true;
|
||||
Name := 'RunSpeedbutton';
|
||||
@ -1772,6 +1774,10 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.30 2001/01/03 18:44:54 lazarus
|
||||
The Speedbutton now has a numglyphs setting.
|
||||
I started the TStringPropertyEditor
|
||||
|
||||
Revision 1.29 2000/12/29 20:43:17 lazarus
|
||||
I added the run button with an Enable and disable icon
|
||||
|
||||
|
@ -39,6 +39,11 @@ type
|
||||
TButtonLayout = (blGlyphLeft, blGlyphRight, blGlyphTop, blGlyphBottom);
|
||||
TButtonState = (bsUp, bsDisabled, bsDown, bsExclusive);
|
||||
|
||||
{TNumGlyphs holds the number of glyphs in an image. We restrict it to 4 to stay compatable
|
||||
but we don't NEED to.
|
||||
If we change this the code in SetNumGlyphs for @link(TSpeedButton) needs to be changed}
|
||||
TNumGlyphs = 1..4;
|
||||
|
||||
TButton = class(TButtonControl) //TButtoncontrol is declared in stdctrls.pp
|
||||
private
|
||||
FCancel : Boolean;
|
||||
@ -86,7 +91,12 @@ type
|
||||
TButtonGlyph = class
|
||||
private
|
||||
FOriginal : TBitmap;
|
||||
FNumGlyphs : TNumGlyphs;
|
||||
|
||||
FOnChange : TNotifyEvent;
|
||||
|
||||
Procedure SetGlyph(Value : TBitmap);
|
||||
Procedure SetNumGlyphs(Value : TNumGlyphs);
|
||||
protected
|
||||
public
|
||||
constructor Create;
|
||||
@ -96,6 +106,9 @@ type
|
||||
const Caption: string; Layout: TButtonLayout; Margin, Spacing: Integer;
|
||||
State: TButtonState; Transparent: Boolean; BiDiFlags: Longint): TRect;
|
||||
property Glyph : TBitmap read FOriginal write SetGlyph;
|
||||
property NumGlyphs : TNumGlyphs read FNumGlyphs write SetNumGlyphs;
|
||||
|
||||
property OnChange : TNotifyEvent read FOnChange write FOnChange;
|
||||
end;
|
||||
|
||||
|
||||
@ -145,6 +158,7 @@ type
|
||||
FSpacing : Integer;
|
||||
FTransparent : Boolean;
|
||||
Function GetGlyph : TBitmap;
|
||||
Function GetNumGlyphs : Integer;
|
||||
Procedure UpdateExclusive;
|
||||
Procedure UpdateTracking;
|
||||
Procedure SetAllowAllUp(Value : Boolean);
|
||||
@ -152,6 +166,7 @@ type
|
||||
Procedure SetFlat(Value : Boolean);
|
||||
Procedure SetGlyph(value : TBitmap);
|
||||
Procedure SetGroupIndex(value : Integer);
|
||||
Procedure SetNumGlyphs(value : Integer);
|
||||
//there should be a procedure called settransparent but it's not used at this point
|
||||
Procedure CMButtonPressed(var MEssage : TLMessage); message CM_BUTTONPRESSED;
|
||||
Procedure CMMouseEnter(var Message :TLMessage); message CM_MouseEnter;
|
||||
@ -159,6 +174,7 @@ type
|
||||
Procedure CMEnabledChanged(var Message: TLMessage); message CM_ENABLEDCHANGED;
|
||||
protected
|
||||
FState : TButtonState;
|
||||
Procedure GlyphChanged(Sender : TObject);
|
||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
|
||||
X, Y: Integer); override;
|
||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||
@ -177,6 +193,7 @@ type
|
||||
property Enabled;
|
||||
property Flat : Boolean read FFlat write SetFlat default False;
|
||||
property GroupIndex : Integer read FGroupIndex write SetGroupIndex default 0;
|
||||
property NumGlyphs : Integer read GetNumGlyphs write SetNumGlyphs default 1;
|
||||
property Transparent : Boolean read FTransparent write FTransparent default false;
|
||||
property Visible;
|
||||
end;
|
||||
@ -217,6 +234,10 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.6 2001/01/03 18:44:54 lazarus
|
||||
The Speedbutton now has a numglyphs setting.
|
||||
I started the TStringPropertyEditor
|
||||
|
||||
Revision 1.5 2000/12/01 18:12:40 lazarus
|
||||
Modified Gloabal so TDesignForm isn't included anymore.
|
||||
Shane
|
||||
|
122
lcl/forms.pp
122
lcl/forms.pp
@ -273,6 +273,9 @@ function KeysToShiftState(Keys:Word): TShiftState;
|
||||
function KeyDataToShiftState(KeyData: Longint): TShiftState;
|
||||
function GetParentForm(Control:TControl): TCustomForm;
|
||||
function IsAccel(VK : Word; const Str : String): Boolean;
|
||||
function CreateLFM(AForm:TCustomForm):integer;
|
||||
function InitResourceComponent(Instance: TComponent; RootAncestor: TClass):Boolean;
|
||||
|
||||
|
||||
var
|
||||
Application : TApplication;
|
||||
@ -284,7 +287,7 @@ implementation
|
||||
|
||||
|
||||
uses
|
||||
buttons,stdctrls,interfaces {,designer};
|
||||
buttons,stdctrls,interfaces,lresources {,designer};
|
||||
|
||||
var
|
||||
FocusMessages : Boolean; //Should set it to TRUE by defualt but fpc does not handle that yet.
|
||||
@ -322,6 +325,123 @@ begin
|
||||
Result := true;
|
||||
end;
|
||||
|
||||
|
||||
//==============================================================================
|
||||
{
|
||||
This function creates a LFM file from any form.
|
||||
To create the LFC file use the program lazres or the
|
||||
LFMtoLFCfile function.
|
||||
}
|
||||
function CreateLFM(AForm:TCustomForm):integer;
|
||||
// 0 = ok
|
||||
// -1 = error while streaming AForm to binary stream
|
||||
// -2 = error while streaming binary stream to text file
|
||||
var BinStream,TxtMemStream:TMemoryStream;
|
||||
Driver: TAbstractObjectWriter;
|
||||
Writer:TWriter;
|
||||
TxtFileStream:TFileStream;
|
||||
begin
|
||||
BinStream:=TMemoryStream.Create;
|
||||
try
|
||||
try
|
||||
Driver:=TBinaryObjectWriter.Create(BinStream,4096);
|
||||
try
|
||||
Writer:=TWriter.Create(Driver);
|
||||
try
|
||||
Writer.WriteDescendent(AForm,nil);
|
||||
finally
|
||||
Writer.Free;
|
||||
end;
|
||||
finally
|
||||
Driver.Free;
|
||||
end;
|
||||
except
|
||||
Result:=-1;
|
||||
exit;
|
||||
end;
|
||||
try
|
||||
// transform binary to text and save LFM file
|
||||
TxtMemStream:=TMemoryStream.Create;
|
||||
TxtFileStream:=TFileStream.Create(lowercase(AForm.ClassName)+'.lfm',fmCreate);
|
||||
try
|
||||
BinStream.Position:=0;
|
||||
ObjectBinaryToText(BinStream,TxtMemStream);
|
||||
TxtMemStream.Position:=0;
|
||||
TxtFileStream.CopyFrom(TxtMemStream,TxtMemStream.Size);
|
||||
finally
|
||||
TxtMemStream.Free;
|
||||
TxtFileStream.Free;
|
||||
end;
|
||||
except
|
||||
Result:=-2;
|
||||
exit;
|
||||
end;
|
||||
finally
|
||||
BinStream.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
//==============================================================================
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
||||
function InitResourceComponent(Instance: TComponent;
|
||||
RootAncestor: TClass):Boolean;
|
||||
|
||||
function InitComponent(ClassType: TClass): Boolean;
|
||||
var CompResource:LResource;
|
||||
a:integer;
|
||||
begin
|
||||
Result:=false;
|
||||
if (ClassType=TComponent) or (ClassType=RootAncestor) then exit;
|
||||
if Assigned(ClassType.ClassParent) then
|
||||
Result:=InitComponent(ClassType.ClassParent);
|
||||
CompResource:=LazarusResources.Find(Instance.ClassName);
|
||||
if (CompResource.Value='') then exit;
|
||||
if (ClassType.InheritsFrom(TForm))
|
||||
and (CompResource.ValueType<>'FORMDATA') then exit;
|
||||
with TMemoryStream.Create do
|
||||
try
|
||||
Write(CompResource.Value[1],length(CompResource.Value));
|
||||
Position:=0;
|
||||
writeln('Signature=',copy(CompResource.Value,1,4));
|
||||
Instance:=ReadComponent(Instance);
|
||||
// MG: workaround til Visible=true is default
|
||||
if Instance is TControl then
|
||||
for a:=0 to Instance.ComponentCount-1 do
|
||||
if Instance.Components[a] is TControl then
|
||||
TControl(Instance.Components[a]).Visible:=true;
|
||||
// MG end of workaround
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
// InitResourceComponent
|
||||
//var LocalizedLoading: Boolean;
|
||||
begin
|
||||
//GlobalNameSpace.BeginWrite; // hold lock across all ancestor loads (performance)
|
||||
try
|
||||
//LocalizedLoading:=(Instance.ComponentState * [csInline,csLoading])=[];
|
||||
//if LocalizedLoading then BeginGloabelLoading; // push new loadlist onto stack
|
||||
try
|
||||
Result:=InitComponent(Instance.ClassType);
|
||||
//if LocalizedLoading then NotifyGloablLoading; // call Loaded
|
||||
finally
|
||||
//if LocalizedLoading then EndGloablLoading; // pop loadlist off stack
|
||||
end;
|
||||
finally
|
||||
//GlobalNameSpace.EndWrite;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
||||
|
||||
|
||||
{$I form.inc}
|
||||
{$I Customform.inc}
|
||||
{$I screen.inc}
|
||||
|
@ -19,6 +19,9 @@ inherited Destroy;
|
||||
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TButtonGlyph SetGlyph }
|
||||
{------------------------------------------------------------------------------}
|
||||
Procedure TButtonGlyph.SetGlyph(Value : TBitmap);
|
||||
Begin
|
||||
if FOriginal = Value then exit;
|
||||
@ -27,19 +30,45 @@ FOriginal := Value;
|
||||
//FOriginal.Assign(Value);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TButtonGlyph Draw }
|
||||
{------------------------------------------------------------------------------}
|
||||
Function TButtonGlyph.Draw(Canvas: TCanvas; const Client: TRect; const Offset: TPoint;
|
||||
const Caption: string; Layout: TButtonLayout; Margin, Spacing: Integer;
|
||||
State: TButtonState; Transparent: Boolean; BiDiFlags: Longint): TRect;
|
||||
var
|
||||
W,H : Integer;
|
||||
Begin
|
||||
|
||||
if State= bsDisabled then
|
||||
if NumGlyphs > 1 then
|
||||
Begin
|
||||
if (TPixMap(FOriginal).Width > 25) then
|
||||
Canvas.Copyrect(Client, TPixmap(FOriginal).Canvas, Rect(25, 0, 50, 25))
|
||||
else
|
||||
Canvas.Copyrect(Client, TPixmap(FOriginal).Canvas, Rect(0, 0, 25, 25));
|
||||
W := TPixMap(FOriginal).Width;
|
||||
W := W div NumGlyphs;
|
||||
|
||||
H := TPixMap(FOriginal).Height;
|
||||
if (State=bsDown) and (NumGlyphs < 3) then State := bsUp;
|
||||
|
||||
if State= bsDisabled then
|
||||
Canvas.Copyrect(Client, TPixmap(FOriginal).Canvas, Rect(W, 0, (2*W)-1, H-1))
|
||||
else
|
||||
if State=bsDown then
|
||||
Canvas.Copyrect(Client, TPixmap(FOriginal).Canvas, Rect(2*W, 0, (3*W)-1, H-1))
|
||||
else
|
||||
Canvas.Copyrect(Client, TPixmap(FOriginal).Canvas, Rect(0, 0, w-1, H-1));
|
||||
end
|
||||
else
|
||||
Canvas.Copyrect(Client, TPixmap(FOriginal).Canvas, Rect(0, 0, 25, 25));
|
||||
end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TButtonGlyph SetNumGlyphs }
|
||||
{------------------------------------------------------------------------------}
|
||||
Procedure TButtonGlyph.SetNumGlyphs(Value : TNumGlyphs);
|
||||
Begin
|
||||
if Value <> FNumGlyphs then
|
||||
Begin
|
||||
FNumGlyphs := Value;
|
||||
if Assigned(FOnChange) then FOnChange(Glyph);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
@ -544,8 +544,12 @@ begin
|
||||
begin
|
||||
Include(FFormState, fsCreating);
|
||||
try
|
||||
// if not InitInheritedComponent(Self, TForm) then
|
||||
// raise EResNotFound.CreateFmt('Resource %s not found', [ClassName]);
|
||||
// *** New
|
||||
if not InitResourceComponent(Self, TForm) then begin
|
||||
writeln('[TCustomForm.Create] Resource '''+ClassName+''' not found');
|
||||
|
||||
end;
|
||||
// ***
|
||||
finally
|
||||
Exclude(FFormState, fsCreating);
|
||||
end;
|
||||
@ -820,6 +824,10 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.8 2001/01/03 18:44:54 lazarus
|
||||
The Speedbutton now has a numglyphs setting.
|
||||
I started the TStringPropertyEditor
|
||||
|
||||
Revision 1.7 2000/12/19 18:43:13 lazarus
|
||||
Removed IDEEDITOR. This causes the PROJECT class to not function.
|
||||
Saving projects no longer works.
|
||||
|
@ -22,6 +22,8 @@ var
|
||||
n, BufIndex: Integer;
|
||||
t : String;
|
||||
begin
|
||||
writeln('Entering');
|
||||
|
||||
FreeContext;
|
||||
|
||||
// Convert a XPM filedata format to a XPM memory format
|
||||
@ -76,11 +78,16 @@ begin
|
||||
finally
|
||||
S.Free;
|
||||
end;
|
||||
writeln('leaving');
|
||||
end;
|
||||
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.4 2001/01/03 18:44:54 lazarus
|
||||
The Speedbutton now has a numglyphs setting.
|
||||
I started the TStringPropertyEditor
|
||||
|
||||
Revision 1.3 2000/12/29 20:32:33 lazarus
|
||||
Speedbuttons can now draw disabled images.
|
||||
Shane
|
||||
|
@ -20,10 +20,14 @@ begin
|
||||
|
||||
Inherited Create(AOwner);
|
||||
FCompStyle := csSpeedButton;
|
||||
|
||||
FGlyph := TButtonGlyph.Create;
|
||||
FGlyph.OnChange := @GlyphChanged;
|
||||
|
||||
SetBounds(0, 0, 23, 22);
|
||||
ControlStyle := [csCaptureMouse, csDoubleClicks];
|
||||
|
||||
FGlyph := TButtonGlyph.Create;
|
||||
|
||||
{set default alignment}
|
||||
Align := alNone;
|
||||
FMouseInControl := False;
|
||||
@ -117,7 +121,6 @@ end;
|
||||
procedure TSpeedButton.SetGlyph(Value : TBitmap);
|
||||
begin
|
||||
FGlyph.Glyph := Value;
|
||||
//SendMessage(LM_IMAGECHANGED,Self,nil);
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
@ -137,7 +140,26 @@ begin
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TSpeedButton.SetGroupIndex
|
||||
Method: TSpeedButton.SetNumGlyphs
|
||||
Params: Value : Integer = Number of glyphs in the file/resource
|
||||
Returns: nothing
|
||||
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TSpeedButton.SetNumGlyphs(Value : Integer);
|
||||
Begin
|
||||
if Value < 0 then Value := 1;
|
||||
if Value > 4 then Value := 4;
|
||||
|
||||
if Value <> TButtonGlyph(fGlyph).NumGlyphs then
|
||||
Begin
|
||||
TButtonGlyph(fGlyph).NumGlyphs := Value;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TSpeedButton.UpdateExclusive
|
||||
Params: none
|
||||
Returns: nothing
|
||||
|
||||
@ -169,6 +191,29 @@ begin
|
||||
Result := FGlyph.Glyph;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TSpeedButton.GetNumGlyphs
|
||||
Params: none
|
||||
Returns: The number stored in TButtonGlyph(FGlyph).NumGlyphs
|
||||
|
||||
------------------------------------------------------------------------------}
|
||||
Function TSpeedButton.GetNumGlyphs : Integer;
|
||||
Begin
|
||||
Result := TButtonGlyph(fGlyph).NumGlyphs;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TSpeedButton.GlyphChanged
|
||||
Params: Sender - The glyph that changed
|
||||
Returns: zippo
|
||||
|
||||
------------------------------------------------------------------------------}
|
||||
Procedure TSpeedButton.GlyphChanged(Sender : TObject);
|
||||
Begin
|
||||
//redraw the button;
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TSpeedbutton.Paint
|
||||
Params: none
|
||||
@ -186,7 +231,7 @@ var
|
||||
R : TRect;
|
||||
Offset: TPoint;
|
||||
begin
|
||||
if not Enabled
|
||||
if not Enabled
|
||||
then begin
|
||||
FState := bsDisabled;
|
||||
FDragging := False;
|
||||
@ -204,15 +249,15 @@ begin
|
||||
PaintRect := Bounds(Left, Top, Width, Height);
|
||||
// PaintRect := Rect(0, 0, Width, Height);
|
||||
|
||||
if not FFlat then
|
||||
if not FFlat then
|
||||
begin
|
||||
DrawFlags := DFCS_BUTTONPUSH or DFCS_ADJUSTRECT;
|
||||
if FState in [bsDown, bsExclusive]
|
||||
if FState in [bsDown, bsExclusive]
|
||||
then DrawFlags := DrawFlags or DFCS_PUSHED;
|
||||
DrawFrameControl(Canvas.Handle, PaintRect, DFC_BUTTON, DrawFlags);
|
||||
end
|
||||
else begin //flat
|
||||
if (FState in [bsDown, bsExclusive])
|
||||
if (FState in [bsDown, bsExclusive])
|
||||
or (FMouseInControl and (FState <> bsDisabled))
|
||||
or (csDesigning in ComponentState)
|
||||
then
|
||||
@ -229,7 +274,7 @@ begin
|
||||
InflateRect(PaintRect, -1, -1);
|
||||
end;
|
||||
|
||||
if FState in [bsDown, bsExclusive]
|
||||
if FState in [bsDown, bsExclusive]
|
||||
then begin
|
||||
if (FState = bsExclusive)
|
||||
and (not FFlat or not FMouseInControl)
|
||||
@ -479,6 +524,10 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.2 2001/01/03 18:44:54 lazarus
|
||||
The Speedbutton now has a numglyphs setting.
|
||||
I started the TStringPropertyEditor
|
||||
|
||||
Revision 1.1 2000/07/13 10:28:28 michael
|
||||
+ Initial import
|
||||
|
||||
|
@ -794,7 +794,6 @@ begin
|
||||
Assert(False, 'Trace:************************************************');
|
||||
Assert(False, 'Trace:DRAWFRAMECONTROL');
|
||||
Assert(False, 'Trace:************************************************');
|
||||
|
||||
case uType of
|
||||
DFC_CAPTION:
|
||||
begin //all draw CAPTION commands here
|
||||
@ -3117,6 +3116,10 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.10 2001/01/03 18:44:54 lazarus
|
||||
The Speedbutton now has a numglyphs setting.
|
||||
I started the TStringPropertyEditor
|
||||
|
||||
Revision 1.9 2000/10/09 22:50:33 lazarus
|
||||
MWE:
|
||||
* fixed some selection code
|
||||
|
Loading…
Reference in New Issue
Block a user