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
userlogin.o: userlogin.cpp
c++ -c $(CFLAGS) userlogin.cpp
+
+testwindow.o: testwindow.cpp
+ c++ -c $(CFLAGS) testwindow.cpp
#include "citclient.hpp"
#include "userlogin.hpp"
+#include "testwindow.hpp"
// ----------------------------------------------------------------------------
// private classes
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()
IG_About,
IG_Text,
MENU_CONNECT,
+ WMENU_CASCADE,
+ WMENU_TILE,
+ WMENU_ARRANGE,
+ WMENU_NEXT,
+ WMENU_PREVIOUS,
BUTTON_DO_CMD
};
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()
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
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;
if (retval == 0) {
SetStatusText("** connected **");
new UserLogin(citadel, this);
+ new TestWindow(citadel, this);
} else {
wxMessageBox("Could not connect to server.", "Error");
}
--- /dev/null
+// ============================================================================
+// 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);
+ }
+}
--- /dev/null
+// 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()
+};
void UserLogin::OnButtonPressed(wxCommandEvent& whichbutton) {
+ if (whichbutton.GetId() == BUTTON_EXIT) {
+ delete this;
+ }
}