/*
* File: client.cpp
* Purpose: wxSocket: client demo
- * Author: LAVAUX Guilhem (from minimal.cc)
+ * Author: LAVAUX Guilhem
* Created: June 1997
* Updated:
- * Copyright: (c) 1993, AIAI, University of Edinburgh
- * (C) 1997, LAVAUX Guilhem
+ * Copyright: (c) 1997, LAVAUX Guilhem
*/
+
#ifdef __GNUG__
#pragma implementation
#pragma interface
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
+
#include "wx/socket.h"
#include "wx/url.h"
#include "wx/protocol/http.h"
+#if defined(__WXMOTIF__) || defined(__WXGTK__)
+#include "mondrian.xpm"
+#endif
+
// Define a new application type
class MyApp: public wxApp
{ public:
};
// ID for the menu quit command
-const SKDEMO_QUIT = 101;
-const SKDEMO_CONNECT = 102;
-const SKDEMO_TEST1 = 103;
-const SKDEMO_TEST2 = 104;
-const SKDEMO_CLOSE = 105;
-const SKDEMO_TEST3 = 106;
-const ID_TEST_CLOSE = 107;
+const int SKDEMO_QUIT = 101;
+const int SKDEMO_CONNECT = 102;
+const int SKDEMO_TEST1 = 103;
+const int SKDEMO_TEST2 = 104;
+const int SKDEMO_CLOSE = 105;
+const int SKDEMO_TEST3 = 106;
+const int ID_TEST_CLOSE = 107;
IMPLEMENT_APP(MyApp)
MyFrame *frame = new MyFrame();
// Give it an icon
-#ifdef wx_msw
- frame->SetIcon(new wxIcon("mondrian"));
-#endif
-#ifdef wx_x
- frame->SetIcon(new wxIcon("mondrian.xbm"));
-#endif
+ frame->SetIcon(wxICON(mondrian));
// Make a menubar
wxMenu *file_menu = new wxMenu();
socket_menu->Append(SKDEMO_CONNECT, "Open session");
socket_menu->AppendSeparator();
socket_menu->Append(SKDEMO_TEST1, "Start test 1");
- socket_menu->Append(SKDEMO_TEST2, "Start test 2");
socket_menu->AppendSeparator();
socket_menu->Append(SKDEMO_CLOSE, "Close session");
socket_menu->AppendSeparator();
frame->SetMenuBar(menu_bar);
// Make a panel with a message
- (void)new wxPanel(frame, 0, 0, 300, 100);
+ (void)new wxPanel(frame, -1, wxPoint(0, 0), wxSize(300, 100));
// Show the frame
frame->Show(TRUE);
// Return the main frame window
- return true;
+ return TRUE;
}
/*
if (!sock->IsConnected())
return;
- wxDialog *dlgbox = new wxDialog(this, -1, "Test 1", wxDefaultPosition, wxSize(410, 270));
+ wxDialog *dlgbox = new wxDialog(this, -1, "Test 1", wxDefaultPosition, wxSize(414, 250));
wxTextCtrl *text_win = new wxTextCtrl(dlgbox, -1, "",
wxPoint(0, 0), wxSize(400, 200),
wxTE_MULTILINE);
(void)new wxButton(dlgbox, ID_TEST_CLOSE, "Close",
- wxPoint(100, 210), wxSize(100, 40));
+ wxPoint(100, 210), wxSize(100, -1));
char *buf, *buf2;
dlgbox->Layout();
text_win->WriteText("Initializing test 1 ...\n");
+ wxYield();
+
/* Init */
buf = copystring("Salut ! Salut ! Salut ! Salut Toto\n");
buf2 = new char[strlen(buf)+1];
void MyFrame::OnExecUrlTest(wxCommandEvent& WXUNUSED(evt))
{
- wxString urlname = wxGetTextFromUser("Enter the address of the wxSocket Sample Server",
- "Connect ...", "localhost");
+ wxString urlname = wxGetTextFromUser("Enter an URL to get",
+ "URL:", "http://localhost");
wxURL url(urlname);
wxInputStream *datas = url.GetInputStream();
if (!datas)
wxMessageBox("Error in getting data from the URL.", "Alert !");
else {
- wxMessageBox("Success !!", "OK !");
+ wxMessageBox("Success !! Click on OK to see the text.", "OK");
delete datas;
}
}