And I would do this with a TStringGrid Control
--Column[0] Width=0 to store Icon Names.
..
grids.colWidths[0]:=0;
..
--Define one onDrawCell to draw Column[1] icons, and call
defaultDrawCell for any other cells.
...
if col=1 Then begin
grid.Canvas.CopyRect(R,Icon.Canvas,classes.Rect(...));
End else DefaultDrawCell(col,row,rect,state)
..
--Define a TMyBitBtn Editor
TMyBitBtn=Class(TBitBtn)
Private
FGrid: TCustomGrid;
Protected
Procedure msg_SetGrid(Var Msg: TGridMessage); Message GM_SETGRID;
Procedure msg_SetPos(Var Msg: TGridMessage); Message GM_SETPOS;
End;
...
procedure TMyBitBtn.msg_SetGrid(var Msg: TGridMessage);
begin
FGrid:=Msg.Grid;
Msg.Options:=EO_HOOKKEYS or EO_HOOKEXIT;
end;
procedure TMyBitBtn.msg_SetPos(var Msg: TGridMessage);
begin
With Msg.CellRect do begin
If Right-Left>25 Then Left:=Right-25;
SetBounds(Left, Top, Right-Left, Bottom-Top);
End;
end;
--Attach it to the [run] column in the OnSelectEditor grid event and set TMyBitBtn icon there too.
..
If col=colRun Then begin
Editor:=FMybitbtn
//update FMybitBtn Icon with Cells[0,row] icon name
End;
..
--Define Grid's onSelection to handle clicks on Column[1] and handle TMyBitBtn clicks there too.
..
if col=1 then fMybitBtnClick1();
..
--Define Grid's OnCellAttr to allow WordWrap on Description column (can be the same that [run] column), I haven't tested wordwraping but it should work.
..
if col=colRUN Then
attr.textstyle.(sigleline|wordbreak):=(true|false)
--in the filling part i would set:
grid.BeginUpdate;
doTheFilling/gridResizing
grid.EndUpdate(true);
Regards.
Jesus Reyes A.
--- Shane Miller escribi�: > A.J.
Show quoted text 201 lines
I would do this (or something like this)
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
MyButtonList : TList; //keeps track of the "buttons" created
at
runtime
Procedure ShowEntry(Command, Name, Description, Icon :
String);
end;
TCommandString = class //actually creates the button
//and handles the onclick.
private
fExeCommand: String;
fButton: TBitBtn;
FCommand: String;
FIcon: String;
FName: String;
FDescription: String;
procedure SetCommand(const Value: String);
procedure SetDescription(const Value: String);
procedure SetIcon(const Value: String);
procedure SetName(const Value: String);
Procedure ButtonClick(Sender : TObject);
public
constructor Create(AOwner : TComponent);
destructor Destroy; override;
property ExeCommand : String read fExeCommand write
fExeCommand;
property Button : TBitBtn read fButton write fButton;
property Icon : String read FIcon write SetIcon;
property Command : String read FCommand write SetCommand;
property Name : String read FName write SetName;
property Description : String read FDescription write
SetDescription;
end;
var
Form1: TForm1;
implementation
Procedure TForm1.ShowEntry(Command, Name, Description, Icon :
String);
Var
MyNewButton : TCommandString;
Begin
MyNewButton := TCommandString.Create(self);
MyNewButton.Icon := Icon;
MyNewButton.Name := Name;
MyNewButton.Command := Command;
MyNewButton.Description := Description;
// MyButtonList is a TList that keeps track of the
"TCommandString"
objects.
// When the form closes, run through the list and free each one.
MyButtonlist.Add(MyNewButton);
end;
{$R *.dfm}
{ TCommandString }
procedure TCommandString.ButtonClick(Sender: TObject);
begin
//execute the command here
end;
constructor TCommandString.Create(AOwner : TComponent);
begin
inherited create;
fButton := tBitBtn.Create(AOwner);
fButton.Parent := aOwner;
fButton.OnClick := ButtonClick;
end;
destructor TCommandString.Destroy;
begin
fButton.free;
inherited;
end;
procedure TCommandString.SetCommand(const Value: String);
begin
FCommand := Value;
end;
procedure TCommandString.SetDescription(const Value: String);
begin
FDescription := Value;
end;
procedure TCommandString.SetIcon(const Value: String);
begin
FIcon := Value;
fButton.Glyph.LoadFromFile(Value);
end;
procedure TCommandString.SetName(const Value: String);
begin
FName := Value;
end;
End;
...main program....
While mysql_row = mysql_fetch_row(mysql_result) do
ShowEntry(mysql_row[1],mysql_row[2],mysql_row[3],mysql_row[4]);
End.
Something like that. Then you would need to place the
"TCommandString.button" at the appropriate place on your form.
Make sense?
Shane
-----Original Message-----
From: A.J. Venter
Sent: Tuesday, May 06, 2003 9:44 AM
To: lazarus
Subject: RE: [lazarus] Dynamic GUI
I am afraid none of those options would work here.
I want to deliberately prevent the use of hints in this program.
The reason is that it is intended to be part of a system to create
a
Linux Application menu for new users. If a user chooses say
"Graphics"
from the main menu, a window should come up informing him of the
installed Graphics Programs and explaining what each is, and the
strengths and weaknesses.
For example, Gimp if you want to edit graphics, FLphoto to view
large
collections of images etc.
I tend to agree that Tbitbutton would be ideal for the icon and the
name, but can tbitbuttons be loaded from file paths ?
Remember I do not know until runtime what entries will need to be
displayed, and at that time must basically generate the GUI
dynamically
based on the database for this category.
Obviously that rules out RAD and the GUI will need to be coded by
hand.
Lets asume that a procedure to show each entry is saved in some
unit.
The main program would have to do something like this:
While mysql_row = mysql_fetch_row(mysql_result) do
ShowEntry(mysql_row[1],mysql_row[2],mysql_row[3],mysql_row[4]);
What do you think ?
A.J.
On Tue, 2003-05-06 at 16:35, Shane Miller wrote:
> A.J.
>
> One option you could do is create a TBitbtn for each using the
Icon
as
> the glyph and the NAME as the text. Then on a mouseover display
the
> Description as a hint. This would allow you to put many
"commands" in
a
> small area because the buttons would be pretty small.
>
> Otherwise you could use a Listview with the Icon and Text
displayed
and
> the Description again being the hint.
>
> A TTreeView would work too. Expanding the item would display the
> description.
>
> If you categorized the commands then you could list them by
category
on
> separate tabs which would allow you to break them into smaller
parts
and
> make them easier to display.
=== message truncated ===
_________________________________________________________ Do You Yahoo!?
La mejor conexi�n a internet y 25MB extra a tu correo por $100 al mes. http://net.yahoo.com.mx