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(
20 wxMDIParentFrame *MyMDI,
22 unsigned int roomflags)
24 : wxMDIChildFrame(MyMDI, //parent
26 roomname + ": enter message",
29 wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL,
33 wxString sendcmd, recvcmd;
38 finduser_panel = (SelectUser *) NULL;
40 wxButton *cancel_button = new wxButton(
46 wxLayoutConstraints *c1 = new wxLayoutConstraints;
47 c1->bottom.SameAs(this, wxBottom, 2);
50 c1->right.SameAs(this, wxRight, 2);
51 cancel_button->SetConstraints(c1);
53 wxButton *save_button = new wxButton(
60 wxLayoutConstraints *c2 = new wxLayoutConstraints;
61 c2->bottom.SameAs(cancel_button, wxBottom);
62 c2->right.LeftOf(cancel_button, 5);
63 c2->height.SameAs(cancel_button, wxHeight);
65 save_button->SetConstraints(c2);
70 // If the user has a choice of several posting names, present them.
72 wxStaticText *fromlabel = new wxStaticText(this, -1, "From: ");
74 wxLayoutConstraints *c6 = new wxLayoutConstraints;
75 c6->top.SameAs(this, wxTop, 10);
76 c6->left.SameAs(this, wxLeft, 2);
79 fromlabel->SetConstraints(c6);
81 wxString posting_name_choices[2];
84 if (roomflags & QR_ANONONLY) {
85 posting_name_choices[0] = "****";
88 posting_name_choices[0] = citsock->curr_user;
92 if (roomflags & QR_ANONOPT) {
93 posting_name_choices[num_choices++] = "Anonymous";
96 fromname = new wxChoice(this, -1,
97 wxDefaultPosition, wxSize(150,25),
98 num_choices, posting_name_choices);
100 wxLayoutConstraints *c7 = new wxLayoutConstraints;
101 c7->centreY.SameAs(fromlabel, wxCentreY);
102 c7->left.RightOf(fromlabel, 3);
105 fromname->SetConstraints(c7);
109 // There may also be the opportunity to present a recipient.
110 // FIX ... disable this if we're not in a mail room
112 wxStaticText *tolabel = new wxStaticText(this, -1, "To: ");
114 wxLayoutConstraints *c8 = new wxLayoutConstraints;
115 c8->centreY.SameAs(fromname, wxCentreY);
116 c8->left.RightOf(fromname, 5);
119 tolabel->SetConstraints(c8);
121 toname = new wxTextCtrl(this, -1, "",
122 wxDefaultPosition, wxSize(150,25));
124 wxLayoutConstraints *c9 = new wxLayoutConstraints;
125 c9->centreY.SameAs(tolabel, wxCentreY);
126 c9->left.RightOf(tolabel, 3);
129 toname->SetConstraints(c9);
131 wxButton *findrecp = new wxButton(
137 wxLayoutConstraints *d1 = new wxLayoutConstraints;
138 d1->centreY.SameAs(toname, wxCentreY);
139 d1->left.RightOf(toname, 3);
142 findrecp->SetConstraints(d1);
146 // The main portion of this screen is a text entry box.
148 TheMessage = new wxTextCtrl(this, -1, "",
149 wxDefaultPosition, wxDefaultSize,
152 wxLayoutConstraints *d9 = new wxLayoutConstraints;
153 d9->top.Below(fromname, 2);
154 d9->bottom.Above(cancel_button, -5);
155 d9->left.SameAs(this, wxLeft, 2);
156 d9->right.SameAs(this, wxRight, 2);
157 TheMessage->SetConstraints(d9);
168 void EnterMessage::OnCancel(wxCommandEvent& whichbutton) {
173 // The user clicked "Find" ... so we have to go looking for a recipient.
174 // Shove a FindUser panel right in front of everything else.
176 void EnterMessage::OnFind(wxCommandEvent& whichbutton) {
177 finduser_panel = new SelectUser(citsock, this,
178 "Please select a recipient",
183 wxLayoutConstraints *f1 = new wxLayoutConstraints;
184 f1->centreX.SameAs(this, wxCentreX);
185 f1->centreY.SameAs(this, wxCentreY);
186 f1->width.SameAs(this, wxWidth);
187 f1->height.SameAs(this, wxHeight);
188 finduser_panel->SetConstraints(f1);
193 void EnterMessage::OnSave(wxCommandEvent& whichbutton) {
194 wxString sendcmd, recvcmd, xferbuf;
196 sendcmd = "ENT0 1|" + toname->GetValue() + "|"
197 + ((!fromname->GetString(fromname->GetSelection()).CmpNoCase("Anonymous")) ? "1" : "0")
199 xferbuf = TheMessage->GetValue();
200 if (citsock->serv_trans(sendcmd, recvcmd,
201 xferbuf, ThisRoom) == 4) {
204 // Display the error message
205 wxMessageDialog save_error(this,
208 wxOK | wxCENTRE | wxICON_INFORMATION,
210 save_error.ShowModal();