8d.wxWidgets – wxStaticLine

OVERVIEW

wxStaticLine lets you draw horizontal or vertical lines in a window. The default style is horizontal unless your specify a wxLI_VERTICAL style. For both style of lines, the wxSize parameter specifies the length. You cannot change the thickness.

SAMPLE CODE

staticline.h
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
    #include <wx/wx.h>
#endif

class StaticLine: public wxFrame {

    public:
      StaticLine(const wxString &title);

};


staticline.cpp
#include "staticline.h"
#include <wx/statline.h>

StaticLine::StaticLine(const wxString &title):

    wxFrame(NULL, -1, title, wxDefaultPosition, wxSize(500,200)) {
 
    wxPanel *panel = new wxPanel(this, -1);   
    panel->SetBackgroundColour(wxColour(255,255,255)); 

    wxStaticLine *line1 = new wxStaticLine(panel, -1, wxPoint(10,10), wxSize(200,1));
    wxStaticLine *line2 = new wxStaticLine(panel, -1, wxPoint(30,70), wxSize(200,1));
    wxStaticLine *line3 = new wxStaticLine(panel, -1, wxPoint(30,70), wxSize(10,200), wxLI_VERTICAL);

    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 "staticline.h"
 
IMPLEMENT_APP(Main)

bool Main::OnInit() {

    StaticLine *app = new StaticLine(wxT("StaticLine"));
    app->Show(true);
}

The output is shown below

Be the first to comment

Leave a Reply

Your email address will not be published.


*