mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 08:40:24 +02:00
MG: fixed window shrinking
git-svn-id: trunk@693 -
This commit is contained in:
parent
cebd8c957b
commit
e4f8add4fa
@ -757,26 +757,27 @@ begin
|
||||
|
||||
LM_POPUPSHOW :
|
||||
Begin
|
||||
gtk_menu_popup (PgtkMenu(TPopupMenu(Sender).Handle),
|
||||
gtk_menu_popup(PgtkMenu(TPopupMenu(Sender).Handle),
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
0,
|
||||
0);
|
||||
{Displays a menu and makes it available for selection. Applications can use this
|
||||
function to display context-sensitive menus, and will typically supply NULL for
|
||||
the parent_menu_shell, parent_menu_item, func and data parameters.
|
||||
The default menu positioning function will position the menu at the current
|
||||
pointer position.
|
||||
menu : a GtkMenu.
|
||||
parent_menu_shell : the menu shell containing the triggering menu item.
|
||||
parent_menu_item : the menu item whose activation triggered the popup.
|
||||
func : a user supplied function used to position the menu.
|
||||
data : user supplied data to be passed to func.
|
||||
button : the button which was pressed to initiate the event.
|
||||
activate_time : the time at which the activation event occurred.
|
||||
}
|
||||
{Displays a menu and makes it available for selection. Applications
|
||||
can use this function to display context-sensitive menus, and will
|
||||
typically supply NULL for the parent_menu_shell, parent_menu_item,
|
||||
func and data parameters.
|
||||
The default menu positioning function will position the menu at the
|
||||
current pointer position.
|
||||
menu : a GtkMenu.
|
||||
parent_menu_shell: the menu shell containing the triggering menu item.
|
||||
parent_menu_item: the menu item whose activation triggered the popup.
|
||||
func : a user supplied function used to position the menu.
|
||||
data : user supplied data to be passed to func.
|
||||
button : the button which was pressed to initiate the event.
|
||||
activate_time : the time at which the activation event occurred.
|
||||
}
|
||||
|
||||
end;
|
||||
|
||||
@ -808,7 +809,7 @@ activate_time : the time at which the activation event occurred.
|
||||
|
||||
LM_SETFOCUS:
|
||||
begin
|
||||
writeln('[TgtkObject.IntSendMessage3] LM_SETFOCUS ',TObject(Sender).ClassName);
|
||||
writeln('[TgtkObject.IntSendMessage3] LM_SETFOCUS ',TObject(Sender).ClassName);
|
||||
if GTK_WIDGET_CAN_FOCUS(PgtkWidget(Handle)) then
|
||||
gtk_widget_grab_focus(PgtkWidget(handle))
|
||||
else
|
||||
@ -818,12 +819,12 @@ writeln('[TgtkObject.IntSendMessage3] LM_SETFOCUS ',TObject(Sender).ClassName);
|
||||
LM_SetSize :
|
||||
begin
|
||||
Assert(False, Format('Trace: [TgtkObject.IntSendMessage3] %s --> LM_SetSize(%d, %d, %d, %d)', [Sender.ClassNAme, PRect(Data)^.Left,PRect(Data)^.Top,PRect(Data)^.Right,PRect(Data)^.Bottom]));
|
||||
//writeln('[IntSendMessage3.lm_setsize] Left=',PRect(Data)^.Left,' Top=',PRect(Data)^.Top,
|
||||
// ' Right=',PRect(Data)^.Right,' Bottom=',PRect(Data)^.Bottom);
|
||||
//writeln('[LM_SetSize] A ',Sender.ClassName,' ',PgtkWidget(Handle)^.window<>nil);
|
||||
//writeln('[IntSendMessage3.lm_setsize] Left=',PRect(Data)^.Left,' Top=',PRect(Data)^.Top,
|
||||
// ' Right=',PRect(Data)^.Right,' Bottom=',PRect(Data)^.Bottom);
|
||||
//writeln('[LM_SetSize] A ',Sender.ClassName,' ',PgtkWidget(Handle)^.window<>nil);
|
||||
ResizeChild(Sender,PRect(Data)^.Left,PRect(Data)^.Top,
|
||||
PRect(Data)^.Right,PRect(Data)^.Bottom);
|
||||
//writeln('[LM_SetSize] B ',Sender.ClassName,' ',PgtkWidget(Handle)^.window<>nil);
|
||||
//writeln('[LM_SetSize] B ',Sender.ClassName,' ',PgtkWidget(Handle)^.window<>nil);
|
||||
end;
|
||||
|
||||
LM_ShowModal :
|
||||
@ -974,7 +975,7 @@ writeln('[TgtkObject.IntSendMessage3] LM_SETFOCUS ',TObject(Sender).ClassName);
|
||||
if Sender is TCustomForm then begin
|
||||
if (Handle<>0) and (Data<>nil) then begin
|
||||
FormIconGdiObject:=Data;
|
||||
//writeln('LM_SETFORMICON ',FormIconGdiObject<>nil,' ',pgtkWidget(Handle)^.Window<>nil);
|
||||
//writeln('LM_SETFORMICON ',FormIconGdiObject<>nil,' ',pgtkWidget(Handle)^.Window<>nil);
|
||||
if (FormIconGdiObject<>nil) and (pgtkWidget(Handle)^.Window<>nil)
|
||||
then begin
|
||||
gdk_window_set_icon(pgtkWidget(Handle)^.Window, nil,
|
||||
@ -1069,9 +1070,9 @@ writeln('[TgtkObject.IntSendMessage3] LM_SETFOCUS ',TObject(Sender).ClassName);
|
||||
csNotebook:
|
||||
begin
|
||||
Assert(False, 'Trace:Setting Page to ' + IntToStr(TLMNotebookEvent(Data^).Page));
|
||||
//writeln('LM_SETITEMINDEX A ',HexStr(Cardinal(Handle),8),', ',TLMNotebookEvent(Data^).Page);
|
||||
//writeln('LM_SETITEMINDEX A ',HexStr(Cardinal(Handle),8),', ',TLMNotebookEvent(Data^).Page);
|
||||
gtk_notebook_set_page(PGtkNotebook(Handle), TLMNotebookEvent(Data^).Page);
|
||||
//writeln('LM_SETITEMINDEX B ',TLMNotebookEvent(Data^).Page);
|
||||
//writeln('LM_SETITEMINDEX B ',TLMNotebookEvent(Data^).Page);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -1255,10 +1256,14 @@ writeln('[TgtkObject.IntSendMessage3] LM_SETFOCUS ',TObject(Sender).ClassName);
|
||||
Widget:= PGtkWidget(TWinControl(Sender).Handle);
|
||||
if Widget <> nil then begin
|
||||
with Geometry, TControl(Sender) do begin
|
||||
if Constraints.MinWidth > 0 then min_width:= Constraints.MinWidth else min_width:= 1;
|
||||
if Constraints.MaxWidth > 0 then max_width:= Constraints.MaxWidth else max_width:= 32767;
|
||||
if Constraints.MinHeight > 0 then min_height:= Constraints.MinHeight else min_height:= 1;
|
||||
if Constraints.MaxHeight > 0 then max_height:= Constraints.MaxHeight else max_height:= 32767;
|
||||
if Constraints.MinWidth > 0 then
|
||||
min_width:= Constraints.MinWidth else min_width:= 1;
|
||||
if Constraints.MaxWidth > 0 then
|
||||
max_width:= Constraints.MaxWidth else max_width:= 32767;
|
||||
if Constraints.MinHeight > 0 then
|
||||
min_height:= Constraints.MinHeight else min_height:= 1;
|
||||
if Constraints.MaxHeight > 0 then
|
||||
max_height:= Constraints.MaxHeight else max_height:= 32767;
|
||||
base_width:= Width;
|
||||
base_height:= Height;
|
||||
width_inc:= 1;
|
||||
@ -1266,7 +1271,8 @@ writeln('[TgtkObject.IntSendMessage3] LM_SETFOCUS ',TObject(Sender).ClassName);
|
||||
min_aspect:= 0;
|
||||
max_aspect:= 1;
|
||||
end;
|
||||
gtk_window_set_geometry_hints(PGtkWindow(Widget), nil, @Geometry, GDK_HINT_MIN_SIZE or GDK_HINT_MAX_SIZE);
|
||||
gtk_window_set_geometry_hints(PGtkWindow(Widget), nil, @Geometry,
|
||||
GDK_HINT_MIN_SIZE or GDK_HINT_MAX_SIZE);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -1319,11 +1325,16 @@ end;
|
||||
*Note: Resize a child widget on the parents fixed widget
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TgtkObject.ResizeChild(Sender : TObject;Left,Top,Width,Height : Integer);
|
||||
{ $DEFINE VerboseResizeChild}
|
||||
var
|
||||
pFixed: PGTKFixed;
|
||||
pWidget: PGTKWidget;
|
||||
Parent: TWinControl;
|
||||
IsTopLevelWidget: boolean;
|
||||
{$IFDEF VerboseResizeChild}
|
||||
DummyWidget: PGtkWidget;
|
||||
Dummy: TPoint;
|
||||
{$ENDIF}
|
||||
begin
|
||||
//writeln('[TgtkObject.ResizeChild] START ',TControl(Sender).Name,':',Sender.Classname,' Left=',Left,' Top=',Top,' Width=',Width,' Height=',Height);
|
||||
Assert(false, (Format('trace: [TgtkObject.ResizeChild] %s --> Resize', [Sender.ClassNAme])));
|
||||
@ -1336,35 +1347,63 @@ begin
|
||||
|
||||
IsTopLevelWidget:= (Sender is TCustomForm) and (Parent = nil);
|
||||
|
||||
if IsTopLevelWidget then
|
||||
begin
|
||||
if IsTopLevelWidget then begin
|
||||
gtk_window_set_default_size(PgtkWindow(pWidget),Width,Height);
|
||||
end;
|
||||
|
||||
gtk_widget_set_usize(pWidget, -1, -1);
|
||||
gtk_widget_set_usize(pWidget, Width, Height);
|
||||
{$IFDEF VerboseResizeChild}
|
||||
if pWidget^.Window<>nil then begin
|
||||
gdk_window_get_size(pWidget^.Window, @Dummy.X, @Dummy.Y);
|
||||
write('ResizeChild: ',TControl(Sender).Name,':',Sender.Classname,
|
||||
' OldWidSize=',Dummy.X,',',Dummy.Y,
|
||||
' NewSize=',Width,',',Height);
|
||||
DummyWidget := GetFixedWidget(pWidget);
|
||||
if (DummyWidget <> nil) then begin
|
||||
if (DummyWidget^.Window<>nil) then begin
|
||||
gdk_window_get_size(DummyWidget^.Window, @Dummy.X, @Dummy.Y);
|
||||
writeln(' OldFixWidSize=',Dummy.X,',',Dummy.Y);
|
||||
end else
|
||||
writeln(' FixWid^.Window=nil');
|
||||
end else begin
|
||||
writeln(' NoFixWid');
|
||||
end;
|
||||
end else begin
|
||||
writeln('ResizeChild: ',TControl(Sender).Name,':',Sender.Classname,
|
||||
' pWidget^.Window=nil',
|
||||
' NewSize=',Width,',',Height);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
// if pWidget^.window <> null then begin
|
||||
// gdk_window_move_resize(pWidget^.window, Left, Top, Width, Height);
|
||||
// end;
|
||||
|
||||
{ Only move when needed }
|
||||
// move widget on the fixed widget of parent control
|
||||
if not IsTopLevelWidget then begin
|
||||
//gtk_widget_set_usize(pWidget, -1, -1);
|
||||
gtk_widget_set_usize(pWidget, Width, Height);
|
||||
if Parent <> nil then begin
|
||||
pFixed := GetFixedWidget(PGtkWidget(Parent.Handle));
|
||||
if pFixed <> nil then begin
|
||||
gtk_fixed_move(pFixed, pWidget, Left, Top);
|
||||
end
|
||||
else begin
|
||||
Assert(False, 'Trace:ERROR!!!! - no Fixed Widget found to use when resizing....');
|
||||
end else begin
|
||||
if not (Parent is TNoteBook) then begin
|
||||
writeln('WARNING: TgtkObject.ResizeChild - no Fixed Widget found');
|
||||
writeln(' Control=',TControl(Sender).Name,':',Sender.ClassName,
|
||||
' Parent=',Parent.Name,':',Parent.ClassName);
|
||||
end;
|
||||
end
|
||||
else begin
|
||||
Assert(False, 'Trace:ERROR !!! - no Fixed Widget found to use when resizing....');
|
||||
raise Exception('ARG2');
|
||||
Assert(False, 'WARNING: TgtkObject.ResizeChild - no Fixed Widget found');
|
||||
//raise Exception.Create('TgtkObject.ResizeChild - no Fixed Widget found');
|
||||
end;
|
||||
end else begin
|
||||
Assert(False, 'ERROR: TgtkObject.ResizeChild - no Parent Control found');
|
||||
raise Exception.Create('TgtkObject.ResizeChild - no Parent Control found');
|
||||
end;
|
||||
end
|
||||
else begin
|
||||
// resize form
|
||||
if pWidget^.window<>nil then begin
|
||||
gdk_window_move_resize(pWidget^.window, Left, Top, Width, Height);
|
||||
end else begin
|
||||
gtk_widget_set_usize(pWidget, Width, Height);
|
||||
end;
|
||||
gtk_widget_set_uposition(pWidget, Left, Top);
|
||||
end;
|
||||
end;
|
||||
@ -2194,10 +2233,12 @@ begin
|
||||
end
|
||||
else
|
||||
if (Sender is TMenu) or (Sender is TPopupMenu)
|
||||
then CompStyle := TMenu(Sender).FCompStyle
|
||||
then
|
||||
CompStyle := TMenu(Sender).FCompStyle
|
||||
else
|
||||
if (Sender is TCommonDialog)
|
||||
then CompStyle := TCommonDialog(Sender).FCompStyle;
|
||||
then
|
||||
CompStyle := TCommonDialog(Sender).FCompStyle;
|
||||
|
||||
if caption = '' then caption := 'Blank';
|
||||
|
||||
@ -2684,7 +2725,7 @@ begin
|
||||
gtk_scale_set_digits (PGTKSCALE (P), 0);
|
||||
end;
|
||||
|
||||
end; //case
|
||||
end; //end case
|
||||
|
||||
|
||||
if (Sender is TWinControl) then
|
||||
@ -2718,9 +2759,7 @@ begin
|
||||
//--------------------------
|
||||
|
||||
StrDispose(StrTemp);
|
||||
if P <> nil then
|
||||
HookSignals(Sender);
|
||||
|
||||
if P <> nil then HookSignals(Sender);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -2882,6 +2921,8 @@ begin
|
||||
gtk_Object_set_data(pgtkobject(Widget),'Image',Image);
|
||||
end;
|
||||
|
||||
// ToDo: free allocated gdk color
|
||||
|
||||
GDKColor:=AllocGDKColor(TLMSetGetPixel(data^).PixColor);
|
||||
//writeln('SetPixel: Color=',HexStr(TLMSetGetPixel(data^).PixColor,8),' GDKColor=',HexStr(GDKColor.Pixel,8));
|
||||
gdk_image_put_pixel(Image,TLMSetGetPixel(data^).X,TLMSetGetPixel(data^).Y,
|
||||
@ -3267,6 +3308,7 @@ begin
|
||||
gtk_misc_set_alignment(PGTKMISC(Handle), xAlign, yAlign);
|
||||
gtk_label_set_line_wrap(PGTKLABEL(Handle),WordWrap);
|
||||
end;
|
||||
|
||||
csListView :
|
||||
begin
|
||||
//set up columns..
|
||||
@ -3367,6 +3409,7 @@ begin
|
||||
then TWinControl(sender).Handle := THandle(gtk_image_new(Image,nil))
|
||||
else gtk_image_set(PgtkImage(handle),Image,nil);
|
||||
end;
|
||||
|
||||
csSpinEdit:
|
||||
Begin
|
||||
gtk_spin_button_set_digits(PgtkSpinButton(Widget),TSpinEdit(Sender).Decimal_Places);
|
||||
@ -3841,6 +3884,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.115 2002/04/27 15:35:51 lazarus
|
||||
MG: fixed window shrinking
|
||||
|
||||
Revision 1.114 2002/04/26 12:26:50 lazarus
|
||||
MG: improved clean up
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user