3 LocationView - View for the Location Controls on DUNWindow
5 Authors: Misza (misza@ihug.com.au)
6 Sikosis (beos@gravity24hr.com)
8 (C) 2002 OpenBeOS under MIT license
13 #include "LocationView.h"
19 // LocationView -- View inside DUNWindow
20 LocationView::LocationView() : BView(BRect(55,31,285,87),"locationview",B_FOLLOW_NONE
,B_WILL_DRAW
)
22 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR
));
24 BRect
line1(0,5,125,20);
25 disablecallwaiting
= new BCheckBox(line1
,"disablecallwaiting","Disable call waiting:",new BMessage(DCW_CHKBOX
));
27 AddChild(disablecallwaiting
);
31 dcwvalue
= new BTextControl(BRect(125,5,175,20),"dcwvalue",NULL
,NULL
,new BMessage(CHANGE_DCW
));
36 dcwlist
= new BPopUpMenu("");
38 dcwone
= new BMenuItem("*70,",new BMessage(DCW_ITEMS
));
39 dcwtwo
= new BMenuItem("70#,",new BMessage(DCW_ITEMS
));
40 dcwthree
= new BMenuItem("1170,",new BMessage(DCW_ITEMS
));
41 dcwlist
->AddItem(dcwone
);
42 dcwlist
->AddItem(dcwtwo
);
43 dcwlist
->AddItem(dcwthree
);
45 dcwlistfield
= new BMenuField(BRect(180,5,240,20),
47 dcwone
->SetMarked(true);
48 AddChild(dcwlistfield
);
51 BRect
line2(0,30,125,45);
53 dialoutprefix
= new BCheckBox(line2
,"dialoutprefix",
54 "Dial out prefix:",new BMessage(DOP_CHKBOX
));
55 AddChild(dialoutprefix
);
57 dopvalue
= new BTextControl(BRect(125,30,175,45),"dopvalue",NULL
,NULL
,
58 new BMessage(CHANGE_DOP
));
61 doplist
= new BPopUpMenu("");
63 dopone
= new BMenuItem("1,",new BMessage(DOP_ITEMS
));
64 doptwo
= new BMenuItem("9,",new BMessage(DOP_ITEMS
));
65 dopthree
= new BMenuItem("9,1,",new BMessage(DOP_ITEMS
));
67 doplist
->AddItem(dopone
);
68 doplist
->AddItem(doptwo
);
69 doplist
->AddItem(dopthree
);
70 doplistfield
= new BMenuField(BRect(180,30,240,45),
72 dopone
->SetMarked(true);
73 AddChild(doplistfield
);
75 //turned off by default
76 dcwlistfield
->SetEnabled(false);
77 dcwvalue
->SetEnabled(false);
79 doplistfield
->SetEnabled(false);
80 dopvalue
->SetEnabled(false);
82 // ------------------------------------------------------------------------------- //
85 // LocationView::MessageReceived -- Receives Messages
86 void LocationView::MessageReceived(BMessage
*msg
)
91 if(disablecallwaiting
->Value() == B_CONTROL_ON
)
93 cout
<< "dcw on" << endl
;
94 dcwlistfield
->SetEnabled(true);
95 dcwvalue
->SetEnabled(true);
97 cout
<< "dcw off" << endl
;
98 dcwlistfield
->SetEnabled(false);
99 dcwvalue
->SetEnabled(false);
103 if(dialoutprefix
->Value() == B_CONTROL_ON
)
105 cout
<< "dop on" << endl
;
106 doplistfield
->SetEnabled(true);
107 dopvalue
->SetEnabled(true);
109 cout
<< "dop off" << endl
;
110 doplistfield
->SetEnabled(false);
111 dopvalue
->SetEnabled(false);
115 cout
<< "DOP is set to: " << dopvalue
->Text() << endl
;
118 cout
<< "DCW is set to: " << dcwvalue
->Text() << endl
;
121 if(dcwone
->IsMarked())
122 dcwvalue
->SetText("*70,");
123 else if(dcwtwo
->IsMarked())
124 dcwvalue
->SetText("70#,");
125 else if(dcwthree
->IsMarked())
126 dcwvalue
->SetText("1170,");
127 dcwvalue
->MakeFocus();
128 cout
<< "DCW is set to: " << dcwvalue
->Text() << endl
;
131 if(dopone
->IsMarked())
132 dopvalue
->SetText("1,");
133 else if(doptwo
->IsMarked())
134 dopvalue
->SetText("9,");
135 else if(dopthree
->IsMarked())
136 dopvalue
->SetText("9,1,");
137 dopvalue
->MakeFocus();
138 cout
<< "DOP is set to: " << dopvalue
->Text() << endl
;
141 BView::MessageReceived(msg
);
145 // ------------------------------------------------------------------------------- //
147 // LocationView::AttachedToWindow -- facilitates the LocationView to be able to receive messages in MessageReceived()
148 void LocationView::AttachedToWindow()
150 disablecallwaiting
->SetTarget(this);
151 dcwvalue
->SetTarget(this);
152 dcwone
->SetTarget(this);
153 dcwtwo
->SetTarget(this);
154 dcwthree
->SetTarget(this);
156 dialoutprefix
->SetTarget(this);
157 dopvalue
->SetTarget(this);
158 dopone
->SetTarget(this);
159 doptwo
->SetTarget(this);
160 dopthree
->SetTarget(this);
162 // ------------------------------------------------------------------------------- //