Author: dylan
Date: 2004-06-28 00:38:48 -0400 (Mon, 28 Jun 2004)
New Revision: 269

Added:
   trunk/wxhaver/src/Makefile.mingw.in
   trunk/wxhaver/src/command.cpp
   trunk/wxhaver/src/lineread.cpp
   trunk/wxhaver/src/lineread.h
   trunk/wxhaver/src/loginbox.cpp
Log:
commiting a few changes here so I can move it.
this is still broken.


Added: trunk/wxhaver/src/Makefile.mingw.in
===================================================================
--- trunk/wxhaver/src/Makefile.mingw.in 2004-06-28 04:36:03 UTC (rev 268)
+++ trunk/wxhaver/src/Makefile.mingw.in 2004-06-28 04:38:48 UTC (rev 269)
@@ -0,0 +1,16 @@
+#
+# File:         makefile.g95
+# Author:       Julian Smart
+# Created:      1999
+# Updated:
+# Copyright:    (c) Julian Smart, 1999
+#
+# Makefile for wxWindows sample (Cygwin/Mingw32).
+
[EMAIL PROTECTED]@
+
+TARGET=layout
+OBJECTS = $(TARGET).o
+
+include $(WXDIR)/src/makeprog.g95
+

Added: trunk/wxhaver/src/command.cpp
===================================================================
--- trunk/wxhaver/src/command.cpp       2004-06-28 04:36:03 UTC (rev 268)
+++ trunk/wxhaver/src/command.cpp       2004-06-28 04:38:48 UTC (rev 269)
@@ -0,0 +1,7 @@
+#include <wx/wx.h>
+
+
+class CommandParser
+{
+       
+}

Added: trunk/wxhaver/src/lineread.cpp
===================================================================
--- trunk/wxhaver/src/lineread.cpp      2004-06-28 04:36:03 UTC (rev 268)
+++ trunk/wxhaver/src/lineread.cpp      2004-06-28 04:38:48 UTC (rev 269)
@@ -0,0 +1,67 @@
+/*
+ * lineread.cpp
+ * Version 0.0.2
+ * Classes to process one line at a time from sockets
+ *
+ * Copyright 2003 Brian Victor
+ * Released under the terms of the wxWindows license
+ *
+*/
+
+#include "lineread.h"
+#include <wx/socket.h>
+
+BEGIN_EVENT_TABLE(wxSocketLineReader, wxEvtHandler)
+  EVT_SOCKET(-1, wxSocketLineReader::OnSocketRead)
+END_EVENT_TABLE()
+
+wxSocketLineReader::wxSocketLineReader(wxSocketBase& sock, 
wxSocketLineHandler& hndl) : m_sock(sock), m_hndl(hndl)
+{
+}
+
+wxSocketLineReader::~wxSocketLineReader()
+{
+}
+
+void wxSocketLineReader::OnSocketRead(wxSocketEvent& ev)
+{
+  switch (ev.GetSocketEvent())
+  {
+    case wxSOCKET_INPUT:
+      {
+        char buf[1024];
+        wxString line;
+        m_sock.Read(buf, 1024);
+        m_buf.Append(buf, m_sock.LastCount());
+        while (1)
+        {
+          line = m_buf.BeforeFirst('\n');
+          if (line == m_buf) break;
+          while (line[0] == '\r')
+          {
+            line = line.Remove(0, 1);
+          }
+          m_hndl.HandleLine(ev.GetId(), line);
+          m_buf = m_buf.AfterFirst('\n');
+        }
+      }
+  }
+}
+
+void wxSocketLineHandler::CreateReader(wxSocketBase& sock, int id)
+{
+  m_reader = new wxSocketLineReader(sock, *this);
+  sock.SetEventHandler(*m_reader, id);
+  sock.SetNotify(wxSOCKET_INPUT_FLAG);
+  sock.Notify(true);
+}
+
+wxSocketLineHandler::wxSocketLineHandler()
+{
+  m_reader = NULL;
+}
+
+wxSocketLineHandler::~wxSocketLineHandler()
+{
+  delete m_reader;
+}

Added: trunk/wxhaver/src/lineread.h
===================================================================
--- trunk/wxhaver/src/lineread.h        2004-06-28 04:36:03 UTC (rev 268)
+++ trunk/wxhaver/src/lineread.h        2004-06-28 04:38:48 UTC (rev 269)
@@ -0,0 +1,39 @@
+/*
+ * lineread.h
+ * Version 0.0.2
+ * Classes to process one line at a time from sockets
+ *
+ * Copyright 2003 Brian Victor
+ * Released under the terms of the wxWindows license
+ *
+*/
+
+#include <wx/event.h>
+
+class wxSocketBase;
+class wxSocketLineReader;
+class wxSocketEvent;
+
+class WXDLLEXPORT wxSocketLineHandler
+{
+  public:
+    wxSocketLineHandler();
+    virtual ~wxSocketLineHandler();
+    virtual void HandleLine(int sockid, const wxString &line) = 0;
+    void CreateReader(wxSocketBase& sock, int id);
+  private:
+    wxSocketLineReader *m_reader;
+};
+
+class WXDLLEXPORT wxSocketLineReader : public wxEvtHandler
+{
+  public:
+    wxSocketLineReader(wxSocketBase& sock, wxSocketLineHandler& hdnl);
+    virtual ~wxSocketLineReader();
+    void OnSocketRead(wxSocketEvent& ev);
+  private:
+    wxSocketBase& m_sock;
+    wxString m_buf;
+    wxSocketLineHandler &m_hndl;
+    DECLARE_EVENT_TABLE()
+};

Added: trunk/wxhaver/src/loginbox.cpp
===================================================================
--- trunk/wxhaver/src/loginbox.cpp      2004-06-28 04:36:03 UTC (rev 268)
+++ trunk/wxhaver/src/loginbox.cpp      2004-06-28 04:38:48 UTC (rev 269)
@@ -0,0 +1,91 @@
+/* main window of the application.
+ * Copyright (C) 2004  Dylan William Hardison
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#include "menu.h"
+#include "mainwin.h"
+#include <wx/splitter.h>
+
+BEGIN_EVENT_TABLE(MainWin, wxFrame)
+    EVT_MENU(ID_Quit, MainWin::OnQuit)
+    EVT_MENU(ID_About, MainWin::OnAbout)
+       EVT_TEXT_ENTER(ID_CmdLine, MainWin::OnCmdLine)
+END_EVENT_TABLE()
+
+
+
+MainWin::MainWin(const wxString &title, const wxPoint &pos, const wxSize &size)
+: wxFrame((wxFrame *)NULL, -1, title, pos, size)
+{
+    Menu *menuBar = new Menu;
+    SetMenuBar( (wxMenuBar *) menuBar );
+
+    CreateStatusBar(2);
+    SetStatusText("Welcome to wxHaver!", 0);
+       int widths[2] = {-1, 30};
+       SetStatusWidths(2, widths);
+
+       wxBoxSizer *sizer         = new wxBoxSizer( wxVERTICAL );
+       wxBoxSizer *topsizer      = new wxBoxSizer( wxHORIZONTAL );
+       wxBoxSizer *cmdline_sizer = new wxBoxSizer( wxHORIZONTAL );
+       
+       /* initialize display, cmdline, and userlist instance variables. */
+       display  = new wxTextCtrl(this, -1, "Foobar",
+                       wxDefaultPosition, wxSize(350, 240),
+                       wxTE_MULTILINE | wxTE_WORDWRAP | wxTE_RICH2 | 
wxTE_AUTO_URL);
+       display->SetEditable(0);
+       cmdline  = new wxTextCtrl(this, ID_CmdLine, "",
+                       wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
+       userlist = new wxListBox(this, -1);
+
+
+       /* create text ctrl with minimal size 100x60 */
+       topsizer->Add(display,
+                       1,            // make vertically stretchable
+                       wxEXPAND,    // make horizontally stretchable
+                       0);         // set border width to 0
+
+       topsizer->Add(userlist,
+                       0,            // make vertically stretchable
+                       wxEXPAND);         // set border width to 0
+       
+       
+       cmdline_sizer->Add(cmdline, 1);
+       
+       
+       sizer->Add(topsizer, 1, wxEXPAND);
+       sizer->Add(cmdline_sizer, 0, wxEXPAND);
+
+        SetSizer( sizer );
+        sizer->SetSizeHints( this );
+}
+
+void MainWin::OnQuit(wxCommandEvent& WXUNUSED(event))
+{
+    Close(TRUE);
+}
+
+void MainWin::OnAbout(wxCommandEvent& WXUNUSED(event))
+{
+    wxMessageBox("This is a wxWindows Hello world sample",
+        "About Hello World", wxOK | wxICON_INFORMATION, this);
+}
+
+void MainWin::OnCmdLine(wxCommandEvent &event)
+{
+       wxString string = cmdline->GetLineText(0);
+}


Reply via email to