/** * @brief ファイルが選択されたときの処理 * @param[in] fileIndex どっちのファイルか * @param[in] message 選択されたパラメータを含むメッセージ */ void OpenFilesDialog::doFileSelected(OpenFilesDialog::FileIndex fileIndex, BMessage* message) { entry_ref ref; if (B_OK != message->FindRef("refs", &ref)) { return; } BPath path(&ref); const char* viewName; switch (fileIndex) { case LeftFile: viewName = NAME_LEFT_TEXT_CONTROL; break; case RightFile: viewName = NAME_RIGHT_TEXT_CONTROL; break; default: viewName = NULL; // ここには来ない break; } BTextControl* textControl = dynamic_cast<BTextControl*>(FindView(viewName)); if (NULL != textControl) { textControl->SetText(path.Path()); } }
void BrowserWindow::SetLocationBarURL( const std::string &/*cURL*/ ) { // m_pcURLView->Set( m_pcHTMLPart->url().prettyURL().utf8().data(), false ); m_pcURLView->SetText( m_pcHTMLPart->url().prettyURL().utf8().data() ); //?? m_pcURLView->SetText( cURL.c_str() ); // m_pcURLView->Set( cURL.c_str(), false ); }
void MimeTypeEditor::_UpdateText() { BAutolock locker(fEditor); const char* mimeType; if (fEditor.GetViewBuffer((const uint8 **)&mimeType) == B_OK) { fTextControl->SetText(mimeType); fPreviousText.SetTo(mimeType); } }
void BrowserWindow::OpenURL( const std::string& cURL, const KParts::URLArgs& cArgs ) { // GlobalMutex::Lock(); // m_pcURLView->Set( cURL.c_str(), false ); m_pcURLView->SetText( cURL.c_str() ); m_pcHTMLPart->browserExtension()->setURLArgs( cArgs ); m_pcHTMLPart->openURL( cURL.c_str() ); // GlobalMutex::Unlock(); }
void TFilePanel::SetSaveText(const char* text) { if (text == NULL) return; BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("text view")); if (textControl != NULL) { textControl->SetText(text); if (textControl->TextView() != NULL) textControl->TextView()->SelectAll(); } }
BFIV_PrefWin::BFIV_PrefWin(BRect frame) : BWindow(frame, "Preferences", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_RESIZABLE|B_NOT_ZOOMABLE) { BRect rect = Bounds(); BView *back; BTextControl *scratchPath; BButton *cancelButton, *okButton, *selectButton; font_height fontHeight; float fontSize, tmp; // private data filePanel = NULL; // some font voodoo be_plain_font->GetHeight(&fontHeight); fontSize = fontHeight.ascent + fontHeight.descent; // the background back = new BView(rect, "background", B_FOLLOW_ALL, 0); back->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(back); // the select button tmp = be_plain_font->StringWidth("Select"); rect.Set(frame.Width() - tmp - 20., 5., frame.Width() - 5., 5. + fontSize + 10.); selectButton = new BButton(rect, "select", "Select", new BMessage(SELECT_SCRATCH_PATH)); back->AddChild(selectButton); // the path rect.Set(5.,5., selectButton->Frame().left - 5., 5. + fontSize + 10.); scratchPath = new BTextControl(rect, "path", "Scratch Location", NULL, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); back->AddChild(scratchPath); scratchPath->SetText(((BFIV_App *)be_app)->ScratchDirectory()); // current dir scratchPath->TextView()->MakeEditable(false); // only works after AddChild() (!!) // the ok button tmp = be_plain_font->StringWidth("OK"); rect.Set(frame.Width() - tmp - 35., Frame().Height() - fontSize - 20., frame.Width() - 10., Frame().Height() - 10.); okButton = new BButton(rect, "ok", "OK", new BMessage(APPLY_PREFS_CHANGE)); back->AddChild(okButton); okButton->MakeDefault(true); // the cancel button tmp = be_plain_font->StringWidth("Cancel"); rect.Set(okButton->Frame().left - tmp - 20., okButton->Frame().top, okButton->Frame().left - 5., okButton->Frame().bottom); cancelButton = new BButton(rect, "cancel", "Cancel", new BMessage(B_QUIT_REQUESTED)); back->AddChild(cancelButton); }
void SetPrefs(const BMessage* prefs) { if( !prefs ) return; mOldPrefs.MakeEmpty(); mOldPrefs = *prefs; delete mRef; mRef = 0; bool b; const char* str; entry_ref ref; if( mOnBox && prefs->FindBool( "on", &b ) == B_OK ) mOnBox->SetValue( (b) ? B_CONTROL_ON : B_CONTROL_OFF ); if( mNameCtrl && prefs->FindString( "name", &str ) == B_OK ) mNameCtrl->SetText( str ); if( prefs->FindRef( "ref", &ref ) == B_OK ) mRef = new entry_ref( ref ); if( mSkipBox && prefs->FindBool( "skip", &b ) == B_OK ) mSkipBox->SetValue( (b) ? B_CONTROL_ON : B_CONTROL_OFF ); }
/*********************************************************** * MessageReceived ***********************************************************/ void HAddressView::MessageReceived(BMessage *message) { switch(message->what) { case M_ACCOUNT_CHANGE: { const char* name; if(message->FindString("name",&name) != B_OK) break; ChangeAccount(name); PRINT(("Name:%s\n",name)); break; } case M_SEL_GROUP: { BMenu *menu; BTextControl *control; if(message->FindPointer("menu",(void**)&menu) != B_OK || message->FindPointer("control",(void**)&control) != B_OK) break; if(control) { BString text = control->Text(); if(text.Length() != 0) text += ","; int32 count = menu->CountItems(); for(int32 i = 0;i < count;i++) { const char* label = menu->ItemAt(i)->Label(); text += label; if(i != count-1) text += ","; } control->SetText(text.String() ); } break; } default: BView::MessageReceived(message); } }
void HDialog::SetText(const char *name, const char *text) { BView *c = FindView(name); if (!c) { ASSERT(false); return; } BTextControl *tc = dynamic_cast<BTextControl*>(c); if (tc) { tc->SetText(text); if (tc->IsFocus()) tc->TextView()->SelectAll(); } else if (typeid(*c) == typeid(BStringView)) static_cast<BStringView *>(c)->SetText(text); } /* HDialog::SetText */
void PecoApp::New() { fWindow->Lock(); fListView->MakeEmpty(); //...und Updaten... BListItem* myListItem; fListView->AddItem(myListItem = new BStringItem("")); fListView->RemoveItem(myListItem); BTextControl* pfadView = (BTextControl *)fWindow->FindView("pfadView"); pfadView->SetText(NULL); fWindow->Unlock(); for( FileListItem* myItem; (myItem = (FileListItem *)fList->RemoveItem((int32)0) ) != NULL; ) delete myItem; UpdateWindowStatus(); }
IMAPConfig::IMAPConfig(BMessage *archive) : BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_USERNAME | B_MAIL_PROTOCOL_HAS_PASSWORD | B_MAIL_PROTOCOL_HAS_HOSTNAME | B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER #ifdef USE_SSL | B_MAIL_PROTOCOL_HAS_FLAVORS #endif ) { #ifdef USE_SSL AddFlavor("No encryption"); AddFlavor("SSL"); #endif SetTo(archive); ((BControl *)(FindView("leave_mail_remote")))->SetValue(B_CONTROL_ON); ((BControl *)(FindView("leave_mail_remote")))->Hide(); BRect frame = FindView("delete_remote_when_local")->Frame(); ((BControl *)(FindView("delete_remote_when_local")))->SetEnabled(true); ((BControl *)(FindView("delete_remote_when_local")))->MoveBy(0,-25); frame.right -= 10;// FindView("pass")->Frame().right; /*frame.top += 10; frame.bottom += 10;*/ BTextControl *folder = new BTextControl(frame,"root","Top mailbox folder: ","",NULL); folder->SetDivider(be_plain_font->StringWidth("Top mailbox folder: ")); if (archive->HasString("root")) folder->SetText(archive->FindString("root")); AddChild(folder); ResizeToPreferred(); }
void TFilePanel::AdjustButton() { // adjust button state BButton* button = dynamic_cast<BButton*>(FindView("default button")); if (button == NULL) return; BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("text view")); BObjectList<BPose>* selectionList = fPoseView->SelectionList(); BString buttonText = fButtonText; bool enabled = false; if (fIsSavePanel && textControl != NULL) { enabled = textControl->Text()[0] != '\0'; if (fPoseView->IsFocus()) { fPoseView->ShowSelection(true); if (selectionList->CountItems() == 1) { Model* model = selectionList->FirstItem()->TargetModel(); if (model->ResolveIfLink()->IsDirectory()) { enabled = true; buttonText = B_TRANSLATE("Open"); } else { // insert the name of the selected model into // the text field textControl->SetText(model->Name()); textControl->MakeFocus(true); } } } else fPoseView->ShowSelection(false); } else { int32 count = selectionList->CountItems(); if (count) { enabled = true; // go through selection list looking at content for (int32 index = 0; index < count; index++) { Model* model = selectionList->ItemAt(index)->TargetModel(); uint32 modelFlavor = GetLinkFlavor(model, false); uint32 linkFlavor = GetLinkFlavor(model, true); // if only one item is selected and we're not in dir // selection mode then we don't disable button ever if ((modelFlavor == B_DIRECTORY_NODE || linkFlavor == B_DIRECTORY_NODE) && count == 1) break; if ((fNodeFlavors & modelFlavor) == 0 && (fNodeFlavors & linkFlavor) == 0) { enabled = false; break; } } } } button->SetLabel(buttonText.String()); button->SetEnabled(enabled); }
void NumberEditor::_UpdateText() { if (fEditor.Lock()) { const char* number; if (fEditor.GetViewBuffer((const uint8**)&number) == B_OK) { char buffer[64]; char format[16]; switch (fEditor.Type()) { case B_FLOAT_TYPE: { float value = *(float*)number; snprintf(buffer, sizeof(buffer), "%g", value); break; } case B_DOUBLE_TYPE: { double value = *(double *)number; snprintf(buffer, sizeof(buffer), "%g", value); break; } case B_SSIZE_T_TYPE: case B_INT8_TYPE: case B_INT16_TYPE: case B_INT32_TYPE: case B_INT64_TYPE: case B_OFF_T_TYPE: { _Format(format); switch (_Size()) { case 1: { int8 value = *(int8 *)number; snprintf(buffer, sizeof(buffer), format, value); break; } case 2: { int16 value = *(int16 *)number; snprintf(buffer, sizeof(buffer), format, value); break; } case 4: { int32 value = *(int32 *)number; snprintf(buffer, sizeof(buffer), format, value); break; } case 8: { int64 value = *(int64 *)number; snprintf(buffer, sizeof(buffer), format, value); break; } } break; } default: { _Format(format); switch (_Size()) { case 1: { uint8 value = *(uint8 *)number; snprintf(buffer, sizeof(buffer), format, value); break; } case 2: { uint16 value = *(uint16 *)number; snprintf(buffer, sizeof(buffer), format, value); break; } case 4: { uint32 value = *(uint32 *)number; snprintf(buffer, sizeof(buffer), format, value); break; } case 8: { uint64 value = *(uint64 *)number; snprintf(buffer, sizeof(buffer), format, value); break; } } break; } } fTextControl->SetText(buffer); fPreviousText.SetTo(buffer); } fEditor.Unlock(); } }
void PecoApp::RefsReceived ( BMessage* msg ) { entry_ref ref; BPath aPath; BEntry aEntry; off_t size; time_t timer; fWindow->Lock(); BTextControl* pfadView = (BTextControl *)fWindow->FindView("pfadView"); fWindow->Unlock(); //Pfad finden for ( int i=0; msg->FindRef("refs", i, &ref) == B_OK; i++ ) if ( ref.device > 1 ) break; if ( ref.device > 1 ) { New(); fWindow->Lock(); ((PecoApp *)be_app)->fStatusBar->SetText(STATUS_IMPORT); fWindow->Unlock(); aEntry = BEntry(&ref); BPath( &aEntry ).GetParent(&fPfad); fWindow->Lock(); pfadView->SetText( fPfad.Path() ); fWindow->Unlock(); //zählen type_code typeFound; long total = 0; msg->GetInfo("refs", &typeFound, &total); fWindow->Lock(); fStatusBar->SetMaxValue( total ); fWindow->Unlock(); BPath newPath; bool didntshow_msgmultidir = true; for ( int i=0; msg->FindRef("refs", i, &ref) == B_OK; i++ ) { fWindow->Lock(); fStatusBar->Update(1); fWindow->Unlock(); // Laufwerke ausfiltern if ( ref.device == 1 ) continue; // Dateien mit falschem Pfad ausfiltern aEntry = BEntry(&ref); aPath = BPath(&aEntry); BPath( &aEntry ).GetParent(&newPath); if ( (strcmp( fPfad.Path(), newPath.Path() ) != 0 ) ) { if ( didntshow_msgmultidir ) { BAlert* myAlert = new BAlert(NULL, MESSAGE_MULTIDIR, STR_OK); myAlert->Go(); didntshow_msgmultidir = false; } continue; } // Werte auslesen if (aEntry.IsFile()) aEntry.GetSize(&size); else if (aEntry.IsSymLink()) size = -1; else if (aEntry.IsDirectory()) size = -2; else continue; aEntry.GetModificationTime(&timer); fList->AddItem(new FileListItem(aPath.Leaf(), size, timer, &ref)); } fWindow->Lock(); fListView->AddList(fList); float Hoehe = be_plain_font->Size() + 2; if (Hoehe < 18) { BListItem* myListItem; for (int i=0; (myListItem = fListView->ItemAt(i)); i++) myListItem->SetHeight(18); // Zum Updaten: fListView->AddItem(myListItem = new BStringItem("")); fListView->RemoveItem(myListItem); } fStatusBar->Reset(STATUS_STATUS); fStatusBar->SetMaxValue(fList->CountItems()); fWindow->Unlock(); MakeList(); } fWindow->Activate(); UpdateWindowStatus(); }
void PrefsWindow::MessageReceived(BMessage* message) { switch(message->what) { case PrefsConstants::K_PREFS_VIEW_RESET_COLOUR_DEFAULTS: { ResetToDefaults(PrefsConstants::K_RESET_COLOUR_PREFS); } break; case PrefsConstants::K_PREFS_VIEW_RESET_COMMAND_DEFAULTS: { ResetToDefaults(PrefsConstants::K_RESET_COMMAND_PREFS); } break; case PrefsConstants::K_PREFS_VIEW_RESET_TOOLBAR_DEFAULTS: { ResetToDefaults(PrefsConstants::K_RESET_TOOLBAR_PREFS); } break; case PrefsConstants::K_PREFS_VIEW_RESET_GENERAL_DEFAULTS: { ResetToDefaults(PrefsConstants::K_RESET_GENERAL_PREFS); } break; case PrefsConstants::K_PREFS_UPDATE: { //update the preferences message, from view values BString prefsID; if (message->FindString(K_PREFS_ID, &prefsID) == B_OK) { BView *changedView = m_parent->FindView(prefsID.String()); prefsLock.Lock(); //different view have different kinds of values if (is_instance_of(changedView, BTextControl)) { //a textcontrol value was changed, update preferences with new text BTextControl *textControl = dynamic_cast<BTextControl*>(changedView); preferences.ReplaceString(prefsID.String(), textControl->Text()); } else if (is_instance_of(changedView, BCheckBox)) { //a checkbox value was changed, update preferences with new bool value(on/off) BCheckBox *checkBox = dynamic_cast<BCheckBox*>(changedView); preferences.ReplaceBool(prefsID.String(), checkBox->Value()); } else if (is_instance_of(changedView, BSlider)) { //a slider value was changed, update preferences with new slider value BSlider *slider = dynamic_cast<BSlider*>(changedView); preferences.ReplaceInt32(prefsID.String(), slider->Value()); } else if (is_instance_of(changedView, ColourButton)) { //a colourcontrol value was changed, update preferences with new colour ColourButton *colourControl = dynamic_cast<ColourButton*>(changedView); preferences.ReplaceData(prefsID.String(),B_RGB_COLOR_TYPE, &colourControl->Value(), sizeof(rgb_color)); } prefsLock.Unlock(); } } break; case PrefsConstants::K_LOAD_PREFERENCES: { //set preferences view values to values of the preferences message BString prefsID; if (message->FindString(K_PREFS_ID, &prefsID) == B_OK) { //find out which view value has to be updated BView *changedView = m_parent->FindView(prefsID.String()); prefsLock.Lock(); char *name; uint32 type; int32 count; for (int32 i = 0; preferences.GetInfo(B_ANY_TYPE, i, &name, &type, &count) == B_OK; i++) { //find out what kind of field we are using switch (type) { case B_INT32_TYPE: { int32 value; preferences.FindInt32(name, &value); if (is_instance_of(changedView, BSlider)) { BSlider *slider = dynamic_cast<BSlider*>(changedView); slider->SetValue(value); } } break; case B_BOOL_TYPE: { bool value; preferences.FindBool(name, &value); if (is_instance_of(changedView, BCheckBox)) { BCheckBox *checkBox = dynamic_cast<BCheckBox*>(changedView); checkBox->SetValue(value); } } break; case B_RGB_COLOR_TYPE: { rgb_color *colour; ssize_t size; preferences.FindData(name, B_RGB_COLOR_TYPE, (const void**)&colour, &size); if (is_instance_of(changedView, ColourButton)) { ColourButton *colourControl = dynamic_cast<ColourButton*>(changedView); colourControl->SetValue(*colour); } } break; case B_STRING_TYPE: { BString string; preferences.FindString(name, &string); if (is_instance_of(changedView, ColourButton)) { BTextControl *textControl = dynamic_cast<BTextControl*>(changedView); textControl->SetText(string.String()); } } break; } } prefsLock.Unlock(); //make sure the new view values are drawn! changedView->Invalidate(); } } break; default: BWindow::MessageReceived(message); break; } }