Blog
Lgi Table Layout For Controls
Date: 7/3/2005
It's always been a bit of sore point that Lgi hasn't supported any means of making the user interface, esp dialogs, sensitive to the size of the fonts and text in the controls. And well about 3 years too late I decided to do something about it. The main mechanism for storing information about controls in Lgi is the lr8 resource file, which any translator of Scribe will know all about. It stores a XML representation of all the strings, dialogs and menus the application uses.

What I've been working on is adding a new type of control, called GTableLayout to both LgiRes, the graphical design studio for lr8 files and the Lgi runtime shared library. The control takes the concepts of layout applied to HTML tables and applies them to windows controls. There are differences in how it works and it's somewhat simplified to keep code complexity down but it's essentially the same idea. This is what it looks like in the design tool:

As you can see it lets you add and remove rows and columns, span cells and add controls to the cells. The layout is irrelevant in this view. All that matters is the controls are sitting in the right cell.

The design tool saves the table's layout into the lr8 file like this:

<TableLayout pos="10,24,310,345" ref="2" cols="0.333,0.333,0.333" rows="0.500,0.500">
	<tr>
		<td>
			<StaticText pos="4,39,80,59" ref="3" />
		</td>
		<td colspan="2">
			<EditBox pos="102,67,262,87" ref="4" />
		</td>
	</tr>
	<tr>
		<td>
			<StaticText pos="4,186,80,199" ref="5" />
		</td>
		<td>
			<EditBox pos="112,224,160,244" ref="7" />
		</td>
		<td>
			<Button pos="207,193,227,213" ref="6" />
		</td>
	</tr>
</TableLayout>


Which neatly maps HTML tables into the lr8 format.

At runtime a layout algorithm puts the controls into more traditional positions. e.g. with normal and large fonts:

This technology should hopefully find it's way into Scribe and other Lgi application over time as it matures enough to be used in production code. The old days of having to hack the font size to fit in the controls fixed space are soon going to be a thing of the past. :)
 
Reply
From:
Email (optional): (Will be HTML encoded to evade harvesting)
Message:
 
Remember username and/or email in a cookie.
Notify me of new posts in this thread via email.
BBcode:
[q]text[/q]
[url=link]description[/url]
[img]url_to_image[/img]
[pre]some_code[/pre]
[b]bold_text[/b]