コード例 #1
0
ファイル: WidgetBackend.cs プロジェクト: joncham/xwt
        void HandleWidgetSizeAllocated(object o, Gtk.SizeAllocatedArgs args)
        {
            if ((enabledEvents & sizeCheckEvents) == 0)
            {
                // If no sizing event is set, it means this handler was set because there is a min size.
                // In that case, there isn't any thing left to do here
                return;
            }

            Toolkit.Invoke(delegate {
                if (sizeCheckStep == SizeCheckStep.SizeRequest)
                {
                    Console.WriteLine("SizeRequest not called. Should not happen");
                }
                else if (sizeCheckStep == SizeCheckStep.PreAllocate || sizeCheckStep == SizeCheckStep.AdjustSize)
                {
                    if (EventSink.GetSizeRequestMode() == SizeRequestMode.HeightForWidth)
                    {
                        realRequestedWidth = args.Allocation.Width;
                        Toolkit.Invoke(delegate {
                            realRequestedHeight = (int)eventSink.OnGetPreferredHeightForWidth(args.Allocation.Width).MinSize;
                        });
                        sizeCheckStep = SizeCheckStep.AdjustSize;
                        Widget.QueueResize();
                    }
                    else
                    {
                        realRequestedHeight = args.Allocation.Height;
                        Toolkit.Invoke(delegate {
                            realRequestedWidth = (int)eventSink.OnGetPreferredWidthForHeight(args.Allocation.Height).MinSize;
                        });
                        sizeCheckStep = SizeCheckStep.AdjustSize;
                        Widget.QueueResize();
                    }
                }
            });
        }
コード例 #2
0
ファイル: WidgetBackend.cs プロジェクト: Clancey/xwt
        void HandleWidgetSizeAllocated(object o, Gtk.SizeAllocatedArgs args)
        {
            if ((enabledEvents & sizeCheckEvents) == 0)
            {
                // If no sizing event is set, it means this handler was set because there is a min size.
                // In that case, there isn't any thing left to do here
                return;
            }

            Toolkit.Invoke(delegate {
                if (sizeCheckStep == SizeCheckStep.SizeRequest && (enabledEvents & sizeCheckEvents) != sizeCheckEvents)
                {
                    var ev = EventSink.GetSizeRequestMode() == SizeRequestMode.HeightForWidth ? WidgetEvent.PreferredWidthCheck | WidgetEvent.PreferredHeightForWidthCheck : WidgetEvent.PreferredHeightCheck | WidgetEvent.PreferredWidthForHeightCheck;
                    // If all size request methods are overriden, the widget's size request won't be called, so this status is correct
                    if ((enabledEvents & ev) != ev)
                    {
                        Console.WriteLine("SizeRequest not called. Should not happen.");
                    }
                }
                else if (sizeCheckStep == SizeCheckStep.PreAllocate || sizeCheckStep == SizeCheckStep.AdjustSize)
                {
                    if (EventSink.GetSizeRequestMode() == SizeRequestMode.HeightForWidth)
                    {
                        realRequestedHeight = (int)eventSink.OnGetPreferredHeightForWidth(args.Allocation.Width).MinSize;
                        sizeCheckStep       = SizeCheckStep.AdjustSize;
                        Widget.QueueResize();
                    }
                    else
                    {
                        realRequestedWidth = (int)eventSink.OnGetPreferredWidthForHeight(args.Allocation.Height).MinSize;
                        sizeCheckStep      = SizeCheckStep.AdjustSize;
                        Widget.QueueResize();
                    }
                }
            });
        }
コード例 #3
0
ファイル: WidgetBackend.cs プロジェクト: Clancey/xwt
        void HandleWidgetSizeRequested(object o, Gtk.SizeRequestedArgs args)
        {
            if (gettingPreferredSize)
            {
                return;
            }

            var req = args.Requisition;

            if ((enabledEvents & sizeCheckEvents) == 0)
            {
                // If no sizing event is set, it means this handler was set because there is a min size.
                if (Frontend.MinWidth != -1)
                {
                    req.Width = (int)Frontend.MinWidth;
                }
                if (Frontend.MinHeight != -1)
                {
                    req.Height = (int)Frontend.MinHeight;
                }
                return;
            }

            if (sizeCheckStep == SizeCheckStep.AdjustSize)
            {
                req.Width     = realRequestedWidth;
                req.Height    = realRequestedHeight;
                sizeCheckStep = SizeCheckStep.FinalAllocate;
            }
            else
            {
                Toolkit.Invoke(delegate {
                    if (EventSink.GetSizeRequestMode() == SizeRequestMode.HeightForWidth)
                    {
                        if ((enabledEvents & WidgetEvent.PreferredWidthCheck) != 0)
                        {
                            var w     = eventSink.OnGetPreferredWidth();
                            req.Width = (int)w.MinSize;
                        }
                        if ((enabledEvents & WidgetEvent.PreferredHeightForWidthCheck) != 0)
                        {
                            if (doubleSizeRequestCheckSupported)
                            {
                                sizeCheckStep      = SizeCheckStep.PreAllocate;
                                realRequestedWidth = req.Width;                                 // Store the width, since it will be used in the next iteration
                            }
                            else
                            {
                                var h         = eventSink.OnGetPreferredHeightForWidth(req.Width);
                                req.Height    = (int)h.MinSize;
                                sizeCheckStep = SizeCheckStep.FinalAllocate;
                            }
                        }
                        else if ((enabledEvents & WidgetEvent.PreferredHeightCheck) != 0)
                        {
                            var h         = eventSink.OnGetPreferredHeight();
                            req.Height    = (int)h.MinSize;
                            sizeCheckStep = SizeCheckStep.FinalAllocate;
                        }
                    }
                    else
                    {
                        if ((enabledEvents & WidgetEvent.PreferredHeightCheck) != 0)
                        {
                            var h      = eventSink.OnGetPreferredHeight();
                            req.Height = (int)h.MinSize;
                        }
                        if ((enabledEvents & WidgetEvent.PreferredWidthForHeightCheck) != 0)
                        {
                            if (doubleSizeRequestCheckSupported)
                            {
                                sizeCheckStep       = SizeCheckStep.PreAllocate;
                                realRequestedHeight = req.Height;                                 // Store the height, since it will be used in the next iteration
                            }
                            else
                            {
                                var w         = eventSink.OnGetPreferredWidthForHeight(req.Height);
                                req.Width     = (int)w.MinSize;
                                sizeCheckStep = SizeCheckStep.FinalAllocate;
                            }
                        }
                        else if ((enabledEvents & WidgetEvent.PreferredWidthCheck) != 0)
                        {
                            var w         = eventSink.OnGetPreferredWidth();
                            req.Width     = (int)w.MinSize;
                            sizeCheckStep = SizeCheckStep.FinalAllocate;
                        }
                    }
                });
            }
            args.Requisition = req;
        }