void SeqPhraseMatrixView::MouseDown(BPoint where) { inherited::MouseDown(where); mDownTime = -1; mDownPt = where; StopPopUpTimer(); SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY); SeqSongWinPropertiesI* win = dynamic_cast<SeqSongWinPropertiesI*>( Window() ); _SeqPhraseToolTarget* target; if (win && (target = new _SeqPhraseToolTarget(win, this, &mMtc)) ) { mTool.MouseDown(target, where); delete target; } uint32 buttons; GetMouse(&where, &buttons, false); if (buttons&B_SECONDARY_MOUSE_BUTTON) { bigtime_t doubleClickTime; get_click_speed(&doubleClickTime); // doubleClickTime *= 2; StartPopUpTimer(BMessage(SHOW_POPUP_MSG), doubleClickTime); mDownTime = system_time(); } }
ExtraAttributeLazyInstaller::~ExtraAttributeLazyInstaller() { if (fMimeType.InitCheck() == B_OK && fDirty && fMimeType.SetAttrInfo(&fExtraAttrs) != B_OK) { fExtraAttrs = BMessage(); } }
/* * Sets up the Node Monitoring for Dropbox folder and contents * and creates data structure for determining which files are deleted or edited */ App::App(void) : BApplication("application/x-vnd.lh-MyDropboxClient") { pull_and_apply_deltas(); printf("Done pulling changes, now to start tracking\n"); //start watching ~/Dropbox folder contents (create, delete, move) BDirectory dir(local_path_string_noslash); //don't use ~ here node_ref nref; status_t err; if(dir.InitCheck() == B_OK){ dir.GetNodeRef(&nref); err = watch_node(&nref, B_WATCH_DIRECTORY, be_app_messenger); if(err != B_OK) printf("Watch Node: Not OK\n"); } printf("Done watching root directory\n"); //watch all the child files for edits and the folders for create/delete/move this->recursive_watch(&dir); printf("Done watching and tracking all children of ~/Dropbox.\n"); BMessage msg = BMessage(MY_DELTA_CONST); bigtime_t microseconds = HOW_OFTEN_TO_POLL; this->msg_runner = new BMessageRunner(be_app_messenger, msg, microseconds, -1); }
BF_GUI_SetupDialog::BF_GUI_SetupDialog(BRect & o_Rect,BView *po_View) :BF_GUI_Dialog(o_Rect,BF_DictAt(BF_DICT_MAINSETUP),"",BMessage(),BG_GUI_DIALOG_WINRESIZE_RESIZE_ALL) { poSysSetup->CopyTo(oSetup); // oMessage.what = BF_MSG_MAINVIEW_MAINSETUP_CLOSE; oMessage.AddPointer("bf_focus",po_View); /* make left menu*/ BL_List *ploLeftList = new BL_List(); ploLeftList->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_MAINSETUP_COLSFONTS),"colors_fonts")); ploLeftList->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_MAINSETUP),"flags_main")); ploLeftList->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_MAINSETUP_FILES),"filetasks_copy")); ploLeftList->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_MAINSETUP_DEBUG),"flags_debug")); BRect oRect; LocalBounds(oRect); oRect.bottom -= oSetup.oFontToolView.fHeight*2; poMenu = new BF_GUI_DlgView_VMenu(oRect,"main_menu", B_FOLLOW_LEFT|B_FOLLOW_TOP_BOTTOM,ploLeftList,0); AddChild(poMenu); /* make bottom menu */ LocalBounds(oRect); oRect.top = oRect.bottom - oSetup.oFontToolView.fHeight; BL_List *ploMenu = new BL_List(); ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_OK),"ok")); AddMenu(oRect,ploMenu,true); // load icons // poFontSIcon = BL_Load_SIconFromMIME(BL_MIME_FONT); }
ExtraAttributeLazyInstaller::ExtraAttributeLazyInstaller(const char* type) : fMimeType(type), fDirty(false) { if (fMimeType.InitCheck() != B_OK || fMimeType.GetAttrInfo(&fExtraAttrs) != B_OK) { fExtraAttrs = BMessage(); } }
void BoolRenderer::MouseUp(BPoint where) { TRACE(); BMessage *valueContainer = new BMessage(); BMessage sendMessage = BMessage(*changeMessage); sendMessage.FindMessage("valueContainer",valueContainer); valueContainer->AddBool("newValue",!value); sendMessage.ReplaceMessage("valueContainer",valueContainer); BMessenger *sender = new BMessenger(editor->BelongTo()); sender->SendMessage(&sendMessage); }
/* '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 設定のキャンセルを反映するために、設定変更のメッセージを飛ばす UpdateCompos() によって設定の変更が通知される項目については、この関数でメッセージを飛ばす必要はない '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' */ void TPrefsView::NotifyPrefDifferences(const TPrefs& oOldPrefs, const TPrefs& oNewPrefs) { list<uint32> aWhats; list<uint32>::iterator p; BMessage aSendMsg; // 直ちに効果を反映しなくてはならない設定を検索 // 発効 p = aWhats.begin(); while ( p != aWhats.end() ) { aSendMsg = BMessage(*p); dynamic_cast<TDialogWindow*>(Window())->Target().SendMessage(&aSendMsg); p++; } }
void ArpIntControl::MouseUp(BPoint pt) { if (IsEnabled() == false) return; if (mMotion) mMotion->MouseUp(pt); if ( mDownPt == pt && Bounds().Contains(pt) ) { /* Start the edit timer in case the user is invoking an inline * text view. */ bigtime_t doubleClickTime; get_click_speed(&doubleClickTime); doubleClickTime *= 2; SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY); StartTimer(BMessage(EDIT_START_MSG), doubleClickTime); } else Invoke(); }
floppyFilePanel::floppyFilePanel (int32_t drive): BFilePanel (B_OPEN_PANEL, NULL, NULL, 0, false, NULL, 0, true, true) { char title[80]; BEntry dir = BEntry (currprefs.df[drive]); BMessage msg = BMessage (MSG_FLOPPY_PANEL_DRIVE0 + drive); dir.GetParent (&dir); sprintf (title, "UAE: Select image to insert in drive DF%d:", drive); done_sem = create_sem (0, NULL); be_app->Lock (); be_app->AddHandler (this); be_app->Unlock (); this->SetTarget (BMessenger (this)); this->SetMessage (&msg); this->SetPanelDirectory (&dir); this->Window ()->SetTitle (title); }
BF_GUI_FilesPanel_SearchDialog::BF_GUI_FilesPanel_SearchDialog( const BRect & o_Rect, const char *pc_SearchName, BF_GUI_FilesPanel *po_Panel, BF_Path & o_Path) :BF_GUI_Dialog(o_Rect,BF_DictAt(BF_DICT_SEARCH),"search",BMessage(),BG_GUI_DIALOG_WINRESIZE_RESIZE_ALL) { oMessage.what = BF_MSG_FILEPANEL_SEARCH_CLOSE; oMessage.AddPointer("bf_focus",po_Panel); // sSearchName = pc_SearchName; poPanel = po_Panel; idThreadQuery = 0; poSearch = NULL; oPath = o_Path; bFromCurrentFolder = false; //// nodes list //// BRect oRect; LocalBounds(oRect); oRect.bottom-=poSysSetup->oFontToolView.fHeight*3+5; BL_List *ploCol = new BL_List(); float fWidthSize = poSysSetup->oFontToolView.oFont.StringWidth("1234567890121")+10; ploCol->AddItem(new BF_GUI_DlgView_VCMenu_Column(BF_DictAt(BF_DICT_NAME),oRect.Width()-fWidthSize)); ploCol->AddItem(new BF_GUI_DlgView_VCMenu_Column(BF_DictAt(BF_DICT_NAME),fWidthSize)); poList = new BF_GUI_DlgView_VCMenu(oRect,"results",B_FOLLOW_ALL,new BL_List(),BF_GUI_DLGVIEW_VMENU_SICON, ploCol); AddChild(poList); ///// oRect.top = oRect.bottom + 5; oRect.bottom = oRect.top+poSysSetup->oFontToolView.fHeight; poComment = new BF_GUI_ViewText(oRect,"comment",BF_DictAt(BF_DICT_FILESEARCH_PROGRESS),B_FOLLOW_BOTTOM|B_FOLLOW_LEFT_RIGHT,0,false); AddChild(poComment); ///// BL_List *ploMenu = new BL_List(); ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_GOTO),"go")); ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_CANCEL),"cancel")); AddMenu(oRect,ploMenu); }
status_t PeThemesAddon::FindPrefWindow(BMessenger &messenger) { BMessenger app(PE_SIG); BMessenger win; status_t err; int i; if (!app.IsValid()) return B_ERROR; BMessage answer; BMessage msgGetMsgr(B_GET_PROPERTY); msgGetMsgr.AddSpecifier("Windows"); err = app.SendMessage(&msgGetMsgr, &answer, 2000000LL, 2000000LL); if (B_OK == err) { for (i = 0; answer.FindMessenger("result", i, &win) == B_OK; i++) { BString title; //TODO: FIXME: title might get localized someday... BMessage m(B_GET_PROPERTY); m.AddSpecifier("Title"); err = win.SendMessage(&m, &m, 20000LL, 20000LL); if (m.FindString("result", &title) == B_OK && title == "Preferences") { // get the top level view BMessenger view; m = BMessage(B_GET_PROPERTY); m.AddSpecifier("View", 0L); err = win.SendMessage(&m, &m, 20000LL, 20000LL); if (m.FindMessenger("result", &view) == B_OK) { messenger = view; return B_OK; } } } } // force showing the prefs window BMessage msgShowPref(msg_Preferences); err = app.SendMessage(&msgShowPref); err = app.SendMessage(&msgGetMsgr, &answer, 2000000LL, 2000000LL); if (B_OK == err) { for (i = 0; answer.FindMessenger("result", i, &win) == B_OK; i++) { BString title; BMessage m(B_GET_PROPERTY); m.AddSpecifier("Title"); err = win.SendMessage(&m, &m, 20000LL, 20000LL); if (m.FindString("result", &title) == B_OK && title == "Preferences") { // hide the prefs window BMessage hide(B_SET_PROPERTY); hide.AddSpecifier("Hidden"); hide.AddBool("data", true); err = win.SendMessage(&hide); // get the top level view BMessenger view; m = BMessage(B_GET_PROPERTY); m.AddSpecifier("View", 0L); err = win.SendMessage(&m, &m, 20000LL, 20000LL); if (m.FindMessenger("result", &view) == B_OK) { messenger = view; return B_OK; } } } } return B_ERROR; }
BBitmap* OilManipulator::ManipulateBitmap(BBitmap *original,Selection *selection,BStatusBar *status_bar) { BWindow *status_bar_window = NULL; if (status_bar != NULL) status_bar_window = status_bar->Window(); BRect a_rect = original->Bounds(); BBitmap *spare_buffer = DuplicateBitmap(original); BitmapDrawer *target = new BitmapDrawer(original); BitmapDrawer *source = new BitmapDrawer(spare_buffer); int32 width = original->Bounds().Width() + 1; int32 height = original->Bounds().Height() + 1; float status_bar_update_step = 100.0 / (width*height) * 1000.0; BMessage progress_message = BMessage(B_UPDATE_STATUS_BAR); progress_message.AddFloat("delta",0.0); // We must select all pixels between 0 and width*height in a // pseudo-random order. int32 *offsets = new int32[width*height]; for (int32 i=0;i<width*height;i++) offsets[i] = i; /* We copy each pixel with the following pattern: O OOO X -> OXOO O */ int32 size_of_area = width*height-1; int32 width_times_height = width*height; uint32 moved_pixel; union { uint8 bytes[4]; uint32 word; } color; int32 random_array_size = 32; int32 *random_array = new int32[random_array_size]; for (int32 i=0;i<random_array_size;i++) { random_array[i] = random()%10 * (random()%2 == 0?-1:1); } if ((selection == NULL) || (selection->IsEmpty() == TRUE)) { // for (int32 i=0;i<width_times_height;i++) { while (size_of_area > 0) { // Select one pixel at random int32 new_offset = rand() % size_of_area; int32 spare = offsets[new_offset]; offsets[new_offset] = offsets[size_of_area]; size_of_area--; int32 x = spare % width; int32 y = spare / width; color.word = source->GetPixel(BPoint(x,y)); // randomize the color a bit color.bytes[0] = min_c(255,max_c(0,(int32)color.bytes[0] + random_array[size_of_area%random_array_size])); color.bytes[1] = min_c(255,max_c(0,(int32)color.bytes[1] + random_array[size_of_area%random_array_size])); color.bytes[2] = min_c(255,max_c(0,(int32)color.bytes[2] + random_array[size_of_area%random_array_size])); moved_pixel = color.word; target->SetPixel(BPoint(x-2,y-1),moved_pixel); target->SetPixel(BPoint(x-1,y-1),moved_pixel); target->SetPixel(BPoint(x,y-1),moved_pixel); target->SetPixel(BPoint(x-1,y-2),moved_pixel); target->SetPixel(BPoint(x-1,y),moved_pixel); target->SetPixel(BPoint(x,y),moved_pixel); target->SetPixel(BPoint(x+1,y),moved_pixel); target->SetPixel(BPoint(x+2,y),moved_pixel); target->SetPixel(BPoint(x,y+1),moved_pixel); if (((size_of_area % 1000) == 0) && (status_bar != NULL) && (status_bar_window != NULL) && (status_bar_window->LockWithTimeout(0) == B_OK)) { status_bar->Update(status_bar_update_step); status_bar_window->Unlock(); } } } else { while (size_of_area > 0) { // Select one pixel at random int32 new_offset = rand() % size_of_area; int32 spare = offsets[new_offset]; offsets[new_offset] = offsets[size_of_area]; size_of_area--; int32 x = spare % width; int32 y = spare / width; color.word = source->GetPixel(BPoint(x,y)); // randomize the color a bit color.bytes[0] = min_c(255,max_c(0,(int32)color.bytes[0] + random_array[size_of_area%random_array_size])); color.bytes[1] = min_c(255,max_c(0,(int32)color.bytes[1] + random_array[size_of_area%random_array_size])); color.bytes[2] = min_c(255,max_c(0,(int32)color.bytes[2] + random_array[size_of_area%random_array_size])); moved_pixel = color.word; target->SetPixel(BPoint(x-2,y-1),moved_pixel,selection); target->SetPixel(BPoint(x-1,y-1),moved_pixel,selection); target->SetPixel(BPoint(x,y-1),moved_pixel,selection); target->SetPixel(BPoint(x-1,y-2),moved_pixel,selection); target->SetPixel(BPoint(x-1,y),moved_pixel,selection); target->SetPixel(BPoint(x,y),moved_pixel,selection); target->SetPixel(BPoint(x+1,y),moved_pixel,selection); target->SetPixel(BPoint(x+2,y),moved_pixel,selection); target->SetPixel(BPoint(x,y+1),moved_pixel,selection); if (((size_of_area % 1000) == 0) && (status_bar != NULL) && (status_bar_window != NULL) && (status_bar_window->LockWithTimeout(0) == B_OK)) { status_bar->Update(status_bar_update_step); status_bar_window->Unlock(); } } } // we should also delete the spare-bitmap delete spare_buffer; delete target; delete source; delete[] offsets; return original; }
void ProjectWindow::MessageReceived(BMessage *msg) { status_t status; if ( (msg->WasDropped() && msg->what == B_SIMPLE_DATA) || msg->what == M_ADD_FILES) { fAddFileStruct.refmsg = *msg; fAddFileStruct.parent = this; uint32 buttons; fProjectList->GetMouse(&fAddFileStruct.droppt,&buttons); thread_id addThread = spawn_thread(AddFileThread,"file adding thread", B_NORMAL_PRIORITY, &fAddFileStruct); if (addThread >= 0) resume_thread(addThread); } switch (msg->what) { case M_IMPORT_REFS: { fImportStruct.refmsg = *msg; fImportStruct.parent = this; thread_id importThread = spawn_thread(ImportFileThread,"file import thread", B_NORMAL_PRIORITY, &fImportStruct); if (importThread >= 0) resume_thread(importThread); break; } case M_BACKUP_PROJECT: { thread_id backupThread = spawn_thread(BackupThread,"project backup thread", B_NORMAL_PRIORITY, this); if (backupThread >= 0) { fStatusBar->SetText(TR("Backing up project")); UpdateIfNeeded(); SetMenuLock(true); resume_thread(backupThread); } break; } case M_GET_CHECK_IN_MSG: { if (!fSourceControl) { printf("NULL source control\n"); break; } BString out; fSourceControl->GetCheckinHeader(out); bool select = false; if (out.CountChars() > 1) out.Prepend("\n\n"); else { out = TR("Enter the description for the changes in this revision."); select = true; } GetTextWindow *gtw = new GetTextWindow("Paladin", out.String(), BMessage(M_CHECK_IN_PROJECT), BMessenger(this)); if (!select) gtw->GetTextView()->Select(0,0); gtw->Show(); break; } case M_CHECK_IN_PROJECT: { BString commitstr; if (msg->FindString("text", &commitstr) == B_OK && fSourceControl) { SCMOutputWindow *win = new SCMOutputWindow(TR("Commit")); win->Show(); fSourceControl->Commit(commitstr.String()); } break; } case M_REVERT_PROJECT: { if (!fSourceControl) break; int32 result = ShowAlert(TR("This will undo all changes since the last commit. " "Continue?"), "Don't Revert", "Revert"); if (result == 1) { SCMOutputWindow *win = new SCMOutputWindow(TR("Revert")); win->Show(); fSourceControl->Revert(NULL); } break; } case M_REBUILD_FILE: case M_ADD_SELECTION_TO_REPO: case M_REMOVE_SELECTION_FROM_REPO: case M_REVERT_SELECTION: case M_DIFF_SELECTION: { ActOnSelectedFiles(msg->what); break; } case M_DIFF_PROJECT: { if (fSourceControl) { SCMOutputWindow *win = new SCMOutputWindow(TR("Differences")); win->Show(); fSourceControl->Diff(NULL); } break; } case M_PROJECT_SCM_STATUS: { if (fSourceControl) { SCMOutputWindow *win = new SCMOutputWindow(TR("Project Status")); BString strstatus; fSourceControl->GetChangeStatus(strstatus); win->GetTextView()->SetText(strstatus.String()); win->Show(); } break; } case M_PUSH_PROJECT: { if (fSourceControl) { SCMOutputWindow *win = new SCMOutputWindow(TR("Push")); win->Show(); fSourceControl->Push(NULL); } break; } case M_PULL_PROJECT: { if (fSourceControl) { SCMOutputWindow *win = new SCMOutputWindow(TR("Pull")); win->Show(); status = fSourceControl->Pull(NULL); if (!status) ShowAlert("Unable to pull from the remote repository. If it " "uses a secure connection, please set up the appropriate " "SSH keys on the remote server.", "OK"); } break; } case M_CULL_EMPTY_GROUPS: { CullEmptyGroups(); break; } case M_RUN_FILE_TYPES: { int32 selection = fProjectList->FullListCurrentSelection(); if (selection < 0) break; SourceFileItem *item = dynamic_cast<SourceFileItem*>(fProjectList->FullListItemAt(selection)); if (!item) break; SpawnFileTypes(item->GetData()->GetPath()); break; } case M_OPEN_PARENT_FOLDER: { BMessage openmsg(B_REFS_RECEIVED); int32 selindex = 0; int32 selection = fProjectList->FullListCurrentSelection(); selindex++; if (selection >= 0) { while (selection >= 0) { SourceFileItem *item = dynamic_cast<SourceFileItem*>(fProjectList->FullListItemAt(selection)); if (!item) break; SourceFile *file = item->GetData(); BString abspath = file->GetPath().GetFullPath(); if (abspath[0] != '/') { abspath.Prepend("/"); abspath.Prepend(fProject->GetPath().GetFolder()); } DPath filepath(abspath); entry_ref ref; BEntry(filepath.GetFolder()).GetRef(&ref); openmsg.AddRef("refs",&ref); selection = fProjectList->FullListCurrentSelection(selindex++); } BMessenger msgr("application/x-vnd.Be-TRAK"); msgr.SendMessage(&openmsg); } break; } case M_SHOW_PROJECT_FOLDER: { entry_ref ref; BEntry(fProject->GetPath().GetFolder()).GetRef(&ref); BMessenger msgr("application/x-vnd.Be-TRAK"); BMessage openmsg(B_REFS_RECEIVED); openmsg.AddRef("refs",&ref); msgr.SendMessage(&openmsg); break; } case M_SHOW_ASCII_TABLE: { AsciiWindow *ascwin = new AsciiWindow(); ascwin->Show(); break; } case M_SHOW_VREGEX: { VRegWindow *vregwin = new VRegWindow(); vregwin->Show(); break; } case M_SHOW_LICENSES: { LicenseManager *man = new LicenseManager(fProject->GetPath().GetFolder()); man->Show(); break; } case M_RUN_TOOL: { BString sig; if (msg->FindString("signature", &sig) == B_OK) { LaunchHelper launcher(sig.String()); launcher.Launch(); } break; } case M_MAKE_MAKE: { DPath out(fProject->GetPath().GetFolder()); out.Append("Makefile"); if (MakeMake(fProject,out) == B_OK); { BEntry entry(out.GetFullPath()); entry_ref ref; if (entry.InitCheck() == B_OK) { entry.GetRef(&ref); BMessage refmsg(B_REFS_RECEIVED); refmsg.AddRef("refs",&ref); be_app->PostMessage(&refmsg); } } break; } case M_SHOW_CODE_LIBRARY: { #ifdef BUILD_CODE_LIBRARY CodeLibWindow *libwin = CodeLibWindow::GetInstance(BRect(100,100,500,350)); libwin->Show(); #endif break; } case M_OPEN_PARTNER: { int32 selection = fProjectList->FullListCurrentSelection(); if (selection < 0) break; SourceFileItem *item = dynamic_cast<SourceFileItem*>( fProjectList->FullListItemAt(selection)); if (!item) break; entry_ref ref; BEntry(fProject->GetPathForFile(item->GetData()).GetFullPath()).GetRef(&ref); BMessage refmsg(M_OPEN_PARTNER); refmsg.AddRef("refs",&ref); be_app->PostMessage(&refmsg); break; } case M_NEW_GROUP: { MakeGroup(fProjectList->FullListCurrentSelection()); PostMessage(M_SHOW_RENAME_GROUP); break; } case M_SHOW_RENAME_GROUP: { int32 selection = fProjectList->FullListCurrentSelection(); SourceGroupItem *groupItem = NULL; if (selection < 0) { // Don't need a selection if there is only one group in the project if (fProject->CountGroups() == 1) groupItem = fProjectList->ItemForGroup(fProject->GroupAt(0)); } else { BStringItem *strItem = (BStringItem*)fProjectList->FullListItemAt(selection); groupItem = fProjectList->GroupForItem(strItem); } if (!groupItem) break; GroupRenameWindow *grwin = new GroupRenameWindow(groupItem->GetData(), BMessage(M_RENAME_GROUP), BMessenger(this)); grwin->Show(); break; } case M_RENAME_GROUP: { SourceGroup *group; BString newname; if (msg->FindPointer("group",(void**)&group) != B_OK || msg->FindString("newname",&newname) != B_OK) break; group->name = newname; SourceGroupItem *groupItem = fProjectList->ItemForGroup(group); if (!groupItem) break; groupItem->SetText(newname.String()); fProjectList->InvalidateItem(fProjectList->IndexOf(groupItem)); fProject->Save(); break; } case M_SORT_GROUP: { int32 selection = fProjectList->FullListCurrentSelection(); SourceGroupItem *groupItem = NULL; if (selection < 0) { // Don't need a selection if there is only one group in the project if (fProject->CountGroups() == 1) groupItem = fProjectList->ItemForGroup(fProject->GroupAt(0)); } else { BStringItem *strItem = (BStringItem*)fProjectList->FullListItemAt(selection); groupItem = fProjectList->GroupForItem(strItem); } if (!groupItem) break; fProjectList->SortItemsUnder(groupItem,true,compare_source_file_items); groupItem->GetData()->Sort(); fProject->Save(); break; } case M_TOGGLE_ERROR_WINDOW: { ToggleErrorWindow(fProject->GetErrorList()); break; } case M_SHOW_ERROR_WINDOW: { ShowErrorWindow(fProject->GetErrorList()); break; } case M_SHOW_PROJECT_SETTINGS: { BRect r(0,0,350,300); BRect screen(BScreen().Frame()); r.OffsetTo((screen.Width() - r.Width()) / 2.0, (screen.Height() - r.Height()) / 2.0); ProjectSettingsWindow *win = new ProjectSettingsWindow(r,fProject); win->Show(); break; } case M_SHOW_RUN_ARGS: { RunArgsWindow *argwin = new RunArgsWindow(fProject); argwin->Show(); break; } case M_JUMP_TO_MSG: { entry_ref ref; if (msg->FindRef("refs",&ref) == B_OK) { msg->what = B_REFS_RECEIVED; be_app->PostMessage(msg); } break; } case B_ABOUT_REQUESTED: { be_app->PostMessage(B_ABOUT_REQUESTED); break; } case M_SHOW_OPEN_PROJECT: { be_app->PostMessage(msg); break; } case M_NEW_WINDOW: { be_app->PostMessage(M_NEW_PROJECT); break; } case M_SHOW_PROGRAM_SETTINGS: { PrefsWindow *prefwin = new PrefsWindow(BRect(0,0,500,400)); prefwin->Show(); break; } case M_SHOW_FIND_AND_OPEN_PANEL: { BString text; msg->FindString("name",&text); // Passing a NULL string to this is OK FindOpenFileWindow *findwin = new FindOpenFileWindow(text.String()); findwin->Show(); break; } case M_FILE_NEEDS_BUILD: { SourceFile *file; if (msg->FindPointer("file",(void**)&file) == B_OK) { SourceFileItem *item = fProjectList->ItemForFile(file); if (item) { item->SetDisplayState(SFITEM_NEEDS_BUILD); fProjectList->InvalidateItem(fProjectList->IndexOf(item)); } } break; } case M_EDIT_FILE: { int32 i = 0; int32 selection = fProjectList->FullListCurrentSelection(i); i++; BMessage refmsg(B_REFS_RECEIVED); while (selection >= 0) { SourceFileItem *item = dynamic_cast<SourceFileItem*> (fProjectList->FullListItemAt(selection)); if (item && item->GetData()) { BString abspath = item->GetData()->GetPath().GetFullPath(); if (abspath[0] != '/') { abspath.Prepend("/"); abspath.Prepend(fProject->GetPath().GetFolder()); } BEntry entry(abspath.String()); if (entry.InitCheck() == B_OK) { entry_ref ref; entry.GetRef(&ref); refmsg.AddRef("refs",&ref); } else { if (!entry.Exists()) { BString errmsg = TR("Couldn't find XXXXX. It may have been moved or renamed."); errmsg.ReplaceFirst("XXXXX",abspath.String()); ShowAlert(errmsg.String()); } } } else { SourceGroupItem *groupItem = dynamic_cast<SourceGroupItem*> (fProjectList->FullListItemAt(selection)); if (groupItem) { if (groupItem->IsExpanded()) fProjectList->Collapse(groupItem); else fProjectList->Expand(groupItem); groupItem->GetData()->expanded = groupItem->IsExpanded(); } } selection = fProjectList->CurrentSelection(i); i++; } be_app->PostMessage(&refmsg); break; } case M_LIBWIN_CLOSED: { fShowingLibs = false; break; } case M_SHOW_LIBRARIES: { fShowingLibs = true; LibraryWindow *libwin = new LibraryWindow(Frame().OffsetByCopy(15,15), BMessenger(this), fProject); libwin->Show(); break; } case M_SHOW_ADD_NEW_PANEL: { AddNewFileWindow *anfwin = new AddNewFileWindow(BMessage(M_ADD_NEW_FILE), BMessenger(this)); anfwin->Show(); break; } case M_SHOW_FIND_IN_PROJECT_FILES: { if (!gLuaAvailable) { ShowAlert("Paladin's multi-file Find window depends on Lua. It will " "need to be installed if you wish to use this feature.", "OK", NULL, NULL, B_STOP_ALERT); break; } FindWindow *findwin = new FindWindow(); findwin->Show(); break; } case M_ADD_NEW_FILE: { BString name; bool makepair; if (msg->FindString("name",&name) == B_OK && msg->FindBool("makepair",&makepair) == B_OK) AddNewFile(name,makepair); break; } case M_SHOW_ADD_PANEL: { if (!fFilePanel) { BMessenger msgr(this); BEntry entry(fProject->GetPath().GetFolder()); entry_ref ref; entry.GetRef(&ref); fFilePanel = new BFilePanel(B_OPEN_PANEL,&msgr,&ref,B_FILE_NODE,true, new BMessage(M_ADD_FILES)); } fFilePanel->Show(); break; } case M_REMOVE_FILES: { bool save = false; for (int32 i = 0; i < fProjectList->CountItems(); i++) { SourceFileItem *item = dynamic_cast<SourceFileItem*>(fProjectList->ItemAt(i)); if (item && item->IsSelected()) { fProjectList->RemoveItem(item); fProject->RemoveFile(item->GetData()); delete item; save = true; i--; } } CullEmptyGroups(); if (save) fProject->Save(); break; } case M_EMPTY_CCACHE: { // We don't do this when forcing a rebuild of the sources because sometimes it // can take quite a while if (gUseCCache && gCCacheAvailable) { fStatusBar->SetText(TR("Emptying build cache")); UpdateIfNeeded(); system("ccache -c > /dev/null"); fStatusBar->SetText(""); UpdateIfNeeded(); } break; } case M_FORCE_REBUILD: { fProject->ForceRebuild(); for (int32 i = 0; i < fProjectList->FullListCountItems(); i++) { SourceFileItem *item = dynamic_cast<SourceFileItem*>(fProjectList->FullListItemAt(i)); if (!item) continue; SourceFile *file = item->GetData(); if (file->UsesBuild()) { item->SetDisplayState(SFITEM_NEEDS_BUILD); fProjectList->InvalidateItem(i); } } // This is necessary because InvalidateItem() uses indices from ItemAt(), // not FullListItemAt fProjectList->Invalidate(); break; } case M_UPDATE_DEPENDENCIES: { UpdateDependencies(); break; } case M_MAKE_PROJECT: case M_BUILD_PROJECT: { fBuildingFile = 0; DoBuild(POSTBUILD_NOTHING); break; } case M_RUN_PROJECT: { DoBuild(POSTBUILD_RUN); break; } case M_RUN_IN_TERMINAL: { DoBuild(POSTBUILD_RUN_IN_TERMINAL); break; } case M_DEBUG_PROJECT: { if (!fProject->Debug()) { BString errmsg = TR("Your project does not have debugging information compiled "); errmsg << TR("in and will need to be rebuilt to debug. Do you wish to rebuild and ") << TR("run the debugger?"); int32 result = ShowAlert("Debugging information needs to compiled into " "your project. This may take some time for large " "projects. Do you wish to rebuild and run " "the debugger?", "Rebuild","Cancel"); if (result == 1) break; fProject->SetDebug(true); fProject->Save(); fProject->ForceRebuild(); } DoBuild(POSTBUILD_DEBUG); break; } case M_EXAMINING_FILE: { SourceFile *file; if (msg->FindPointer("file",(void**)&file) == B_OK) { BString out; out << TR("Examining ") << file->GetPath().GetFileName(); fStatusBar->SetText(out.String()); } break; } case M_BUILDING_FILE: { SourceFile *file; if (msg->FindPointer("sourcefile",(void**)&file) == B_OK) { SourceFileItem *item = fProjectList->ItemForFile(file); if (item) { item->SetDisplayState(SFITEM_BUILDING); fProjectList->InvalidateItem(fProjectList->IndexOf(item)); BString out; int32 count,total; if (msg->FindInt32("count",&count) == B_OK && msg->FindInt32("total",&total) == B_OK) { fBuildingFile = MAX(fBuildingFile, count); out << "(" << fBuildingFile << "/" << total << ") "; } out << TR("Building ") << item->Text(); fStatusBar->SetText(out.String()); } } break; } case M_BUILDING_DONE: { SourceFile *file; if (msg->FindPointer("sourcefile",(void**)&file) == B_OK) { SourceFileItem *item = fProjectList->ItemForFile(file); if (item) { item->SetDisplayState(SFITEM_NORMAL); fProjectList->InvalidateItem(fProjectList->IndexOf(item)); } } break; } case M_LINKING_PROJECT: { fStatusBar->SetText(TR("Linking")); break; } case M_UPDATING_RESOURCES: { fStatusBar->SetText(TR("Updating Resources")); break; } case M_DOING_POSTBUILD: { fStatusBar->SetText(TR("Performing Post-build tasks")); break; } case M_BUILD_FAILURE: { SetMenuLock(false); // fall through } case M_BUILD_MESSAGES: case M_BUILD_WARNINGS: { if (!fErrorWindow) { BRect screen(BScreen().Frame()); BRect r(screen); r.left = r.right / 4.0; r.right *= .75; r.top = r.bottom - 200; BDeskbar deskbar; if (deskbar.Location() == B_DESKBAR_BOTTOM) r.OffsetBy(0,-deskbar.Frame().Height()); fErrorWindow = new ErrorWindow(r,this); fErrorWindow->Show(); } else { if (!fErrorWindow->IsFront()) fErrorWindow->Activate(); } fStatusBar->SetText(""); // Should this be an Unflatten or an Append? ErrorList *errorList = fProject->GetErrorList(); errorList->Unflatten(*msg); fErrorWindow->PostMessage(msg); break; } case M_BUILD_SUCCESS: { SetMenuLock(false); fStatusBar->SetText(""); break; } case M_ERRORWIN_CLOSED: { fErrorWindow = NULL; break; } case M_SYNC_MODULES: { #ifdef BUILD_CODE_LIBRARY thread_id syncID = spawn_thread(SyncThread,"module update thread", B_NORMAL_PRIORITY, this); if (syncID >= 0) resume_thread(syncID); #endif break; } case M_TOGGLE_DEBUG_MENU: { ToggleDebugMenu(); break; } case M_DEBUG_DUMP_DEPENDENCIES: { DumpDependencies(fProject); break; } case M_DEBUG_DUMP_INCLUDES: { DumpIncludes(fProject); break; } default: { DWindow::MessageReceived(msg); break; } } }
void TestWindow::MakeTermSettings() { BView* settings = 0; BView* root = 0; BWindow* win = 0; try { // Pick some arbitrary initial frame for the window. BRect initFrame(0,0,100,100); // Create our three objects: the settings view, the top-level view // in the window, and the window itself. settings = GetTermSettings(BMessenger(), BMessage()); root = new BView(initFrame, "root", B_FOLLOW_ALL, B_WILL_DRAW); win = new BWindow(initFrame, "Terminal Settings", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS); // Set the background color of the root view and add it to the window. root->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); win->AddChild(root); // Set the size and position of the settings view -- inset a little // from the root -- and add it. float fw = be_plain_font->StringWidth("W"); font_height fhs; be_plain_font->GetHeight(&fhs); float fh = fhs.ascent+fhs.descent+fhs.leading; settings->MoveTo(fw, fh); settings->ResizeTo(initFrame.right-fw*2, initFrame.bottom-fh*2); root->AddChild(settings); win->Run(); mTermWin = win; mTermSet = settings; if( root ) { // Send a message to the view with our current global settings. // If the view is an ArpRootView, it will get the message and // know what to do with it. const BMessage* curGlobs = this->root->Globals()->GlobalValues(); if( curGlobs ) { BMessage globals(*curGlobs); globals.what = ARP_PREF_MSG; BMessage ret; mTermSet.SendMessage(&globals, &ret); } } // Get preferred size of settings view, and make final window dimensions // from this. float width=0, height=0; settings->GetPreferredSize(&width, &height); width += fw*2; height += fh*2; float minw=0,minh=0,maxw=0,maxh=0; win->GetSizeLimits(&minw,&maxw,&minh,&maxh); win->SetSizeLimits(width,maxw,height,maxh); BRect frm = Frame(); win->ResizeTo(width, height); BRect cfrm = Frame(); win->MoveTo( frm.left + (frm.Width()-cfrm.Width())/2, frm.top + (frm.Height()-cfrm.Height())/2); win->Show(); mTermWin = win; mTermSet = settings; } catch(...) { delete settings; delete root; delete win; } }