]> code.citadel.org Git - citadel.git/blob - daphne/hosts.cpp
squished the last remaining calls to sprintf
[citadel.git] / daphne / hosts.cpp
1 // $Id$
2
3 // =========================================================================
4 // declarations
5 // =========================================================================
6
7 #include "includes.hpp"
8
9 // ----------------------------------------------------------------------------
10 // constants
11 // ----------------------------------------------------------------------------
12
13 // IDs for the controls and the menu commands
14 enum
15 {
16         BUTTON_ADD,
17         BUTTON_FINISH,
18 };
19
20 // ----------------------------------------------------------------------------
21 // event tables and other macros for wxWindows
22 // ----------------------------------------------------------------------------
23
24 // the event tables connect the wxWindows events with the functions (event
25 // handlers) which process them. It can be also done at run-time, but for the
26 // simple menu events like this the static method is much simpler.
27 BEGIN_EVENT_TABLE(      Hosts, wxMDIChildFrame)
28         EVT_BUTTON(     BUTTON_ADD,             Hosts::OnButtonPressed)
29         EVT_BUTTON(     BUTTON_FINISH,          Hosts::OnButtonPressed)
30 END_EVENT_TABLE()
31
32 // ============================================================================
33 // implementation
34 // ============================================================================
35
36
37 // ----------------------------------------------------------------------------
38 // the application class
39 // ----------------------------------------------------------------------------
40
41 // frame constructor
42 Hosts::Hosts(   CitClient *sock,
43                                 wxMDIParentFrame *MyMDI)
44        : wxMDIChildFrame(MyMDI, //parent
45                         -1,     //window id
46                         " Hosts ",
47                         wxDefaultPosition,
48                         wxDefaultSize,
49                         wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL,
50                         "Hosts"
51                         ) {
52         
53         wxString buf;
54
55         citsock = sock;
56         citMyMDI = MyMDI;
57
58         // set the frame icon
59         /* SetIcon(wxICON(mondrian)); */
60
61         wxButton *add_button = new wxButton(
62                 this,
63                 BUTTON_ADD,
64                 "Add",
65                 wxPoint(200,200),
66                 wxSize(100,30),
67                 0L,
68                 wxDefaultValidator,
69                 "add_button"
70                 );
71
72         wxButton *finish_button = new wxButton(
73                 this,
74                 BUTTON_FINISH,
75                 "Finish",
76                 wxPoint(300,300),
77                 wxSize(100,30),
78                 0L,
79                 wxDefaultValidator,
80                 "finish_button"
81                 );
82
83         wxLayoutConstraints *c1 = new wxLayoutConstraints;
84         c1->bottom.SameAs(this, wxBottom, 5);
85         c1->left.SameAs(this, wxLeft, 10);
86         c1->height.AsIs(); c1->width.AsIs();
87         add_button->SetConstraints(c1);
88
89         wxLayoutConstraints *c3 = new wxLayoutConstraints;
90         c3->bottom.SameAs(add_button, wxBottom);
91         c3->right.SameAs(this, wxRight, 10);
92         c3->height.AsIs(); c3->width.AsIs();
93         finish_button->SetConstraints(c3);
94
95         wxStaticText *server_host_label = new wxStaticText(
96                 this, -1, "Server host");
97
98         server_host = new wxTextCtrl(this, -1);
99         
100         wxStaticText *server_port_label = new wxStaticText(
101                 this, -1, "Server port");
102         
103         server_port = new wxTextCtrl(this, -1);
104
105         wxLayoutConstraints *c4 = new wxLayoutConstraints;
106         c4->top.SameAs(this, wxTop, 10);
107         c4->left.SameAs(this, wxLeft, 10);
108         c4->height.AsIs(); c4->width.AsIs();
109         server_host_label->SetConstraints(c4);
110
111         wxLayoutConstraints *c5 = new wxLayoutConstraints;
112         c5->centreY.SameAs(server_host_label, wxCentreY);
113         c5->left.RightOf(server_host_label, 10);
114         c5->right.SameAs(this, wxRight, 10);
115         c5->height.AsIs();
116         server_host->SetConstraints(c5);
117
118         wxLayoutConstraints *c6 = new wxLayoutConstraints;
119         c6->top.Below(server_host_label, 15);
120         c6->left.SameAs(this, wxLeft, 10);
121         c6->height.AsIs(); c6->width.AsIs();
122         server_port_label->SetConstraints(c6);
123
124         wxLayoutConstraints *c7 = new wxLayoutConstraints;
125         c7->centreY.SameAs(server_port_label, wxCentreY);
126         c7->left.SameAs(server_host, wxLeft);
127         c7->right.PercentOf(this, wxWidth, 50);
128         c7->height.AsIs();
129         server_port->SetConstraints(c7);
130
131
132 /*      wxLayoutConstraints *c8 = new wxLayoutConstraints;
133         c8->centreY.SameAs(server_port, wxCentreY);
134         c8->left.RightOf(server_port, 5);
135         c8->width.AsIs(); c8->height.AsIs();
136         server_autoconnect->SetConstraints(c8); */
137
138
139
140
141
142         SetAutoLayout(TRUE);
143         Show(TRUE);
144         Layout();
145 }
146
147
148
149 void Hosts::OnButtonPressed(wxCommandEvent& whichbutton) {
150         if (whichbutton.GetId() == BUTTON_FINISH) {
151                 delete this;
152         } else if (whichbutton.GetId() == BUTTON_ADD) {
153                 ini->Write("/BBSList/Host", server_host->GetValue());
154                 ini->Write("/BBSList/Port", server_port->GetValue());
155                                 
156                 ini->Flush(FALSE);
157         }
158 }