CMake/Source/WXDialog/wxCMakeSetup.cxx

176 lines
5.3 KiB
C++
Raw Normal View History

2002-09-19 17:47:18 +04:00
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
2002-09-19 17:47:18 +04:00
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
2002-09-19 17:47:18 +04:00
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
// wxCMakeSetup.cxx : implementation file
//
#include "cmSystemTools.h"
#include "cmWXCommandLineInfo.h"
#include "cmWXMainFrame.h"
class wxCMakeSetup : public wxApp
{
public:
virtual bool OnInit();
virtual int OnExit();
};
class testFrame : public wxFrame
{
public:
testFrame(const wxString& title, const wxSize& size)
: wxFrame((wxFrame*)NULL, 0, title, wxDefaultPosition, size)
{
wxPanel *panel = new wxPanel(this, -1);
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
wxWindow *value = new wxStaticText(panel, -1, "Some label");
sizer->Add(value, 1, wxALIGN_CENTER_VERTICAL );
value = new wxButton(panel, -1, "Button", wxDefaultPosition, wxSize(25, 0));
sizer->Add(value, 0, wxALIGN_RIGHT);
panel->SetAutoLayout( TRUE );
panel->SetSizer(sizer);
sizer->Fit(panel);
sizer->SetSizeHints(panel);
sizer->Layout();
}
};
class testFrame1 : public wxFrame
{
public:
testFrame1(const wxString& title, const wxSize& size)
: wxFrame((wxFrame*)NULL, 0, title, wxDefaultPosition, size)
{
wxPanel *panel = new wxPanel(this, -1);
panel->SetBackgroundColour(*wxRED);
wxSizer *sizer = new wxFlexGridSizer(2, 5, 5);
wxWindow *value = 0;
int cc;
for ( cc = 0; cc < 4; cc ++ )
{
char buffer[200];
sprintf(buffer, "Long, Long Label; this label should be "
"bigger than button %d",cc);
2002-09-19 17:47:18 +04:00
value = new wxStaticText(panel, -1, buffer);
sizer->Add(value, 1, wxGROW | wxALL );
sprintf(buffer, "Button %d", cc);
value = new wxButton(panel, -1, buffer);
sizer->Add(value, 1, wxGROW | wxALL );
}
panel->SetAutoLayout( TRUE );
panel->SetSizer(sizer);
sizer->Fit(panel);
sizer->SetSizeHints(panel);
sizer->Layout();
}
};
class testFrame2 : public wxFrame
{
public:
testFrame2(const wxString& title, const wxSize& size)
: wxFrame((wxFrame*)NULL, 0, title, wxDefaultPosition, size)
{
wxPanel *panel = new wxPanel(this, -1);
panel->SetBackgroundColour(*wxRED);
2002-09-23 21:32:14 +04:00
new wxTextCtrl(panel, -1, "Test", wxPoint(40, 5));
new wxButton(panel, -1, "Test", wxPoint(-1, 5));
2002-09-19 17:47:18 +04:00
}
};
class testFrame3 : public wxFrame
{
public:
testFrame3(const wxString& title, const wxSize& size)
: wxFrame((wxFrame*)NULL, 0, title, wxDefaultPosition, size)
{
this->CreateStatusBar();
this->SetSizeHints(300, 300);
wxPanel *panel = new wxPanel(this, -1);
wxSizer *sizer = new wxFlexGridSizer(2, 5, 5);
wxWindow *value = 0;
int cc;
for ( cc = 0; cc < 10; cc ++ )
{
char buffer[200];
sprintf(buffer, "Label %d",cc);
value = new wxStaticText(panel, -1, buffer);
sizer->Add(value, 1, wxGROW | wxALL );
sprintf(buffer, "Button %d", cc);
value = new wxButton(panel, -1, buffer);
sizer->Add(value, 1, wxGROW | wxALL );
value->SetClientData(this);
value->Connect(-1, wxEVT_MOTION,
(wxObjectEventFunction) &testFrame3::OnStatusBar);
}
panel->SetAutoLayout( TRUE );
panel->SetSizer(sizer);
sizer->Fit(panel);
sizer->SetSizeHints(panel);
sizer->Layout();
}
void OnStatusBar(wxEvent& event)
{
wxControl* eobject = static_cast<wxControl*>(event.GetEventObject());
testFrame3* self = static_cast<testFrame3*>(eobject->GetClientData());
wxString str;
const char* chars = "|-\\/jg@_^";
char ch = chars[((int)eobject)/1024 % strlen(chars)];
int cc;
for ( cc = 0; cc < 10; cc ++ )
{
str += ch;
}
self->SetStatusText(str);
}
};
bool wxCMakeSetup::OnInit()
{
cmSystemTools::DisableRunCommandOutput();
cmCommandLineInfo cm;
2002-09-20 01:35:06 +04:00
cm.SetValidArguments("ABGHQ");
2002-09-19 17:47:18 +04:00
cm.ParseCommandLine(wxApp::argc, wxApp::argv);
2002-11-15 02:18:49 +03:00
this->SetVendorName("Kitware");
2002-09-19 17:47:18 +04:00
this->SetAppName("CMakeSetup");
cmMainFrame *frame = new cmMainFrame("CMake", wxSize(200, 100));
2002-11-15 02:18:49 +03:00
frame->SetApplication(this);
2002-09-19 17:47:18 +04:00
frame->Initialize(&cm);
//wxFrame *frame = new testFrame("CMake", wxSize(200, 100));
//wxFrame *frame = new testFrame1("Frame", wxSize(200, 100));
//wxFrame *frame = new testFrame2("Frame", wxSize(200, 100));
//wxFrame *frame = new testFrame3("Frame", wxSize(200, 100));
frame->Show(TRUE);
this->SetTopWindow(frame);
return TRUE;
2002-09-19 17:47:18 +04:00
}
int wxCMakeSetup::OnExit()
{
// clean up: Set() returns the active config object as Get() does, but unlike
// Get() it doesn't try to create one if there is none (definitely not what
// we want here!)
//delete wxConfigBase::Set((wxConfigBase *) NULL);
return 0;
}
IMPLEMENT_APP(wxCMakeSetup)