]> code.citadel.org Git - citadel.git/blob - daphne/express_message.cpp
Calendar day view :
[citadel.git] / daphne / express_message.cpp
1 // ============================================================================
2 // declarations
3 // ============================================================================
4
5 #include "includes.hpp"
6
7 // ----------------------------------------------------------------------------
8 // private classes
9 // ----------------------------------------------------------------------------
10
11 // ----------------------------------------------------------------------------
12 // constants
13 // ----------------------------------------------------------------------------
14
15 // IDs for the controls and the menu commands
16 enum
17 {
18         BUTTON_OK,
19         BUTTON_REPLY
20 };
21
22 // ----------------------------------------------------------------------------
23 // event tables and other macros for wxWindows
24 // ----------------------------------------------------------------------------
25
26 // the event tables connect the wxWindows events with the functions (event
27 // handlers) which process them. It can be also done at run-time, but for the
28 // simple menu events like this the static method is much simpler.
29 BEGIN_EVENT_TABLE(      express_message, wxFrame)
30         EVT_BUTTON(     BUTTON_OK,      express_message::OnButtonPressed)
31         EVT_BUTTON(     BUTTON_REPLY,   express_message::OnButtonPressed)
32 END_EVENT_TABLE()
33
34 // ============================================================================
35 // implementation
36 // ============================================================================
37
38
39 // ----------------------------------------------------------------------------
40 // the application class
41 // ----------------------------------------------------------------------------
42
43 // frame constructor
44 express_message::express_message(
45                         CitClient *sock,
46                         wxString sender,
47                         wxString sendsys,
48                         wxString msg)
49                 : wxFrame(
50                         NULL,   //parent
51                         -1,     //window id
52                         "Express message",
53                         wxDefaultPosition,
54                         wxSize(500, 200),
55                         wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL,
56                         "express_message"
57                         ) {
58
59         wxString more_informative_title;
60
61         citsock = sock;
62         reply_to = sender;
63
64         // set the frame icon
65         /* SetIcon(wxICON(mondrian)); */
66
67         more_informative_title = 
68                 "Express message from " + sender + " @ " + sendsys + "..." ;
69
70         SetTitle(more_informative_title);
71
72         wxButton *ok_button = new wxButton(
73                 this,
74                 BUTTON_OK,
75                 " OK ",
76                 wxPoint(100,100),
77                 wxSize(100,30),
78                 0L,
79                 wxDefaultValidator,
80                 "ok_button"
81                 );
82
83         wxButton *reply_button = new wxButton(
84                 this,
85                 BUTTON_REPLY,
86                 " Reply ",
87                 wxPoint(100,100),
88                 wxSize(100,30),
89                 0L,
90                 wxDefaultValidator,
91                 "reply_button"
92                 );
93
94         wxTextCtrl *msgbox = new wxTextCtrl(
95                 this,
96                 -1,
97                 msg,
98                 wxDefaultPosition,
99                 wxDefaultSize,
100                 wxTE_MULTILINE | wxTE_READONLY,
101                 wxDefaultValidator,
102                 "msgbox"
103                 );
104
105         wxLayoutConstraints *c0 = new wxLayoutConstraints;
106         c0->bottom.SameAs(this, wxBottom, 10);
107         c0->left.SameAs(this, wxLeft, 10);
108         c0->height.AsIs(); c0->width.AsIs();
109         ok_button->SetConstraints(c0);
110
111         wxLayoutConstraints *c1 = new wxLayoutConstraints;
112         c1->bottom.SameAs(this, wxBottom, 10);
113         c1->right.SameAs(this, wxRight, 10);
114         c1->height.AsIs(); c1->width.AsIs();
115         reply_button->SetConstraints(c1);
116
117         wxLayoutConstraints *c2 = new wxLayoutConstraints;
118         c2->top.SameAs(this, wxTop, 10);
119         c2->left.SameAs(this, wxLeft, 10);
120         c2->right.SameAs(this, wxRight, 10);
121         c2->bottom.Above(ok_button, -10);
122         msgbox->SetConstraints(c2);
123
124         SetAutoLayout(TRUE);
125         Show(TRUE);
126
127 }
128
129
130 void express_message::OnButtonPressed(wxCommandEvent& whichbutton) {
131         if (whichbutton.GetId() == BUTTON_OK) {
132                 delete this;
133         }
134         if (whichbutton.GetId() == BUTTON_REPLY) {
135                 new SendExpress(citsock, BigMDI, reply_to);
136                 delete this;
137         }
138 }