/* ConfigViews - config views for the account, protocols, and filters ** ** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved. */ #include "ConfigViews.h" #include "Account.h" #include "CenterContainer.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // AccountConfigView const uint32 kMsgAccountTypeChanged = 'atch'; const uint32 kMsgAccountNameChanged = 'anmc'; // ProtocolsConfigView const uint32 kMsgProtocolChanged = 'prch'; // FiltersConfigView const uint32 kMsgItemDragged = 'itdr'; const uint32 kMsgFilterMoved = 'flmv'; const uint32 kMsgChainSelected = 'chsl'; const uint32 kMsgAddFilter = 'addf'; const uint32 kMsgRemoveFilter = 'rmfi'; const uint32 kMsgFilterSelected = 'fsel'; AccountConfigView::AccountConfigView(BRect rect,Account *account) : BBox(rect), fAccount(account) { SetLabel(MDR_DIALECT_CHOICE ("Account Configuration","アカウント設定")); rect = Bounds().InsetByCopy(8,8); rect.top += 10; CenterContainer *view = new CenterContainer(rect,false); view->SetSpacing(5); // determine font height font_height fontHeight; view->GetFontHeight(&fontHeight); int32 height = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 5; rect = view->Bounds(); rect.bottom = height + 5; float labelWidth = view->StringWidth(MDR_DIALECT_CHOICE ("Account Name:","アカウント名:")) + 6; view->AddChild(fNameControl = new BTextControl(rect,NULL,MDR_DIALECT_CHOICE ("Account Name:","アカウント名:"),NULL,new BMessage(kMsgAccountNameChanged))); fNameControl->SetDivider(labelWidth); view->AddChild(fRealNameControl = new BTextControl(rect,NULL,MDR_DIALECT_CHOICE ("Real Name:","名前    :"),NULL,NULL)); fRealNameControl->SetDivider(labelWidth); view->AddChild(fReturnAddressControl = new BTextControl(rect,NULL,MDR_DIALECT_CHOICE ("Return Address:","返信アドレス:"),NULL,NULL)); fReturnAddressControl->SetDivider(labelWidth); // control->TextView()->HideTyping(true); BPopUpMenu *chainsPopUp = new BPopUpMenu(B_EMPTY_STRING); const char *chainModes[] = { MDR_DIALECT_CHOICE ("Inbound Only","受信のみ"), MDR_DIALECT_CHOICE ("Outbound Only","送信のみ"), MDR_DIALECT_CHOICE ("Inbound & Outbound","送受信")}; BMenuItem *item; for (int32 i = 0;i < 3;i++) chainsPopUp->AddItem(item = new BMenuItem(chainModes[i],new BMessage(kMsgAccountTypeChanged))); fTypeField = new BMenuField(rect,NULL,MDR_DIALECT_CHOICE ("Account Type:","用途    :"),chainsPopUp); fTypeField->SetDivider(labelWidth + 3); view->AddChild(fTypeField); float w,h; view->GetPreferredSize(&w,&h); ResizeTo(w + 15,h + 22); view->ResizeTo(w,h); AddChild(view); } void AccountConfigView::DetachedFromWindow() { fAccount->SetName(fNameControl->Text()); fAccount->SetRealName(fRealNameControl->Text()); fAccount->SetReturnAddress(fReturnAddressControl->Text()); } void AccountConfigView::AttachedToWindow() { UpdateViews(); fNameControl->SetTarget(this); fTypeField->Menu()->SetTargetForItems(this); } void AccountConfigView::MessageReceived(BMessage *msg) { switch (msg->what) { case kMsgAccountTypeChanged: { int32 index; if (msg->FindInt32("index",&index) < B_OK) break; if (fAccount->Type() < 0) { fNameControl->SetEnabled(true); fRealNameControl->SetEnabled(true); fReturnAddressControl->SetEnabled(true); } fAccount->SetType(index); UpdateViews(); break; } case kMsgAccountNameChanged: fAccount->SetName(fNameControl->Text()); break; default: BView::MessageReceived(msg); } } void AccountConfigView::UpdateViews() { if (!fAccount->Inbound() && !fAccount->Outbound()) { if (BMenuItem *item = fTypeField->Menu()->FindMarked()) item->SetMarked(false); fTypeField->Menu()->Superitem()->SetLabel(MDR_DIALECT_CHOICE ("