xref: /netbsd-src/external/gpl2/gettext/dist/gettext-tools/examples/hello-csharp-forms/README (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
1*946379e7SchristosBefore you read the hello.cs source code:
2*946379e7Schristos
3*946379e7SchristosPreface about GUI Programming Methodologies
4*946379e7Schristos===========================================
5*946379e7Schristos
6*946379e7SchristosThe traditional GUI programming methodology for Windows GUI programmers
7*946379e7Schristosis to assemble controls using a GUI builder. These GUI builders
8*946379e7Schristosdon't have good techniques for determining the size and position of the
9*946379e7Schristoscontrols depending on their contents. Instead, they *hardcode* the
10*946379e7Schristossize and positions of the controls in each panel, as fixed numbers,
11*946379e7Schristosmeasured in pixels.
12*946379e7Schristos
13*946379e7SchristosWhat are the consequences?
14*946379e7Schristos
15*946379e7Schristos1) Consequences for all users:
16*946379e7Schristos   Such panels would not look nice when the user resizes them. So the
17*946379e7Schristos   programmer simply makes the dialogs non-resizable. When such a
18*946379e7Schristos   panel then contains a scrollable list of items, with 100 items and
19*946379e7Schristos   a scroll window of 5 items, a user's normal reaction is to enlarge
20*946379e7Schristos   the dialog, to see more items. But the dialog is not resizable!
21*946379e7Schristos   Frustration.
22*946379e7Schristos
23*946379e7Schristos2) Consequences for disabled users:
24*946379e7Schristos   Some users need bigger fonts for working comfortably. Guess what
25*946379e7Schristos   happens when the user changes the size of the default system font?
26*946379e7Schristos   Many labels in dialogs are truncated.
27*946379e7Schristos
28*946379e7Schristos3) Consequences for internationalization:
29*946379e7Schristos   The translation of a term or label in another language often needs
30*946379e7Schristos   more screen space. For example, Japanese translations often are 30%
31*946379e7Schristos   longer than the original English label. Therefore, if only the strings
32*946379e7Schristos   of a dialog are localized, many labels are truncated.
33*946379e7Schristos
34*946379e7SchristosProblems 1 and 2 are usually accepted in the Windows programmers
35*946379e7Schristoscommunity. (Problem 1 is not fatal, only frustrating. And problem 2
36*946379e7Schristosaffects only a small proportion of the users; they are simply ignored.)
37*946379e7SchristosProblem 3 is "solved" by letting the localization team not only translate
38*946379e7Schristosthe strings, but also redo the layout of each dialog.
39*946379e7Schristos
40*946379e7SchristosIn contrast, the methodology of programmers of the Qt/KDE, Gtk/GNOME,
41*946379e7SchristoswxWidgets, AWT, Swing, Tk toolkits is to have the positions and sizes
42*946379e7Schristosof controls determined at runtime, according to
43*946379e7Schristos  - the needs of the control itself,
44*946379e7Schristos  - the needs of the other controls in the panel,
45*946379e7Schristos  - the available panel size, given by the user through resizing.
46*946379e7SchristosThe common technology for this approach is to group related controls
47*946379e7Schristostogether in containers, and perform size and position propagations
48*946379e7Schristosbetween the controls of the container, the container, the container's
49*946379e7Schristoscontainer etc. These computations are performed by so-called
50*946379e7Schristos"layout manager" objects.
51*946379e7SchristosOther technologies such as global constraint systems (as in Garnet) or
52*946379e7Schristosspring-like attachments are not so much in use anymore nowadays.
53*946379e7Schristos
54*946379e7SchristosThis programmed-resizing methodology solves the problems 1), 2) and 3).
55*946379e7Schristos
56*946379e7SchristosWhat are the associated costs and efforts? Taking the programmed-resizing
57*946379e7Schristosmethodology as baseline, the hardcoded sizes and positions approach has
58*946379e7Schristos  - the advantage that the programmer saves about 1/3 of the GUI
59*946379e7Schristos    programming work (namely choosing the layout managers and setting
60*946379e7Schristos    alignment hints),
61*946379e7Schristos  - the drawback that each localization team has much more work, namely
62*946379e7Schristos    to rearrange the controls in the panel.
63*946379e7SchristosIn most free software projects, there are at least ca. 5 localizations;
64*946379e7Schristossuccessful projects even have 30 or 50 localizations.
65*946379e7SchristosIn other words, a program built with hardcoded sizes and positions
66*946379e7Schristoscannot afford many localizations, or the effort for localization will
67*946379e7Schristosbe prohibitively high.
68*946379e7Schristos
69*946379e7SchristosFor this reason, we strongly recommend to use the programmed-resizing
70*946379e7Schristosmethodology. In this example, since the Windows.Forms package lacks
71*946379e7Schristoslayout manager classes, we compute the layout by hand, through an
72*946379e7Schristosoverride of the OnResize method. For larger programs, we would recommend
73*946379e7Schristosto build a few simple layout managers, to get on par with the layout
74*946379e7Schristosabilities found in Qt, Swing, etc.
75*946379e7Schristos(The layout system of Gtk/GNOME is somewhat particular: It does not
76*946379e7Schristosprovide the ability to set a preferred alignment on controls like labels.
77*946379e7SchristosInstead one uses intermediate containers for the purpose of alignment.)
78*946379e7Schristos
79*946379e7SchristosAcknowledgement: This preface borrows ideas from an article of Luke Plant.
80*946379e7Schristos
81*946379e7SchristosCopyright (C) 2006 Free Software Foundation, Inc.
82