Fixed identation and moved attachment of Gtk2 window state change callback setter to the correct location.

git-svn-id: trunk@11544 -
This commit is contained in:
sekelsenmat 2007-07-17 12:47:33 +00:00
parent f1d1abb3bd
commit 469476cde9
2 changed files with 37 additions and 25 deletions

View File

@ -4036,10 +4036,12 @@ function GetWidgetInfo(const AWidget: Pointer;
var
MainWidget: PGtkObject;
begin
if AWidget <> nil then begin
if AWidget <> nil then
begin
MainWidget := GetMainWidget(AWidget);
Result := gtk_object_get_data(MainWidget, 'widgetinfo');
if (Result = nil) and ACreate then begin
if (Result = nil) and ACreate then
begin
Result := CreateWidgetInfo(MainWidget);
// use the main widget as default
Result^.CoreWidget := PGtkWidget(MainWidget);
@ -7558,17 +7560,19 @@ begin
// Create the VBox. We need that to place controls outside
// the client area (like menu)
Result := gtk_vbox_new(False, 0);
If FormWidget = nil then
FormWidget := Result;
// Create the form client area (a scrolled window with a gtklayout
// with the style of a window)
ScrolledWidget := gtk_scrolled_window_new(nil,nil);
ScrolledWidget := gtk_scrolled_window_new(nil, nil);
gtk_box_pack_end(Result, ScrolledWidget, True, True, 0);
gtk_widget_show(ScrolledWidget);
ClientAreaWidget := gtk_layout_new(nil, nil);
WindowStyle:=GetStyle(lgsWindow);
gtk_widget_set_style(ClientAreaWidget,WindowStyle);
WindowStyle := GetStyle(lgsWindow);
gtk_widget_set_style(ClientAreaWidget, WindowStyle);
//debugln('CreateFormContents Style=',GetStyleDebugReport(WindowStyle));
gtk_container_add(PGtkContainer(ScrolledWidget), ClientAreaWidget);
@ -7578,7 +7582,8 @@ begin
SetFixedWidget(FormWidget, ClientAreaWidget);
SetMainWidget(FormWidget, ClientAreaWidget);
if ScrolledWidget<>nil then begin
if ScrolledWidget <> nil then
begin
GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(ScrolledWidget)^.hscrollbar,
GTK_CAN_FOCUS);
GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(ScrolledWidget)^.vscrollbar,
@ -7587,14 +7592,14 @@ begin
GTK_POLICY_NEVER,GTK_POLICY_NEVER);
Adjustment := gtk_scrolled_window_get_vadjustment(PGTKScrolledWindow(ScrolledWidget));
if Adjustment <> nil
then gtk_object_set_data(PGTKObject(Adjustment), odnScrollBar,
PGTKScrolledWindow(ScrolledWidget)^.vscrollbar);
if Adjustment <> nil then
gtk_object_set_data(PGTKObject(Adjustment), odnScrollBar,
PGTKScrolledWindow(ScrolledWidget)^.vscrollbar);
Adjustment := gtk_scrolled_window_get_hadjustment(PGTKScrolledWindow(ScrolledWidget));
if Adjustment <> nil
then gtk_object_set_data(PGTKObject(Adjustment), odnScrollBar,
PGTKScrolledWindow(ScrolledWidget)^.hscrollbar);
if Adjustment <> nil then
gtk_object_set_data(PGTKObject(Adjustment), odnScrollBar,
PGTKScrolledWindow(ScrolledWidget)^.hscrollbar);
end;
end;

View File

@ -193,8 +193,13 @@ class procedure TGtkWSCustomForm.SetCallbacks(const AWinControl: TWinControl;
const AWidgetInfo: PWidgetInfo);
begin
{$IFDEF GTK1}
gtk_signal_connect(PGtkObject(AWidgetInfo^.CoreWidget),'map-event', TGtkSignalFunc(@GtkWSFormMapEvent), AWidgetInfo);
gtk_signal_connect(PGtkObject(AWidgetInfo^.CoreWidget),'unmap-event', TGtkSignalFunc(@GtkWSFormUnMapEvent), AWidgetInfo);
gtk_signal_connect(PGtkObject(AWidgetInfo^.CoreWidget),'map-event', TGtkSignalFunc(@GtkWSFormMapEvent), AWidgetInfo);
gtk_signal_connect(PGtkObject(AWidgetInfo^.CoreWidget),'unmap-event', TGtkSignalFunc(@GtkWSFormUnMapEvent), AWidgetInfo);
{$ENDIF}
{$IFDEF Gtk2}
g_signal_connect(PGtkObject(AWidgetInfo^.CoreWidget), 'window-state-event',
gtk_signal_func(@GTKWindowStateEventCB),
AWinControl);
{$ENDIF}
end;
@ -235,16 +240,17 @@ begin
begin
// create a floating form
P := gtk_window_new(WindowType);
// gtk_window_set_policy is deprecated in Gtk2
{$IFDEF Gtk2}
g_signal_connect(GTK_OBJECT(P), 'window-state-event',
gtk_signal_func(@GTKWindowStateEventCB),
ACustomForm);
gtk_window_set_resizable(GTK_WINDOW(P), gboolean(FormResizableMap[ABorderStyle]));
{$ELSE}
gtk_window_set_policy(GTK_WINDOW(P), FormResizableMap[ABorderStyle],
FormResizableMap[ABorderStyle], 0);
{$ENDIF}
gtk_window_set_policy(GTK_WINDOW(P), FormResizableMap[ABorderStyle],
FormResizableMap[ABorderStyle], 0);
PCaption:=PChar(ACustomForm.Caption);
if PCaption=nil then PCaption:=#0;
PCaption := PChar(ACustomForm.Caption);
if (PCaption = nil) then PCaption := #0;
gtk_window_set_title(pGtkWindow(P), PCaption);
// Shows in taskbar only Main Form.
@ -264,7 +270,7 @@ begin
{$ENDIF}
// the clipboard needs a widget
if ClipboardWidget=nil then
if (ClipboardWidget = nil) then
GtkWidgetSet.SetClipboardWidget(P);
//drag icons
@ -279,16 +285,17 @@ begin
else
begin
// create a form as child control
P := gtk_hbox_new(false,0);
P := gtk_hbox_new(false, 0);
end;
Box := CreateFormContents(ACustomForm, P);
gtk_container_add(PGtkContainer(P), Box);
{$IfDef GTK2}
//so we can double buffer ourselves, eg, the Form Designer
gtk_widget_set_double_buffered(Box, False);
//so we can double buffer ourselves, eg, the Form Designer
gtk_widget_set_double_buffered(Box, False);
{$EndIf}
gtk_widget_show(Box);
// main menu