fat: Greatly simplify and clean up dosfs_get_file_map().
[haiku.git] / src / preferences / dun / ModemWindow.cpp
blobb3a8097f4e8f2cfc8f39ac2d693ffaee899dedd1
1 /*
3 ModemWindow - Modem Settings Window
5 Author: Sikosis (beos@gravity24hr.com)
7 (C) 2002 OpenBeOS under MIT license
9 */
11 #include <stdlib.h>
13 #include "ModemWindow.h"
16 // ModemWindow -- constructor for ModemWindow Class
17 ModemWindow::ModemWindow(BRect frame) : BWindow (frame, "", B_MODAL_WINDOW, B_NOT_RESIZABLE , 0)
19 InitWindow();
20 CenterOnScreen();
21 Show();
23 // ------------------------------------------------------------------------------- //
25 // ModemWindow::InitWindow -- Initialization Commands here
26 void ModemWindow::InitWindow(void)
28 BRect r;
29 r = Bounds();
31 // Add the Drawing View
32 aModemview = new ModemView(r);
33 aModemview->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
34 AddChild(aModemview);
36 // Buttons
37 BRect btn1(10,r.bottom - 34,83,r.bottom - 16);
38 BRect btn2(108,r.bottom - 34,184,r.bottom - 16);
39 BRect btn3(196,r.bottom - 34,271,r.bottom - 16);
40 btnModemWindowCustom = new BButton(btn1,"Custom"," Custom" B_UTF8_ELLIPSIS " ", new BMessage(BTN_MODEM_WINDOW_CUSTOM), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
41 btnModemWindowCancel = new BButton(btn2,"Cancel"," Cancel ", new BMessage(BTN_MODEM_WINDOW_CANCEL), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
42 btnModemWindowDone = new BButton(btn3,"Done"," Done ", new BMessage(BTN_MODEM_WINDOW_DONE), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
44 // YourModemIs MenuField
45 BRect mfld1(15,20,350,30);
46 BMenuItem *menu[100];
47 YourModemIsMenu = new BMenu("<Pick One> ");
48 YourModemIsMenu->AddSeparatorItem();
49 YourModemIsMenu->AddItem(menu[1] = new BMenuItem("New" B_UTF8_ELLIPSIS, new BMessage(MENU)));
50 menu[1]->SetTarget(be_app);
51 YourModemIsMenuField = new BMenuField(mfld1,"yourmodem_menufield","Your modem is:",YourModemIsMenu,B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
52 YourModemIsMenuField->SetDivider(76);
53 YourModemIsMenuField->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
55 // ConnectVia MenuField
56 BRect mfld2(28,45,350,55);
57 BMenuItem *menu2[100];
58 ConnectViaMenu = new BMenu("serial 1 ");
60 //ConnectViaMenu->AddSeparatorItem();
61 ConnectViaMenu->AddItem(menu2[1] = new BMenuItem("serial 2 ", new BMessage(MENU)));
62 menu2[1]->SetTarget(be_app);
63 ConnectViaMenuField = new BMenuField(mfld2,"connectvia_menufield","Connect via:",ConnectViaMenu,B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
64 ConnectViaMenuField->SetDivider(63);
65 ConnectViaMenuField->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
67 // Speed MenuField
68 BRect mfld3(54,70,350,80);
69 BMenuItem *menu3[100];
70 SpeedMenu = new BMenu("9600 ");
71 SpeedMenu->AddItem(menu3[1] = new BMenuItem("19200 ", new BMessage(MENU)));
72 menu3[1]->SetTarget(be_app);
73 SpeedMenuField = new BMenuField(mfld3,"speed_menufield","Speed:",SpeedMenu,B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
74 SpeedMenuField->SetDivider(37);
75 SpeedMenuField->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
77 // TextView - Redial
78 BRect RedialLocation (15,112,350,132);
79 tvRedial = new BTextView(r, "Redial", RedialLocation, B_FOLLOW_ALL, B_WILL_DRAW);
80 tvRedial->SetText("Redial");
81 tvRedial->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
82 tvRedial->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
83 tvRedial->MakeSelectable(false);
84 tvRedial->MakeEditable(false);
86 // TextView - Use:
87 BRect UseLocation (15,142,40,154);
88 tvUse = new BTextView(r, "Use", UseLocation, B_FOLLOW_ALL, B_WILL_DRAW);
89 tvUse->SetText("Use:");
90 tvUse->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
91 tvUse->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
92 tvUse->MakeSelectable(false);
93 tvUse->MakeEditable(false);
95 // RadioButton - Use Tone or Pulse
96 BRect RBToneLocation(42,140,350,152);
97 rbTone = new BRadioButton(RBToneLocation,"Tone","Tone dialing", new BMessage(RB_TONE_DIALING), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
98 BRect RBPulseLocation(125,140,350,152);
99 rbPulse = new BRadioButton(RBPulseLocation,"Pulse","Pulse dialing", new BMessage(RB_PULSE_DIALING), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
101 // TextView - TimesBusySignal
102 BRect TimesBusySignalLocation (82,112,400,132);
103 tvTimesBusySignal = new BTextView(r, "TimesBusySignal", TimesBusySignalLocation, B_FOLLOW_ALL, B_WILL_DRAW);
104 tvTimesBusySignal->SetText("time(s) on busy signal");
105 tvTimesBusySignal->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
106 tvTimesBusySignal->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
107 tvTimesBusySignal->MakeSelectable(false);
108 tvTimesBusySignal->MakeEditable(false);
110 // TextView - ReadLogPath
111 BRect ReadLogPathLocation (32,238,350,258);
112 tvReadLogPath = new BTextView(r, "ReadLogPath", ReadLogPathLocation, B_FOLLOW_ALL, B_WILL_DRAW);
113 tvReadLogPath->SetText("Read log file path: /boot/var/log/ppp-read.log");
114 tvReadLogPath->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
115 tvReadLogPath->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
116 tvReadLogPath->MakeSelectable(false);
117 tvReadLogPath->MakeEditable(false);
119 // TextView - WriteLogPath
120 BRect WriteLogPathLocation (32,256,350,276);
121 tvWriteLogPath = new BTextView(r, "WriteLogPath", WriteLogPathLocation, B_FOLLOW_ALL, B_WILL_DRAW);
122 tvWriteLogPath->SetText("Write log file path: /boot/var/log/ppp-write.log");
123 tvWriteLogPath->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
124 tvWriteLogPath->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
126 tvWriteLogPath->MakeSelectable(false);
127 tvWriteLogPath->MakeEditable(false);
129 // CheckBox - chkMakeConnection
130 BRect chkMakeConnectionLocation (15,159,300,179);
131 chkMakeConnection = new BCheckBox(chkMakeConnectionLocation, "chkMakeConnection", "Make connection when necessary", new BMessage(CHK_MAKE_CONNECTION), B_FOLLOW_LEFT | B_FOLLOW_TOP , B_WILL_DRAW | B_NAVIGABLE);
132 chkMakeConnection->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
134 // CheckBox - chkShowTerminal
135 BRect chkShowTerminalLocation (15,196,300,216);
136 chkShowTerminal = new BCheckBox(chkShowTerminalLocation, "chkShowTerminal", "Show terminal when connecting", new BMessage(CHK_SHOW_TERMINAL), B_FOLLOW_LEFT | B_FOLLOW_TOP , B_WILL_DRAW | B_NAVIGABLE);
137 chkShowTerminal->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
139 // CheckBox - chkLogAll
140 BRect chkLogAllLocation (15,215,300,235);
141 chkLogAll = new BCheckBox(chkLogAllLocation, "chkLogAll", "Log all bytes sent/received", new BMessage(CHK_LOG_ALL), B_FOLLOW_LEFT | B_FOLLOW_TOP , B_WILL_DRAW | B_NAVIGABLE);
142 chkLogAll->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
144 // Add Objects to View
145 aModemview->AddChild(YourModemIsMenuField);
146 aModemview->AddChild(ConnectViaMenuField);
147 aModemview->AddChild(SpeedMenuField);
148 aModemview->AddChild(btnModemWindowCancel);
149 aModemview->AddChild(btnModemWindowCustom);
150 aModemview->AddChild(btnModemWindowDone);
151 aModemview->AddChild(chkMakeConnection);
152 aModemview->AddChild(chkShowTerminal);
153 aModemview->AddChild(chkLogAll);
154 aModemview->AddChild(rbPulse);
155 aModemview->AddChild(rbTone);
156 aModemview->AddChild(tvUse);
157 aModemview->AddChild(tvRedial);
158 aModemview->AddChild(tvTimesBusySignal);
159 aModemview->AddChild(tvReadLogPath);
160 aModemview->AddChild(tvWriteLogPath);
162 btnModemWindowDone->MakeDefault(true);
165 // ------------------------------------------------------------------------------- //
168 // ModemWindow::~ModemWindow -- destructor
169 ModemWindow::~ModemWindow()
171 exit(0);
173 // ------------------------------------------------------------------------------- //
176 // ModemWindow::MessageReceived -- receives messages
177 void ModemWindow::MessageReceived (BMessage *message)
179 switch(message->what)
181 case BTN_MODEM_WINDOW_DONE:
182 //Quit(); // debugging purposes
183 Hide();
184 break;
185 case BTN_MODEM_WINDOW_CANCEL:
186 Hide(); // must find a better way to close this window and not the entire application
187 // any suggestions would be greatly appreciated ;)
188 break;
189 default:
190 BWindow::MessageReceived(message);
191 break;
194 // end