Starting a C++ version of the UI
authorviric <viriketo@gmail.com>
Sun, 13 Feb 2011 07:57:02 +0100
changeset 2 5331bd08a294
parent 1 d89c6e7de299
child 3 01dafa022fa1
Starting a C++ version of the UI
cpp/CMakeLists.txt
cpp/MainWindow.cpp
cpp/MainWindow.hpp
cpp/main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cpp/CMakeLists.txt	Sun Feb 13 07:57:02 2011 +0100
@@ -0,0 +1,13 @@
+PROJECT(lingvigilo)
+
+FIND_PACKAGE(wxWidgets)
+
+IF (wxWidgets_FOUND)
+    INCLUDE(${wxWidgets_USE_FILE})
+ENDIF (wxWidgets_FOUND)
+
+
+ADD_EXECUTABLE(lingvigilo
+    main.cpp
+    MainWindow.cpp)
+TARGET_LINK_LIBRARIES(lingvigilo ${wxWidgets_LIBRARIES})
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cpp/MainWindow.cpp	Sun Feb 13 07:57:02 2011 +0100
@@ -0,0 +1,18 @@
+#include <wx/wx.h>
+#include <wx/image.h>
+#include "MainWindow.hpp"
+
+MainWindow::MainWindow()
+    :wxFrame(0, wxID_ANY, _("Lingvigilo"), wxDefaultPosition)
+{
+    wxBoxSizer *s = new wxBoxSizer(wxVERTICAL);
+    wxStaticText *label = new wxStaticText(this, wxID_ANY,
+            _("Introdueix la frase:"));
+    wxTextCtrl *text = new wxTextCtrl(this, wxID_ANY);
+    s->Add(label);
+    s->Add(text);
+
+    text->SetFocus();
+
+    SetSizerAndFit(s);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cpp/MainWindow.hpp	Sun Feb 13 07:57:02 2011 +0100
@@ -0,0 +1,12 @@
+#ifndef _HEADER_MAINWINDOW_HPP_
+#define _HEADER_MAINWINDOW_HPP_
+
+#include <wx/wx.h>
+
+class MainWindow : public wxFrame
+{
+public:
+    MainWindow();
+};
+
+#endif /* _HEADER_MAINWINDOW_HPP_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cpp/main.cpp	Sun Feb 13 07:57:02 2011 +0100
@@ -0,0 +1,27 @@
+#include <wx/wx.h>
+#include <wx/log.h>
+#include <wx/image.h>
+#include <wx/string.h>
+#include <wx/init.h>
+
+#include "MainWindow.hpp"
+
+class MyApp : public wxApp
+{
+    public:
+        virtual bool OnInit();
+};
+
+IMPLEMENT_APP(MyApp)
+
+bool MyApp::OnInit()
+{
+    if(!wxApp::OnInit())
+        return false;
+
+    MainWindow *mw = new MainWindow();
+    mw->Show();
+    SetTopWindow(mw);
+
+    return true;
+}