]> code.citadel.org Git - citadel.git/commitdiff
Added the test window
authorArt Cancro <ajc@citadel.org>
Sat, 20 Feb 1999 04:49:07 +0000 (04:49 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 20 Feb 1999 04:49:07 +0000 (04:49 +0000)
daphne/Makefile
daphne/daphne
daphne/main.cpp
daphne/testwindow.cpp [new file with mode: 0644]
daphne/testwindow.hpp [new file with mode: 0644]
daphne/userlogin.cpp

index 3e80ce71083ffa858821e17fdcdd9f308f64ef5d..bbed94aa6880460e05bf78f2d4d2918419babf70 100644 (file)
@@ -1,8 +1,8 @@
 CFLAGS=`wx-config --cflags`
 LFLAGS=`wx-config --libs`
 
-daphne: main.o citclient.o userlogin.o
-       c++ main.o citclient.o userlogin.o $(LFLAGS) -o daphne
+daphne: main.o citclient.o userlogin.o testwindow.o
+       c++ main.o citclient.o userlogin.o testwindow.o $(LFLAGS) -o daphne
 
 main.o: main.cpp
        c++ -c $(CFLAGS) main.cpp
@@ -12,3 +12,6 @@ citclient.o: citclient.cpp
 
 userlogin.o: userlogin.cpp
        c++ -c $(CFLAGS) userlogin.cpp
+
+testwindow.o: testwindow.cpp
+       c++ -c $(CFLAGS) testwindow.cpp
index 0cddc514096d8365431c6a5aa8c2662bf5f3118e..26180fafb5e046f9118a90c781873349c77c8c8c 100755 (executable)
Binary files a/daphne/daphne and b/daphne/daphne differ
index a57ef0806ded19be8997488d5359cfd8b596eb10..4af31594070ec3c9efd58f356057477e6a1f7985 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "citclient.hpp"
 #include "userlogin.hpp"
+#include "testwindow.hpp"
 
 // ----------------------------------------------------------------------------
 // private classes
@@ -44,8 +45,8 @@ public:
        void OnAbout(wxCommandEvent& event);
        void OnDoCmd(wxCommandEvent& event);
        void OnConnect(wxCommandEvent& event);
-
 private:
+       void OnWindowMenu(wxCommandEvent& cmd);
        wxButton *do_cmd;
        // any class wishing to process wxWindows events must use this macro
        DECLARE_EVENT_TABLE()
@@ -62,6 +63,11 @@ enum
        IG_About,
        IG_Text,
        MENU_CONNECT,
+       WMENU_CASCADE,
+       WMENU_TILE,
+       WMENU_ARRANGE,
+       WMENU_NEXT,
+       WMENU_PREVIOUS,
        BUTTON_DO_CMD
 };
 
@@ -76,6 +82,11 @@ BEGIN_EVENT_TABLE(   MyFrame, wxMDIParentFrame)
        EVT_MENU(       IG_Quit,                MyFrame::OnQuit)
        EVT_MENU(       IG_About,               MyFrame::OnAbout)
        EVT_MENU(       MENU_CONNECT,           MyFrame::OnConnect)
+       EVT_MENU(       WMENU_CASCADE,          MyFrame::OnWindowMenu)
+       EVT_MENU(       WMENU_TILE,             MyFrame::OnWindowMenu)
+       EVT_MENU(       WMENU_ARRANGE,          MyFrame::OnWindowMenu)
+       EVT_MENU(       WMENU_NEXT,             MyFrame::OnWindowMenu)
+       EVT_MENU(       WMENU_PREVIOUS,         MyFrame::OnWindowMenu)
        EVT_BUTTON(     BUTTON_DO_CMD,          MyFrame::OnDoCmd)
 END_EVENT_TABLE()
 
@@ -137,12 +148,20 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
        menuFile->AppendSeparator(); 
        menuFile->Append(IG_Quit, "E&xit");
 
+       wxMenu *menuWindow = new wxMenu;
+       menuWindow->Append(WMENU_CASCADE, "&Cascade");
+       menuWindow->Append(WMENU_TILE, "&Tile");
+       menuWindow->Append(WMENU_ARRANGE, "&Arrange icons");
+       menuWindow->Append(WMENU_NEXT, "&Next window");
+       menuWindow->Append(WMENU_PREVIOUS, "&Previous window");
+
        wxMenu *menuHelp = new wxMenu;
        menuHelp->Append(IG_About, "&About...");
 
        // now append the freshly created menu to the menu bar...
        wxMenuBar *menuBar = new wxMenuBar;
        menuBar->Append(menuFile, "&File");
+       menuBar->Append(menuWindow, "&Window");
        menuBar->Append(menuHelp, "&Help");
 
        // ... and attach this menu bar to the frame
@@ -165,6 +184,21 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
        Close(TRUE);
 }
 
+
+// Window menu handler
+void MyFrame::OnWindowMenu(wxCommandEvent& cmd) {
+       int id;
+       
+       id = cmd.GetId();
+       if (id == WMENU_CASCADE)                Cascade();
+       else if (id == WMENU_TILE)              Tile();
+       else if (id = WMENU_ARRANGE)            ArrangeIcons();
+       else if (id == WMENU_NEXT)              ActivateNext();
+       else if (id == WMENU_PREVIOUS)          ActivatePrevious();
+}
+
+
+
 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
 {
        wxString msg;
@@ -191,6 +225,7 @@ void MyFrame::OnConnect(wxCommandEvent& unused) {
                if (retval == 0) {
                        SetStatusText("** connected **");
                        new UserLogin(citadel, this);
+                       new TestWindow(citadel, this);
                } else {
                        wxMessageBox("Could not connect to server.", "Error");
                }
diff --git a/daphne/testwindow.cpp b/daphne/testwindow.cpp
new file mode 100644 (file)
index 0000000..2e47a44
--- /dev/null
@@ -0,0 +1,126 @@
+// ============================================================================
+// declarations
+// ============================================================================
+
+
+#include <wx/wx.h>
+#include "citclient.hpp"
+#include "testwindow.hpp"
+
+// ----------------------------------------------------------------------------
+// private classes
+// ----------------------------------------------------------------------------
+
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+// IDs for the controls and the menu commands
+enum
+{
+       BUTTON_SENDCMD,
+       BUTTON_CLOSE
+};
+
+// ----------------------------------------------------------------------------
+// event tables and other macros for wxWindows
+// ----------------------------------------------------------------------------
+
+// the event tables connect the wxWindows events with the functions (event
+// handlers) which process them. It can be also done at run-time, but for the
+// simple menu events like this the static method is much simpler.
+BEGIN_EVENT_TABLE(     TestWindow, wxMDIChildFrame)
+       EVT_BUTTON(     BUTTON_SENDCMD,         TestWindow::OnButtonPressed)
+       EVT_BUTTON(     BUTTON_CLOSE,           TestWindow::OnButtonPressed)
+END_EVENT_TABLE()
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+
+// ----------------------------------------------------------------------------
+// the application class
+// ----------------------------------------------------------------------------
+
+// frame constructor
+TestWindow::TestWindow(CitClient *sock, wxMDIParentFrame *MyMDI)
+       : wxMDIChildFrame(MyMDI,        //parent
+                       -1,     //window id
+                       "Test Window",
+                       wxDefaultPosition,
+                       wxDefaultSize,
+                       wxDEFAULT_FRAME_STYLE,
+                       "TestWindow"
+                       ) {
+
+       citsock = sock;
+
+       // set the frame icon
+       /* SetIcon(wxICON(mondrian)); */
+
+       panel = new wxPanel(this);
+
+       sendcmd = new wxTextCtrl(
+               panel,
+               -1,
+               "",
+               wxPoint(10,10),
+               wxSize(300,30),
+               0, // no style
+               wxDefaultValidator,
+               "sendcmd"
+               );
+
+       recvcmd = new wxTextCtrl(
+               panel,
+               -1,
+               "",
+               wxPoint(10,100),
+               wxSize(300,30),
+               0, // no style
+               wxDefaultValidator,
+               "sendcmd"
+               );
+
+       cmd_button = new wxButton(
+               panel,
+               BUTTON_SENDCMD,
+               "Send command",
+               wxPoint(10,300),
+               wxSize(100,30),
+               0L,
+               wxDefaultValidator,
+               "cmd_button"
+               );
+
+       close_button = new wxButton(
+               panel,
+               BUTTON_CLOSE,
+               "Close",
+               wxPoint(100,300),
+               wxSize(100,30),
+               0L,
+               wxDefaultValidator,
+               "close_button"
+               );
+
+       Show(TRUE);
+}
+
+
+
+void TestWindow::OnButtonPressed(wxCommandEvent& whichbutton) {
+       wxString sendbuf = "";
+       wxString recvbuf = "";
+
+       if (whichbutton.GetId()==BUTTON_CLOSE) {
+               delete this;
+       }
+       else if (whichbutton.GetId()==BUTTON_SENDCMD) {
+               sendbuf = sendcmd->GetValue();
+               recvcmd->Clear();
+               citsock->serv_trans(sendbuf, recvbuf);
+               recvcmd->SetValue(recvbuf);
+       }
+}
diff --git a/daphne/testwindow.hpp b/daphne/testwindow.hpp
new file mode 100644 (file)
index 0000000..a2a5ef4
--- /dev/null
@@ -0,0 +1,14 @@
+// userlogin is the frame for logging in.
+class TestWindow : public wxMDIChildFrame {
+public:
+       TestWindow(CitClient *sock, wxMDIParentFrame *MyMDI);
+private:
+       wxPanel *panel;
+       wxTextCtrl *sendcmd;
+       wxTextCtrl *recvcmd;
+       wxButton *cmd_button;
+       wxButton *close_button;
+       void OnButtonPressed(wxCommandEvent& whichbutton);
+       CitClient *citsock;
+       DECLARE_EVENT_TABLE()
+};
index 85673382fc558193f6a531ace17990d5d3196917..0201208cca15ed5bcd189b9f2b94e4178d92910f 100644 (file)
@@ -122,4 +122,7 @@ UserLogin::UserLogin(CitClient *sock, wxMDIParentFrame *MyMDI)
 
 
 void UserLogin::OnButtonPressed(wxCommandEvent& whichbutton) {
+       if (whichbutton.GetId() == BUTTON_EXIT) {
+               delete this;
+       }
 }