Re: Discussion - how do you GUI?
- Posted by ryanj Apr 16, 2016
- 2094 views
I make GUI programs for my work and at home for various projects. For work the tasks are mainly conversion that take some type of data and process it to produce another form. I generally break up the task into these common discrete phases:
1 Load data into a form for viewing 2 Check/augment the data 3 Output the data to destination
It seems to me that it could be useful to have textboxes that can automatically format data to reduce the amount of logic code needed, or pop up an error when you click OK if data is invalid, and explain why it is invalid. I wrote some code that does this, and i was thinking about how to integrate it into Redy's GUI.
I try to make the programs as simple as possible since my users are non-technical. Windows are kept to a minimum. Listviews are used a LOT for viewing the kinds of data we deal with. A common control theme I use is to have a tab control sitting on the main window with each functional module sitting self-contained inside its own tab. Each tab/module has its own include file to keep the code structure intuitive.
That sounds similar to what i have been doing lately. Either lists or tabs to switch between views or files. I only use separate windows/dialogs for things that are a "separate thought process", like a Preferences dialog that you specifically open, change some things, and close, then going back to thinking about information in main window.
For work the only graphics I (currently) need are for dollying up pushbuttons. However, I have had to use my own 2d graphics library in the past to create a document previewer. I manually (or copy n paste) create each form in my IDE (which is really just a glorified text editor). One thing that would help the form design phase is to have a proper GUI designer. For my home projects I use the graphics library a lot in GUI programs.
As an aside, you mention support for 16 x 16 icons. As you know, Windows has different formats for different types of graphics (icons, cursors, bitmaps, dibsections). This has been such an annoyance for me that I ignored adding support for these things directly into my win32 library. I think it'd be better to have one format that can be manipulated by the one graphics library. This would imply creating certain controls as custom controls. For instance, instead of having a PushButton and a PictureButton, why not just have a Button that can have both an image and/or text on the face?
In Redy, i created a simple graphics "language", which is really just a simple parser that converts a sequence of drawing commands to platform-specific API calls. It can load images into memory and set up fonts and styles so you don't have to deal with the complicated handles and device contexts. Once an image is loaded from a file (or an embedded euphoria sequence), you can use in a canvas widget or other widget classes can use them (menu items, tool buttons, list items, tree nodes). I plan to add more features to this drawing language later, such as an "iff" command that can select a branch of commands based on the return value of a routine_id (for choosing a color, for example).
Another annoyance to do with graphics is the sizing issue. Your 16x16 icons become too small at certain resolutions. But is the way to solve this to create a set of icon images at different resolutions? A smart graphics library should be able to resize (a copy of) the icon to the desired resolution without amplifying jaggies. Using similar logic the same icon could serve as the basis of a disabled version. I do this with my custom HotButton controls. Only one icon is associated with the control. When the button state changes a new image is made, based on that one icon. I don't have to manually create a set of images beforehand to reflect the different button states.
Spock
I agree with this. I wanted to at least have 16x16 bitmaps for typical menu items and tool buttons for now, but it's definitely not a long-term solution. The problem i am running in to is i haven't wrapped enough API to load common image formats (besides bmp), scale images, fade them to grey, or use transparency. Then, there is the problem of putting together a collection of good icons. Definitely a lot of work.