wxCMakeSetup.cxx 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. // wxCMakeSetup.cxx : implementation file
  14. //
  15. #include "cmSystemTools.h"
  16. #include "cmWXCommandLineInfo.h"
  17. #include "cmWXMainFrame.h"
  18. class wxCMakeSetup : public wxApp
  19. {
  20. public:
  21. virtual bool OnInit();
  22. virtual int OnExit();
  23. };
  24. class testFrame : public wxFrame
  25. {
  26. public:
  27. testFrame(const wxString& title, const wxSize& size)
  28. : wxFrame((wxFrame*)NULL, 0, title, wxDefaultPosition, size)
  29. {
  30. wxPanel *panel = new wxPanel(this, -1);
  31. wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
  32. wxWindow *value = new wxStaticText(panel, -1, "Some label");
  33. sizer->Add(value, 1, wxALIGN_CENTER_VERTICAL );
  34. value = new wxButton(panel, -1, "Button", wxDefaultPosition, wxSize(25, 0));
  35. sizer->Add(value, 0, wxALIGN_RIGHT);
  36. panel->SetAutoLayout( TRUE );
  37. panel->SetSizer(sizer);
  38. sizer->Fit(panel);
  39. sizer->SetSizeHints(panel);
  40. sizer->Layout();
  41. }
  42. };
  43. class testFrame1 : public wxFrame
  44. {
  45. public:
  46. testFrame1(const wxString& title, const wxSize& size)
  47. : wxFrame((wxFrame*)NULL, 0, title, wxDefaultPosition, size)
  48. {
  49. wxPanel *panel = new wxPanel(this, -1);
  50. panel->SetBackgroundColour(*wxRED);
  51. wxSizer *sizer = new wxFlexGridSizer(2, 5, 5);
  52. wxWindow *value = 0;
  53. int cc;
  54. for ( cc = 0; cc < 4; cc ++ )
  55. {
  56. char buffer[200];
  57. sprintf(buffer, "Long, Long Label; this label should be "
  58. "bigger than button %d",cc);
  59. value = new wxStaticText(panel, -1, buffer);
  60. sizer->Add(value, 1, wxGROW | wxALL );
  61. sprintf(buffer, "Button %d", cc);
  62. value = new wxButton(panel, -1, buffer);
  63. sizer->Add(value, 1, wxGROW | wxALL );
  64. }
  65. panel->SetAutoLayout( TRUE );
  66. panel->SetSizer(sizer);
  67. sizer->Fit(panel);
  68. sizer->SetSizeHints(panel);
  69. sizer->Layout();
  70. }
  71. };
  72. class testFrame2 : public wxFrame
  73. {
  74. public:
  75. testFrame2(const wxString& title, const wxSize& size)
  76. : wxFrame((wxFrame*)NULL, 0, title, wxDefaultPosition, size)
  77. {
  78. wxPanel *panel = new wxPanel(this, -1);
  79. panel->SetBackgroundColour(*wxRED);
  80. new wxTextCtrl(panel, -1, "Test", wxPoint(40, 5));
  81. new wxButton(panel, -1, "Test", wxPoint(-1, 5));
  82. }
  83. };
  84. class testFrame3 : public wxFrame
  85. {
  86. public:
  87. testFrame3(const wxString& title, const wxSize& size)
  88. : wxFrame((wxFrame*)NULL, 0, title, wxDefaultPosition, size)
  89. {
  90. this->CreateStatusBar();
  91. this->SetSizeHints(300, 300);
  92. wxPanel *panel = new wxPanel(this, -1);
  93. wxSizer *sizer = new wxFlexGridSizer(2, 5, 5);
  94. wxWindow *value = 0;
  95. int cc;
  96. for ( cc = 0; cc < 10; cc ++ )
  97. {
  98. char buffer[200];
  99. sprintf(buffer, "Label %d",cc);
  100. value = new wxStaticText(panel, -1, buffer);
  101. sizer->Add(value, 1, wxGROW | wxALL );
  102. sprintf(buffer, "Button %d", cc);
  103. value = new wxButton(panel, -1, buffer);
  104. sizer->Add(value, 1, wxGROW | wxALL );
  105. value->SetClientData(this);
  106. value->Connect(-1, wxEVT_MOTION,
  107. (wxObjectEventFunction) &testFrame3::OnStatusBar);
  108. }
  109. panel->SetAutoLayout( TRUE );
  110. panel->SetSizer(sizer);
  111. sizer->Fit(panel);
  112. sizer->SetSizeHints(panel);
  113. sizer->Layout();
  114. }
  115. void OnStatusBar(wxEvent& event)
  116. {
  117. wxControl* eobject = static_cast<wxControl*>(event.GetEventObject());
  118. testFrame3* self = static_cast<testFrame3*>(eobject->GetClientData());
  119. wxString str;
  120. const char* chars = "|-\\/jg@_^";
  121. char ch = chars[((int)eobject)/1024 % strlen(chars)];
  122. int cc;
  123. for ( cc = 0; cc < 10; cc ++ )
  124. {
  125. str += ch;
  126. }
  127. self->SetStatusText(str);
  128. }
  129. };
  130. bool wxCMakeSetup::OnInit()
  131. {
  132. cmSystemTools::DisableRunCommandOutput();
  133. cmCommandLineInfo cm;
  134. cm.SetValidArguments("ABGHQ");
  135. cm.ParseCommandLine(wxApp::argc, wxApp::argv);
  136. this->SetVendorName("Kitware");
  137. this->SetAppName("CMakeSetup");
  138. cmMainFrame *frame = new cmMainFrame("CMake", wxSize(200, 100));
  139. frame->SetApplication(this);
  140. frame->Initialize(&cm);
  141. //wxFrame *frame = new testFrame("CMake", wxSize(200, 100));
  142. //wxFrame *frame = new testFrame1("Frame", wxSize(200, 100));
  143. //wxFrame *frame = new testFrame2("Frame", wxSize(200, 100));
  144. //wxFrame *frame = new testFrame3("Frame", wxSize(200, 100));
  145. frame->Show(TRUE);
  146. this->SetTopWindow(frame);
  147. return TRUE;
  148. }
  149. int wxCMakeSetup::OnExit()
  150. {
  151. // clean up: Set() returns the active config object as Get() does, but unlike
  152. // Get() it doesn't try to create one if there is none (definitely not what
  153. // we want here!)
  154. //delete wxConfigBase::Set((wxConfigBase *) NULL);
  155. return 0;
  156. }
  157. IMPLEMENT_APP(wxCMakeSetup)