Sign in Join

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

Mailing lists / lazarus / 2010-01

GTK2 behaviors

9 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Kjow

Hi all,

I need some GTK2 behaviors in my Lazarus application, so I added "gtk2" unit to uses... but how to "link" (???) my form with "PGtkWindow"?

e.g. new lazarus application with two buttons on the form: _________________________

unit main;
{$mode objfpc}{$H+}
interface
uses
   ..., ..., gtk2;

...
...
...

var
  Form1: TForm1;
  window :  PGtkWindow;
implementation

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
begin
   window :=  gtk_window_new (GTK_WINDOW_TOPLEVEL); ------> it returns
PGtkWidget, not PGtkWindow
   //I think I need something that link window to Form1, but I don't
know how/what...
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
  gtk_window_fullscreen(window);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
  gtk_window_unfullscreen(window);
end;
initialization
  {$I main.lrs}
end.

_________________________

Thank you!

Reply by email

Paul Ishenin
to Kjow
Kjow wrote
window := gtk_window_new (GTK_WINDOW_TOPLEVEL); ------> it returns PGtkWidget, not PGtkWindow

All gtk_something_new() return PGtkWidget. Just typecast it: PGtkWindow(gtk_window_new())

Best regards,
Paul Ishenin.

Reply by email

Mattias Gaertner
to Kjow: I need some GTK2 behaviors in my Lazarus application, so I added "gtk2" unit to uses...…
Show quoted text 46 lines
Hi all, I need some GTK2 behaviors in my Lazarus application, so I added "gtk2" unit to uses... but how to "link" (???) my form with "PGtkWindow"? e.g. new lazarus application with two buttons on the form: _________________________ unit main; {$mode objfpc}{$H+} interface uses ..., ..., gtk2; ... ... ... var Form1: TForm1; window : PGtkWindow; implementation { TForm1 } procedure TForm1.FormCreate(Sender: TObject); begin window := gtk_window_new (GTK_WINDOW_TOPLEVEL); ------> it returns PGtkWidget, not PGtkWindow //I think I need something that link window to Form1, but I don't know how/what... end; procedure TForm1.Button1Click(Sender: TObject); begin gtk_window_fullscreen(window); end; procedure TForm1.Button2Click(Sender: TObject); begin gtk_window_unfullscreen(window);
If you want to make a form full screen under gtk, use:
uses gtkproc;
SetWindowFullScreen(Form1,true);

Mattias

Reply by email

Mattias Gaertner
to Kjow
Show quoted text 11 lines
2010/1/9 Mattias Gaertner : > If you want to make a form full screen under gtk, use: > uses gtkproc; > > SetWindowFullScreen(Form1,true); > > > Mattias Thank you! It works, but can I use gtk2 calls in lazzarus apps?

It depends. They may conflict with the gtk2 interface of the LCL.

Mattias

Reply by email

Kjow
to Mattias Gaertner

2010/1/9 Mattias Gaertner :

It depends. They may conflict with the gtk2 interface of the LCL. Mattias

e.g. I need to use: gtk_widget_show (menu)

Where menu is a menu like TMainMenu, but I don't know how to create the menu itself...

I'm sorry if I'm not using technical terms, but I'm starting to develop with this things...

I need to use gtk calls because I'm trying to follow Maemo references here:

http://www.forum.nokia.com/info/sw.nokia.com/id/a3187f95-ad88-4233-b0ef-a182da3ec1c7/Hildon_2_2_Widget_UI_Specification_v1_0_en.pdf.html In specific:
http://sw.nokia.com/id/a3187f95-ad88-4233-b0ef-a182da3ec1c7/Hildon_2_2_Widget_UI_Specification_v1_0_en.pdf

Kjow

Reply by email

cobines
to Kjow

2010/1/9 Kjow :

e.g. I need to use: gtk_widget_show (menu) Where menu is a menu like TMainMenu, but I don't know how to create the menu itself...

If you want to use LCL components in GTK then cast the Handle:

MainMenu := TMainMenu.Create(...);
...
gtk_widget_show(PGtkWidget(MainMenu.Handle))

cobines

Reply by email