Wednesday, April 26, 2006

Form layout styling with CSS

You can style forms using CSS and definition lists instead of tables. This has only been tested in IE6 and Firefox. As a basis I define the form in HTML as follows:

<fieldset class="form">
 <legend>Add Contact</legend>
 <dl>
  <dt>Forename: </dt>
  <dd><input type="text" name="forename" id="forename" /></dd>
  <dt>Surname: </dt>
  <dd><input type="text" name="surname" id="surname" /></dd>
  <dt>Email: </dt>
  <dd><input type="text" name="email" id="email" /></dd>
  <dt></dt>
  <dd><input type="submit" value="Add" /></dd>
 </dl>
</fieldset>

And the CSS:

fieldset.form {
 width: 95%;
 border: 1px dotted #ccc;
 padding: 12px;
}

fieldset.form legend {
 font-weight: bold;
 background: #fff;
}

fieldset.form dl {
 float: left;
 clear: both;
}

fieldset.form dl dt {
 clear: left;
 float: left;
 width: 110px;
 margin: .5em 0;
 text-align: right;
}

fieldset.form dl dd {
 margin: .5em 0;
 float: left;
 padding: 0 0 0 4px;
}

* html fieldset.form dl dd {
 float: none;
 margin: .5em 0 0 0;
}

fieldset.form dl dt is the definition for the label accompanying an input control. It has a fixed width and is right-aligned. fieldset.form dl dd is the input control next to the label. The * html fieldset.form dl dd is used to fix a few bugs in IE - without it, the input controls are not next to the labels, and the seperation between items is greater than it should be.

Sample:

Add Contact
Forename:
Surname:
Email:

Tags: ,

Friday, April 07, 2006

Portable GIMP + Extras (Help and Animation Package)

It is possible to run The GIMP (an open source alternative to Photoshop) off an external USB drive. There are instruction on how to do it from Cemetech | View topic - Making The GIMP Portable and a Zip file (XGimp_2.2.10_all_lang.zip) from WinPenPack's Grafica section (Italian site, found via tech poetic » Blog Archive » portable GIMP by winpenpack.com). The problem with these solutions is that they do not include the extras, and (in the case of the WinPenPack site) depend on a third party to update them when new versions of the software come out. Here is another way to do it manually, and should apply to future updates.

First of all download The GIMP for Windows, GTK + Runtime Environment, GIMP Help 2 and GIMP Animation Package from http://gimp-win.sourceforge.net/stable.html. You will require approximately 90MB free disk space on your external drive, 100MB if you want to be on the safe side. After you have downloaded the files and confirmed that you have enough space, install in order:

  1. GTK + Runtime Environment
  2. The GIMP for Windows (uncheck the box prompting you to launch the GIMP after setup)
  3. GIMP Help 2
  4. GIMP Animation Package

If you have any other plugins etc that you use, install them before continuing. After these have all been installed, you need to copy the GTK runtime:

  1. Go to C:\Program Files\Common Files
  2. Copy GTK folder
  3. Go to external drive (e.g. E:)
  4. Paste GTK folder
  5. Go to E:\GTK\2.0
  6. Delete unins000.dat, unins000.exe and uninst.isl

Now copy over The GIMP:

  1. Go to C:\Program Files
  2. Copy GIMP-2.0
  3. Go to external drive (e.g. E:)
  4. Paste GIMP-2.0 folder
  5. Go to E:\GIMP-2.0
  6. Delete unins000.dat, unins000.exe and uninst.ini

Now uninstall The GIMP and GTK + (unless you use GTK + for other applications).

In the root of your external drive (e.g. E:\), create a text file named gimp.cmd containing the following:

@echo off
SET HOME=
SET GIMP2_DIRECTORY=\GIMP-2.0\pref
SET PATH=\GTK\2.0\bin\;%PATH%
cd \GIMP-2.0\bin
echo Starting GIMP...
start gimp-2.2.exe

If you want your settings to be different on each computer, remove the line SET GIMP2_DIRECTORY=\GIMP-2.0\pref

To use the built-in help browser (which is what I prefer to use) rather than the systems default web browser, launch The GIMP (from the gimp.cmd file) and choose Preferences from the File menu. Click Help System and set Help Browser to GIMP help browser.


Tags: ,