Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2003-05

Dynamic GUI

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Shane Miller

A.J.

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

Earlier message 124 lines
-----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. > > Just some thoughts > Shane > > > -----Original Message----- > From: A.J. Venter > Sent: Tuesday, May 06, 2003 8:12 AM > To: lazarus > Subject: [lazarus] Dynamic GUI > > Hi, > A program I am working on, will need to generate most of it's GUI based > on a commandline argument. > With this argument, a search will be done inside an SQL database > returning records with three fields: > Command, Name, Description, Icon > > Command, Name and Icon are single line text, the others are multiline > text. > > What the program then needs to do is to take all the results and display > A tabular structure: > _________________________ > | |Name | > |Icon |Description | > | | [Run] | > ------------------------- > > In the above example, Icon must be replaced with an image. The path to > this image will be the text from the icon field. Name and description > need merely be displayed. > > [Run] Is a button, which, when executed, will execute command, and close > the window. > If possible, clicking on Icon should perform the same function as [Run]. > > I am curious as to the best way to implement Icon, and the display of > Name and Description. Keeping in mind that there may well be several of > these tables to display, vertically. The implication being that the > window should resize itself according to the size of the contents, and > scroll if it can no longer fit them all. > > I have not yet started coding, so I can still change anything (this is > still pure theory) according to suggestions. > > I would appreciate any help. > > A.J. -- Story of my life: "Semper in excretum, set alta variant" A.J. Venter DireqLearn Linux Guru _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

Reply by email

A.J. Venter

Hi,
A program I am working on, will need to generate most of it's GUI based on a commandline argument.
With this argument, a search will be done inside an SQL database returning records with three fields:
Command, Name, Description, Icon

Command, Name and Icon are single line text, the others are multiline text.

What the program then needs to do is to take all the results and display A tabular structure:
_________________________
| |Name |
|Icon |Description |
| | [Run] |
-------------------------

In the above example, Icon must be replaced with an image. The path to this image will be the text from the icon field. Name and description need merely be displayed.

[Run] Is a button, which, when executed, will execute command, and close the window.
If possible, clicking on Icon should perform the same function as [Run].

I am curious as to the best way to implement Icon, and the display of Name and Description. Keeping in mind that there may well be several of these tables to display, vertically. The implication being that the window should resize itself according to the size of the contents, and scroll if it can no longer fit them all.

I have not yet started coding, so I can still change anything (this is still pure theory) according to suggestions.

I would appreciate any help.

A.J.

Story of my life: "Semper in excretum, set alta variant" A.J. Venter DireqLearn Linux Guru

Reply by email

A.J. Venter
to Shane Miller: A.J. One option you could do is create a TBitbtn for each using the Icon as the glyph and…

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.

Shane Miller wrote 65 lines
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. Just some thoughts Shane -----Original Message----- From: A.J. Venter Sent: Tuesday, May 06, 2003 8:12 AM To: lazarus Subject: [lazarus] Dynamic GUI Hi, A program I am working on, will need to generate most of it's GUI based on a commandline argument. With this argument, a search will be done inside an SQL database returning records with three fields: Command, Name, Description, Icon Command, Name and Icon are single line text, the others are multiline text. What the program then needs to do is to take all the results and display A tabular structure: _________________________ | |Name | |Icon |Description | | | [Run] | ------------------------- In the above example, Icon must be replaced with an image. The path to this image will be the text from the icon field. Name and description need merely be displayed. [Run] Is a button, which, when executed, will execute command, and close the window. If possible, clicking on Icon should perform the same function as [Run]. I am curious as to the best way to implement Icon, and the display of Name and Description. Keeping in mind that there may well be several of these tables to display, vertically. The implication being that the window should resize itself according to the size of the contents, and scroll if it can no longer fit them all. I have not yet started coding, so I can still change anything (this is still pure theory) according to suggestions. I would appreciate any help. A.J.
Story of my life: "Semper in excretum, set alta variant" A.J. Venter DireqLearn Linux Guru

Reply by email

Shane Miller

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.

Just some thoughts
Shane

Earlier message 59 lines
-----Original Message----- From: A.J. Venter Sent: Tuesday, May 06, 2003 8:12 AM To: lazarus Subject: [lazarus] Dynamic GUI Hi, A program I am working on, will need to generate most of it's GUI based on a commandline argument. With this argument, a search will be done inside an SQL database returning records with three fields: Command, Name, Description, Icon Command, Name and Icon are single line text, the others are multiline text. What the program then needs to do is to take all the results and display A tabular structure: _________________________ | |Name | |Icon |Description | | | [Run] | ------------------------- In the above example, Icon must be replaced with an image. The path to this image will be the text from the icon field. Name and description need merely be displayed. [Run] Is a button, which, when executed, will execute command, and close the window. If possible, clicking on Icon should perform the same function as [Run]. I am curious as to the best way to implement Icon, and the display of Name and Description. Keeping in mind that there may well be several of these tables to display, vertically. The implication being that the window should resize itself according to the size of the contents, and scroll if it can no longer fit them all. I have not yet started coding, so I can still change anything (this is still pure theory) according to suggestions. I would appreciate any help. A.J. -- Story of my life: "Semper in excretum, set alta variant" A.J. Venter DireqLearn Linux Guru _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

Reply by email

Jesus Reyes
to Shane Miller: A.J. I would do this (or something like this) TForm1 = class(TForm) private { Private…

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

Reply by email