CatBrowser::CatBrowser(const BRect &frame, const BMessenger &msgr, const char *category, bool editmode) : BWindow(frame,"Recipe Browser",B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS), fMessenger(msgr), fCategoryCount(-1), fCurrentPage(-1), fEditMode(editmode) { AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); AddShortcut('Q', B_COMMAND_KEY, new BMessage(M_QUIT_APP)); BView *back = new BView(Bounds(),"back",B_FOLLOW_ALL, B_WILL_DRAW); back->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(back); fCategories = new BMenu("Categories"); CppSQLite3Query query = DBQuery("select category from categories order by category;", "FindWindow:get categories"); while(!query.eof()) { BString cat(DeescapeIllegalCharacters(query.getStringField(0))); fCategories->AddItem(new BMenuItem(cat.String(),new BMessage(M_SET_CATEGORY))); query.nextRow(); } fCategories->SetRadioMode(true); fCategories->SetLabelFromMarked(true); if(fCategories->CountItems()>0) fCategories->ItemAt(0)->SetMarked(true); BRect r(10,10,10 + fCategories->MaxContentWidth(),11); BMenuField *field = new BMenuField(r,"field","Category",fCategories); back->AddChild(field); field->ResizeToPreferred(); r = field->Frame(); BMenuItem *marked = fCategories->FindItem(category); if(marked) marked->SetMarked(true); r.OffsetBy(0,r.Height() + 10); r.right = Bounds().right - 10 - B_V_SCROLL_BAR_WIDTH; r.bottom = Bounds().bottom - 10; fList = new BListView(r, "newlist", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL); fList->SetInvocationMessage(new BMessage(M_SET_RECIPE)); BScrollView *newscroll = new BScrollView("newscroll",fList, B_FOLLOW_ALL, 0, false, true); back->AddChild(newscroll); fBack = new BButton(BRect(10,10,11,11),"back","Back", new BMessage(M_RESULTS_BACK), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW); fBack->ResizeToPreferred(); fBack->ResizeTo(be_plain_font->StringWidth("Back") + 15,fBack->Frame().Height()); fBack->MoveTo(10,Bounds().bottom - fBack->Bounds().Height() - 10); r = fBack->Frame(); back->AddChild(fBack); fBack->SetEnabled(false); r.OffsetBy(r.Width() + 5, 0); fNext = new BButton(r,"next","Next", new BMessage(M_RESULTS_NEXT), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW); back->AddChild(fNext); fNext->SetEnabled(false); fClose = new BButton(BRect(10,10,11,11),"close","View Recipe", new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW); fClose->ResizeToPreferred(); fClose->SetLabel("Close"); fClose->MoveTo(Bounds().right - fClose->Bounds().Width() - 10,r.top); r = fClose->Frame(); fClose->MakeDefault(true); r.OffsetBy(-r.Width() - 10, 0); fOpen = new BButton(r,"openrecipe","View Recipe",new BMessage(M_SET_RECIPE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW); back->AddChild(fOpen); back->AddChild(fClose); fList->MakeFocus(true); r = fList->Parent()->Frame(); r.bottom = fClose->Frame().top - 10; fList->Parent()->ResizeTo(r.Width(),r.Height()); float controlwidth = (fBack->Frame().Width() * 2) + (fOpen->Frame().Width() * 2) + 65; if( Frame().Width() < controlwidth ) ResizeTo(controlwidth, Frame().Height()); if(fEditMode) { // This hidden mode (Command-Click on the browser menu item) is for doing // massive edits on the database fList->SetListType(B_MULTIPLE_SELECTION_LIST); fList->SetSelectionMessage(new BMessage(M_SET_RECIPE)); BMenu *editmenu = new BMenu("Edit"); editmenu->AddItem(new BMenuItem("Mass Recategorize",new BMessage(M_SHOW_RECAT))); editmenu->AddItem(new BMenuItem("Delete Recipe",new BMessage(M_DELETE_RECIPE))); r.Set(10,10,10 + be_plain_font->StringWidth("Edit") + 25,11); r.OffsetTo(Bounds().right - 10 - r.Width(), 10); BMenuField *editfield = new BMenuField(r,"editfield","Edit",editmenu, B_FOLLOW_RIGHT | B_FOLLOW_TOP); editfield->SetDivider(0); back->AddChild(editfield); fSortString = " order by number "; } PostMessage(M_SET_CATEGORY); }
// Private function to add the config view of the currently // selected output format to our window void OutputFormatView::AddConfigView() { the_window->Lock(); // Remove the window size limits, // so we are free to do whatever we like the_window->SetSizeLimits(0.0, 32767.0, 0.0, 32767.0); // The current views must stay put while we resize // the window to make room for the config view MakeFollowBottom(false); // Remove the old config view if there is one if (config_view) { RemoveChild(config_view); delete config_view; config_view = 0; } BRect config_rect; if (the_roster->MakeConfigurationView( output_list[index].translator, 0, &config_view, &config_rect) == B_NO_ERROR && config_view != 0) { // Create a caption for the config view // if there wasn't one already if (!config_caption) { config_caption = new CaptionView( BRect(8.0, info_view->Frame().bottom + 1.0, Bounds().right - 8.0, 0.0), "config caption", StringsRsrc[STR_TRANSLATOR_SETTINGS]); config_caption->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); AddChild(config_caption); } // Move the config view to just below the config caption config_view->MoveBy( 16.0 - config_view->Frame().left, config_caption->Frame().bottom + 1.0 - config_view->Frame().top); // Colour it gray config_view->SetViewColor(222, 222, 222); config_view->SetLowColor(222, 222, 222); // First resize the window so that the config view will fit, // otherwise the config view may want to change with us float width_diff = config_view->Frame().right + 16.0 - Bounds().Width(); the_window->ResizeTo( Bounds().Width() + (width_diff > 0.0 ? width_diff : 0.0), config_view->Frame().bottom + 8.0); // Add it to the main view AddChild(config_view); // Make the config_view and its children follow the bottom of the window RecursiveSetMode(config_view); } else { // This translator doesn't have a config view if (config_caption) { RemoveChild(config_caption); delete config_caption; config_caption = 0; } the_window->ResizeTo(Bounds().right, info_view->Frame().bottom + 8.0); } // Make all views follow the bottom of the window again MakeFollowBottom(); // Set the window's minimum size float min_width = (config_view ? config_view->Frame().right : 200.0); if (min_width < 200.0) min_width = 200.0; the_window->SetSizeLimits( min_width, 32767.0, Bounds().Height() - scroll_view->Bounds().Height() + 50.0, 32767.0); the_window->Unlock(); }
void StatusView::drawInto(BView *v, BRect updateRect) { BRect r(Bounds()); D_OPERATION(("StatusView::drawInto(%.1f, %.1f)\n", r.Width(), r.Height())); // draw border (minus right edge, which the scrollbar draws) v->SetDrawingMode(B_OP_COPY); v->BeginLineArray(8); v->AddLine(r.LeftTop(), r.RightTop(), M_MED_GRAY_COLOR); BPoint rtop = r.RightTop(); rtop.y++; v->AddLine(rtop, r.RightBottom(), tint_color(M_MED_GRAY_COLOR, B_LIGHTEN_1_TINT)); v->AddLine(r.RightBottom(), r.LeftBottom(), M_MED_GRAY_COLOR); v->AddLine(r.LeftBottom(), r.LeftTop(), M_MED_GRAY_COLOR); r.InsetBy(1.0, 1.0); v->AddLine(r.LeftTop(), r.RightTop(), M_LIGHT_GRAY_COLOR); rtop.y++; rtop.x--; v->AddLine(rtop, r.RightBottom(), M_GRAY_COLOR); v->AddLine(r.RightBottom(), r.LeftBottom(), tint_color(M_MED_GRAY_COLOR, B_LIGHTEN_1_TINT)); v->AddLine(r.LeftBottom(), r.LeftTop(), M_LIGHT_GRAY_COLOR); v->EndLineArray(); r.InsetBy(1.0, 1.0); v->SetLowColor(M_GRAY_COLOR); v->FillRect(r, B_SOLID_LOW); r.InsetBy(2.0, 0.0); v->SetDrawingMode(B_OP_ALPHA); v->SetHighColor(0, 0, 0, uchar(255 * m_opacity)); // draw icon if (m_icon) { v->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY); BPoint p = r.LeftTop(); p.y--; v->DrawBitmap(m_icon, p); } // draw text r.left += 10.0; font_height fh; be_plain_font->GetHeight(&fh); r.bottom = Bounds().bottom - fh.descent - (Bounds().Height() - fh.ascent - fh.descent) / 2; v->MovePenTo(r.LeftBottom()); v->DrawString(Text()); // draw resize dragger v->SetDrawingMode(B_OP_OVER); r = Bounds(); r.right -= 2.0; r.left = r.right - 2.0; r.InsetBy(0.0, 3.0); r.top += 1.0; for (int32 i = 0; i < r.IntegerHeight(); i += 3) { BPoint p = r.LeftTop() + BPoint(0.0, i); v->SetHighColor(M_MED_GRAY_COLOR); v->StrokeLine(p, p, B_SOLID_HIGH); p += BPoint(1.0, 1.0); v->SetHighColor(M_WHITE_COLOR); v->StrokeLine(p, p, B_SOLID_HIGH); } }
void InfoView::AttachedToWindow() { bool isAway = false; int awayOff = awayOffset; if( !isAway ) awayOff = 0; BRect labelFrame1, labelFrame2; BFont chatFont; // Make the box frame BRect boxFrame = Bounds(); boxFrame.InsetBy(10,5); boxFrame.bottom = 125; // make the box infoBox = new BBox( boxFrame ); // set up the label frames labelFrame1 = boxFrame; labelFrame1.InsetBy( 12, 15 ); labelFrame1.bottom = labelFrame1.top + 20; labelFrame2 = labelFrame1; // labelFrame2.right += 10; labelFrame2.left = Bounds().Width() / 2 - 13; // make lots of labels label1 = new BStringView( labelFrame1, "label1", "User Class:" ); label1->SetFont(be_bold_font); label1->SetFontSize(11); labelFrame1.top += 18; labelFrame1.bottom += 18; infoBox->AddChild( label1 ); label2 = new BStringView( labelFrame2, "label2", "--" ); label2->SetFont(be_plain_font); label2->SetFontSize(11); labelFrame2.top += 18; labelFrame2.bottom += 18; infoBox->AddChild( label2 ); label3 = new BStringView( labelFrame1, "label3", "Member Since:" ); label3->SetFont(be_bold_font); label3->SetFontSize(11); labelFrame1.top += 18; labelFrame1.bottom += 18; infoBox->AddChild( label3 ); label4 = new BStringView( labelFrame2, "label4", "--" ); label4->SetFont(be_plain_font); label4->SetFontSize(11); labelFrame2.top += 18; labelFrame2.bottom += 18; infoBox->AddChild( label4 ); label5 = new BStringView( labelFrame1, "label5", "Online Time:" ); label5->SetFont(be_bold_font); label5->SetFontSize(11); labelFrame1.top += 18; labelFrame1.bottom += 18; infoBox->AddChild( label5 ); label6 = new BStringView( labelFrame2, "label6", "--" ); label6->SetFont(be_plain_font); label6->SetFontSize(11); labelFrame2.top += 18; labelFrame2.bottom += 18; infoBox->AddChild( label6 ); label7 = new BStringView( labelFrame1, "label7", "Warning Level:" ); label7->SetFont(be_bold_font); label7->SetFontSize(11); labelFrame1.top += 18; labelFrame1.bottom += 18; infoBox->AddChild( label7 ); label8 = new BStringView( labelFrame2, "label8", "--" ); label8->SetFont(be_plain_font); label8->SetFontSize(11); labelFrame2.top += 18; labelFrame2.bottom += 18; infoBox->AddChild( label8 ); label9 = new BStringView( labelFrame1, "label9", "Status:" ); label9->SetFont(be_bold_font); label9->SetFontSize(11); labelFrame1.top += 18; labelFrame1.bottom += 18; infoBox->AddChild( label9 ); label10 = new BStringView( labelFrame2, "label10", "--" ); label10->SetFont(be_plain_font); label10->SetFontSize(11); labelFrame2.top += 18; labelFrame2.bottom += 18; infoBox->AddChild( label10 ); // resize for the away stuff if necessary if( isAway ) { ResizeBy( 0, awayOff ); Window()->ResizeBy( 0, awayOff ); } // make the away label BRect awayLabelRect = boxFrame; awayLabelRect.bottom = awayLabelRect.top + 20; awayLabelRect.OffsetBy( 0, boxFrame.Height() + 3 ); awayLabel = new BStringView( awayLabelRect, "awaylabel", "Away Message:" ); awayLabel->SetFont(be_bold_font); awayLabel->SetFontSize(12); AddChild( awayLabel ); if( !isAway ) awayLabel->Hide(); // make the textview BRect trect, txrect; trect = boxFrame; trect.OffsetBy( 0, boxFrame.Height() + 25 ); trect.right -= B_V_SCROLL_BAR_WIDTH; trect.bottom = trect.top + 48; txrect = trect; txrect.OffsetTo( 0, 0 ); txrect.InsetBy( 2, 2 ); awaymessage = new FancyTextView( trect, "text_view", txrect, B_FOLLOW_NONE ); awayHolder = new BScrollView( "profholder", awaymessage, B_FOLLOW_NONE, 0, false, true ); if( !isAway ) awayHolder->Hide(); // Whew... make the profile label BRect profLabelRect = boxFrame; profLabelRect.bottom = profLabelRect.top + 20; profLabelRect.OffsetBy( 0, boxFrame.Height() + 3 + awayOff ); profileLabel = new BStringView( profLabelRect, "proflabel", "Profile:" ); profileLabel->SetFont(be_bold_font); profileLabel->SetFontSize(12); AddChild( profileLabel ); // make the textview trect = boxFrame; trect.OffsetBy( 0, boxFrame.Height() + 25 + awayOff ); trect.right -= B_V_SCROLL_BAR_WIDTH; trect.bottom = trect.top + 80; txrect = trect; txrect.OffsetTo( 0, 0 ); txrect.InsetBy( 2, 2 ); profile = new FancyTextView( trect, "text_view", txrect, B_FOLLOW_NONE ); profHolder = new BScrollView( "profholder", profile, B_FOLLOW_NONE, 0, false, true ); // Set the textview's base font and attributes rgb_color black; black.red = black.green = black.blue = 0; chatFont.SetSize( 12.0 ); profile->SetBaseFontAndColor( chatFont, black ); profile->MakeEditable( false ); profile->SetStylable( true ); profile->SetAutoScrollEnabled( false ); awaymessage->SetBaseFontAndColor( chatFont, black ); awaymessage->MakeEditable( false ); awaymessage->SetStylable( true ); awaymessage->SetAutoScrollEnabled( false ); // make some buttons addToListButton = new BButton( BRect(7,trect.bottom+10,120,trect.bottom+34), "add", Language.get("ADD_BLIST_LABEL"), new BMessage(BEAIM_ADD_BUDDY) ); addToListButton->ResizeToPreferred(); addToListButton->SetEnabled( !isBuddy ); closeButton = new BButton( BRect(Bounds().right-68, trect.bottom + 10, Bounds().right-8, trect.bottom + 34), "close", Language.get("CLOSE_LABEL"), new BMessage(BEAIM_CLOSE_WINDOW) ); closeButton->ResizeToPreferred(); closeButton->MoveTo( Bounds().Width() - closeButton->Bounds().Width() - 8, closeButton->Frame().top ); closeButton->MakeDefault( true ); // add the views AddChild( infoBox ); AddChild( profHolder ); AddChild( awayHolder ); AddChild( addToListButton ); AddChild( closeButton ); profile->MakeEditable( false ); profile->SetStylable( true ); // finally, send the message PostAppMessage( reqMsg ); }
// Main view constructor OutputFormatView::OutputFormatView( BRect frame, BPositionIO *stream, BInvoker *item_selected, BTranslatorRoster *roster) : BView(frame, "background", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE) , selected_invoker(item_selected) , the_roster(roster) , message_sent(false) , config_caption(0) , config_view(0) , output_list(0) { index = -1; version_line[0] = '\0'; name_line = info_line = version_line; // Set the background colour to gray SetViewColor(222, 222, 222); SetLowColor(222, 222, 222); // Top caption CaptionView *caption_view = new CaptionView( BRect(8.0, 0.0, Bounds().right - 8.0, 0.0), "list caption", StringsRsrc[STR_OUTPUT_FORMAT]); AddChild(caption_view); // Create the main list view; we'll put it in a scroll view later list_view = new BListView( BRect( 10.0, caption_view->Frame().bottom + 3.0, Bounds().right - 10.0 - B_V_SCROLL_BAR_WIDTH, caption_view->Frame().bottom + 108.0), "list"); list_view->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP_BOTTOM); list_view->SetSelectionMessage(new BMessage(ITEM_SELECTED)); list_view->SetInvocationMessage(new BMessage(SEND_MESSAGE)); // Identify type and group of incoming stream translator_info in_info; if (the_roster->Identify(stream, 0, &in_info) == B_NO_ERROR) { uint32 in_type = in_info.type; uint32 in_group = in_info.group; translator_info *info_list = 0; int32 info_count = 0; if (the_roster->GetTranslators(stream, 0, &info_list, &info_count) == B_OK) { // One format per translator is a good starting point, // we'll dynamically resize if necessary int32 max_formats = info_count; output_list = new OutputFormat[max_formats]; int32 output_count = 0; for (int32 i = 0; i < info_count; ++i) { const translation_format *format_list = 0; int32 format_count = 0; if (the_roster->GetOutputFormats( info_list[i].translator, &format_list, &format_count) == B_NO_ERROR) { for (int32 j = 0; j < format_count; ++j) { // Only list formats that differ from the input format // and belong to the same group. if (format_list[j].type != in_type && format_list[j].group == in_group) { if (output_count == max_formats) { max_formats += 10; OutputFormat *new_list = new OutputFormat[max_formats]; for (int32 k = 0; k < output_count; ++k) new_list[k] = output_list[k]; delete[] output_list; output_list = new_list; } output_list[output_count].translator = info_list[i].translator; output_list[output_count].type = format_list[j].type; // Put the format names in the list view list_view->AddItem(new BStringItem(format_list[j].name)); ++output_count; } } } } } delete[] info_list; } // Identify() rummaged around the stream, so let's reset it stream->Seek(0, SEEK_SET); // Put the list view in a scroll view with a vertical scroll bar scroll_view = new BScrollView( "scroll view", list_view, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW, false, true, B_FANCY_BORDER); AddChild(scroll_view); // Cancel button cancel_button = new BButton( BRect(0.0, 0.0, 0.0, 0.0), "cancel", StringsRsrc[STR_CANCEL], new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_TOP); // Resize to make the text fit the button cancel_button->ResizeToPreferred(); AddChild(cancel_button); // Main button the_button = new BButton( BRect(0.0, 0.0, 0.0, 0.0), "use", StringsRsrc[STR_USE], new BMessage(INVOKE_LIST), B_FOLLOW_RIGHT | B_FOLLOW_TOP); // Make it the default button the_button->MakeDefault(true); // Resize to make the text fit the button the_button->ResizeToPreferred(); // Move it to the extreme right the_button->MoveBy( scroll_view->Frame().right - the_button->Frame().right, scroll_view->Frame().bottom - the_button->Frame().top + 7.0); AddChild(the_button); // Center the cancel button next to the main button cancel_button->MoveBy( the_button->Frame().left - cancel_button->Frame().right - 10.0, the_button->Frame().top - cancel_button->Frame().top + (the_button->Frame().Height() - cancel_button->Frame().Height()) / 2.0); // Caption for the info view info_caption = new CaptionView( BRect(8.0, the_button->Frame().bottom + 1.0, Bounds().right - 8.0, 0.0), "info caption", StringsRsrc[STR_TRANSLATOR_INFORMATION]); AddChild(info_caption); // Info view info_view = new InfoLinesView( BRect(16.0, info_caption->Frame().bottom + 1.0, Bounds().right, 0.0), 3); AddChild(info_view); // Resize the main view so that everything fits ResizeTo(Bounds().right, info_view->Frame().bottom + 8.0); // Make all views follow the bottom of the window when it is resized MakeFollowBottom(); }
void GenesisCopyWindow::PrepareCopy(void) //////////////////////////////////////////////////////////////////////// { BRect rect; rgb_color BarColor; BarColor.red = 180; BarColor.green = 190; BarColor.blue = 200; m_DestPath.SetTo(m_DirName->Text()); if (m_SingleCopy) m_DestFileName.SetTo(m_FileAsName->Text()); if (IsDirReadOnly(m_DestPath.String())) { BAlert *myAlert = new BAlert("Copy", "Cannot copy to a write protected volume.", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT); myAlert->SetShortcut(0, B_ESCAPE); myAlert->Go(); return; } BEntry dest(m_DestPath.String()); if (dest.InitCheck()!=B_OK) { BAlert *myAlert = new BAlert("Copy","Cannot initialize destination entry.","OK", NULL, NULL,B_WIDTH_AS_USUAL,B_OFFSET_SPACING,B_WARNING_ALERT); myAlert->Go(); return; } if (!dest.Exists()) { BAlert *myAlert = new BAlert("Copy","Destination path does not exist.","OK", NULL, NULL,B_WIDTH_AS_USUAL,B_OFFSET_SPACING,B_WARNING_ALERT); myAlert->Go(); return; } if (!dest.IsDirectory()) { BAlert *myAlert = new BAlert("Copy","Destination path is not a folder.","OK", NULL, NULL,B_WIDTH_AS_USUAL,B_OFFSET_SPACING,B_WARNING_ALERT); myAlert->Go(); return; } BAutolock autolocker(this); m_AbortButton = m_CopyButton; m_AbortButton->SetMessage(new BMessage(BUTTON_MSG_ABORTCOPY)); m_PauseButton = m_CancelButton; m_PauseButton->SetMessage(new BMessage(BUTTON_MSG_PAUSECOPY)); m_DirName->RemoveSelf(); m_Label->RemoveSelf(); // m_Label->MoveBy(0,40); if (m_SingleCopy) m_FileAsName->RemoveSelf(); SetTitle("Copy in progress..."); // Add ProgressBar if (!m_SingleCopy) { rect = Bounds(); rect.left += 24; rect.right -= 24; rect.top += 8; rect.bottom = rect.top+40; m_ProgressBar = new BStatusBar(rect,"progressbar","0%","100%"); m_ProgressBar->SetViewColor(216,216,216); m_ProgressBar->SetLowColor(216,216,216); m_ProgressBar->SetHighColor(0,0,0); m_ProgressBar->SetBarColor(BarColor); m_ProgressBar->SetMaxValue(m_FileCount); m_View->AddChild(m_ProgressBar); } // Add File Bar rect = Bounds(); rect.left += 24; rect.right -= 24; if (m_SingleCopy) rect.top += 32; else rect.top += 48; rect.bottom = rect.top+40; m_FileBar = new BStatusBar(rect,"filebar","",""); m_FileBar->SetViewColor(216,216,216); m_FileBar->SetLowColor(216,216,216); m_FileBar->SetHighColor(0,0,0); m_FileBar->SetBarColor(BarColor); m_View->AddChild(m_FileBar); m_AbortButton->SetLabel("Abort"); m_PauseButton->SetLabel("Pause"); RemoveParentSelection(); if (m_SingleCopy) m_CopyThread = spawn_thread(SingleCopyThreadFunc, "CopyThread", B_NORMAL_PRIORITY, (void *)this); else m_CopyThread = spawn_thread(MultiCopyThreadFunc, "CopyThread", B_NORMAL_PRIORITY, (void *)this); resume_thread(m_CopyThread); }
void ProcessController::DoDraw(bool force) { BRect bounds(Bounds()); float h = floorf(bounds.Height ()) - 2; float top = 1, left = 1; float bottom = top + h; float barWidth = layout[gCPUcount].cpu_width; // interspace float right = left + gCPUcount * (barWidth + layout[gCPUcount].cpu_inter) - layout[gCPUcount].cpu_inter; // right of CPU frame... if (force && Parent()) { SetHighColor(Parent()->ViewColor ()); FillRect(BRect(right + 1, top - 1, right + 2, bottom + 1)); } if (force) { SetHighColor(frame_color); StrokeRect(BRect(left - 1, top - 1, right, bottom + 1)); if (gCPUcount == 2) { StrokeLine(BPoint(left + barWidth, top), BPoint(left + barWidth, bottom)); } } float leftMem = bounds.Width() - layout[gCPUcount].mem_width; if (force) StrokeRect(BRect(leftMem - 1, top - 1, leftMem + layout[gCPUcount].mem_width, bottom + 1)); for (int x = 0; x < gCPUcount; x++) { right = left + barWidth - 1; float rem = fCPUTimes[x] * (h + 1); float barHeight = floorf (rem); rem -= barHeight; float limit = bottom - barHeight; // horizontal line float previousLimit = bottom - fLastBarHeight[x]; float idleTop = top; if (!force && previousLimit > top) idleTop = previousLimit - 1; if (limit > idleTop) { SetHighColor(idle_color); FillRect(BRect(left, idleTop, right, limit - 1)); } if (barHeight <= h) { rgb_color fraction_color; mix_colors(fraction_color, idle_color, active_color, rem); SetHighColor(fraction_color); StrokeLine(BPoint(left, bottom - barHeight), BPoint(right, bottom - barHeight)); } float active_bottom = bottom; if (!force && previousLimit < bottom) active_bottom = previousLimit + 1; if (limit < active_bottom) { SetHighColor(active_color); FillRect(BRect(left, limit + 1, right, active_bottom)); } left += layout[gCPUcount].cpu_width + layout[gCPUcount].cpu_inter; fLastBarHeight[x] = barHeight; } float rightMem = bounds.Width () - 1; float rem = fMemoryUsage * (h + 1); float barHeight = floorf (rem); rem -= barHeight; rgb_color used_memory_color; float sq = fMemoryUsage * fMemoryUsage; sq *= sq; sq *= sq; mix_colors(used_memory_color, memory_color, swap_color, sq); float limit = bottom - barHeight; // horizontal line float previousLimit = bottom - fLastMemoryHeight; float free_top = top; if (!force && previousLimit > top) free_top = previousLimit - 1; if (limit > free_top) { SetHighColor (idle_color); FillRect(BRect(leftMem, free_top, rightMem, limit - 1)); } if (barHeight <= h) { rgb_color fraction_color; mix_colors(fraction_color, idle_color, used_memory_color, rem); SetHighColor(fraction_color); StrokeLine(BPoint(leftMem, bottom - barHeight), BPoint(rightMem, bottom - barHeight)); } float usedBottom = bottom; // if (!force && previousLimit < bottom) // usedBottom = previousLimit + 1; if (limit < usedBottom) { SetHighColor(used_memory_color); FillRect(BRect(leftMem, limit + 1, rightMem, usedBottom)); } fLastMemoryHeight = barHeight; }
void ArpDocumentButton::Draw(BRect) { enum { ShineColor = 0, MedShineColor = 1, ShadowColor = 2, MedShadowColor = 3, NumColors = 4 }; static float ColorTints[NumColors] = { .2, B_DARKEN_2_TINT, B_DARKEN_4_TINT, B_DARKEN_1_TINT }; static int32 StandardMap[NumColors] = { ShineColor, MedShineColor, ShadowColor, MedShadowColor }; static int32 PressedMap[NumColors] = { ShadowColor, MedShadowColor, ShineColor, MedShineColor }; rgb_color bgcolor = LowColor(); if( mDropped ) bgcolor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); BRect bounds(Bounds()); ArpD(cdb << ADH << "Drawing ArpDocument Button..." << endl); ArpD(cdb << ADH << "Initial view bounds=" << bounds << endl); int32* cmap = mPressed ? PressedMap : StandardMap; BeginLineArray(8); rgb_color curcol; if( bounds.IsValid() ) { ArpD(cdb << ADH << "Drawing interior frame at bounds=" << bounds << endl); curcol = tint_color(bgcolor, ColorTints[cmap[MedShineColor]]); AddLine( BPoint(bounds.left, bounds.bottom), BPoint(bounds.left, bounds.top), curcol ); AddLine( BPoint(bounds.left, bounds.top), BPoint(bounds.right, bounds.top), curcol ); curcol = tint_color(bgcolor, ColorTints[cmap[ShadowColor]]); AddLine( BPoint(bounds.right, bounds.top), BPoint(bounds.right, bounds.bottom), curcol ); AddLine( BPoint(bounds.right, bounds.bottom), BPoint(bounds.left, bounds.bottom), curcol ); bounds.InsetBy(1, 1); } if( bounds.IsValid() ) { ArpD(cdb << ADH << "Drawing interior frame at bounds=" << bounds << endl); curcol = tint_color(bgcolor, ColorTints[cmap[ShineColor]]); if( IsFocus() ) curcol = ui_color(B_KEYBOARD_NAVIGATION_COLOR); AddLine( BPoint(bounds.left, bounds.bottom), BPoint(bounds.left, bounds.top), curcol ); AddLine( BPoint(bounds.left, bounds.top), BPoint(bounds.right, bounds.top), curcol ); curcol = tint_color(bgcolor, ColorTints[cmap[MedShadowColor]]); if( IsFocus() ) curcol = ui_color(B_KEYBOARD_NAVIGATION_COLOR); AddLine( BPoint(bounds.right, bounds.top), BPoint(bounds.right, bounds.bottom), curcol ); AddLine( BPoint(bounds.right, bounds.bottom), BPoint(bounds.left, bounds.bottom), curcol ); bounds.InsetBy(1, 1); } EndLineArray(); BRect ibounds; BBitmap* shownBitmap = 0; if( mPressed ) bgcolor = tint_color(LowColor(), B_DARKEN_MAX_TINT); else if( mMenued ) bgcolor = tint_color(LowColor(), B_DARKEN_2_TINT); if( bounds.IsValid() ) { shownBitmap = mDocIcon; if( shownBitmap ) ibounds = shownBitmap->Bounds(); if( mSmallIcon && ( !ibounds.IsValid() || ibounds.Width() > bounds.Width() || ibounds.Height() > bounds.Height() ) ) { shownBitmap = mSmallIcon; ibounds = shownBitmap->Bounds(); } ArpD(cdb << ADH << "Current view bounds=" << bounds << ", icon bounds=" << ibounds << endl); SetHighColor(bgcolor); const float xdiff = bounds.Width() - ibounds.Width(); const float xoff = floor(xdiff/2); if( xdiff > 0 ) { // Fill in background to left and right of bitmap. if( xoff > 0 ) { FillRect(BRect(bounds.left, bounds.top, bounds.left+xoff-1, bounds.bottom)); } FillRect(BRect(bounds.right-(xdiff-xoff)+1, bounds.top, bounds.right, bounds.bottom)); bounds.left += xoff; bounds.right -= (xdiff-xoff); ArpD(cdb << ADH << "Fill view X to bounds=" << bounds << endl); } else { #if 1 ibounds.left -= xoff; ibounds.right += (xdiff-xoff); #endif ArpD(cdb << ADH << "Indent icon X to bounds=" << ibounds << endl); } const float ydiff = bounds.Height() - ibounds.Height(); const float yoff = floor(ydiff/2); if( ydiff > 0 ) { // Fill in background to left and right of bitmap. if( yoff > 0 ) { FillRect(BRect(bounds.left, bounds.top, bounds.right, bounds.top+yoff-1)); } FillRect(BRect(bounds.left, bounds.bottom-(ydiff-yoff)+1, bounds.right, bounds.bottom)); bounds.top += yoff; bounds.bottom -= (ydiff-yoff); ArpD(cdb << ADH << "Fill view Y to bounds=" << bounds << endl); } else { #if 1 ibounds.top -= yoff; ibounds.bottom += (ydiff-yoff); #endif ArpD(cdb << ADH << "Indent icon Y to bounds=" << ibounds << endl); } } if( bounds.IsValid() && ibounds.IsValid() && shownBitmap ) { ArpD(cdb << ADH << "Drawing icon at bounds=" << bounds << ", icon bounds=" << ibounds << endl); SetHighColor(bgcolor); SetLowColor(bgcolor); FillRect(bounds); SetDrawingMode(B_OP_ALPHA); SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); DrawBitmapAsync(shownBitmap, ibounds, bounds); SetDrawingMode(B_OP_COPY); } }
void BrowseView::NewList(HappyLink *t, unsigned int mode) { tasks->GiveUp(); LockLooper(); top = t; // on récupère le numéro du lien actuellement sélectionné int n = GetLinkNum(); // on vide la vue actuelle Clear(); // on la reconstruit bottomSpace = 8; if (mode & BW_NEXTBUTTON) bottomSpace += 24; if (mode & BW_SEARCHTXTV) { bottomSpace += 24; if (mode & BW_CONTAINS) bottomSpace += 24; } if (mode & BW_INFOTEXT) bottomSpace += 14; BRect r=Bounds(); r.top+=8; r.bottom-=bottomSpace; r.left+=8; r.right-=22; BRect lr(r); if (mode & BW_SECONDLIST) { lr.bottom = (r.top+r.bottom)/2-6; mainList = new LinkList2(lr,NULL,B_SINGLE_SELECTION_LIST,this,B_FOLLOW_ALL); BRect mr; mr.top = lr.bottom+4; mr.bottom = mr.top+4; mr.left = Bounds().left; mr.right = Bounds().right; horizontalMover = new Mover(mr,B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP,false); AddChild(horizontalMover); mainScroll = new BScrollView(NULL,mainList,B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP,0,false,true); AddChild(mainScroll); lr.top = lr.bottom+12; lr.bottom = r.bottom; } linksList = new LinkList(lr,NULL,this,B_SINGLE_SELECTION_LIST,B_FOLLOW_ALL); linksScroll = new BScrollView(NULL,linksList,B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP_BOTTOM,0,false,true); AddChild(linksScroll); if (mode & BW_NEXTBUTTON) { r.top = r.bottom+4; r.bottom = r.top+16; nextButton = new BButton(r,NULL,T("Next"),new BMessage('NEXT'),B_FOLLOW_BOTTOM|B_FOLLOW_LEFT_RIGHT); AddChild(nextButton); r.bottom += 4; } if (mode & BW_SEARCHTXTV) { if (mode & BW_CONTAINS) { r.top = r.bottom+4; r.bottom = r.top+16; containsView = new BCheckBox(r,NULL,T("Containing:"),new BMessage('IDCN'),B_FOLLOW_LEFT_RIGHT|B_FOLLOW_BOTTOM); AddChild(containsView); r.bottom += 4; } r.top = r.bottom+4; r.bottom = r.top+16; searchTextView = new BTextControl(r,NULL,"","",new BMessage('IDXV'),B_FOLLOW_LEFT_RIGHT|B_FOLLOW_BOTTOM); searchTextView->SetDivider(-2); searchTextView->SetModificationMessage(new BMessage('IDXC')); AddChild(searchTextView); r.bottom += 4; } if (mode & BW_INFOTEXT) { r.top = r.bottom+2; r.bottom = r.top+12; infoText = new BStringView(r,NULL,"",B_FOLLOW_LEFT_RIGHT|B_FOLLOW_BOTTOM); AddChild(infoText); } containsSearch = false; BusyOn(); if (mainList != NULL) { if (top != NULL) { RemoveChild(mainScroll); UpdateList(mainList,NULL,top->child); AddChild(mainScroll); } } else { if (top != NULL) { RemoveChild(linksScroll); UpdateList(linksList,NULL,top->child,false); AddChild(linksScroll); } } // si un lien était sélectionné avant le changement de liste, on tente de le retrouver if (n>=0) SetLinkNum(n,top); BusyOff(); UnlockLooper(); }
ChatWindow::ChatWindow( Network *aNetwork, MainWindow *aWindow, uin_t aWho ) : BWindow( CHATWIN_RECT, CHATWIN_NAME, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_ZOOMABLE ) { iNetwork = aNetwork; iWindow = aWindow; iWho = aWho; SetSizeLimits( 300, 2000, 200, 2000 ); /* we're fixing a title and checking that we have that number in our people list if true, set to iDisplay */ Person *person; BString title = Title(); BString *pe = NULL; for( int i = 0; i < iWindow->GetProfile()->GetUserlist()->GetList()->CountItems(); i++ ) { person = ( Person* ) iWindow->GetProfile()->GetUserlist()->GetList()->ItemAt( i ); if( aWho == person->GetUIN() ) { pe = new BString( person->GetDisplay() ); break; } } if( !pe ) { pe = new BString(); pe->SetTo( _T("[Stranger]") ); } title.Append( pe->String() ); title << " (" << iWho << ")"; SetTitle( title.String()); /* making a default background */ BRect r = Bounds(); BView *someView; someView = new BView( r, "some view", B_FOLLOW_ALL, B_WILL_DRAW ); someView->SetViewColor( 60, 60, 60 ); AddChild( someView ); /* 'chat' at base of BTextView */ r = someView->Bounds(); r.InsetBy( 10, 10 ); r.right -= B_V_SCROLL_BAR_WIDTH; r.bottom -= 25; BRect textRect = BRect( 5, 5, r.Width() - 5, r.Height() - 5 ); iChat = new BTextView( r, "chat view", textRect, B_FOLLOW_ALL, B_WILL_DRAW ); iChat->MakeEditable( false ); iChat->SetStylable( true ); BFont *font = new BFont( be_plain_font ); font->SetSize( 15.0 ); font->SetEncoding( B_ISO_8859_2 ); iChat->SetFontAndColor( font ); iScrollView = new BScrollView( "scroll view", iChat, B_FOLLOW_ALL, 0, false, true ); someView->AddChild( iScrollView ); iChat->SetViewColor( 70, 70, 70 ); /* new message edit box */ r = someView->Bounds(); r.InsetBy( 10, 10 ); r.top = r.bottom - 15; iSayControl = new BTextControl( r, "say control", "", NULL, new BMessage( BEGG_SEND ), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM ); iSayControl->MakeFocus( true ); float width, height; iSayControl->GetPreferredSize( &width, &height ); iSayControl->SetDivider( width / 2 ); iSayControl->SetFont( font ); someView->AddChild( iSayControl ); }
ToolSelectionWindow::ToolSelectionWindow(BRect frame) : BWindow(frame, StringServer::ReturnString(TOOLS_STRING), B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_H_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK | B_AVOID_FRONT) { int32 pictureSize = LARGE_TOOL_ICON_SIZE + 4.0; window_feel feel = B_NORMAL_WINDOW_FEEL; if (SettingsServer* server = SettingsServer::Instance()) { server->SetValue(SettingsServer::Application, skSelectToolWindowVisible, true); BMessage settings; server->GetApplicationSettings(&settings); settings.FindInt32(skSelectToolWindowFeel, (int32*)&feel); } fMatrixView = new MatrixView(pictureSize, pictureSize, kExtraEdge); _AddTool(ToolManager::Instance().ReturnTool(FREE_LINE_TOOL)); _AddTool(ToolManager::Instance().ReturnTool(STRAIGHT_LINE_TOOL)); _AddTool(ToolManager::Instance().ReturnTool(RECTANGLE_TOOL)); _AddTool(ToolManager::Instance().ReturnTool(ELLIPSE_TOOL)); // Here we could add a separator to the tool window. _AddTool(ToolManager::Instance().ReturnTool(BRUSH_TOOL)); _AddTool(ToolManager::Instance().ReturnTool(HAIRY_BRUSH_TOOL)); _AddTool(ToolManager::Instance().ReturnTool(AIR_BRUSH_TOOL)); _AddTool(ToolManager::Instance().ReturnTool(BLUR_TOOL)); _AddTool(ToolManager::Instance().ReturnTool(FILL_TOOL)); _AddTool(ToolManager::Instance().ReturnTool(TEXT_TOOL)); _AddTool(ToolManager::Instance().ReturnTool(TRANSPARENCY_TOOL)); _AddTool(ToolManager::Instance().ReturnTool(ERASER_TOOL)); _AddTool(ToolManager::Instance().ReturnTool(SELECTOR_TOOL)); _AddTool(ToolManager::Instance().ReturnTool(COLOR_SELECTOR_TOOL)); ToolMap::iterator it = gToolMap.find(ToolManager::Instance().ReturnActiveToolType()); if (it != gToolMap.end()) it->second->SetValue(B_CONTROL_ON); AddChild(fMatrixView); fMatrixView->ResizeTo(Bounds().Width(), Bounds().Height()); SetFeel(feel); if (feel == B_NORMAL_WINDOW_FEEL) SetLook(B_TITLED_WINDOW_LOOK); else SetLook(B_FLOATING_WINDOW_LOOK); float minDimension = 2 * kExtraEdge + pictureSize; float maxDimension = 1 + kExtraEdge + fMatrixView->CountChildren() * (pictureSize + kExtraEdge); SetSizeLimits(minDimension, maxDimension, minDimension, maxDimension); if (Lock()) { AddCommonFilter(new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, B_MOUSE_DOWN, window_activation_filter)); AddCommonFilter(new BMessageFilter(B_KEY_DOWN, AppKeyFilterFunction)); Unlock(); } Show(); // NOTE: this is broken/ not implemented in Haiku, so the tools window // will not show up horizontal as it should be, enable if implemented //SetWindowAlignment(B_PIXEL_ALIGNMENT, 0, 0, picture_size + kExtraEdge, // kExtraEdge + 1, 0, 0, picture_size + kExtraEdge, kExtraEdge + 1); // remove this if SetWindowAlignment is implemented ResizeBy(0.0, maxDimension - pictureSize); fSelectionWindow = this; FloaterManager::AddFloater(this); }
void CAssemblyWindow::AddToolBar() { BMessage *message; // make the pop up menu for 'Select' tool BPopUpMenu *selectMenu = new BPopUpMenu("", false, false); selectMenu->SetFont(be_plain_font); message = new BMessage(SELECT_MODE_CHANGED); message->AddInt32("mev:mode", CEventEditor::RECTANGLE_SELECTION); selectMenu->AddItem(new CIconMenuItem("Rectangle", message, ResourceUtils::LoadImage("ArrowTool"))); message = new BMessage(*message); message->ReplaceInt32("mev:mode", CEventEditor::LASSO_SELECTION); selectMenu->AddItem(new CIconMenuItem("Lasso", message, ResourceUtils::LoadImage("LassoTool"))); selectMenu->SetTargetForItems(this); // make the pop up menu for 'Create' tool BPopUpMenu *createMenu = new BPopUpMenu("", false, false); createMenu->SetFont(be_plain_font); message = new BMessage(NEW_EVENT_TYPE_CHANGED); message->AddInt32("type", EvtType_Count); createMenu->AddItem(new CIconMenuItem("Default", message, ResourceUtils::LoadImage("PencilTool"))); createMenu->AddSeparatorItem(); message = new BMessage(*message); message->ReplaceInt32("type", EvtType_Tempo); createMenu->AddItem(new CIconMenuItem("Tempo", message, ResourceUtils::LoadImage("MetroTool"))); message = new BMessage(*message); message->ReplaceInt32("type", EvtType_TimeSig); createMenu->AddItem(new CIconMenuItem("Time Signature", message, ResourceUtils::LoadImage("TimeSigTool"))); message = new BMessage(*message); message->ReplaceInt32("type", EvtType_Repeat); createMenu->AddItem(new CIconMenuItem("Repeat", message, ResourceUtils::LoadImage("RepeatTool"))); message = new BMessage(*message); message->ReplaceInt32("type", EvtType_End); createMenu->AddItem(new CIconMenuItem("Part End", message, ResourceUtils::LoadImage("EndTool"))); createMenu->SetTargetForItems(this); BRect rect(Bounds()); if (KeyMenuBar()) rect.top = KeyMenuBar()->Frame().bottom + 1.0; rect.right += 1.0; // add the tool bar CToolBar *toolBar = new CToolBar(rect, "General"); CTool *tool; toolBar->AddTool(tool = new CBitmapTool("Snap To Grid", ResourceUtils::LoadImage("GridTool"), new BMessage(CEventEditor::TOOL_GRID))); tool->SetValue(B_CONTROL_ON); toolBar->AddSeparator(); toolBar->AddTool(tool = new CMenuTool("Select", ResourceUtils::LoadImage("ArrowTool"), selectMenu, new BMessage(CEventEditor::TOOL_SELECT))); tool->SetValue(B_CONTROL_ON); toolBar->AddTool(new CMenuTool("Create", ResourceUtils::LoadImage("PencilTool"), createMenu, new BMessage(CEventEditor::TOOL_CREATE))); toolBar->AddTool(tool = new CBitmapTool("Eraser", ResourceUtils::LoadImage("EraserTool"), new BMessage(CEventEditor::TOOL_ERASE))); toolBar->MakeRadioGroup("Select", "Eraser", true); SetToolBar(toolBar); }
void DataView::KeyDown(const char *bytes, int32 numBytes) { int32 modifiers; if (Looper()->CurrentMessage() == NULL || Looper()->CurrentMessage()->FindInt32("modifiers", &modifiers) != B_OK) modifiers = ::modifiers(); // check if the selection is going to be changed switch (bytes[0]) { case B_LEFT_ARROW: case B_RIGHT_ARROW: case B_UP_ARROW: case B_DOWN_ARROW: if (modifiers & B_SHIFT_KEY) { if (fKeySelectionStart == -1) fKeySelectionStart = fStart; } else fKeySelectionStart = -1; break; } switch (bytes[0]) { case B_LEFT_ARROW: { int32 position = fStart - 1; if (modifiers & B_SHIFT_KEY) { if (fKeySelectionStart == fEnd) SetSelection(fStart - 1, fEnd); else { SetSelection(fStart, fEnd - 1); position = fEnd; } } else SetSelection(fStart - 1, fStart - 1); MakeVisible(position); break; } case B_RIGHT_ARROW: { int32 position = fEnd + 1; if (modifiers & B_SHIFT_KEY) { if (fKeySelectionStart == fStart) SetSelection(fStart, fEnd + 1); else SetSelection(fStart + 1, fEnd); } else SetSelection(fEnd + 1, fEnd + 1); MakeVisible(position); break; } case B_UP_ARROW: { int32 start, end; if (modifiers & B_SHIFT_KEY) { if (fKeySelectionStart == fStart) { start = fEnd - int32(kBlockSize); end = fStart; } else { start = fStart - int32(kBlockSize); end = fEnd; } if (start < 0) start = 0; } else { start = fStart - int32(kBlockSize); if (start < 0) start = fStart; end = start; } SetSelection(start, end); MakeVisible(start); break; } case B_DOWN_ARROW: { int32 start, end; if (modifiers & B_SHIFT_KEY) { if (fKeySelectionStart == fEnd) { start = fEnd; end = fStart + int32(kBlockSize); } else { start = fStart; end = fEnd + int32(kBlockSize); } if (end >= int32(fSizeInView)) end = int32(fSizeInView) - 1; } else { end = fEnd + int32(kBlockSize); if (end >= int32(fSizeInView)) start = fEnd; start = end; } SetSelection(start, end); MakeVisible(end); break; } case B_PAGE_UP: { // scroll one page up, but keep the same cursor column BRect frame = SelectionFrame(fFocus, fStart, fStart); frame.OffsetBy(0, -Bounds().Height()); if (frame.top <= kVerticalSpace) frame.top = kVerticalSpace + 1; ScrollBy(0, -Bounds().Height()); int32 position = PositionAt(fFocus, frame.LeftTop()); SetSelection(position, position); break; } case B_PAGE_DOWN: { // scroll one page down, but keep the same cursor column BRect frame = SelectionFrame(fFocus, fStart, fStart); frame.OffsetBy(0, Bounds().Height()); float lastLine = DataBounds().Height() - 1 - kVerticalSpace; if (frame.top > lastLine) frame.top = lastLine; ScrollBy(0, Bounds().Height()); int32 position = PositionAt(fFocus, frame.LeftTop()); SetSelection(position, position); break; } case B_HOME: SetSelection(0, 0); MakeVisible(fStart); break; case B_END: SetSelection(fDataSize - 1, fDataSize - 1); MakeVisible(fStart); break; case B_TAB: SetFocus(fFocus == kHexFocus ? kAsciiFocus : kHexFocus); MakeVisible(fStart); break; case B_FUNCTION_KEY: // this is ignored break; case B_BACKSPACE: if (fBitPosition == 0) SetSelection(fStart - 1, fStart - 1); if (fFocus == kHexFocus) fBitPosition = (fBitPosition + 4) % 8; // supposed to fall through case B_DELETE: SetSelection(fStart, fStart); // to make sure only the cursor is selected if (fFocus == kHexFocus) { const uint8 *data = DataAt(fStart); if (data == NULL) break; uint8 c = data[0] & (fBitPosition == 0 ? 0x0f : 0xf0); // mask out region to be cleared fEditor.Replace(fOffset + fStart, &c, 1); } else fEditor.Replace(fOffset + fStart, (const uint8 *)"", 1); break; default: if (fFocus == kHexFocus) { // only hexadecimal characters are allowed to be entered const uint8 *data = DataAt(fStart); uint8 c = bytes[0]; if (c >= 'A' && c <= 'F') c += 'A' - 'a'; const char *hexNumbers = "0123456789abcdef"; addr_t number; if (data == NULL || (number = (addr_t)strchr(hexNumbers, c)) == 0) break; SetSelection(fStart, fStart); // to make sure only the cursor is selected number -= (addr_t)hexNumbers; fBitPosition = (fBitPosition + 4) % 8; c = (data[0] & (fBitPosition ? 0x0f : 0xf0)) | (number << fBitPosition); // mask out overwritten region and bit-wise or the number to be inserted if (fEditor.Replace(fOffset + fStart, &c, 1) == B_OK && fBitPosition == 0) SetSelection(fStart + 1, fStart + 1); } else { if (fEditor.Replace(fOffset + fStart, (const uint8 *)bytes, numBytes) == B_OK) SetSelection(fStart + 1, fStart + 1); } break; } }
void DeskbarView::MessageReceived(BMessage *message) { // message->PrintToStream(); switch (message->what) { case 'LIVE': { ticks++; Invalidate(); team_info teamInfo; status_t error = get_team_info(team, &teamInfo); if (error != B_OK && id>0) { BDeskbar deskbar; deskbar.RemoveItem(id); } else { BMessage *mes=new BMessage(*message); mes->AddRect("rect",ConvertToScreen(Bounds())); ReplyMessenger.SendMessage(mes); } break; } case B_SET_PROPERTY: { switch( message->FindInt32("what2") ) { case 'TTIP': { const char *tip=NULL; status_t res = message->FindString("tooltip",&tip); if(!tip || res!=B_OK) tip = applicationName.String(); if(strlen(tip)==0) tip = applicationName.String(); if(strlen(tip)!=0) SetToolTip(tip); break; } case 'BITS': { BBitmap *oldicon=icon; icon=NULL; delete oldicon; BMessage bits; message->FindMessage("icon", &bits); icon = new BBitmap(&bits); bits.MakeEmpty(); Invalidate(); break; } case '_ID_': { message->FindInt32("ReplicantID",&id); break; } case 'MSGR': { ssize_t numBytes; const char *name=NULL; message->FindMessenger("messenger", &ReplyMessenger); message->FindData("qtrayobject",B_ANY_TYPE,&traysysobject,&numBytes); if(message->FindString("application_name",&name)==B_OK) applicationName.SetTo(name); break; } } } break; default: BView::MessageReceived(message); break; } }
void BBox::_DrawFancy(BRect labelBox) { BRect rect = Bounds(); rect.top += TopBorderOffset(); if (be_control_look != NULL) { rgb_color base = ViewColor(); if (rect.Height() == 1.0) { // used as horizontal separator be_control_look->DrawGroupFrame(this, rect, rect, base, BControlLook::B_TOP_BORDER); } else if (rect.Width() == 1.0) { // used as vertical separator be_control_look->DrawGroupFrame(this, rect, rect, base, BControlLook::B_LEFT_BORDER); } else { // used as box be_control_look->DrawGroupFrame(this, rect, rect, base); } return; } rgb_color light = tint_color(ViewColor(), B_LIGHTEN_MAX_TINT); rgb_color shadow = tint_color(ViewColor(), B_DARKEN_3_TINT); if (rect.Height() == 1.0) { // used as horizontal separator BeginLineArray(2); AddLine(BPoint(rect.left, rect.top), BPoint(rect.right, rect.top), shadow); AddLine(BPoint(rect.left, rect.bottom), BPoint(rect.right, rect.bottom), light); EndLineArray(); } else if (rect.Width() == 1.0) { // used as vertical separator BeginLineArray(2); AddLine(BPoint(rect.left, rect.top), BPoint(rect.left, rect.bottom), shadow); AddLine(BPoint(rect.right, rect.top), BPoint(rect.right, rect.bottom), light); EndLineArray(); } else { // used as box BeginLineArray(8); AddLine(BPoint(rect.left, rect.bottom - 1.0), BPoint(rect.left, rect.top), shadow); AddLine(BPoint(rect.left + 1.0, rect.top), BPoint(rect.right - 1.0, rect.top), shadow); AddLine(BPoint(rect.left, rect.bottom), BPoint(rect.right, rect.bottom), light); AddLine(BPoint(rect.right, rect.bottom - 1.0), BPoint(rect.right, rect.top), light); rect.InsetBy(1.0, 1.0); AddLine(BPoint(rect.left, rect.bottom - 1.0), BPoint(rect.left, rect.top), light); AddLine(BPoint(rect.left + 1.0, rect.top), BPoint(rect.right - 1.0, rect.top), light); AddLine(BPoint(rect.left, rect.bottom), BPoint(rect.right, rect.bottom), shadow); AddLine(BPoint(rect.right, rect.bottom - 1.0), BPoint(rect.right, rect.top), shadow); EndLineArray(); } }
float BMenuField::_MenuBarWidth() const { return Bounds().Width() - (_MenuBarOffset() + kVMargin); }
void TouchpadView::DrawSliders() { BView* view = fOffScreenView != NULL ? fOffScreenView : this; if (!LockLooper()) return; if (fOffScreenBitmap->Lock()) { view->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); view->FillRect(Bounds()); view->SetHighColor(100, 100, 100); view->FillRoundRect(fPadRect, 4, 4); int32 dragSize = 3; // half drag size // scroll areas view->SetHighColor(145, 100, 100); BRect rightRect(fPadRect.left + fXScrollRange, fPadRect.top, fPadRect.right, fPadRect.bottom); view->FillRoundRect(rightRect, 4, 4); BRect bottomRect(fPadRect.left, fPadRect.top + fYScrollRange, fPadRect.right, fPadRect.bottom); view->FillRoundRect(bottomRect, 4, 4); // Stroke Rect view->SetHighColor(100, 100, 100); view->SetPenSize(2); view->StrokeRoundRect(fPadRect, 4, 4); // x scroll range line view->SetHighColor(200, 0, 0); view->StrokeLine(BPoint(fPadRect.left + fXScrollRange, fPadRect.top), BPoint(fPadRect.left + fXScrollRange, fPadRect.bottom)); fXScrollDragZone = BRect(fPadRect.left + fXScrollRange - dragSize, fPadRect.top - dragSize, fPadRect.left + fXScrollRange + dragSize, fPadRect.bottom + dragSize); fXScrollDragZone1 = BRect(fPadRect.left + fXScrollRange - dragSize, fPadRect.top - dragSize, fPadRect.left + fXScrollRange + dragSize, fPadRect.top + dragSize); view->FillRect(fXScrollDragZone1); fXScrollDragZone2 = BRect(fPadRect.left + fXScrollRange - dragSize, fPadRect.bottom - dragSize, fPadRect.left + fXScrollRange + dragSize, fPadRect.bottom + dragSize); view->FillRect(fXScrollDragZone2); // y scroll range line view->StrokeLine(BPoint(fPadRect.left, fPadRect.top + fYScrollRange), BPoint(fPadRect.right, fPadRect.top + fYScrollRange)); fYScrollDragZone = BRect(fPadRect.left - dragSize, fPadRect.top + fYScrollRange - dragSize, fPadRect.right + dragSize, fPadRect.top + fYScrollRange + dragSize); fYScrollDragZone1 = BRect(fPadRect.left - dragSize, fPadRect.top + fYScrollRange - dragSize, fPadRect.left + dragSize, fPadRect.top + fYScrollRange + dragSize); view->FillRect(fYScrollDragZone1); fYScrollDragZone2 = BRect(fPadRect.right - dragSize, fPadRect.top + fYScrollRange - dragSize, fPadRect.right + dragSize, fPadRect.top + fYScrollRange + dragSize); view->FillRect(fYScrollDragZone2); view->Sync(); fOffScreenBitmap->Unlock(); DrawBitmap(fOffScreenBitmap, B_ORIGIN); } UnlockLooper(); }
GenesisCopyWindow::GenesisCopyWindow(CustomListView *list, PanelView *destpanel, const char *destination, BLooper* looper, BWindow *mainwindow) : BWindow(BRect(0,0,320,140), "Copy...", B_TITLED_WINDOW , B_WILL_DRAW) //////////////////////////////////////////////////////////////////////// { BRect rect; m_CustomListView = list; m_DestPanel = destpanel; m_DestPath.SetTo(destination); m_Looper = looper; m_Window = mainwindow; m_SingleCopy = false; m_Paused = false; m_SkipAllCopyError = false; m_OverwriteAll = false; m_SkipSymLinkCreationError = false; // After the delete process we have to select an item if no item selected... m_Selection = GetFirstSelection(); // First we have to remove the parent selection if selected... // RemoveParentSelection(); m_FileCount = m_CustomListView->CountSelectedEntries(CT_WITHOUTPARENT); if (m_FileCount == 1) m_SingleCopy = true; SetType(B_FLOATING_WINDOW); SetFeel(B_MODAL_SUBSET_WINDOW_FEEL); SetFlags(B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE); AddToSubset(mainwindow); m_View = new BView(Bounds(), "copyview", B_FOLLOW_ALL, B_WILL_DRAW); m_View->SetViewColor(216, 216, 216, 0); AddChild(m_View); // Bottom View rect = Bounds(); rect.top = rect.bottom-44; BView *BottomView = new BView(rect, "infobottomview", B_FOLLOW_BOTTOM, B_WILL_DRAW); BottomView->SetViewColor(180, 190, 200, 0); m_View->AddChild(BottomView); /* // More checkbox rect = BottomView->Bounds(); rect.top = rect.bottom-30; rect.bottom = rect.bottom-14; rect.left = 20; rect.right = rect.left+40; m_MoreCB = new BCheckBox(rect,"more","Show more",new BMessage(COPY_MORE), B_FOLLOW_BOTTOM, B_WILL_DRAW); m_MoreCB->ResizeToPreferred(); BottomView->AddChild(m_MoreCB); */ // OK Button rect = BottomView->Bounds(); rect.top = rect.bottom-34; rect.bottom = rect.bottom-14; rect.left = rect.right-80; rect.right = rect.right-20; m_CopyButton = new BButton(rect,"copy","Copy",new BMessage(BUTTON_MSG_COPY),B_FOLLOW_BOTTOM,B_WILL_DRAW); BottomView->AddChild(m_CopyButton); //Cancel Button rect = BottomView->Bounds(); rect.top = rect.bottom-34; rect.bottom = rect.bottom-14; rect.left = rect.right-160; rect.right = rect.right-100; m_CancelButton = new BButton(rect,"cancel","Cancel",new BMessage(BUTTON_MSG_CANCELCOPY),B_FOLLOW_BOTTOM,B_WILL_DRAW); BottomView->AddChild(m_CancelButton); SetDefaultButton(m_CopyButton); // Info string rect = Bounds(); rect.left += 24; rect.right -= 24; if (m_SingleCopy) rect.top += 8; else rect.top += 16; rect.bottom = rect.top+20; m_Label = new BStringView(rect,"filename","Copy"); m_Label->SetAlignment(B_ALIGN_CENTER); m_Label->SetViewColor(216,216,216); m_Label->SetLowColor(216,216,216); m_Label->SetHighColor(0,0,0); AddChild(m_Label); // Edit field rect = BottomView->Bounds(); if (m_SingleCopy) rect.top = rect.top+36; else rect.top = rect.top+56; rect.bottom = rect.top+32; rect.left += 20; rect.right -= 20; m_DirName = new BTextControl( rect, "destname", "to", "", NULL ); m_DirName->SetDivider(m_View->StringWidth("to")+4); m_DirName->SetModificationMessage(new BMessage(COPYNAME_CHANGED)); m_DirName->SetText(m_DestPath.String()); m_View->AddChild(m_DirName); // "as" field if (m_SingleCopy) { rect = BottomView->Bounds(); rect.top = rect.top+64; rect.bottom = rect.top+32; rect.left += 20; rect.right -= 20; m_FileAsName = new BTextControl( rect, "destfilename", "as", "", NULL ); m_FileAsName->SetDivider(m_View->StringWidth("to")+4); m_FileAsName->SetModificationMessage(new BMessage(COPYNAME_CHANGED)); if (((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_Type == FT_PARENT) m_FileAsName->SetText( ((CustomListItem *)m_CustomListView->GetSelectedEntry(1))->m_FileName.String() ); else m_FileAsName->SetText( ((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_FileName.String() ); m_View->AddChild(m_FileAsName); } m_DirName->MakeFocus(true); // Ctrl + Q closes the window... AddShortcut('Q', 0, new BMessage(BUTTON_MSG_CANCELCOPY)); // Set copy label... if (m_SingleCopy) { BString text; text.SetTo("Copy '"); if (((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_Type == FT_PARENT) text << ((CustomListItem *)m_CustomListView->GetSelectedEntry(1))->m_FileName; else text << ((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_FileName; text << "'"; m_Label->SetText(text.String()); } else { BString text; text.SetTo("Copy "); text << m_FileCount << " files"; m_Label->SetText(text.String()); } AddCommonFilter(new EscapeFilter(this, new BMessage(BUTTON_MSG_CANCELCOPY))); // If there is a given window, let's align our window to its center... if (mainwindow) { BRect myrect = Bounds(); rect = mainwindow->Frame(); float w = rect.right - rect.left; float h = rect.bottom - rect.top; MoveTo(rect.left + w/2 - (myrect.right-myrect.left)/2, rect.top + h/2 - (myrect.bottom-myrect.top)/2); } }