Jump to content

GDI "Widgets"


MattyD
 Share

Recommended Posts

Hey folks,

Let me start by saying that this is not widgets as in the Windows sense! This was project that I developed last year for a specific purpose, so yeah, I’m in no way expecting it to go anywhere (probably in the tldr bin).  I did think it was pretty cool though, and it was a ton of work - so here we go..

In short it’s a framework for dynamically drawing and refreshing GDI images in different areas of a screen or window.

The goals:

  • the "widgets" should scale themselves based on it's underlying window's size and dimensions

  • widgets should be able to be easily laid out, and be easily aligned with it's neighbours

  • widgets should dynamically update based on internal or external influences.

  • the framework should be scalable, and not resource intensive

  • Widgets should be modular - they should be able to be dropped in and out of a build, and easily written (within reason)

Currently the built in widgets are clocks, timers and textboxes.

The concept:

The window is first broken down into a grid of any number of rows and columns. Each one of the cells is designated a number based on its position in the grid.

When a widget is originally built, you can specify how many of these cells it should take up. The resulting space, be it a single cell or a group of cells is known as the widget’s canvas. This “canvas” is the only area that is redrawn when a widget needs to be refreshed.

The widget itself can have a specified aspect ratio, margin, zoom setting etc. These parameters are all combined to provide a bounding box for the widget to be drawn into.  When any of the values change, or the widget is retargeted to another part of the grid, the widget will redraw. Each widget also has abstract “data” parameters– if these are updated the widget will refresh itself.

So all up the process looks something like this:
- Create a parent/host window
- Pass the gui’s handle to the engine, along with how you’d like it sliced up
- Build an instance of a widget, while specifying it’s target canvas size (cell span).
- Send ‘paint’ commands to the widget, along with any other parameters you wish to update. The widget won’t actually redraw itself unless it needs to.


The ‘paint’ command for the most part should be continuously called in loop. This may be called on and ad-hoc basis if widget is designed to display something (more or less) static

To get started:

  1. extract the zip

  2. run the "build.au3"

this should build two binarys –

  • ·      Widg_Ctrl.exe (i.e. the "controller") can be used to control widgets via the binary’s STDInput.

  • ·      Widg_CLI.exe just creates a console attached to the controller - this is more for testing purposes

there are also two example scripts –

  • ·      SampleCtrlProj.au3 shows how you can use the controller, and pass through a ton of prepared commands/parameters via a text file (sample.conf)

  • ·      SampleLibProj.au3 bypasses the controller, and shows how you can manipulate widgets natively.

Lastly as a quick disclaimer, I never managed to put a good polish on the project - but it should be workable for the most part.

 

Widgets.zip

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...