Window Painter

Introduction and Purpose

Window Painter allows the easy creation and/or amendment of simple dialogue windows. Controls may be inserted, resized, repositioned, or even moved onto a different parent. Window Painter simplifies the task of producing create() statements only; these are extracted from an existing program source and written back in plain text form. It remains the programmer's responsibility to attach handling routines such as the code to be run when a button is clicked.

Window Painter is intended to be a fairly simple but important time saver, not the heart of where software development occurs. Typically a programmer should not spend more than a few minutes at a time using it, though perhaps longer when experimenting with different approaches. Despite being an optional and technically stand-alone component, it is fully and seamlessly integrated into Edita.

Generally speaking, complex dynamic windows are outside the scope of this program, for example the main window of Edita, which has seven optional components (toolbar, tabs, treeview, message view, horizontal and vertical scrollbars, and status bar), and five (main editor pane, treeview, the message area, and both scrollbars) that are dynamically sized. If you try it, the window will be shown, but it won't look very familiar. Besides, in the case of the Edita main window, if you move or resize any of the controls shown, it will make little or no difference because they are automatically resized and repositioned when the program is run.

Instead, Window Painter is intended for use with the much larger number of simpler windows, typically those found on Tools and Options menus, and of course the main window on simpler applications.

Window Painter is not really intended to compete, for example, with the much more extensive Judith's IDE which many users, especially beginners, may prefer (not that I belive that product handles complex dynamic windows any better). Instead as the name suggests it only addresses the window painting aspect.

Personally, I find an IDE too restrictive, but without a simple Window Painter even a trivial dialogue with only three or four fields can sometimes take several edit/test cycles to get right. A good example, and perhaps the main impetus for writing Window Painter, is the Colour Selection dialogue in Edita. That deceptively simple window is in fact the fourth or fifth significant redesign; the swatches have been on the right of the radio buttons, the standard colours on the left, the edit text now at the top right has been a combo on the left hand side, and probably a few others I have forgotten. A relatively simple window like that can prove unusable if the controls are placed in the wrong order, for example if you have to select something on the right before something on the left is enabled. Window Painter makes such redesign a snip.

Status

Alpha Release 09/04/2005.
There are obviously a fair few bugs, but given the nature of this project, it is unlikely you will loose much work. One thing which is very irritating is the inability to redisplay the design window correctly with updated styles; I am using SetWindowPos with SWP_UPDATECACHE, but it is not doing the complete job (under windows 98). Suggestions welcome.

There is extensive checking, however in many cases failure simply terminates with a (deliberate) divide by zero. These will be replaced by more meaningful messages in the next few releases.

Features and Limitations

As usual, I shall be my own harshest critic. Hopefully you will read the positives into all these negative statements, because they basically state that many edge conditions have been thoroughly thought through.

Window Painter is complete, and works far better than I ever hoped.

It is of course possible to "work round" many of these limitations by using Window Painter to create a simple static version, and then edit the source to complete the program, in fact that is almost mandatory. It is also possible to leave a commented out "Window-Painter-friendly" version of each control next to the "live" one, switch between the two for layout modification, and then copy changes back by hand when finished (tip: search for "create").

Usage

Window Painter is invoked from the tools menu of Edita and operates on the currently active file. It may also be invoked standalone when Edita is not running, in which case it operates on ealtest.exw.

The current source is scanned and organised into windows. A selection dialogue is shown to allow one of the existing windows to be selected or a new one created. If the program contains no recognisable windows then the selection dialogue only permits a new window to be created, otherwise the initial focus is on the selection list, allowing up and down arrow to be used to choose the window to be amended. If any of the rules above are broken by the existing create statements, either an error message will be displayed when the window is selected, or in more severe cases the window will not be recognised as such, and will simply not appear in the list.

Two windows appear. The Window Painter window is initially show on the left. The design window is initially (when created anew) shown to the right, but in its final position during amendment, which in some cases may completely obscure the other window. Both windows can be resized, overlapped, minimised or maximised. For windows which should appear on the left hand side of the screen in the final application, the recommendation is to drag them over to the right while working on them in Window Painter, and drag them back to the left just before exiting.

The design (right hand) window is shown with the title as expected in the application; bear this in mind when the term "design window" is used below.

Right click on an empty area of the design window, or an existing Group, Tab, or ToolBar to insert a new control. Right clicking on other existing controls sets the focus to Window Painter to allow the properties to be updated.

Click on the titlebar of the design window if required to set Focus, and move the mouse over the design window to select, resize, or drag an existing control. Right click on a control or press F4 to set the focus to the Window Painter, with the text field (if visible) selected for amendment. Failing to right click and attempting to move the mouse over to the Window Painter (a natural thing to attempt) will usually select a different control as the mouse is moved.

Note the behaviour of the mouse cursor depends on whether the design window has focus or not.

The design window itself can be moved by dragging the title bar, or resized in the usual manner.

At the top of the Window Painter is a ComboDropDownList containing all the currently defined controls.

Name. The variable name. You should always change this to something more meaningful. This field always recieves focus first when a new control is created.

Type. The control type (non amendable).

Parent. The control's parent. This changes automatically as the control is dragged onto or off a Group or TabItem.

Text. Only shown for selected control types. Changes here are immediately reflected in the other window.

Bitmap. Only shown for selected control types. (Currently this is completely unsupported).

Style and StyleEx. Shows a selection of windows constants. When one of the constants shown is a combination of other constants, for example WS_CAPTION = WS_BORDER + WS_DLGFRAME, changing the setting of one may also change the setting of the others. Some entries may be disabled to indicate they are part of the class defaults, which Arwen always expects and therefore should not be altered. Note that some may be inappropriate or incorrectly applied when checked. (work in progress).

While it is possible to switch back to Edita and modify the current file while Window Painter is running, this should be considered highly dangerous, in that it may become impossible for Window Painter to safely apply the modifications made to the source file. If this happens, Window Painter will issue an error, and discard the amendments just made. This will also happen if you switch to a different source in Edita or close the file being amended by Window Painter. You should at the very least avoid modifying any create statements, which includes using cut/paste to change their order, or inserting or deleting any lines above the last relevant create statement. Amendments to lines below that point should not cause a problem. If possible, exit Window Painter, make whatever changes are needed in Edita, and re-invoke Window Painter.

Changes are automatically saved when Window Painter is exited. You can reverse any changes made to the program source using the standard undo facility (Ctrl Z).

Licence

Window Painter is an independant component of Edita.

Edita does not require Window Painter to be installed; Window Painter merely simplifies a common task which can be performed manually.

Window Painter does not store any required proprietory information about the layouts created or otherwise lock a developer into continued use. The result of using Window Painter is the complete source code (well, create statements) for your application. You are perfectly free to develop an application using Window Painter and then maintain it "by hand". Equally you can often take an application previously developed "by hand" and modify it using Window Painter. A licencing scheme is planned, but at the moment Window Painter is free.

The complete source code is not freely available. Few users would understand it, even fewer would contribute to its development, and no-one would gain since it would prevent Edita from (ever) being self-financing.

Selected parts of the source code may be released into the public domain. Please state any requirements in functional terms, for example if you would like the list of manual reorders to be passed to a routine rather than appear in a message box, or access to the list of currently defined controls, the location of the "insertion point", which will indicate what part of the source code an external program can safely modify, pre- and post-processing of modified create statements, external options for menu, toolbar, status bar or setHandler processing, etc. Simple curiosity is not, however, a functional requirement.

There is no absolute bar on open source advocates developing an equivalent program. However the closed source version must also be supplied so that users continue to have a choice. It is entirely my responsibility to ensure that the closed source version remains better than any open source alternative.