1 #include "includes.hpp"
10 BEGIN_EVENT_TABLE(EnterMessage, wxMDIChildFrame)
11 EVT_BUTTON(BUTTON_CANCEL, EnterMessage::OnCancel)
12 EVT_BUTTON(BUTTON_SAVE, EnterMessage::OnSave)
13 EVT_BUTTON(BUTTON_FIND, EnterMessage::OnFind)
18 EnterMessage::EnterMessage(
19 CitClient *sock, wxMDIParentFrame *MyMDI,
20 wxString roomname, unsigned int roomflags)
21 : wxMDIChildFrame(MyMDI, //parent
23 roomname + ": enter message",
26 wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL,
30 wxString sendcmd, recvcmd;
35 finduser_panel = (SelectUser *) NULL;
37 wxButton *cancel_button = new wxButton(
43 wxLayoutConstraints *c1 = new wxLayoutConstraints;
44 c1->bottom.SameAs(this, wxBottom, 2);
47 c1->right.SameAs(this, wxRight, 2);
48 cancel_button->SetConstraints(c1);
50 wxButton *save_button = new wxButton(
56 wxLayoutConstraints *c2 = new wxLayoutConstraints;
57 c2->bottom.SameAs(cancel_button, wxBottom);
58 c2->right.LeftOf(cancel_button, 5);
59 c2->height.SameAs(cancel_button, wxHeight);
61 save_button->SetConstraints(c2);
66 // If the user has a choice of several posting names, present them.
68 wxStaticText *fromlabel = new wxStaticText(this, -1, "From: ");
70 wxLayoutConstraints *c6 = new wxLayoutConstraints;
71 c6->top.SameAs(this, wxTop, 10);
72 c6->left.SameAs(this, wxLeft, 2);
75 fromlabel->SetConstraints(c6);
77 wxString posting_name_choices[2];
80 if (roomflags & QR_ANONONLY) {
81 posting_name_choices[0] = "****";
84 posting_name_choices[0] = citsock->curr_user;
88 if (roomflags & QR_ANONOPT) {
89 posting_name_choices[num_choices++] = "Anonymous";
92 fromname = new wxChoice(this, -1,
93 wxDefaultPosition, wxSize(150,25),
94 num_choices, posting_name_choices);
96 wxLayoutConstraints *c7 = new wxLayoutConstraints;
97 c7->centreY.SameAs(fromlabel, wxCentreY);
98 c7->left.RightOf(fromlabel, 3);
101 fromname->SetConstraints(c7);
105 // There may also be the opportunity to present a recipient.
106 // FIX ... disable this if we're not in a mail room
108 wxStaticText *tolabel = new wxStaticText(this, -1, "To: ");
110 wxLayoutConstraints *c8 = new wxLayoutConstraints;
111 c8->centreY.SameAs(fromname, wxCentreY);
112 c8->left.RightOf(fromname, 5);
115 tolabel->SetConstraints(c8);
117 toname = new wxTextCtrl(this, -1, "",
118 wxDefaultPosition, wxSize(150,25));
120 wxLayoutConstraints *c9 = new wxLayoutConstraints;
121 c9->centreY.SameAs(tolabel, wxCentreY);
122 c9->left.RightOf(tolabel, 3);
125 toname->SetConstraints(c9);
127 wxButton *findrecp = new wxButton(
133 wxLayoutConstraints *d1 = new wxLayoutConstraints;
134 d1->centreY.SameAs(toname, wxCentreY);
135 d1->left.RightOf(toname, 3);
138 findrecp->SetConstraints(d1);
143 // The main portion of this screen is a text entry box.
145 TheMessage = new wxTextCtrl(this, -1, "",
146 wxDefaultPosition, wxDefaultSize,
149 wxLayoutConstraints *d9 = new wxLayoutConstraints;
150 d9->top.Below(fromname, 2);
151 d9->bottom.Above(cancel_button, -5);
152 d9->left.SameAs(this, wxLeft, 2);
153 d9->right.SameAs(this, wxRight, 2);
154 TheMessage->SetConstraints(d9);
165 void EnterMessage::OnCancel(wxCommandEvent& whichbutton) {
170 // The user clicked "Find" ... so we have to go looking for a recipient.
171 // Shove a FindUser panel right in front of everything else.
173 void EnterMessage::OnFind(wxCommandEvent& whichbutton) {
174 finduser_panel = new SelectUser(citsock, this,
175 "Please select a recipient",
180 wxLayoutConstraints *f1 = new wxLayoutConstraints;
181 f1->centreX.SameAs(this, wxCentreX);
182 f1->centreY.SameAs(this, wxCentreY);
183 f1->width.SameAs(this, wxWidth);
184 f1->height.SameAs(this, wxHeight);
185 finduser_panel->SetConstraints(f1);
190 void EnterMessage::OnSave(wxCommandEvent& whichbutton) {
191 wxString sendcmd, recvcmd, xferbuf;
193 sendcmd = "ENT0 1|" + toname->GetValue() + "|"
194 + ((!fromname->GetString(fromname->GetSelection()).CmpNoCase("Anonymous")) ? "1" : "0")
196 xferbuf = TheMessage->GetValue();
197 if (citsock->serv_trans(sendcmd, recvcmd,
198 xferbuf, ThisRoom) == 4) {
201 // Display the error message
202 wxMessageDialog save_error(this,
205 wxOK | wxCENTRE | wxICON_INFORMATION,
207 save_error.ShowModal();