\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#147: Make Grid's Column/Row Configure Easier}
\date{August 05, 2003}
\author{Peter Spjuth}
\urlstyle{sf}
\setlength{\parskip}{1ex}
\setlength{\parindent}{0pt}
\def\tipversion$#1${\texttt{\$#1\$}}
\def\tiplangle#1{\ensuremath{<}}
\def\tiprangle#1{\ensuremath{>}}
\def\tipbar#1{\ensuremath{|}}
\def\tipmail#1#2{\(\langle\){\small\expandafter\url{#1@#2}}\(\rangle\)}
\ifx\pdfoutput\undefined
\newcommand{\tipimage}[2]{\typeout{Make sure you download #1.eps}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.eps}}{\includegraphics[width=0.8\textwidth]{#1.eps}}}
\newcommand{\tipxref}[1]{}
\newcommand{\tipxrefend}{}
\else
\newcommand{\tipimage}[2]{\typeout{Make sure you create #1.pdf}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.pdf}}{\includegraphics[width=0.8\textwidth]{#1.pdf}}}
\pdfcatalog{/PageMode /UseOutlines}
\newcommand{\tipxref}[1]{\pdfannotlink attr {/C [0.5 0.5 1.0] /Border [0 0 1]} goto name {#1}}
\newcommand{\tipxrefend}{\pdfendlink}
\fi
\newenvironment{tipabstract}{\begin{abstract}}{\end{abstract}}
\begin{document}\maketitle
\begin{center}\begin{tabularx}{\linewidth}{|r@{: }X|}\hline
\textbf{TIP \#147}&\textbf{Make Grid's Column/Row Configure Easier}\\\hline
Author&

Peter Spjuth \tipmail{peter.spjuth}{space.se}
\\
Created&Tuesday, \(\text{5}^{\text{th}}\) August 2003\\
Type&Project\\
Tcl Version&\(8.5\)\\
State&Final\\
Vote&Done\\
Version&\tipversion$Revision: 1.5 $\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

This TIP proposes to add an alternative way to state which columns/rows in a grid are affected by an column/rowconfigure command.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Rationale}

Usually when doing a grid layout I tend to think in terms of what I want to do with a particular widget. For example a canvas or a frame that I want to expand within a resized window. Currently I need to translate that intention into a column and a row number to pass to column/rowconfigure. A more direct approach would be to pass the widget name directly to column/rowconfigure.

Another situation is when all columns should be affected. Here I currently need to list them all \{0 1 2 3 4 5\}. Allowing an ``all'' keyword makes it easier and the code becomes more maintainable since you can add/remove columns without updating the list.

What should be done when columnspan is greater than 1?

There are three obvious possibilities: affect all, affect the first and affect the last. Any of these may be wanted by a programmer at one time or another so whatever is chosen, someone will be annoyed with it. Affecting all seems most logical.

See also \url{http://sf.net/tracker/?func=detail&aid=659218&group_id=12997&atid=362997}

\section{Specification}

Anywhere \textit{column} is used below, the same applies to \textit{row} too.

In the \textit{index} argument to \textit{grid columnconfigure}, widget names and the keyword ``all'' is recognised besides the normal integers.

When a widget name is used, it must be currently managed by the given \textit{master}. The columns currently occupied by the widget are affected by the command.

When the keyword ``all'' is used, all columns currently occupied by widgets in \textit{master} are affected by the command.

\textit{Note:} ``Currently occupied'' means at the time of the invocation of the \textit{grid columnconfigure} command. The grid does not try to trace if a widget is moved in the grid or if more widgets are added.

\section{Examples}
\begingroup\small\begin{verbatim}
canvas .c
scrollbar .sbx -orient horizontal
scrollbar .sby -orient vertical
grid .c .sby -sticky news
grid .sbx    -sticky we
grid columnconfigure . .c -weight 1
grid rowconfigure    . .c -weight 1

button .b1 -text a
button .b2 -text b
button .b3 -text example
button .b4 -text xyzzy
grid .b1 .b2 .b3 .b4 -sticky news
grid columnconfigure . all -uniform a -weight 1
\end{verbatim}
\endgroup

\section{Other Possibilities}

One possibility that is not proposed in this TIP is to also recognise the end-style indexing that indices in Tcl support (through \textit{TclGetIntForIndex()}.)

Comment: ``Personally, I think that end-index handling will be quite tricky since it would require knowing what the *user* thinks is the last column.''

\section{Reference Implementation}

Not implemented yet.

\section{Copyright}

This document has been placed in the public domain.

\section{Colophon}

\textit{TIP AutoGenerator --- written by Donal K. Fellows}
\end{document}
