dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] pnetlib/System.Windows.Forms ButtonBoxLayout.cs, N


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] pnetlib/System.Windows.Forms ButtonBoxLayout.cs, NONE, 1.1 HBoxLayout.cs, 1.1, 1.2 MessageBox.cs, 1.6, 1.7
Date: Fri, 14 Nov 2003 05:54:17 +0000

Update of /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms
In directory subversions:/tmp/cvs-serv16997/System.Windows.Forms

Modified Files:
        HBoxLayout.cs MessageBox.cs 
Added Files:
        ButtonBoxLayout.cs 
Log Message:


Add the "ButtonBoxLayout" class as a variant of "HBoxLayout" - it correctly
lays out buttons at the bottom of a "MessageBox" dialog.


Index: MessageBox.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/MessageBox.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** MessageBox.cs       14 Nov 2003 02:36:32 -0000      1.6
--- MessageBox.cs       14 Nov 2003 05:54:15 -0000      1.7
***************
*** 222,226 ****
                private VBoxLayout vbox;
                private HBoxLayout hbox;
!               private HBoxLayout buttonBox;
                private bool hasCancel;
  
--- 222,226 ----
                private VBoxLayout vbox;
                private HBoxLayout hbox;
!               private ButtonBoxLayout buttonBox;
                private bool hasCancel;
  
***************
*** 248,252 ****
                                vbox = new VBoxLayout();
                                hbox = new HBoxLayout();
!                               buttonBox = new HBoxLayout();
                                vbox.Controls.Add(hbox);
                                vbox.Controls.Add(buttonBox);
--- 248,252 ----
                                vbox = new VBoxLayout();
                                hbox = new HBoxLayout();
!                               buttonBox = new ButtonBoxLayout();
                                vbox.Controls.Add(hbox);
                                vbox.Controls.Add(buttonBox);

Index: HBoxLayout.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/HBoxLayout.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** HBoxLayout.cs       14 Nov 2003 02:36:32 -0000      1.1
--- HBoxLayout.cs       14 Nov 2003 05:54:15 -0000      1.2
***************
*** 33,37 ****
        private bool uniformSize;
        private Control stretchControl;
!       private int margin, spacing;
  
        // Constructor.
--- 33,37 ----
        private bool uniformSize;
        private Control stretchControl;
!       protected int margin, spacing;
  
        // Constructor.
***************
*** 168,172 ****
  
        // Lay out the children in this control uniformly.
!       private void UniformLayout()
                        {
                                int numVisible = 0;
--- 168,172 ----
  
        // Lay out the children in this control uniformly.
!       protected virtual void UniformLayout()
                        {
                                int numVisible = 0;
***************
*** 221,225 ****
  
        // Lay out the children in this control non-uniformly.
!       private void NonUniformLayout()
                        {
                                ControlCollection controls = Controls;
--- 221,225 ----
  
        // Lay out the children in this control non-uniformly.
!       protected virtual void NonUniformLayout()
                        {
                                ControlCollection controls = Controls;

--- NEW FILE: ButtonBoxLayout.cs ---
/*
 * ButtonBoxLayout.cs - Implementation of the
 *                      "System.Windows.Forms.ButtonBoxLayout" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Windows.Forms
{

using System.Drawing;

// This is a special-purpose control that lays out its children horizontally,
// under the assumption that they are buttons along the bottom of a dialog.
// It is intended for use inside dialog box controls like "MessageBox".

internal class ButtonBoxLayout : HBoxLayout
{
        // Constructor.
        public ButtonBoxLayout() : base()
                        {
                                UniformSize = true;
                        }

        // Lay out the children in this control uniformly.  We leave extra
        // space on the left and right, with the buttons laid out in the
        // middle of the layout area.
        protected override void UniformLayout()
                        {
                                int numVisible = 0;
                                int index;
                                int width, height;
                                int maxWidth;
                                int xposn;
                                Size childSize;

                                // Count the number of visible child controls
                                // and discover the maximum control width.
                                maxWidth = 0;
                                foreach(Control child1 in Controls)
                                {
                                        if(child1.visible)
                                        {
                                                childSize = 
GetRecommendedSize(child1);
                                                if(childSize.Width > maxWidth)
                                                {
                                                        maxWidth = 
childSize.Width;
                                                }
                                                ++numVisible;
                                        }
                                }
                                if(numVisible == 0)
                                {
                                        return;
                                }

                                // Determine the optimal width and height.
                                width = maxWidth;
                                xposn = width * numVisible + (numVisible - 1) * 
spacing;
                                xposn = (ClientSize.Width - xposn) / 2;
                                height = ClientSize.Height - margin * 2;

                                // Lay out the visible controls.
                                index = 0;
                                foreach(Control child in Controls)
                                {
                                        if(!(child.visible))
                                        {
                                                continue;
                                        }
                                        child.SetBounds
                                                (xposn + index * (width + 
spacing), margin,
                                                 width, height);
                                        ++index;
                                }
                        }

}; // class ButtonBoxLayout

}; // namespace System.Windows.Forms





reply via email to

[Prev in Thread] Current Thread [Next in Thread]