[program-l] Re: VB: Laying out items

  • From: "Jeff Bishop" <jeff@xxxxxxxxxxxxxx>
  • To: <program-l@xxxxxxxxxxxxx>
  • Date: Thu, 22 Sep 2005 10:48:34 -0700

This would be fantastic... 

-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx [mailto:program-l-bounce@xxxxxxxxxxxxx]
On Behalf Of Jamal Mazrui
Sent: Thursday, September 22, 2005 10:45 AM
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: VB: Laying out items

I have thought it might be useful for the blind programming community,
e.g., folks on this list, to develop a general algorithm for what could
be called "Layout by Code."  The code would define several variables and
constants at the start of a dialog creation routine, and would include
an outline of loops and conditional tests that such a task typically
needs to address a majority of layout cases.  

The algorithm would be implemented with the syntax of the language used
by the developer.  I know there are sophisticated attempts at doing
something like this, but they tend to require learning XML or some other
meta language that is a learning hurdle in itself.  Yet, for layout of
many, typical forms, a relatively simple and understandable outline
would do the job.  

I think that such a Layout by Code outline would be especially useful to
blind programmers, since layout-related challenges tend to be some of
the most common mentioned.

Jamal


-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx
[mailto:program-l-bounce@xxxxxxxxxxxxx] On Behalf Of
gerald.g.weichbrodt@xxxxxx
Sent: Thursday, September 22, 2005 1:07 PM
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: VB: Laying out items


Sounds very much like the sorts of things I do--sort of a homemade grid
layout. I find it lends itself nicely to throwing in little adaptations
for
form resizing, too.  For instance, if you have text boxes near the right
side of a form and know that the user might want to expand the form
horizontally with the hope of making more of the text visible, then
using
some variables that get adjusted based on form coordinates can make for
a
nice, easy way to do some quick adaptation in a resize event.  Sometimes
you can even do it in a loop.  Now, of course, I'm still talking VB 6
Dinosaurese, so some of this may not apply, but I suspect it would for
the
most part.


 

                      "Jamal Mazrui"

                      <Jamal.Mazrui@xxxxx        To:
<program-l@xxxxxxxxxxxxx>

                      ov>                        cc:

                      Sent by:                   Subject:  [program-l]
Re: VB: Laying out items                                          
                      program-l-bounce@fr

                      eelists.org

 

 

                      09/22/2005 11:58 AM

                      Please respond to

                      program-l

 

 





A google search found the following PDF file containing extensive
information on user interface design:

"Official Guidelines for User Interface Developers and Designers "
http://www.gpa.etsmtl.ca/cours/gpa789/pdf/OfficialGUI.pdf

I have not done nearly as much GUI programming as some on this list, but
an approach that seems to work well for layout works like this.  I use
integer variables such as iLeft, iTop, iWidth, and iHeight to hold
values for the position and size of a control in my code.  The function
call that creates a control passes these variables as parameters, so I
can repeat the same code for the same type of control (because these and
other variables are passed rather than literal values).

The coordinate variables are set just before calling the function to
create a control.  In general (but not always), the next control is
placed either to the right of the previous one at the same horizontal
level, or below the previous one at a lower horizontal level of the
form/dialog.  When a new horizontal level is started, controls begin at
the left margin, after a horizontal padding factor, and then proceed to
the right.

The coordinates for the next control to be placed may be obtained from
arithmetic operations on the coordinates for the control that was just
created.  If the next control is to be placed at the right, then
iLeft = iLeft + iWidth + iHorizontalPadding

The iTop variable does not change in this case because the control is at
the same horizontal level as its predecessor.

On the other hand, if the next control is to be placed below, then
iLeft = iHorizontalPadding

and
iTop = iTop + iHeight + iVerticalPadding

I set the iWidth and iHeight variables with common values for the width
and hight of each type of control.  These tend to be minimum values,
however, which may be increased to accomodate text that is longer than
usual in the control.  When the same control types occupy the same
horizontal level, I generally set their width and height dimensions to
be the same for visual asthetics--even if some controls do not need as
much of a bounding rectangle.

Hope this helps,
Jamal

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq



** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq


** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

Other related posts: