Author: egon
Date: 2004-10-10 04:41:48 -0400 (Sun, 10 Oct 2004)
New Revision: 366
Added:
trunk/clients/wxhaver/wxHaver.cpp
trunk/clients/wxhaver/wxHaver.h
trunk/clients/wxhaver/wxh_includes.h
Log:
Basic wxHaver GUI done.
Added: trunk/clients/wxhaver/wxHaver.cpp
===================================================================
--- trunk/clients/wxhaver/wxHaver.cpp 2004-10-08 03:18:58 UTC (rev 365)
+++ trunk/clients/wxhaver/wxHaver.cpp 2004-10-10 08:41:48 UTC (rev 366)
@@ -0,0 +1,90 @@
+/* wxHaver: A client for the Haver chat system.
+ * Can someone add licensey things here? I'm no good at them :)
+ */
+
+#include "wx/wxprec.h"
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
+#endif
+
+#include "wx/splitter.h"
+
+#include "wxHaver.h"
+
+IMPLEMENT_APP(wxHaverApp); // I use these semicolons for vim's sake.
+
+bool wxHaverApp::OnInit()
+{
+ wxString vstr;
+ vstr.Printf("%d.%02d", WH_VERSION_MAJOR, WH_VERSION_MINOR);
+ wxHaverFrame *frame = new wxHaverFrame(_T("wxHaver/") + vstr,
+ wxPoint(-1, -1), wxSize(400, 300));
+ frame->Show(true);
+ SetTopWindow(frame);
+ return true;
+}
+
+//------------------------------------------------------------------------
+// wxHaverFrame
+//------------------------------------------------------------------------
+
+BEGIN_EVENT_TABLE(wxHaverFrame, wxFrame)
+ EVT_MENU(WH_ID_Quit, wxHaverFrame::OnQuit)
+ EVT_SPLITTER_SASH_POS_CHANGED(WH_CTRL_ServerSplitter,
+ wxHaverFrame::OnSashPosChanged)
+ EVT_SIZE(wxHaverFrame::OnSize)
+END_EVENT_TABLE()
+
+wxHaverFrame::wxHaverFrame(const wxString &title, const wxPoint &pos,
+ const wxSize &size):
+ wxFrame((wxFrame*)NULL, -1, title, pos, size), _splitSize(100)
+{
+ wxMenu *File_menu = new wxMenu;
+ File_menu->Append(WH_ID_Quit, "E&xit");
+
+ wxMenuBar *menuBar = new wxMenuBar;
+ menuBar->Append(File_menu, "&File");
+
+ SetMenuBar(menuBar);
+
+ mServerSplit = new wxSplitterWindow(this, WH_CTRL_ServerSplitter,
+ wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE);
+ mTextLines = new wxTextCtrl(mServerSplit, -1);
+ mTextEntry = new wxTextCtrl(this, -1);
+ mUserList = new wxListBox(mServerSplit, -1);
+
+ wxSize txtsize(mTextEntry->GetSize());
+ wxSize boxsize(mUserList->GetSize());
+ wxSize clientsize(GetClientSize());
+ mTextEntry->SetSize(0, clientsize.y - txtsize.y, clientsize.x,
txtsize.y);
+ mUserList->SetSize(clientsize.x - 100, 0, 100, clientsize.y -
txtsize.y);
+ mTextLines->SetSize(0, 0, clientsize.x - 100, clientsize.y - txtsize.y);
+
+ mTextLines->SetEditable(false);
+ mServerSplit->SplitVertically(mTextLines, mUserList, -_splitSize);
+
+ wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
+ topsizer->Add(mServerSplit, 1, wxGROW);
+ topsizer->Add(mTextEntry, 0, wxGROW);
+
+ SetSizer(topsizer);
+}
+
+void wxHaverFrame::OnSashPosChanged(wxSplitterEvent &event)
+{
+ _splitSize = GetClientSize().GetWidth() - event.GetSashPosition();
+ event.Skip();
+}
+
+void wxHaverFrame::OnSize(wxSizeEvent& event)
+{
+ if (mServerSplit)
+ mServerSplit->SetSashPosition(GetClientSize().GetWidth() -
_splitSize);
+ event.Skip();
+}
+
+void wxHaverFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
+{
+ Close(true);
+}
Added: trunk/clients/wxhaver/wxHaver.h
===================================================================
--- trunk/clients/wxhaver/wxHaver.h 2004-10-08 03:18:58 UTC (rev 365)
+++ trunk/clients/wxhaver/wxHaver.h 2004-10-10 08:41:48 UTC (rev 366)
@@ -0,0 +1,42 @@
+/* wxHaver: A client for the Haver chat system.
+ * Can someone add licensey things here? I'm no good at them :)
+ */
+
+#include "wx/wxprec.h"
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
+#endif
+
+#define WH_VERSION_MAJOR 0
+#define WH_VERSION_MINOR 1
+
+class wxHaverApp : public wxApp
+{
+ virtual bool OnInit();
+};
+
+class wxHaverFrame : public wxFrame
+{
+ public:
+ wxHaverFrame(const wxString &title,
+ const wxPoint &pos,
+ const wxSize &size);
+
+ void OnQuit(wxCommandEvent&);
+ void OnSize(wxSizeEvent&);
+ void OnSashPosChanged(wxSplitterEvent&);
+ private:
+ wxSplitterWindow *mServerSplit;
+ wxTextCtrl *mTextLines;
+ wxTextCtrl *mTextEntry;
+ wxListBox *mUserList;
+ int _splitSize;
+
+ DECLARE_EVENT_TABLE()
+};
+
+enum {
+ WH_ID_Quit = 1,
+ WH_CTRL_ServerSplitter,
+};
Added: trunk/clients/wxhaver/wxh_includes.h
===================================================================
--- trunk/clients/wxhaver/wxh_includes.h 2004-10-08 03:18:58 UTC (rev
365)
+++ trunk/clients/wxhaver/wxh_includes.h 2004-10-10 08:41:48 UTC (rev
366)
@@ -0,0 +1,7 @@
+// Just so I don't have to put in all this stuff at the top of every file :)
+
+#include "wx/wxprec.h"
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
+#endif