OVERVIEW
We take a look at placing controls in a window with absolute positioning. This is not of much practical use except if you make GUI which are of fixed sizes. In the example below, the controls will not change in size and position if you resize the window.
SAMPLE CODE
absolute.h
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
class Absolute: public wxFrame {
public:
Absolute(const wxString &title);
};
absolute.cpp
#include "absolute.h"
Absolute::Absolute(const wxString &title):
wxFrame(NULL, -1, title, wxDefaultPosition, wxSize(500,350)) {
wxPanel *panel = new wxPanel(this, -1);
wxButton *btn = new wxButton(panel, -1, wxT("I am at 20,20"), wxPoint(20,20));
wxStaticText *label = new wxStaticText(panel, -1, wxT("I am at 40,100"), wxPoint(40,100));
wxTextCtrl *edit = new wxTextCtrl(panel, -1, wxT("This is first line\nThis is second line"),
wxPoint(100,150), wxSize(220,40), wxTE_MULTILINE);
Center();
}
main.h
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
class Main: public wxApp {
public:
virtual bool OnInit();
};
main.cpp
#include "main.h"
#include "absolute.h"
IMPLEMENT_APP(Main)
bool Main::OnInit() {
Absolute *app = new Absolute(wxT("Absolute Positioning"));
app->Show(true);
}
The output is shown below
Absolute positioning is necessary if you want position view ports with numbers or other info on a fixed image representing some kind of layout (hydraulic electrical, etc.). I hope wxWidgets and wxFormBuilder or other tools will be available in the near future. This is a good start to allow the kind of things I mentioned.