Lightweight GUI Library
3.4.0
This library is aimed at producing small, quality applications that run on multiple platforms.
The way this is acheived is by implementing a common API that is simple to use and allows access to the features of the supported platforms in a (preferably) highest common denominator fashion. Features should be synthesised when not present if practical.
Initially you should configure the required and recomended libraries that Lgi uses.
If you don't have any of these libraries then you should set the appropriate define in
Lgi.h to '0'
If your building on Win32 with Visual C++ then you'll need to make some edits to the default project settings to make linking against the library work. Heres a list of the things you need to change from the defaults:
-
Project Settings:
-
C++ Tab
-
General Section:
-
Warning level: 1
-
[Optional] Release Mode - Optimizations: Smaller
-
[Optional] Debug Mode - Debug Info: Program Database
-
C++ Language:
-
Code Generation:
-
Release Mode - Use runtime library: Multi-threaded DLL
-
Debug Mode - Use runtime library: Debug Multi-threaded DLL
-
Preprocessor:
-
[Optional] Additional Include Directories: ..\lgi\include\common,..\lgi\include\win32 or whatever the paths to the Lgi include directories are. Alternatively you can add the include paths to Visual C++'s Tools -> Options -> Directories window.
-
Link
-
General
-
[Optional, if using GTextView3] Additional Libraries: imm32.lib
Firstly include the file
LgiMain.cpp into your project, which will handle some of the setup for and then call
LgiMain(). In your own source code implement
LgiMain() like this:
int LgiMain(OsAppArguments &Args)
{
GApp *App = new GApp("application/x-MyProgram", Args);
if (App && App->IsOk())
{
App->AppWnd = new MyWindow;
App->Run();
delete App;
}
return 0;
}
Where 'MyWindow' is a class that inherits from
GWindow. This class should initialize the user interface for your application and then make itself visible. This is typically done like this:
class MyWindow : public GWindow
{
public:
MyWindow()
{
GRect r(0, 0, 700, 600);
SetPos(r);
MoveToCenter();
SetQuitOnClose(true);
Name("My Application");
#ifdef WIN32
CreateClass("MyApp");
#endif
if (Attach(0))
{
Visible(true);
}
}
};
This will put a simple empty window on the screen. The sorts of classes you'll be using to fill in the contents of the window will be:
A
GWindow will layout controls automatically according to the order you attach (
GView::Attach) them. The first window gets to lay itself out anywhere in the client area, and once it's positioned itself, the second window gets the area left over. And so on until the window is filled. There are a number of helper functions for layout:
Usually you attach a
GToolBar first, as it will automatically slide in below the menu (if any). Then a GStatusBar, if your going to need one. And finally a
GSplitter or
GList to fill out the rest of the space. The standard method of attaching a view to a
GWindow in the constructor of your window:
Where MyChildWindow1 and MyChildWindow2 are
GView based classes.
At some point you may want to put a dialog on the screen to get input from the user or provide the user with information. There are several pre-rolled dialogs, as well as support for custom dialogs. Firstly the pre-rolled dialogs are:
To create your own custom dialog you derive from:
Throughout Lgi applications windows can be constructed from a variety of Controls (or Widgets, or Views) that form the common methods for interacting with users and displaying information. Lgi has a rich set of bundled controls as well as support for writing your own. Here is an index of the built in controls:
However it's fairly easy to write custom controls by inheriting from
GLayout (or
GView for the hardcore) and implementing the required functionality by override various events like
GView::OnPaint and
GView::OnMouseClick.