tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / preferences / dun / SettingsWindow.cpp
blobe650016aa3a8e165cc20ff8bcf4f52e0a4795eab
1 /*
3 SettingsWindow - Window for Settings
5 Author: Misza (misza@ihug.com.au)
7 (C) 2002 OpenBeOS under MIT license
9 */
11 #include <Application.h>
12 #include <Alert.h>
13 #include <Box.h>
14 #include <Button.h>
15 #include <CheckBox.h>
16 #include <Font.h>
17 #include <ListItem.h>
18 #include <Menu.h>
19 #include <MenuBar.h>
20 #include <MenuField.h>
21 #include <MenuItem.h>
22 #include <OutlineListView.h>
23 #include <Point.h>
24 #include <RadioButton.h>
25 #include <Shape.h>
26 #include <stdio.h>
27 #include <TextControl.h>
28 #include <TextView.h>
29 #include <Window.h>
30 #include <View.h>
31 #include <PopUpMenu.h>
32 #include <StringView.h>
33 #include "DUN.h"
34 //#include "DUNWindow.h"
35 //#include "ModemWindow.h"
36 #include "DUNView.h"
37 #include "SettingsWindow.h"
40 // SettingsWindow -- constructor for SettingsWindow Class
41 SettingsWindow::SettingsWindow(BRect frame) : BWindow (frame, "", B_MODAL_WINDOW, B_NOT_RESIZABLE , 0)
43 InitWindow();
44 Show();
46 // ------------------------------------------------------------------------------- //
49 // Settingsview::InitWindow -- Initialization Commands here
50 void SettingsWindow::InitWindow()
52 BRect r;
53 r = Bounds();
55 // Add the Drawing View
56 aSettingsview = new SettingsView(r);
57 aSettingsview->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
58 AddChild(aSettingsview);
60 //aSettingsview->SetFont(be_bold_font);
62 //THIS should be changed later, I know no other way of setting this :PPP
63 ConnectSettings = new BStringView(BRect(13,5,250,25),"ConnectSettings","Connection settings for: ");
64 //aSettingsview->MovePenTo(30,40);
65 //aSettingsview->DrawString("Connection settings for: ");
66 ConnectSettings->SetFont(be_bold_font);
67 aSettingsview->AddChild(ConnectSettings);
69 aSettingsview->SetFont(be_plain_font);
70 //aSettingsview->DrawString("some_connection");
71 BRect ipbox_rect = aSettingsview->Bounds();
72 ipbox_rect.left = 13;
73 ipbox_rect.right -= 13;
74 ipbox_rect.top = 32;
75 ipbox_rect.bottom = 81;
76 //ipbox_rect.InsetBy(20,20);
77 IPBox = new BBox(ipbox_rect,"IPBox",B_FOLLOW_ALL | B_WILL_DRAW | B_NAVIGABLE_JUMP, B_FANCY_BORDER);
79 //IPBox->SetLabel("<BCheckBox>Use static IP address");
80 BView* iplabel = new BView(BRect(10,10,130,30),"iplabel",B_FOLLOW_ALL_SIDES,B_WILL_DRAW|B_NAVIGABLE);
81 //iplabel->SetViewColor(255,0,0);
82 iplabel->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
84 //BRect stat_ip_rect = iplabel->Bounds();
85 //stat
86 UseStaticIP = new BCheckBox(iplabel->Bounds(),"UseStaticIP","Use static IP address", new BMessage(CHANGE_IP_BOX),B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
87 UseStaticIP->SetLabel("Use static IP address");
88 //UseStaticIP->SetEnabled(false);//by default it is off
89 iplabel->AddChild(UseStaticIP);
91 // IPBox->SetLabel("<BCheckBox>Use static IP address");
92 IPBox->SetLabel(iplabel);
94 // ipbox_rect.left = 23;
95 // ipbox_rect.bottom +=
96 BRect ipaddr_text = IPBox->Bounds();
97 ipaddr_text.right -= 10;
98 ipaddr_text.left += 50;
99 ipaddr_text.top += 20;
100 IPAddress = new BTextControl(ipaddr_text,"IPAddress","IP address:",NULL,
101 new BMessage(CHANGE_IP));
102 IPAddress->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
103 IPAddress->SetDivider(80);
104 IPAddress->SetEnabled(false); //by default it is off
106 IPBox->AddChild(IPAddress);
108 aSettingsview->AddChild(IPBox);
110 ipbox_rect.top += 60;
111 ipbox_rect.bottom += 75;
113 DNSBox = new BBox(ipbox_rect,"IPBox",B_FOLLOW_ALL | B_WILL_DRAW | B_NAVIGABLE_JUMP, B_FANCY_BORDER);
115 ipaddr_text.top -= 10;
117 PrimaryDNS = new BTextControl(ipaddr_text,"PrimaryDNS","Primary DNS:",NULL,
118 new BMessage(CHANGE_P_DNS));
119 PrimaryDNS->SetDivider(80);
120 PrimaryDNS->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
121 DNSBox->AddChild(PrimaryDNS);
122 ipaddr_text.top += 25;
123 SecondaryDNS = new BTextControl(ipaddr_text,"SecondaryDNS","Secondary DNS:",NULL,
124 new BMessage(CHANGE_S_DNS));
125 SecondaryDNS->SetDivider(80);
126 SecondaryDNS->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_LEFT);
127 DNSBox->AddChild(SecondaryDNS);
129 aSettingsview->AddChild(DNSBox);
130 BRect cute_buttons(205,200,280,220);
131 btnSettingsWindowDone = new BButton(cute_buttons,"btnSettingsWindowDone"," Done ", new BMessage(BTN_SETTINGS_WINDOW_DONE), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
132 cute_buttons.OffsetBy(-85,0);
133 btnSettingsWindowCancel = new BButton(cute_buttons,"btnSettingsWindowCancel"," Cancel ", new BMessage(BTN_SETTINGS_WINDOW_CANCEL), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
135 btnSettingsWindowDone->MakeDefault(true);
136 aSettingsview->AddChild(btnSettingsWindowDone);
137 aSettingsview->AddChild(btnSettingsWindowCancel);
139 YourServerTypeIsMenu = new BPopUpMenu("ServerType");
141 //These should be added after looking in /boot/beos/etc/servers.ppp
142 //parse that files contents, put the entries in a list, whatever
143 //loop through the list and add them
144 BMenuItem* item1 = new BMenuItem("Standard PPP",NULL); //n.b bmessage left out, add later
145 YourServerTypeIsMenu->AddItem(item1);
147 BMenuItem* item2 = new BMenuItem("Etc" B_UTF8_ELLIPSIS,NULL);
148 YourServerTypeIsMenu->AddItem(item2);
151 YourServerTypeIsMenuField = new BMenuField(BRect(13,170,203,190),
152 "ServerType","Server Type:",YourServerTypeIsMenu);
153 item1->SetMarked(true);
154 YourServerTypeIsMenuField->SetDivider(70);
155 aSettingsview->AddChild(YourServerTypeIsMenuField);
158 // ------------------------------------------------------------------------------- //
161 // SettingsWindow::~aSettingsview -- destructor
162 SettingsWindow::~SettingsWindow()
164 exit(0);
166 // ------------------------------------------------------------------------------- //
169 // SettingsWindow::MessageReceived -- receives messages
170 void SettingsWindow::MessageReceived (BMessage *message)
172 switch(message->what)
174 case CHANGE_IP_BOX:
176 if(UseStaticIP->Value() == B_CONTROL_ON){
177 /*do something*/
179 //cout << "checkbox is on" << endl;
180 IPAddress->SetEnabled(true);
181 }else
183 /*do something else*/
184 //cout << "checkbox is off" << endl;
185 IPAddress->SetEnabled(false);
189 }break;
190 case CHANGE_IP:
192 //cout << IPAddress->Text() << endl;
193 printf("%s\n",IPAddress->Text());
194 }break;
196 case CHANGE_P_DNS:
199 //cout << PrimaryDNS->Text() << endl;
200 printf("%s\n",PrimaryDNS->Text());
202 }break;
203 case CHANGE_S_DNS:
206 //cout << SecondaryDNS->Text() << endl;
207 printf("%s\n",SecondaryDNS->Text());
208 }break;
210 case BTN_SETTINGS_WINDOW_CANCEL:
212 Hide(); // must find a better way to close this window and not the entire application
213 // any suggestions would be greatly appreciated ;)
214 }break;
215 case BTN_SETTINGS_WINDOW_DONE:
217 /*SAVE SETTINGS*/
219 Hide();
220 //Quit();
221 }break;
222 /*case BTN_MODEM_WINDOW_DONE:
223 Quit(); // debugging purposes
224 break;
225 case BTN_MODEM_WINDOW_CANCEL:
226 Hide(); // must find a better way to close this window and not the entire application
227 // any suggestions would be greatly appreciated ;)
228 break;*/
229 default:
230 BWindow::MessageReceived(message);
231 break;
234 // end