void DCCFileWindow::Show (void) { SetFlags (Flags() & ~(B_AVOID_FOCUS)); SetWorkspaces (B_CURRENT_WORKSPACE); BWindow::Show(); }
const char* FileChooser::Go() { SetWorkspaces(B_CURRENT_WORKSPACE); this->Show(); acquire_sem(sem); // wait return strdup(filename.String()); }
void TrackerSettingsWindow::Show() { if (Lock()) { int32 itemCount = fSettingsTypeListView->CountItems(); for (int32 i = 0; i < itemCount; i++) { _ViewAt(i)->RecordRevertSettings(); _ViewAt(i)->ShowCurrentSettings(); } fSettingsTypeListView->Invalidate(); _UpdateButtons(); Unlock(); } if (IsHidden()) { // move to current workspace SetWorkspaces(B_CURRENT_WORKSPACE); } _inherited::Show(); }
// ShowWindow() shows kouho window on current workspace // This is a bug fix for version 1.0 beta 2 void KouhoWindow::ShowWindow() { if ( IsHidden() ) { SetWorkspaces( B_CURRENT_WORKSPACE ); Show(); } }
void DownloadWindow::_DownloadStarted(BWebDownload* download) { download->Start(BPath(fDownloadPath.String())); int32 finishedCount = 0; int32 missingCount = 0; int32 index = 0; for (int32 i = fDownloadViewsLayout->CountItems() - 1; BLayoutItem* item = fDownloadViewsLayout->ItemAt(i); i--) { DownloadProgressView* view = dynamic_cast<DownloadProgressView*>( item->View()); if (!view) continue; if (view->URL() == download->URL()) { index = i; view->RemoveSelf(); delete view; continue; } if (view->IsFinished()) finishedCount++; if (view->IsMissing()) missingCount++; } fRemoveFinishedButton->SetEnabled(finishedCount > 0); fRemoveMissingButton->SetEnabled(missingCount > 0); DownloadProgressView* view = new DownloadProgressView(download); if (!view->Init()) { delete view; return; } fDownloadViewsLayout->AddView(index, view); // Scroll new download into view if (BScrollBar* scrollBar = fDownloadsScrollView->ScrollBar(B_VERTICAL)) { float min; float max; scrollBar->GetRange(&min, &max); float viewHeight = view->MinSize().height + 1; float scrollOffset = min + index * viewHeight; float scrollBarHeight = scrollBar->Bounds().Height() - 1; float value = scrollBar->Value(); if (scrollOffset < value) scrollBar->SetValue(scrollOffset); else if (scrollOffset + viewHeight > value + scrollBarHeight) { float diff = scrollOffset + viewHeight - (value + scrollBarHeight); scrollBar->SetValue(value + diff); } } _SaveSettings(); SetWorkspaces(B_CURRENT_WORKSPACE); if (IsHidden()) Show(); }
void ProtocolWindow::Show() { SetWorkspaces(B_CURRENT_WORKSPACE); BWindow::Show(); float width, height; Lock(); mb->GetPreferredSize(&width,&height); scrollView->ResizeTo(Bounds().Width()+1, Bounds().Height()-(height)); mb->ResizeTo(Bounds().Width(), height); scrollView->MoveTo(0,height+1); contentView->MakeFocus(true); Unlock(); set_thread_priority(Thread(), 5); // priority change must happen after // first Show(), because Show() sets // priority to 15 at first call. }
WaitWindow::WaitWindow(BMessage *msg, pid_t PID) : BWindow(BRect(110, 80, 380, 180), "analyze files", B_TITLED_WINDOW, B_NOT_CLOSABLE | B_NOT_RESIZABLE | B_NOT_ZOOMABLE, 0) { fParentID = PID; fQuited = false; fQuitStateThread = false; fSemQuit = create_sem(1, "fSemQuit"); fSemQuitedAble = create_sem(1, "semHide"); SetWorkspaces(B_ALL_WORKSPACES); fView = new WaitWindowView(); fView->SetDrawingMode(B_OP_COPY); State = new BString(); Lock(); AddChild(fView); fView->fAnimationBox->Start(); //start the animation Unlock(); Run(); fStateThreadID = spawn_thread(_ReadState, "StateThread", B_LOW_PRIORITY, this); resume_thread(fStateThreadID); }
void SelectionWindow::MoveCloseToMouse() { uint32 buttons; BPoint mousePosition; ChildAt((int32)0)->GetMouse(&mousePosition, &buttons); ConvertToScreen(&mousePosition); // Position the window centered around the mouse... BPoint windowPosition = BPoint(mousePosition.x - Frame().Width() / 2, mousePosition.y - Frame().Height() / 2); // ... unless that's outside of the current screen size: BScreen screen; windowPosition.x = MAX(20, MIN(screen.Frame().right - 20 - Frame().Width(), windowPosition.x)); windowPosition.y = MAX(20, MIN(screen.Frame().bottom - 20 - Frame().Height(), windowPosition.y)); MoveTo(windowPosition); SetWorkspaces(1UL << current_workspace()); }
void ChatWindow::MessageReceived( BMessage * msg ) { switch ( msg->what ) { case IM::SETTINGS_UPDATED: { if (msg->FindString("people_handler", &fPeopleHandler) != B_OK) { fPeopleHandler = kDefaultPeopleHandler; }; RebuildDisplay(); } break; case IM::USER_STOPPED_TYPING: { BMessage im_msg(IM::MESSAGE); im_msg.AddInt32("im_what",IM::USER_STOPPED_TYPING); im_msg.AddRef("contact",&fEntry); fMan->SendMessage(&im_msg); stopSelfTypingTimer(); } break; case IM::USER_STARTED_TYPING: { BMessage im_msg(IM::MESSAGE); im_msg.AddInt32("im_what", IM::USER_STARTED_TYPING); im_msg.AddRef("contact", &fEntry); fMan->SendMessage(&im_msg); startSelfTypingTimer(); } break; case IM::DESKBAR_ICON_CLICKED: { // deskbar icon clicked, move to current workspace and activate SetWorkspaces( 1 << current_workspace() ); Activate(); } break; case IM::ERROR: case IM::MESSAGE: { entry_ref contact; if ( msg->FindRef("contact",&contact) != B_OK ) return; if ( contact != fEntry ) // message not for us, skip it. return; int32 im_what=IM::ERROR; if ( msg->FindInt32("im_what",&im_what) != B_OK ) im_what = IM::ERROR; // int32 old_sel_start, old_sel_end; char timestr[10]; time_t now = time(NULL); strftime(timestr, sizeof(timestr),"[%H:%M]: ", localtime(&now) ); switch ( im_what ) { case IM::STATUS_CHANGED: { // This means we're rebuilding menus we don't rally need to rebuild.. BuildProtocolMenu(); } break; case IM::MESSAGE_SENT: { fText->Append(timestr, C_TIMESTAMP, C_TIMESTAMP, F_TIMESTAMP); BString message; msg->FindString("message", &message); if (message.Compare("/me ", 4) == 0) { fText->Append(_T("* You "), C_ACTION, C_ACTION, F_ACTION); message.Remove(0, 4); fText->Append(message.String(), C_ACTION, C_ACTION, F_ACTION); } else { fText->Append(_T("You say: "), C_OWNNICK, C_OWNNICK, F_TEXT); //fText->Append(msg->FindString("message"), C_TEXT, C_TEXT, F_TEXT); emoticor->AddText(fText,msg->FindString("message"), C_TEXT, F_TEXT,C_TEXT,F_EMOTICON); //by xeD } fText->Append("\n", C_TEXT, C_TEXT, F_TEXT); fText->ScrollToSelection(); } break; case IM::ERROR: { BMessage error; msg->FindMessage("message", &error); int32 error_what = -1; error.FindInt32("im_what", &error_what ); if ( error_what != IM::USER_STARTED_TYPING && error_what != IM::USER_STOPPED_TYPING ) { // ignore messages du to typing fText->Append(timestr, C_TIMESTAMP, C_TIMESTAMP, F_TIMESTAMP); fText->Append("Error: ", C_TEXT, C_TEXT, F_TEXT); fText->Append(msg->FindString("error"), C_TEXT, C_TEXT, F_TEXT); fText->Append("\n", C_TEXT, C_TEXT, F_TEXT); if (!IsActive()) startNotify(); } } break; case IM::MESSAGE_RECEIVED: { if ( msg->FindString("message") == NULL ) { // no message to display, probably opened by user return; } fText->Append(timestr, C_TIMESTAMP, C_TIMESTAMP, F_TIMESTAMP); BString protocol = msg->FindString("protocol"); BString message = msg->FindString("message"); if (protocol.Length() > 0) { fName.ReplaceAll("$protocol$",protocol.String()); } else { fName.ReplaceAll("$protocol$"," "); }; if (message.Compare("/me ", 4) == 0) { fText->Append("* ", C_ACTION, C_ACTION, F_ACTION); fText->Append(fName.String(), C_ACTION, C_ACTION, F_ACTION); fText->Append(" ", C_ACTION, C_ACTION, F_ACTION); message.Remove(0, 4); fText->Append(message.String(), C_ACTION, C_ACTION, F_ACTION); } else { fText->Append(fName.String(), C_OTHERNICK, C_OTHERNICK, F_TEXT); fText->Append(": ", C_OTHERNICK, C_OTHERNICK, F_TEXT); emoticor->AddText(fText,msg->FindString("message"), C_TEXT, F_TEXT,C_TEXT,F_EMOTICON); //by xeD } fText->Append("\n", C_TEXT, C_TEXT, F_TEXT); fText->ScrollToSelection(); if (!IsActive()) startNotify(); stopTypingTimer(); } break; case IM::CONTACT_STARTED_TYPING: { startTypingTimer(); } break; case IM::CONTACT_STOPPED_TYPING: { stopTypingTimer(); } break; } fText->ScrollToSelection(); } break; case SEND_MESSAGE: { if (fInput->TextLength() == 0) return; BMessage im_msg(IM::MESSAGE); im_msg.AddInt32("im_what",IM::SEND_MESSAGE); im_msg.AddRef("contact",&fEntry); im_msg.AddString("message", fInput->Text() ); BMenu *menu = fProtocolMenu->Menu(); if (menu) { IconMenuItem *item = dynamic_cast<IconMenuItem*>(menu->FindMarked()); if ( item ) { BString connection = item->Extra(); if (connection.Length() > 0) { IM::Connection conn(connection.String()); im_msg.AddString("protocol", conn.Protocol()); im_msg.AddString("id", conn.ID()); } } }; if ( fMan->SendMessage(&im_msg) == B_OK ) { fInput->SetText(""); } else { LOG("im_emoclient", liHigh, "Error sending message to im_server"); fText->Append(_T("Error: im_server not running, can't send message\n"), C_TEXT, C_TEXT, F_TEXT); fText->ScrollToSelection(); }; } break; case SHOW_INFO: { BMessage open_msg(B_REFS_RECEIVED); open_msg.AddRef("refs", &fEntry); be_roster->Launch(fPeopleHandler.String(), &open_msg); } break; case VIEW_LOG: { BMessage open(B_REFS_RECEIVED); open.AddRef("refs", &fEntry); be_roster->Launch("application/x-vnd.BeClan.im_binlog_viewer", &open); } break; case VIEW_WEBPAGE: { entry_ref htmlRef; be_roster->FindApp("application/x-vnd.Be.URL.http", &htmlRef); BPath htmlPath(&htmlRef); BMessage argv(B_ARGV_RECEIVED); argv.AddString("argv", htmlPath.Path()); int32 length = -1; char *url = ReadAttribute(BNode(&fEntry), "META:url", &length); if ((url != NULL) && (length > 1)) { url = (char *)realloc(url, (length + 1) * sizeof(char)); url[length] = '\0'; argv.AddString("argv", url); argv.AddInt32("argc", 2); be_roster->Launch(&htmlRef, &argv); } else { LOG("im_emoclient", liMedium, "Contact had no homepage"); }; if (url) free(url); } break; case VIEW_EMOTICONS: { //find emoticon button BView* button = FindView("Emoticons"); BRect buttonBounds = button->Bounds(); //move emoticon window to just below the button BPoint emotLeftBottom = button->ConvertToScreen(buttonBounds.LeftBottom()); popup->SetTargetForItems(this); popup->Go(emotLeftBottom,true,true); } break; case ADD_EMOTICON: { int32 index=msg->FindInt32("index"); BString txt; emoticor->config->menu.FindString("face",index,&txt); txt << " "; fInput->Insert(txt.String()); } break; case EMAIL: { BMessage open_msg(B_REFS_RECEIVED); open_msg.AddRef("refs", &fEntry); // "application/x-vnd.Be-MAIL" be_roster->Launch("text/x-email", &open_msg ); } break; case BLOCK: { IM::Contact contact(fEntry); char status[256]; if ( contact.GetStatus( status, sizeof(status) ) != B_OK ) status[0] = 0; if ( strcmp(status, BLOCKED_TEXT) == 0 ) { // already blocked, unblocked contact.SetStatus(OFFLINE_TEXT); BMessage update_msg(IM::UPDATE_CONTACT_STATUS); update_msg.AddRef("contact", &fEntry); fMan->SendMessage( &update_msg ); } else { if ( contact.SetStatus(BLOCKED_TEXT) != B_OK ) { LOG("im_emoclient", liHigh, "Block: Error setting contact status"); } } } break; case AUTH: { BMessage auth_msg(IM::MESSAGE); auth_msg.AddInt32("im_what", IM::REQUEST_AUTH); auth_msg.AddRef("contact", &fEntry); fMan->SendMessage( &auth_msg ); } break; case B_NODE_MONITOR: { int32 opcode=0; if ( msg->FindInt32("opcode",&opcode) != B_OK ) return; switch ( opcode ) { case B_ENTRY_REMOVED: { // oops. should we close down this window now? // Nah, we'll just disable everything. fInput->MakeEditable(false); fInput->SetViewColor( 198,198,198 ); fInput->Invalidate(); BString title( Title() ); title += " - DELETED!"; SetTitle( title.String() ); } break; case B_ENTRY_MOVED: { entry_ref ref; msg->FindInt32("device", &ref.device); msg->FindInt64("to directory", &ref.directory); ref.set_name( msg->FindString("name") ); fEntry = ref; BEntry entry(&fEntry); if ( !entry.Exists() ) { LOG("im_emoclient", liHigh, "Entry moved: New entry invalid"); } } break; case B_STAT_CHANGED: case B_ATTR_CHANGED: reloadContact(); BuildProtocolMenu(); break; } } break; case kResizeMessage: { BView *view = NULL; msg->FindPointer("view", reinterpret_cast<void**>(&view)); if (dynamic_cast<BScrollView *>(view)) { BPoint point; msg->FindPoint("loc", &point); fResize->MoveTo(fResize->Frame().left, point.y); fTextScroll->ResizeTo(fTextScroll->Frame().Width(), point.y - 1 - fDock->Frame().Height() - 1); fInputScroll->MoveTo(fInputScroll->Frame().left, point.y + 3); fInputScroll->ResizeTo( fInputScroll->Bounds().Width(), fStatusBar->Frame().top - fInputScroll->Frame().top ); fInput->SetTextRect(fInput->Bounds()); fInput->ScrollToSelection(); if ( fSendButton ) { fSendButton->MoveTo(fSendButton->Frame().left, point.y + 3); fSendButton->ResizeTo( fSendButton->Bounds().Width(), fStatusBar->Frame().top - fSendButton->Frame().top ); } }; } break; case B_MOUSE_WHEEL_CHANGED: { fText->MessageReceived(msg); } break; case B_COPY: { int32 start = 0; int32 end = 0; fInput->GetSelection(&start, &end); //printf("%ld - > %ld\n", start, end); } break; case B_SIMPLE_DATA: { entry_ref ref; BNode node; // attr_info info; for (int i = 0; msg->FindRef("refs", i, &ref) == B_OK; i++) { node = BNode(&ref); char *type = ReadAttribute(node, "BEOS:TYPE"); if (strcmp(type, "application/x-person") == 0) { char *name = ReadAttribute(node, "META:name"); char *nickname = ReadAttribute(node, "META:nickname"); char connection[100]; IM::Contact con(ref); con.ConnectionAt(0, connection); if (fInput->TextLength() > 0) fInput->Insert("\n"); fInput->Insert(name); fInput->Insert(" ("); fInput->Insert(nickname); fInput->Insert("): "); fInput->Insert(connection); free(name); free(nickname); }; free(type); }; fInput->ScrollToOffset(fInput->TextLength()); } break; case CLEAR_TYPING: stopTypingTimer(); break; case PROTOCOL_SELECTED: { // a protocol has been selected. Since BMenuField doesn't resize until later, // we have to wait 1000us before actually responding to the change, see below if ( fProtocolHack ) delete fProtocolHack; BMessage protoHack(PROTOCOL_SELECTED2); fProtocolHack = new BMessageRunner( BMessenger(this), &protoHack, 1000, 1 ); } break; case PROTOCOL_SELECTED2: // do what should be done on protocol change fStatusBar->PositionViews(); fInfoView->ResizeTo( fStatusBar->Bounds().Width() - fInfoView->Frame().left, fInfoView->Bounds().Height() ); break; default: BWindow::MessageReceived(msg); } }
EULAWindow::EULAWindow() : BWindow(BRect(0, 0, 600, 450), B_TRANSLATE("README"), B_MODAL_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_AUTO_UPDATE_SIZE_LIMITS) { BString infoText; infoText << B_TRANSLATE( "Welcome to the Haiku Installer!\n\n"); infoText << B_TRANSLATE( "IMPORTANT INFORMATION BEFORE INSTALLING HAIKU\n\n"); infoText << B_TRANSLATE( "This is beta-quality software! It means there is a risk of " "losing important data. Make frequent backups! You have been " "warned.\n\n\n"); infoText << B_TRANSLATE( "1) If you are installing Haiku onto real hardware (not inside an " "emulator), you may want to prepare a hard disk partition from " "another OS (you could, for example, use a GParted Live-CD, which " "can also resize existing partitions to make room).\n" "You can also set up partitions by launching DriveSetup from " "Installer, but you won't be able to resize existing partitions with " "it. While DriveSetup has been quite thoroughly tested over the " "years, it's recommended to have up-to-date backups of the other " "partitions on your system. Just in case" B_UTF8_ELLIPSIS); infoText << "\n\n\n"; infoText << B_TRANSLATE( "2) The Installer will make the Haiku partition itself bootable, " "but takes no steps to integrate Haiku into an existing boot menu. " "If you have GRUB already installed, you can add Haiku to it.\n" "For details, please consult the guide on booting Haiku on our " "website at https://www.haiku-os.org/guides/booting.\n" "Or you can set up a boot menu from Installer's \"Tools\" menu, see " "the Userguide's topic on the application \"BootManager\".\n\n\n"); infoText << B_TRANSLATE( "3) When you successfully boot into Haiku for the first time, make " "sure to read our \"Welcome\" and \"Userguide\" documentation. There " "are links on the Desktop and in WebPositive's bookmarks.\n\n"); infoText << B_TRANSLATE( "Have fun and thanks for trying out Haiku!"); BTextView* textView = new BTextView("eula", be_plain_font, NULL, B_WILL_DRAW); textView->SetInsets(10, 10, 10, 10); textView->MakeEditable(false); textView->MakeSelectable(false); textView->SetText(infoText); BScrollView* scrollView = new BScrollView("eulaScroll", textView, B_WILL_DRAW, false, true); BButton* cancelButton = new BButton(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED)); cancelButton->SetTarget(be_app); BButton* continueButton = new BButton(B_TRANSLATE("Continue"), new BMessage(kMsgAgree)); continueButton->SetTarget(be_app); continueButton->MakeDefault(true); if (!be_roster->IsRunning(kTrackerSignature)) SetWorkspaces(B_ALL_WORKSPACES); BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING) .SetInsets(B_USE_WINDOW_SPACING) .Add(scrollView) .AddGroup(B_HORIZONTAL, B_USE_ITEM_SPACING) .AddGlue() .Add(cancelButton) .Add(continueButton); CenterOnScreen(); Show(); }
void EBePrivateWin::DispatchMessage(BMessage *bMsg, BHandler *handler) { bool handled = true; if(bMsg->what == 'etk_') { int32 what = 0; bMsg->FindInt32("etk:what", &what); switch(what) { case ETK_BEOS_QUIT: doQuit = true; PostMessage(B_QUIT_REQUESTED); break; case ETK_BEOS_CONTACT_TO: { fContactor = EMessenger(); const char *buffer = NULL; ssize_t size = -1; if(bMsg->FindData("etk:messenger", B_ANY_TYPE, (const void**)&buffer, &size) != B_OK) break; if(buffer == NULL || size <= 0) break; fContactor.Unflatten(buffer, (size_t)size); } break; case ETK_BEOS_SET_BACKGROUND: { rgb_color bkColor; if(bMsg->FindInt32("background", (int32*)&bkColor) != B_OK) break; fTopView->SetViewColor(bkColor); fTopView->Invalidate(); } break; case ETK_BEOS_SET_LOOK: { int8 look; if(bMsg->FindInt8("look", &look) != B_OK) break; switch((e_window_look)look) { case E_BORDERED_WINDOW_LOOK: SetLook(B_BORDERED_WINDOW_LOOK); break; case E_NO_BORDER_WINDOW_LOOK: SetLook(B_NO_BORDER_WINDOW_LOOK); break; case E_TITLED_WINDOW_LOOK: SetLook(B_TITLED_WINDOW_LOOK); break; case E_DOCUMENT_WINDOW_LOOK: SetLook(B_DOCUMENT_WINDOW_LOOK); break; case E_MODAL_WINDOW_LOOK: SetLook(B_MODAL_WINDOW_LOOK); break; case E_FLOATING_WINDOW_LOOK: SetLook(B_FLOATING_WINDOW_LOOK); break; default: break; } } break; case ETK_BEOS_SET_TITLE: { const char *title = NULL; if(bMsg->FindString("title", &title) != B_OK) break; SetTitle(title); } break; case ETK_BEOS_SET_WORKSPACES: { uint32 workspaces = 0; if(bMsg->FindInt32("workspaces", (int32*)&workspaces) != B_OK) break; if(workspaces == 0) workspaces = current_workspace() + 1; SetWorkspaces(workspaces); } break; case ETK_BEOS_GET_WORKSPACES: { uint32 workspaces = Workspaces(); bMsg->AddInt32("workspaces", *((int32*)&workspaces)); } break; case ETK_BEOS_ICONIFY: if(!IsMinimized()) Minimize(true); break; case ETK_BEOS_SHOW: if(IsHidden()) { uint32 oldFlags = Flags(); SetFlags(oldFlags | B_AVOID_FOCUS); Show(); if(Look() != B_NO_BORDER_WINDOW_LOOK) SetFlags(oldFlags); } break; case ETK_BEOS_HIDE: if(!IsHidden()) Hide(); break; case ETK_BEOS_RAISE: if(!IsFront()) { uint32 oldFlags = Flags(); SetFlags(oldFlags | B_AVOID_FOCUS); Activate(true); if(Look() != B_NO_BORDER_WINDOW_LOOK) SetFlags(oldFlags); } break; case ETK_BEOS_LOWER: { BHandler *_frontWin = NULL; if(bMsg->FindPointer("front", (void**)&_frontWin) != B_OK) break; BWindow *frontWin = e_cast_as(_frontWin, BWindow); if(frontWin == NULL) break; SendBehind(frontWin); bMsg->AddBool("done", true); } break; case ETK_BEOS_ACTIVATE: { bool state; if(bMsg->FindBool("state", &state) != B_OK || state == IsActive()) break; Activate(state); } break; case ETK_BEOS_GET_ACTIVATED_STATE: bMsg->AddBool("state", IsActive()); break; case ETK_BEOS_MOVE_RESIZE: { if(bMsg->HasPoint("where")) { BPoint pt; if(bMsg->FindPoint("where", &pt) == B_OK) MoveTo(pt); } if(bMsg->HasFloat("width") && bMsg->HasFloat("height")) { float w = -1, h = -1; bMsg->FindFloat("width", &w); bMsg->FindFloat("height", &h); if(w < 0 || h < 0) break; ResizeTo(w, h); } } break; case ETK_BEOS_DRAW_BITMAP: { BBitmap *bitmap = NULL; BRect srcRect, destRect; const ERegion *clipping = NULL; if(bMsg->FindPointer("bitmap", (void**)&bitmap) != B_OK || bitmap == NULL) break; bMsg->FindRect("src", &srcRect); bMsg->FindRect("dest", &destRect); if(srcRect.IsValid() == false || destRect.IsValid() == false) break; bMsg->FindPointer("clipping", (void**)&clipping); BRegion beRegion; __etk_convert_region(clipping, &beRegion, fTopView->Bounds()); fTopView->ConstrainClippingRegion(&beRegion); fTopView->DrawBitmap(bitmap, srcRect, destRect); } break; case ETK_BEOS_GRAB_MOUSE: case ETK_BEOS_UNGRAB_MOUSE: { uint32 options = (what == ETK_BEOS_GRAB_MOUSE ? B_LOCK_WINDOW_FOCUS : 0); if(fTopView->SetEventMask(B_POINTER_EVENTS, options) != B_OK) break; bMsg->AddBool("state", what == ETK_BEOS_GRAB_MOUSE); } break; case ETK_BEOS_GRAB_KEYBOARD: case ETK_BEOS_UNGRAB_KEYBOARD: { uint32 options = (what == ETK_BEOS_GRAB_KEYBOARD ? B_LOCK_WINDOW_FOCUS : 0); if(fTopView->SetEventMask(B_KEYBOARD_EVENTS, options) != B_OK) break; bMsg->AddBool("state", what == ETK_BEOS_GRAB_KEYBOARD); } break; case ETK_BEOS_QUERY_MOUSE: { BPoint pt; uint32 btns = 0; fTopView->GetMouse(&pt, &btns, false); bMsg->AddInt32("x", (int32)pt.x); bMsg->AddInt32("y", (int32)pt.y); bMsg->AddInt32("buttons", (int32)btns); } break; case ETK_BEOS_SET_SIZE_LIMITS: { BRect r; if(bMsg->FindRect("limits", &r) != B_OK) break; SetSizeLimits(r.left, r.right, r.top, r.bottom); bMsg->AddBool("done", true); } break; case ETK_BEOS_GET_SIZE_LIMITS: { BRect r(-1, -1, -1, -1); GetSizeLimits(&(r.left), &(r.right), &(r.top), &(r.bottom)); bMsg->AddRect("limits", r); } break; default: handled = false; break; } if(handled) { BMessage aMsg(*bMsg); bMsg->SendReply(&aMsg); return; } } switch(bMsg->what) { case B_WINDOW_ACTIVATED: { handled = false; if(fContactor.IsValid() == false) break; EMessage message(E_WINDOW_ACTIVATED); message.AddBool("etk:msg_from_gui", true); message.AddInt64("when", e_real_time_clock_usecs()); fContactor.SendMessage(&message); } break; case B_MOUSE_DOWN: case B_MOUSE_UP: case B_MOUSE_MOVED: { if(fContactor.IsValid() == false) break; BPoint where; int32 buttons = 0; bMsg->FindPoint("where", &where); if(bMsg->what != B_MOUSE_UP) bMsg->FindInt32("buttons", &buttons); int32 clicks = 1; if(bMsg->what == B_MOUSE_DOWN) { #if 0 bMsg->FindInt32("clicks", &clicks); #else bigtime_t eventTime; if(bMsg->FindInt64("when", &eventTime) == B_OK) { if(eventTime - fPrevMouseDownTime <= CLICK_TIMEOUT) clicks = (fPrevMouseDownCount += 1); else clicks = fPrevMouseDownCount = 1; fPrevMouseDownTime = eventTime; } #endif } EMessage message; if(bMsg->what == B_MOUSE_DOWN) message.what = E_MOUSE_DOWN; else if(bMsg->what == B_MOUSE_UP) message.what = E_MOUSE_UP; else message.what = E_MOUSE_MOVED; message.AddBool("etk:msg_from_gui", true); message.AddInt64("when", e_real_time_clock_usecs()); if(bMsg->what != B_MOUSE_UP) message.AddInt32("buttons", buttons); if(bMsg->what == B_MOUSE_DOWN) message.AddInt32("clicks", clicks); message.AddPoint("where", EPoint(where.x, where.y)); ConvertToScreen(&where); message.AddPoint("screen_where", EPoint(where.x, where.y)); // TODO: modifiers message.AddMessenger("etk:msg_for_target", fContactor); etk_app->PostMessage(&message); } break; case B_KEY_DOWN: case B_KEY_UP: case B_UNMAPPED_KEY_DOWN: case B_UNMAPPED_KEY_UP: { if(fContactor.IsValid() == false) break; int8 byte[4]; const char *bytes = NULL; int32 numBytes = 0; int32 key = 0; int32 key_repeat = 0; int32 beModifiers = 0; eint32 modifiers = 0; bMsg->FindInt32("key", &key); bMsg->FindInt32("modifiers", &beModifiers); bzero(byte, sizeof(int8) * 4); if(bMsg->what == B_KEY_DOWN || bMsg->what == B_KEY_UP) { for(int32 i = 0; i < 3; i++) bMsg->FindInt8("byte", i, &byte[i]); if(bMsg->FindString("bytes", &bytes) == B_OK) numBytes = strlen(bytes); // if(bMsg->what == B_KEY_DOWN) bMsg->FindInt32("be:key_repeat", &key_repeat); } else { etk_beos_get_byte(beModifiers, key, (char*)byte); } if(beModifiers & B_SHIFT_KEY) modifiers |= E_SHIFT_KEY; if(beModifiers & B_CONTROL_KEY) modifiers |= E_CONTROL_KEY; if(beModifiers & B_COMMAND_KEY) modifiers |= E_COMMAND_KEY; EMessage message; if(bMsg->what == B_KEY_DOWN) message.what = E_KEY_DOWN; else if(bMsg->what == B_KEY_UP) message.what = E_KEY_UP; else if(bMsg->what == B_UNMAPPED_KEY_DOWN) message.what = E_UNMAPPED_KEY_DOWN; else message.what = E_UNMAPPED_KEY_UP; message.AddBool("etk:msg_from_gui", true); message.AddInt64("when", e_real_time_clock_usecs()); message.AddInt32("key", key); message.AddInt32("modifiers", modifiers); if(bMsg->what == B_KEY_DOWN || bMsg->what == B_KEY_UP) { if(bMsg->what == B_KEY_DOWN) message.AddInt32("etk:key_repeat", key_repeat); for(int32 i = 0; i < 3; i++) message.AddInt8("byte", byte[i]); if(!(numBytes != 1 || *bytes != byte[0])) { etk_beos_get_byte(beModifiers, key, (char*)byte); message.AddString("bytes", (char*)byte); } else if(numBytes > 0) { message.AddString("bytes", bytes); } } else if(byte[0] != 0) { message.AddInt8("byte", byte[0]); message.AddString("bytes", (char*)byte); } message.AddMessenger("etk:msg_for_target", fContactor); etk_app->PostMessage(&message); } break; case B_MODIFIERS_CHANGED: { if(fContactor.IsValid() == false) break; eint32 modifiers = 0; eint32 old_modifiers = 0; int32 beModifiers = 0; int32 old_beModifiers = 0; bMsg->FindInt32("modifiers", &beModifiers); bMsg->FindInt32("be:old_modifiers", &old_beModifiers); if(beModifiers & B_SHIFT_KEY) modifiers |= E_SHIFT_KEY; if(beModifiers & B_CONTROL_KEY) modifiers |= E_CONTROL_KEY; if(beModifiers & B_COMMAND_KEY) modifiers |= E_COMMAND_KEY; if(old_beModifiers & B_SHIFT_KEY) old_modifiers |= E_SHIFT_KEY; if(old_beModifiers & B_CONTROL_KEY) old_modifiers |= E_CONTROL_KEY; if(old_beModifiers & B_COMMAND_KEY) old_modifiers |= E_COMMAND_KEY; EMessage message(E_MODIFIERS_CHANGED); message.AddBool("etk:msg_from_gui", true); message.AddInt64("when", e_real_time_clock_usecs()); message.AddInt32("modifiers", modifiers); message.AddInt32("etk:old_modifiers", old_modifiers); message.AddMessenger("etk:msg_for_target", fContactor); etk_app->PostMessage(&message); } break; default: handled = false; break; } if(!handled) BWindow::DispatchMessage(bMsg, handler); }
bool MainWindow::LoadSettings(const BMessage* message) { // restore window positioning BPoint point; bool useAdjust = false; if (message->FindPoint("window position", &point) == B_OK) { fScreenPosition = point; useAdjust = true; } float borderDist; if (message->FindFloat("border distance", &borderDist) == B_OK) { fBorderDist = borderDist; } // restore window frame BRect frame; if (message->FindRect("window frame", &frame) == B_OK) { if (useAdjust) { _AdjustLocation(frame); } else { make_sure_frame_is_on_screen(frame, this); MoveTo(frame.LeftTop()); ResizeTo(frame.Width(), frame.Height()); } } // restore window look window_look look; if (message->FindInt32("window look", (int32*)&look) == B_OK) SetLook(look); // restore orientation int32 orientation; if (message->FindInt32("orientation", &orientation) == B_OK) fPadView->SetOrientation((enum orientation)orientation); // restore icon size int32 iconSize; if (message->FindInt32("icon size", &iconSize) == B_OK) fPadView->SetIconSize(iconSize); // restore ignore double click bool ignoreDoubleClick; if (message->FindBool("ignore double click", &ignoreDoubleClick) == B_OK) fPadView->SetIgnoreDoubleClick(ignoreDoubleClick); // restore buttons const char* path; bool buttonAdded = false; for (int32 i = 0; message->FindString("path", i, &path) >= B_OK; i++) { LaunchButton* button = new LaunchButton("launch button", NULL, new BMessage(MSG_LAUNCH)); fPadView->AddButton(button); BString signature; if (message->FindString("signature", i, &signature) >= B_OK && signature.CountChars() > 0) { button->SetTo(signature.String(), true); } BEntry entry(path, true); entry_ref ref; if (entry.Exists() && entry.GetRef(&ref) == B_OK) button->SetTo(&ref); const char* text; if (message->FindString("description", i, &text) >= B_OK) button->SetDescription(text); buttonAdded = true; } // restore auto raise setting bool autoRaise; if (message->FindBool("auto raise", &autoRaise) == B_OK && autoRaise) ToggleAutoRaise(); // store workspace setting bool showOnAllWorkspaces; if (message->FindBool("all workspaces", &showOnAllWorkspaces) == B_OK) fShowOnAllWorkspaces = showOnAllWorkspaces; SetWorkspaces(showOnAllWorkspaces ? B_ALL_WORKSPACES : 1L << current_workspace()); if (!fShowOnAllWorkspaces) { uint32 workspaces; if (message->FindInt32("workspaces", (int32*)&workspaces) == B_OK) SetWorkspaces(workspaces); } return buttonAdded; }
void MainWindow::MessageReceived(BMessage* message) { switch (message->what) { case MSG_LAUNCH: { BView* pointer; if (message->FindPointer("be:source", (void**)&pointer) < B_OK) break; LaunchButton* button = dynamic_cast<LaunchButton*>(pointer); if (button == NULL) break; BString errorMessage; bool launchedByRef = false; if (button->Ref()) { BEntry entry(button->Ref(), true); if (entry.IsDirectory()) { // open in Tracker BMessenger messenger("application/x-vnd.Be-TRAK"); if (messenger.IsValid()) { BMessage trackerMessage(B_REFS_RECEIVED); trackerMessage.AddRef("refs", button->Ref()); status_t ret = messenger.SendMessage(&trackerMessage); if (ret < B_OK) { errorMessage = B_TRANSLATE("Failed to send " "'open folder' command to Tracker.\n\nError: "); errorMessage << strerror(ret); } else launchedByRef = true; } else errorMessage = ("Failed to open folder - is Tracker " "running?"); } else { status_t ret = be_roster->Launch(button->Ref()); if (ret < B_OK && ret != B_ALREADY_RUNNING) { BString errStr(B_TRANSLATE("Failed to launch '%1'.\n" "\nError:")); BPath path(button->Ref()); if (path.InitCheck() >= B_OK) errStr.ReplaceFirst("%1", path.Path()); else errStr.ReplaceFirst("%1", button->Ref()->name); errorMessage << errStr.String() << " "; errorMessage << strerror(ret); } else launchedByRef = true; } } if (!launchedByRef && button->AppSignature()) { status_t ret = be_roster->Launch(button->AppSignature()); if (ret != B_OK && ret != B_ALREADY_RUNNING) { BString errStr(B_TRANSLATE("\n\nFailed to launch application " "with signature '%2'.\n\nError:")); errStr.ReplaceFirst("%2", button->AppSignature()); errorMessage << errStr.String() << " "; errorMessage << strerror(ret); } else { // clear error message on success (might have been // filled when trying to launch by ref) errorMessage = ""; } } else if (!launchedByRef) { errorMessage = B_TRANSLATE("Failed to launch 'something', " "error in Pad data."); } if (errorMessage.Length() > 0) { BAlert* alert = new BAlert("error", errorMessage.String(), B_TRANSLATE("Bummer"), NULL, NULL, B_WIDTH_FROM_WIDEST); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); } break; } case MSG_ADD_SLOT: { LaunchButton* button; if (message->FindPointer("be:source", (void**)&button) >= B_OK) { fPadView->AddButton(new LaunchButton("launch button", NULL, new BMessage(MSG_LAUNCH)), button); } break; } case MSG_CLEAR_SLOT: { LaunchButton* button; if (message->FindPointer("be:source", (void**)&button) >= B_OK) button->SetTo((entry_ref*)NULL); break; } case MSG_REMOVE_SLOT: { LaunchButton* button; if (message->FindPointer("be:source", (void**)&button) >= B_OK) { if (fPadView->RemoveButton(button)) delete button; } break; } case MSG_SET_DESCRIPTION: { LaunchButton* button; if (message->FindPointer("be:source", (void**)&button) >= B_OK) { const char* name; if (message->FindString("name", &name) >= B_OK) { // message comes from a previous name panel button->SetDescription(name); BRect namePanelFrame; if (message->FindRect("frame", &namePanelFrame) == B_OK) { ((App*)be_app)->SetNamePanelSize( namePanelFrame.Size()); } } else { // message comes from pad view entry_ref* ref = button->Ref(); if (ref) { BString helper(B_TRANSLATE("Description for '%3'")); helper.ReplaceFirst("%3", ref->name); // Place the name panel besides the pad, but give it // the user configured size. BPoint origin = B_ORIGIN; BSize size = ((App*)be_app)->NamePanelSize(); NamePanel* panel = new NamePanel(helper.String(), button->Description(), this, this, new BMessage(*message), size); panel->Layout(true); size = panel->Frame().Size(); BScreen screen(this); BPoint mousePos; uint32 buttons; fPadView->GetMouse(&mousePos, &buttons, false); fPadView->ConvertToScreen(&mousePos); if (fPadView->Orientation() == B_HORIZONTAL) { // Place above or below the pad origin.x = mousePos.x - size.width / 2; if (screen.Frame().bottom - Frame().bottom > size.height + 20) { origin.y = Frame().bottom + 10; } else { origin.y = Frame().top - 10 - size.height; } } else { // Place left or right of the pad origin.y = mousePos.y - size.height / 2; if (screen.Frame().right - Frame().right > size.width + 20) { origin.x = Frame().right + 10; } else { origin.x = Frame().left - 10 - size.width; } } panel->MoveTo(origin); panel->Show(); } } } break; } case MSG_ADD_WINDOW: { BMessage settings('sett'); SaveSettings(&settings); message->AddMessage("window", &settings); be_app->PostMessage(message); break; } case MSG_SHOW_BORDER: SetLook(B_TITLED_WINDOW_LOOK); break; case MSG_HIDE_BORDER: SetLook(B_BORDERED_WINDOW_LOOK); break; case MSG_TOGGLE_AUTORAISE: ToggleAutoRaise(); break; case MSG_SHOW_ON_ALL_WORKSPACES: fShowOnAllWorkspaces = !fShowOnAllWorkspaces; if (fShowOnAllWorkspaces) SetWorkspaces(B_ALL_WORKSPACES); else SetWorkspaces(1L << current_workspace()); break; case B_SIMPLE_DATA: case B_REFS_RECEIVED: case B_PASTE: case B_MODIFIERS_CHANGED: break; default: BWindow::MessageReceived(message); break; } }
void MainWindow::MessageReceived(BMessage* message) { switch (message->what) { case kSearchContact: { void* control = NULL; if (message->FindPointer("source", &control) != B_OK) return; SearchBarTextControl* searchBox = static_cast<SearchBarTextControl*>(control); if (searchBox == NULL) return; RosterMap map = fServer->RosterItems(); for (uint32 i = 0; i < map.CountItems(); i++) { ContactLinker* linker = map.ValueAt(i); RosterItem* item = linker->GetRosterItem(); // If the search filter has been deleted show all the items, // otherwise remove the item in order to show only items // that matches the search criteria if (strcmp(searchBox->Text(), "") == 0) AddItem(item); else if (linker->GetName().IFindFirst(searchBox->Text()) == B_ERROR) RemoveItem(item); else AddItem(item); UpdateListItem(item); } break; } case CAYA_SHOW_SETTINGS: { PreferencesDialog* dialog = new PreferencesDialog(); dialog->Show(); break; } case CAYA_OPEN_CHAT_WINDOW: { int index = message->FindInt32("index"); RosterItem* ritem = ItemAt(index); if (ritem != NULL) ritem->GetContactLinker()->ShowWindow(false, true); break; } case CAYA_REPLICANT_STATUS_SET: { int32 status; message->FindInt32("status", &status); AccountManager* accountManager = AccountManager::Get(); accountManager->SetStatus((CayaStatus)status); break; } case CAYA_REPLICANT_SHOW_WINDOW: { if (LockLooper()) { SetWorkspaces(B_CURRENT_WORKSPACE); if ((IsMinimized() || IsHidden()) || fWorkspaceChanged) { Minimize(false); Show(); fWorkspaceChanged = false; } else if ((!IsMinimized() || !IsHidden()) || (!fWorkspaceChanged)) { Minimize(true); } UnlockLooper(); } break; } case IM_MESSAGE: ImMessage(message); break; case IM_ERROR: ImError(message); break; case B_ABOUT_REQUESTED: be_app->PostMessage(message); break; default: BWindow::MessageReceived(message); } }
MainWindow::MainWindow(void) : BWindow(BRect(200,200,800,750), B_TRANSLATE_SYSTEM_NAME("Slayer"), B_TITLED_WINDOW, 0) { slayer->mainWindow = this; refreshThread = NULL; if (Lock()) { teamView = new TeamListView("MainTeamList"); // MenĂ¼ BMenuBar* menuBar = new BMenuBar("MenuBar"); BMenu* menu; menu = new BMenu(B_TRANSLATE_SYSTEM_NAME("Slayer")); menuBar->AddItem(menu); menu->AddItem(new BMenuItem(B_TRANSLATE("About Slayer..."), new BMessage(B_ABOUT_REQUESTED))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Settings..."), new BMessage(IE_MAINWINDOW_MAINMENU_WINDOWS_SETTINGS))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED), 'Q')); menu = new BMenu(B_TRANSLATE("Action")); menu->AddItem(new BMenuItem(B_TRANSLATE("Kill"), new BMessage(IE_MAINWINDOW_MAINKILL), 'K')); menu->AddItem(new BMenuItem(B_TRANSLATE("Suspend"), new BMessage(IE_MAINWINDOW_MAINSUSPEND), 'S')); menu->AddItem(new BMenuItem(B_TRANSLATE("Resume"), new BMessage(IE_MAINWINDOW_MAINRESUME), 'R')); menu->AddSeparatorItem(); priorityMenu = new PriorityMenu(teamView); menu->AddItem(priorityMenu); priorityMenu->BuildMenu(); menuBar->AddItem(menu); fToolBar = new BToolBar(B_HORIZONTAL); BGroupLayout *topBox = BLayoutBuilder::Group<>(this,B_VERTICAL, 0) .Add(menuBar) .Add(fToolBar) .AddGroup(B_VERTICAL) .SetInsets(B_USE_WINDOW_INSETS, 0, B_USE_WINDOW_INSETS, B_USE_WINDOW_INSETS) .Add(teamView); teamView->LoadState(&(slayer->options.columnsState)); team_items_list = 0; team_amount = 0; iteration = 0; refreshThread = new RefreshThread(); UpdateTeams(); if (slayer->options.wind_rect.IsValid()) { MoveTo(slayer->options.wind_rect.left, slayer->options.wind_rect.top); ResizeTo(slayer->options.wind_rect.Width(), slayer->options.wind_rect.Height()); } minimized = false; if (slayer->options.workspace_activation == Options::all_workspaces) SetWorkspaces(B_ALL_WORKSPACES); else if (slayer->options.workspace_activation == Options::saved_workspace) SetWorkspaces(0x1UL << (slayer->options.workspaces -1 )); if (slayer->options.wind_minimized) Minimize(true); // Quitting has to be disabled if docked if (slayer->docked) { BMenu *menu = (BMenu *)FindView("MainMenu"); BMenuItem *item = menu->FindItem(IE_MAINWINDOW_MAINMENU_FILE_QUIT); item->SetEnabled(false); } fToolBar->AddAction(new BMessage(IE_MAINWINDOW_MAINKILL),this, ResourceVectorToBitmap("KILL"),B_TRANSLATE("Kill"),"",false); fToolBar->AddAction(new BMessage(IE_MAINWINDOW_MAINSUSPEND),this, ResourceVectorToBitmap("SUSPEND"),B_TRANSLATE("Suspend"),"",false); fToolBar->AddAction(new BMessage(IE_MAINWINDOW_MAINRESUME),this, ResourceVectorToBitmap("RESUME"),B_TRANSLATE("Resume"),"",false); fToolBar->AddAction(new BMessage(IE_MAINWINDOW_MAINUPDATE),this, ResourceVectorToBitmap("FORCED_RELOAD"),B_TRANSLATE("Forced reload"),"",false); fToolBar->GetLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); if (teamView != NULL) teamView->MakeFocus(); SetButtonState(); refreshThread->Go(); Unlock(); } Show(); }
void MainWindow::MessageReceived(BMessage* message) { switch (message->what) { case MSG_LAUNCH: { BView* pointer; if (message->FindPointer("be:source", (void**)&pointer) < B_OK) break; LaunchButton* button = dynamic_cast<LaunchButton*>(pointer); if (button == NULL) break; BString errorMessage; bool launchedByRef = false; if (button->Ref()) { BEntry entry(button->Ref(), true); if (entry.IsDirectory()) { // open in Tracker BMessenger messenger("application/x-vnd.Be-TRAK"); if (messenger.IsValid()) { BMessage trackerMessage(B_REFS_RECEIVED); trackerMessage.AddRef("refs", button->Ref()); status_t ret = messenger.SendMessage(&trackerMessage); if (ret < B_OK) { errorMessage = "Failed to send 'open folder' " "command to Tracker.\n\nError: "; errorMessage << strerror(ret); } else launchedByRef = true; } else errorMessage = "Failed to open folder - is Tracker " "running?"; } else { status_t ret = be_roster->Launch(button->Ref()); if (ret < B_OK && ret != B_ALREADY_RUNNING) { errorMessage = "Failed to launch '"; BPath path(button->Ref()); if (path.InitCheck() >= B_OK) errorMessage << path.Path(); else errorMessage << button->Ref()->name; errorMessage << "'.\n\nError: "; errorMessage << strerror(ret); } else launchedByRef = true; } } if (!launchedByRef && button->AppSignature()) { status_t ret = be_roster->Launch(button->AppSignature()); if (ret != B_OK && ret != B_ALREADY_RUNNING) { errorMessage = "Failed to launch application with " "signature '"; errorMessage << button->AppSignature() << "'.\n\nError: "; errorMessage << strerror(ret); } else { // clear error message on success (might have been // filled when trying to launch by ref) errorMessage = ""; } } else if (!launchedByRef) { errorMessage = "Failed to launch 'something', error in " "Pad data."; } if (errorMessage.Length() > 0) { BAlert* alert = new BAlert("error", errorMessage.String(), "Bummer", NULL, NULL, B_WIDTH_FROM_WIDEST); alert->Go(NULL); } break; } case MSG_ADD_SLOT: { LaunchButton* button; if (message->FindPointer("be:source", (void**)&button) >= B_OK) { fPadView->AddButton(new LaunchButton("launch button", fLastID++, NULL, new BMessage(MSG_LAUNCH)), button); } break; } case MSG_CLEAR_SLOT: { LaunchButton* button; if (message->FindPointer("be:source", (void**)&button) >= B_OK) button->SetTo((entry_ref*)NULL); break; } case MSG_REMOVE_SLOT: { LaunchButton* button; if (message->FindPointer("be:source", (void**)&button) >= B_OK) { if (fPadView->RemoveButton(button)) delete button; } break; } case MSG_SET_DESCRIPTION: { LaunchButton* button; if (message->FindPointer("be:source", (void**)&button) >= B_OK) { const char* name; if (message->FindString("name", &name) >= B_OK) { // message comes from a previous name panel button->SetDescription(name); message->FindRect("frame", &fNamePanelFrame); } else { // message comes from pad view entry_ref* ref = button->Ref(); if (ref) { BString helper("Description for '"); helper << ref->name << "'"; make_sure_frame_is_on_screen(fNamePanelFrame, this); new NamePanel(helper.String(), button->Description(), this, this, new BMessage(*message), fNamePanelFrame); } } } break; } case MSG_ADD_WINDOW: { BMessage settings('sett'); SaveSettings(&settings); message->AddMessage("window", &settings); be_app->PostMessage(message); break; } case MSG_SHOW_BORDER: SetLook(B_TITLED_WINDOW_LOOK); break; case MSG_HIDE_BORDER: SetLook(B_BORDERED_WINDOW_LOOK); break; case MSG_TOGGLE_AUTORAISE: ToggleAutoRaise(); break; case MSG_SHOW_ON_ALL_WORKSPACES: fShowOnAllWorkspaces = !fShowOnAllWorkspaces; if (fShowOnAllWorkspaces) SetWorkspaces(B_ALL_WORKSPACES); else SetWorkspaces(1L << current_workspace()); break; case B_SIMPLE_DATA: case B_REFS_RECEIVED: case B_PASTE: case B_MODIFIERS_CHANGED: break; case B_ABOUT_REQUESTED: be_app->PostMessage(message); break; default: BWindow::MessageReceived(message); break; } }
EULAWindow::EULAWindow() : BWindow(BRect(0, 0, 600, 450), B_TRANSLATE("README"), B_MODAL_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_AUTO_UPDATE_SIZE_LIMITS) { BString infoText; infoText << B_TRANSLATE( "Welcome to the Haiku Installer!\n\n"); infoText << B_TRANSLATE( "IMPORTANT INFORMATION BEFORE INSTALLING HAIKU\n\n"); infoText << B_TRANSLATE( "This is alpha-quality software! It means there is a high risk of " "losing important data. Make frequent backups! You have been " "warned.\n\n\n"); infoText << B_TRANSLATE( "1) If you are installing Haiku onto real hardware (not inside an " "emulator) it is recommended that you have already prepared a hard " "disk partition. The Installer and the DriveSetup tool offer to " "initialize existing partitions with the Haiku native file system, " "but the options to change the actual partition layout may not have " "been tested on a sufficiently great variety of computer " "configurations so we do not recommend using it.\n"); infoText << B_TRANSLATE( "If you have not created a partition yet, simply reboot, create the " "partition using whatever tool you feel most comfortable with, and " "reboot into Haiku to continue with the installation. You could for " "example use the GParted Live-CD, it can also resize existing " "partitions to make room.\n\n\n"); infoText << B_TRANSLATE( "2) The Installer will make the Haiku partition itself bootable, " "but takes no steps to integrate Haiku into an existing boot menu. " "If you have GRUB already installed, you can add Haiku to its boot " "menu. Depending on what version of GRUB you use, this is done " "differently.\n\n\n"); infoText << B_TRANSLATE( "2.1) GRUB (since os-prober v1.44)\n"); infoText << B_TRANSLATE( "Starting with os-prober v1.44 (e.g. in Ubuntu 11.04 or later), Haiku " "should be recognized out of the box. To add Haiku to the GRUB menu, " "open a Terminal and enter:\n\n"); infoText << B_TRANSLATE( "\tsudo update-grub\n\n\n"); infoText << B_TRANSLATE( "2.2) GRUB 2\n"); infoText << B_TRANSLATE( "If the os-prober approach doesn't work for you, GRUB 2 uses an extra " "configuration file to add custom entries to the boot menu. To add " "them to the top, you have to create/edit a file by launching your " "favorite editor from a Terminal like this:\n\n"); infoText << B_TRANSLATE( "\tsudo <your favorite text editor> /etc/grub.d/40_custom\n\n"); infoText << B_TRANSLATE( "GRUB's naming scheme for partitions is: (hdN,n)\n\n"); infoText << B_TRANSLATE( "All hard disks start with \"hd\".\n"); infoText << B_TRANSLATE( "\"N\" is the hard disk number, starting with \"0\".\n"); infoText << B_TRANSLATE( "\"n\" is the partition number, which for GRUB 2 starts with \"1\"\n"); infoText << B_TRANSLATE( "With GRUB 2 the first logical partition always has the number \"5\", " "regardless of the number of primary partitions.\n\n"); infoText << B_TRANSLATE( "So below the heading that must not be edited, add something similar " "to these lines:\n\n"); infoText << B_TRANSLATE( "\t# Haiku on /dev/sda7\n"); infoText << B_TRANSLATE( "\tmenuentry \"Haiku Alpha\" {\n"); infoText << B_TRANSLATE( "\t\tset root=(hd0,7)\n"); infoText << B_TRANSLATE( "\t\tchainloader +1\n"); infoText << B_TRANSLATE( "\t}\n\n"); infoText << B_TRANSLATE( "Additionally you have to edit another file to actually display the " "boot menu:\n\n"); infoText << B_TRANSLATE( "\tsudo <your favorite text editor> /etc/default/grub\n\n"); infoText << B_TRANSLATE( "Here you have to comment out the line \"GRUB_HIDDEN_TIMEOUT=0\" by " "putting a \"#\" in front of it in order to actually display the " "boot menu.\n\n"); infoText << B_TRANSLATE( "Finally, you have to update the boot menu by entering:\n\n"); infoText << B_TRANSLATE( "\tsudo update-grub\n\n\n"); infoText << B_TRANSLATE( "3) When you successfully boot into Haiku for the first time, make " "sure to read our \"Welcome\" and \"Userguide\" documentation. There " "are links on the Desktop and in WebPositive's bookmarks.\n\n"); infoText << B_TRANSLATE( "Have fun and thanks a lot for trying out Haiku! We hope you like it!"); BTextView* textView = new BTextView("eula", be_plain_font, NULL, B_WILL_DRAW); textView->SetInsets(10, 10, 10, 10); textView->MakeEditable(false); textView->MakeSelectable(false); textView->SetText(infoText); BScrollView* scrollView = new BScrollView("eulaScroll", textView, B_WILL_DRAW, false, true); BButton* cancelButton = new BButton(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED)); cancelButton->SetTarget(be_app); BButton* continueButton = new BButton(B_TRANSLATE("Continue"), new BMessage(kMsgAgree)); continueButton->SetTarget(be_app); continueButton->MakeDefault(true); if (!be_roster->IsRunning(kTrackerSignature)) SetWorkspaces(B_ALL_WORKSPACES); BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING) .SetInsets(B_USE_WINDOW_SPACING) .Add(scrollView) .AddGroup(B_HORIZONTAL, B_USE_ITEM_SPACING) .AddGlue() .Add(cancelButton) .Add(continueButton); CenterOnScreen(); Show(); }