void WorkspacesView::_ExcludeFromParentClipping() { // Prevent the parent view to draw over us. Do so in a way that allows // restoring the parent to the previous state. fParentWhichDrawsOnChildren->PushState(); BRegion clipping(fParentWhichDrawsOnChildren->Bounds()); clipping.Exclude(Frame()); fParentWhichDrawsOnChildren->ConstrainClippingRegion(&clipping); }
void BPrintJob::_RecurseView(BView* view, BPoint origin, BPicture* picture, BRect rect) { ASSERT(picture != NULL); BRegion region; region.Set(BRect(rect.left, rect.top, rect.right, rect.bottom)); view->fState->print_rect = rect; view->AppendToPicture(picture); view->PushState(); view->SetOrigin(origin); view->ConstrainClippingRegion(®ion); if (view->ViewColor() != B_TRANSPARENT_COLOR) { rgb_color highColor = view->HighColor(); view->SetHighColor(view->ViewColor()); view->FillRect(rect); view->SetHighColor(highColor); } view->fIsPrinting = true; view->Draw(rect); view->fIsPrinting = false; view->PopState(); view->EndPicture(); BView* child = view->ChildAt(0); while (child != NULL) { if ((child->Flags() & B_WILL_DRAW) && !child->IsHidden()) { BPoint leftTop(view->Bounds().LeftTop() + child->Frame().LeftTop()); BRect printRect(rect.OffsetToCopy(rect.LeftTop() - leftTop) & child->Bounds()); if (printRect.IsValid()) _RecurseView(child, origin + leftTop, picture, printRect); } child = child->NextSibling(); } if ((view->Flags() & B_DRAW_ON_CHILDREN) != 0) { view->AppendToPicture(picture); view->PushState(); view->SetOrigin(origin); view->ConstrainClippingRegion(®ion); view->fIsPrinting = true; view->DrawAfterChildren(rect); view->fIsPrinting = false; view->PopState(); view->EndPicture(); } }
void AddUIGroup(const char* text, Statement* statement) { if (statement->GetChildren() == NULL) return; DetailsBuilder builder(fParent, GetView(), GetControlBounds(), statement, fSettings); builder.Visit(statement->GetChildren()); if (IsTop()) { fBounds.OffsetTo(fBounds.left, builder.GetBounds().top); } else { BView* box = GetView(); box->ResizeTo(box->Bounds().Width(), builder.GetBounds().top + kBoxBottomMargin); } }
AddOnListInfo::AddOnListInfo(BRect frame,BView *mother) : BWindow(frame,"DontWorryWindow",B_BORDERED_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL,B_AVOID_FOCUS ), _motherMessenger(mother) { CPreferences prefs(PREF_FILE_NAME,PREF_PATH_NAME); BRect listRect = Bounds(); BScrollView *scrollinfo; BView *scrollHBar; float scrollHsize; _lastClass = NULL; _typeRequested = -1; // initialisees les images prefs.Load(); _classesBitmap = prefs.GetBitmap("classes"); _metodesBitmap = prefs.GetBitmap("metodes"); _variablesBitmap = prefs.GetBitmap("variables"); _privateBitmap = prefs.GetBitmap("private"); _protectedBitmap = prefs.GetBitmap("protected"); _virtualBitmap = prefs.GetBitmap("virtual"); listRect.right -= 15; listRect.bottom -=15; _listOfInfos = new AddOnListView(listRect); scrollinfo = new BScrollView("scroll-info",_listOfInfos,B_FOLLOW_ALL_SIDES,0,true,true); // deplace la scroll bar du bas scrollHBar = scrollinfo->FindView("_HSB_"); scrollHBar->ResizeBy(-70,0); scrollHBar->MoveBy(70,0); scrollHsize = (scrollHBar->Bounds()).Height()+1; listRect = scrollinfo->Bounds(); _progress = new AddOnProgressView(BRect(2,listRect.bottom-scrollHsize,70,listRect.bottom-1)); scrollinfo->AddChild(_progress); AddChild(scrollinfo); // place le focus sur la liste _listOfInfos->MakeFocus(true); // envoyer le pointer de la fenetre a la vue pour les deplacement BMessage moveMsg(MOVE_WINDOW_PTR); moveMsg.AddPointer(WINDOW_RESULT_PTR,this); _motherMessenger.SendMessage(&moveMsg); }
void ImageFilePanel::Show() { if (fImageView == NULL) { Window()->Lock(); BView* background = Window()->ChildAt(0); uint32 poseViewResizingMode = background->FindView("PoseView")->ResizingMode(); uint32 countVwResizingMode = background->FindView("CountVw")->ResizingMode(); uint32 vScrollBarResizingMode = background->FindView("VScrollBar")->ResizingMode(); uint32 hScrollBarResizingMode = background->FindView("HScrollBar")->ResizingMode(); background->FindView("PoseView") ->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP); background->FindView("CountVw") ->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP); background->FindView("VScrollBar") ->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP); background->FindView("HScrollBar") ->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP); Window()->ResizeBy(0, 70); background->FindView("PoseView")->SetResizingMode(poseViewResizingMode); background->FindView("CountVw")->SetResizingMode(countVwResizingMode); background->FindView("VScrollBar") ->SetResizingMode(vScrollBarResizingMode); background->FindView("HScrollBar") ->SetResizingMode(hScrollBarResizingMode); BRect rect(background->Bounds().left + 15, background->Bounds().bottom - 94, background->Bounds().left + 122, background->Bounds().bottom - 15); fImageView = new BView(rect, "ImageView", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_SUBPIXEL_PRECISE); fImageView->SetViewColor(background->ViewColor()); background->AddChild(fImageView); rect = BRect(background->Bounds().left + 132, background->Bounds().bottom - 85, background->Bounds().right, background->Bounds().bottom - 65); fResolutionView = new BStringView(rect, "ResolutionView", NULL, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); background->AddChild(fResolutionView); rect.OffsetBy(0, -16); fImageTypeView = new BStringView(rect, "ImageTypeView", NULL, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); background->AddChild(fImageTypeView); Window()->Unlock(); } BFilePanel::Show(); }
status_t RTFTranslator::MakeConfigurationView(BMessage *ioExtension, BView **_view, BRect *_extent) { if (_view == NULL || _extent == NULL) return B_BAD_VALUE; BView *view = new ConfigView(BRect(0, 0, 225, 175)); if (view == NULL) return BTranslator::MakeConfigurationView(ioExtension, _view, _extent); *_view = view; *_extent = view->Bounds(); return B_OK; }
/* * Make inside state picture. */ BPicture* HToolbarButton::MakeInsidePicture(BBitmap *in) { HToolbar *toolbar = cast_as(Parent(),HToolbar); BRect buttonRect = toolbar->ButtonRect(); BView *view = new BView(BRect(0,0,buttonRect.Width(),buttonRect.Height()) ,"offview",0,0); BBitmap *bitmap = new BBitmap(view->Bounds(), in->ColorSpace(), true); BPicture *pict; bitmap->AddChild(view); bitmap->Lock(); view->SetDrawingMode(B_OP_ALPHA); view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); view->BeginPicture(new BPicture); DrawBitmap(view,in); DrawString(view,fName.String()); //view->SetHighColor(White); //view->FillRect(BRect(0,0,0,22)); //view->FillRect(BRect(0,0,22,0)); //view->SetHighColor(BeShadow); //view->FillRect(BRect(21,0,21,21)); //view->FillRect(BRect(0,21,21,21)); BRect rect(Bounds()); view->SetDrawingMode(B_OP_OVER); rect.InsetBy(1,1); view->BeginLineArray(5); view->AddLine(rect.LeftTop(), rect.LeftBottom(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_MAX_TINT)); view->AddLine(rect.LeftTop(), rect.RightTop(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_MAX_TINT)); view->AddLine(rect.LeftBottom(), rect.RightBottom(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT)); rect.bottom--; view->AddLine(rect.LeftBottom(), rect.RightBottom(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT)); view->AddLine(rect.RightTop(), rect.RightBottom(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT)); view->EndLineArray(); view->SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT)); view->StrokeRect(Bounds()); pict = view->EndPicture(); bitmap->Unlock(); delete bitmap; return pict; }
//***************************************************** void ToolBarView::Update() { tool[3]->SetEnabled(Pool.selection != NONE); // save selection tool[2]->SetEnabled(Pool.sample_type != NONE && Pool.changed); // save tool[10]->SetEnabled(Pool.selection != NONE); // cut tool[11]->SetEnabled(Pool.selection != NONE); // copy tool[8]->SetEnabled(Hist.HasUndo()); // need history class for this #ifdef __SAMPLE_STUDIO_LE tool[9]->SetEnabled(Hist.HasRedo()); // need history class for this tool[14]->SetEnabled(Pool.selection != NONE); // copy to stack tool[13]->SetEnabled(ClipBoard.HasClip()); #endif tool[12]->SetEnabled(ClipBoard.HasClip()); if (Pool.sample_type != STEREO || Pool.selection == NONE){ tool[5]->SetEnabled(false); // L tool[6]->SetEnabled(false); // R tool[7]->SetEnabled(false); // B }else{ tool[5]->SetEnabled(Pool.selection != LEFT); tool[6]->SetEnabled(Pool.selection != RIGHT); tool[7]->SetEnabled(Pool.selection != BOTH); } bool draw = false; BView *view = Window()->FindView("Sample view"); if (view){ float step = (Pool.r_pointer-Pool.l_pointer)/view->Bounds().Width(); if (step < 64) draw = true; } if (Pool.tool_mode == DRAW_TOOL && !draw) // make sure that the correct mode is active Pool.tool_mode = SELECT_TOOL; tool[16]->SetEnabled(Pool.sample_type != NONE); tool[16]->SetValue(Pool.tool_mode == SELECT_TOOL && Pool.sample_type != NONE); tool[17]->SetEnabled(Pool.sample_type != NONE && draw); tool[17]->SetValue(Pool.tool_mode == DRAW_TOOL); tool[18]->SetEnabled(Pool.sample_type != NONE); tool[18]->SetValue(Pool.tool_mode == PLAY_TOOL); tool[19]->SetEnabled(Pool.sample_type != NONE); tool[19]->SetValue(Pool.tool_mode == SCRUB_TOOL); }
AboutWindow::AboutWindow() : BWindow(BRect(250, 200, 650, 500), "AboutWindow", B_MODAL_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_NOT_CLOSABLE) { BRect r; SetTitle("About"); r = Bounds(); BView* aroundView = new BView(r, "AroundView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW); aroundView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(aroundView); r = aroundView->Bounds(); r.InsetBy(5.0, 5.0); aroundView->AddChild(new BButton(r, "close", "Close", new BMessage('ClWi'))); aroundView->AddChild(new AboutView(r, "AboutView")); }
BRect GetControlBounds() { if (IsTop()) { BRect bounds(fBounds); bounds.left += kItemLeftMargin /** GetLevel()*/; bounds.right -= kItemRightMargin /** GetLevel()*/; return bounds; } BView* box = GetView(); BRect bounds(box->Bounds()); bounds.top = bounds.bottom - kBoxBottomMargin; bounds.bottom = bounds.top + kBoxHeight; bounds.left += kBoxLeftMargin; bounds.right -= kBoxRightMargin; return bounds; }
/** * @brief ペインが縦方向にスクロールしたら呼び出します。 * @param[in] y スクロール後の y 座標 * @param[in] fromPaneIndex この関数を呼び出しているペインのインデックス */ void TextDiffView::paneVScrolled(float y, TextDiffView::PaneIndex fromPaneIndex) { // 再入を防ぐ if (isPanesVScrolling) { return; } isPanesVScrolling = true; // 他のペインもスクロールさせる int index; for (index = 0; index < PaneMAX; index++) { if (index == fromPaneIndex) { continue; } const char* viewName; switch (index) { case LeftPane: viewName = NAME_LEFT_PANE; break; case RightPane: viewName = NAME_RIGHT_PANE; break; default: viewName = NULL; break; } if (NULL != viewName) { BView* pane = FindView(viewName); if (NULL != pane) { BRect bounds = pane->Bounds(); pane->ScrollTo(bounds.left, y); } } } isPanesVScrolling = false; }
// show_window void show_window(BRect frame, const char* name) { BWindow* window = new BWindow(frame, name, B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE); BView* view = new TestView(window->Bounds(), "test", B_FOLLOW_ALL, B_WILL_DRAW/* | B_FULL_UPDATE_ON_RESIZE*/); window->AddChild(view); BRect b(0.0, 0.0, 60.0, 15.0); b.OffsetTo(5.0, view->Bounds().bottom - (b.Height() + 15.0)); BButton* control = new BButton(b, "button", "Reset", new BMessage(MSG_RESET)); view->AddChild(control); control->SetTarget(view); window->Show(); }
// --------------------------------------------------------------- // MakeConfigurationView // // Makes a BView object for configuring / displaying info about // this translator. // // Preconditions: // // Parameters: ioExtension, configuration options for the // translator // // outView, the view to configure the // translator is stored here // // outExtent, the bounds of the view are // stored here // // Postconditions: // // Returns: // --------------------------------------------------------------- status_t BaseTranslator::MakeConfigurationView(BMessage *ioExtension, BView **outView, BRect *outExtent) { if (!outView || !outExtent) return B_BAD_VALUE; if (ioExtension && fSettings->LoadSettings(ioExtension) != B_OK) return B_BAD_VALUE; BView *view = NewConfigView(AcquireSettings()); // implemented in derived class if (view) { *outView = view; *outExtent = view->Bounds(); return B_OK; } else return BTranslator::MakeConfigurationView(ioExtension, outView, outExtent); }
BBitmap *DragonView::_MakeNoneImage( void ) { // Draw an "empty" bitmap to represent "no image"; we'll use one // that tells the user what to do. BBitmap *bitmap = new BBitmap( BRect( 0, 0, 319, 199 ), BScreen().ColorSpace(), true ); BView *view = new BView( bitmap->Bounds(), "not a bitmap", B_FOLLOW_ALL_SIDES, 0 ); bitmap->AddChild( view ); DragonApp *app = dynamic_cast<DragonApp *>( be_app ); rgb_color White = { 255, 255, 255, 0 }; rgb_color Black = { 0, 0, 0, 0 }; bitmap->Lock(); view->SetLowColor( White ); view->SetViewColor( White ); view->SetHighColor( Black ); view->SetDrawingMode( B_OP_OVER ); view->FillRect( view->Bounds(), B_SOLID_LOW ); // Excercise for the reader here: Read the old newsletter articles // about how to use the font metrics to find out how large a font is, // then center to font in the window dynamically no matter what font // settings the user has. view->SetFont( be_plain_font ); view->MovePenTo( 5, 100 ); view->DrawString( app->rsrc_strings->FindString( RSRC_Drop_an_image ) ); view->Sync(); bitmap->Unlock(); return bitmap; }
BView *PrefsWindow::create_volumes_pane(void) { BView *pane = new BView(BRect(0, 0, top_frame.right-20, top_frame.bottom-80), GetString(STR_VOLUMES_PANE_TITLE), B_FOLLOW_NONE, B_WILL_DRAW); pane->SetViewColor(fill_color); float right = pane->Bounds().right-10; const char *str; int32 index = 0; volume_list = new VolumeListView(BRect(15, 10, pane->Bounds().right-30, 113), "volumes"); while ((str = PrefsFindString("disk", index++)) != NULL) volume_list->AddItem(new BStringItem(str)); volume_list->SetSelectionMessage(new BMessage(MSG_VOLUME_SELECTED)); volume_list->SetInvocationMessage(new BMessage(MSG_VOLUME_INVOKED)); pane->AddChild(new BScrollView("volumes_border", volume_list, B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true)); pane->AddChild(new BButton(BRect(10, 118, pane->Bounds().right/3, 138), "add_volume", GetString(STR_ADD_VOLUME_BUTTON), new BMessage(MSG_ADD_VOLUME))); pane->AddChild(new BButton(BRect(pane->Bounds().right/3, 118, pane->Bounds().right*2/3, 138), "create_volume", GetString(STR_CREATE_VOLUME_BUTTON), new BMessage(MSG_CREATE_VOLUME))); pane->AddChild(new BButton(BRect(pane->Bounds().right*2/3, 118, pane->Bounds().right-11, 138), "remove_volume", GetString(STR_REMOVE_VOLUME_BUTTON), new BMessage(MSG_REMOVE_VOLUME))); extfs_control = new PathControl(true, BRect(10, 145, right, 160), "extfs", GetString(STR_EXTFS_CTRL), PrefsFindString("extfs"), NULL); extfs_control->SetDivider(90); pane->AddChild(extfs_control); BMenuField *menu_field; BPopUpMenu *menu = new BPopUpMenu(""); menu_field = new BMenuField(BRect(10, 165, right, 180), "bootdriver", GetString(STR_BOOTDRIVER_CTRL), menu); menu_field->SetDivider(90); menu->AddItem(new BMenuItem(GetString(STR_BOOT_ANY_LAB), new BMessage(MSG_BOOT_ANY))); menu->AddItem(new BMenuItem(GetString(STR_BOOT_CDROM_LAB), new BMessage(MSG_BOOT_CDROM))); pane->AddChild(menu_field); int32 i32 = PrefsFindInt32("bootdriver"); BMenuItem *item; if (i32 == 0) { if ((item = menu->FindItem(GetString(STR_BOOT_ANY_LAB))) != NULL) item->SetMarked(true); } else if (i32 == CDROMRefNum) { if ((item = menu->FindItem(GetString(STR_BOOT_CDROM_LAB))) != NULL) item->SetMarked(true); } nocdrom_checkbox = new BCheckBox(BRect(10, 185, right, 200), "nocdrom", GetString(STR_NOCDROM_CTRL), new BMessage(MSG_NOCDROM)); pane->AddChild(nocdrom_checkbox); nocdrom_checkbox->SetValue(PrefsFindBool("nocdrom") ? B_CONTROL_ON : B_CONTROL_OFF); return pane; }
ColorPicker::ColorPicker(BLooper * target) : BWindow(BRect(50, 75, 100 + (CP_COL_WIDTH * 32), 120 + (CP_COL_WIDTH * 8)), str(STR_SET_COLORS), B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE), _target(target), _whichColor(0) { const float margin = 5.0f; const float topRowHeight = 25.0f; _colControl = new BColorControl(BPoint(margin, margin+topRowHeight+margin), B_CELLS_32x8, CP_COL_WIDTH, "color_picker", new BMessage(CP_COL_UPDATE)); ResizeTo(_colControl->Frame().right+margin, _colControl->Frame().bottom+margin); BView * view = new BView(Bounds(), NULL, B_FOLLOW_ALL, 0); AddChild(view); view->SetViewColor(BeBackgroundGrey); const BRect & bounds = view->Bounds(); float revertWidth = view->StringWidth(str(STR_REVERT))+10.0f; BRect revertBounds(bounds.right-(revertWidth+margin), margin, bounds.right-margin, margin+topRowHeight); view->AddChild(_revert = new BButton(revertBounds, NULL, str(STR_REVERT), new BMessage(CP_BUTTON_REVERT))); float defaultWidth = view->StringWidth(str(STR_DEFAULT))+10.0f; BRect defaultBounds(revertBounds.left-(margin+defaultWidth), revertBounds.top, revertBounds.left-margin, revertBounds.bottom); view->AddChild(_default = new BButton(defaultBounds, NULL, str(STR_DEFAULT), new BMessage(CP_BUTTON_DEFAULT))); view->AddChild(_sampleView = new BView(BRect(margin, margin, margin+topRowHeight, margin+topRowHeight), NULL, B_FOLLOW_TOP|B_FOLLOW_LEFT, B_WILL_DRAW)); _colorMenu = new BMenu(""); _colorMenu->SetLabelFromMarked(true); for (int i=0; i<NUM_COLORS; i++) { BMessage * msg = new BMessage(CP_SELECTION_CHANGED); msg->AddInt32("which", i); BMenuItem * mi = new BMenuItem(str(STR_COLOR_BG+i), msg); _colorMenu->AddItem(mi); if (i==0) mi->SetMarked(true); } view->AddChild(new BMenuField(BRect(margin+topRowHeight+margin, margin, revertBounds.left-margin, revertBounds.bottom), NULL, NULL, _colorMenu)); view->AddChild(_colControl); BMessage initMsg(CP_INIT); PostMessage(&initMsg); }
bool ClipView::InitiateDrag(BPoint point, int32 index, bool wasSelected) { ClipItem* sItem = dynamic_cast<ClipItem *> (ItemAt(index)); if (sItem == NULL) return false; BString string(sItem->GetClip()); BMessage message(FAV_ADD); message.AddData("text/plain", B_MIME_TYPE, string, string.Length()); message.AddPointer("clip", sItem); BRect dragRect(0.0f, 0.0f, Bounds().Width(), sItem->Height()); BBitmap* dragBitmap = new BBitmap(dragRect, B_RGB32, true); if (dragBitmap->IsValid()) { BView* view = new BView(dragBitmap->Bounds(), "helper", B_FOLLOW_NONE, B_WILL_DRAW); dragBitmap->AddChild(view); dragBitmap->Lock(); sItem->DrawItem(view, dragRect); view->SetHighColor(0, 0, 0, 255); view->StrokeRect(view->Bounds()); view->Sync(); dragBitmap->Unlock(); } else { delete dragBitmap; dragBitmap = NULL; } if (dragBitmap != NULL) DragMessage(&message, dragBitmap, B_OP_ALPHA, BPoint(0.0, 0.0)); else DragMessage(&message, dragRect.OffsetToCopy(point), this); return true; }
static int cdactivate(cdCtxCanvas *ctxcanvas) { BView* view = ctxcanvas->view; BLooper* looper = view->Looper(); const char* ln = ""; if (looper != NULL) { ln = looper->Name(); } printf("CD Activate view %p (%s), looper is %s\n", view, view->Name(), ln); BRect rect = view->Bounds(); ctxcanvas->canvas->w = (int)(rect.Width()); ctxcanvas->canvas->h = (int)(rect.Height()); ctxcanvas->canvas->w_mm = ((double)ctxcanvas->canvas->w) / ctxcanvas->canvas->xres; ctxcanvas->canvas->h_mm = ((double)ctxcanvas->canvas->h) / ctxcanvas->canvas->yres; if (ctxcanvas->canvas->use_matrix) ctxcanvas->canvas->cxTransform(ctxcanvas, ctxcanvas->canvas->matrix); return CD_OK; }
// --------------------------------------------------------------- // MakeConfigurationView // // Makes a BView object for configuring / displaying info about // this translator. // // Preconditions: // // Parameters: ioExtension, configuration options for the // translator // // outView, the view to configure the // translator is stored here // // outExtent, the bounds of the view are // stored here // // Postconditions: // // Returns: // --------------------------------------------------------------- status_t BaseTranslator::MakeConfigurationView(BMessage *ioExtension, BView **outView, BRect *outExtent) { if (!outView || !outExtent) return B_BAD_VALUE; if (ioExtension && fSettings->LoadSettings(ioExtension) != B_OK) return B_BAD_VALUE; BView *view = NewConfigView(AcquireSettings()); // implemented in derived class if (view) { *outView = view; if ((view->Flags() & B_SUPPORTS_LAYOUT) != 0) view->ResizeTo(view->ExplicitPreferredSize()); *outExtent = view->Bounds(); return B_OK; } else return BTranslator::MakeConfigurationView(ioExtension, outView, outExtent); }
void MediaNodePanel::_updateBitmap() { if (m_bitmap) { delete m_bitmap; } BBitmap *tempBitmap = new BBitmap(Frame().OffsetToCopy(0.0, 0.0), B_CMAP8, true); tempBitmap->Lock(); { BView *tempView = new BView(tempBitmap->Bounds(), "", B_FOLLOW_NONE, 0); tempBitmap->AddChild(tempView); tempView->SetOrigin(0.0, 0.0); int32 layout = dynamic_cast<MediaRoutingView *>(view())->getLayout(); _drawInto(tempView, tempView->Bounds(), layout); tempView->Sync(); tempBitmap->RemoveChild(tempView); delete tempView; } tempBitmap->Unlock(); m_bitmap = new BBitmap(tempBitmap); delete tempBitmap; }
void MonthWindowView::DrawMonth() { Bmp->Lock(); float y=yearStringView->Frame().bottom+h_cell; float x=0; if(NewMonth) { BmpView->SetHighColor(VIEW_COLOR); BmpView->FillRect(BRect(0,y+1, BmpView->Bounds().right,todayStringView->Frame().top-6)); BmpView->SetHighColor(0,0,0,0); NewMonth=false; } int byear=cyear; // base year if(tyear<byear) byear=tyear; int day1=0, m=0, k=byear; while(k<cyear) { day1++; if(k%4==0) // leap year? if((k%100!=0) || (k%400==0)) day1++; // yes k++; } while(++m<cmonth) { day1+=(monthDays[m-1]-28); if(m==2) if((cyear%4)==0) if((cyear%100!=0) || (cyear%400==0)) day1++; } day1++; // day1 is number of 1st day of chosen month in chosen year day1=day1%7; int day2=0; m=0; k=byear; while(k<tyear) { day2++; if((k%4)==0) if((k%100!=0) || (k%400==0)) day2++; k++; } while(++m<tmonth) { day2+=(monthDays[m-1]-28); if(m==2) if((tyear%4)==0) if((tyear%100!=0) || (tyear%400==0)) day2++; } day2+=tday; // day2 - number of today's day in today's year day2=day2%7; k=(twday==0) ? 6 : twday-1; k=k-day2+day1; while(k<0) k+=7; k=k%7; cwday1=k; x=w_cell*k+1; y+=h_cell; int qu_days=monthDays[cmonth-1]; // quantity of days in month if(cmonth==2) if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) qu_days=29; BString s; int t=0; while(t<qu_days) { t++; s<<t; if(cyear==tyear) if(cmonth==tmonth) if(t==tday) BmpView->SetHighColor(200,0,0,0); BmpView->DrawString(s.String(),BPoint(x+(w_cell-StringWidth(s.String()))/2,y)); if(cyear==tyear) if(cmonth==tmonth) if(t==tday) BmpView->SetHighColor(0,0,0,0); if(t==cday) { cwday=k; if(which_focused==2) BmpView->SetHighColor(ACTIVE_COLOR); else BmpView->SetHighColor(NOACTIVE_COLOR); cursor.Set(x,y-h_cell+5,x+w_cell-1,y+4); BmpView->StrokeRect(cursor); BmpView->SetHighColor(0,0,0,0); } x+=w_cell; k++; s.SetTo(""); if(k==7) { k=0; y+=h_cell; x=1; } } BmpView->Sync(); Bmp->Unlock(); Draw(Bounds()); }
ConfigWindow::ConfigWindow() : BWindow(BRect(100.0, 100.0, 580.0, 540.0), "E-mail", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE), fLastSelectedAccount(NULL), fSaveSettings(false) { // create controls BRect rect(Bounds()); BView *top = new BView(rect, NULL, B_FOLLOW_ALL, 0); top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(top); // determine font height font_height fontHeight; top->GetFontHeight(&fontHeight); int32 height = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 5; rect.InsetBy(5, 5); rect.bottom -= 11 + height; BTabView *tabView = new BTabView(rect, NULL); BView *view; rect = tabView->Bounds(); rect.bottom -= tabView->TabHeight() + 4; tabView->AddTab(view = new BView(rect, NULL, B_FOLLOW_ALL, 0)); tabView->TabAt(0)->SetLabel(B_TRANSLATE("Accounts")); view->SetViewColor(top->ViewColor()); // accounts listview rect = view->Bounds().InsetByCopy(8, 8); rect.right = 140 - B_V_SCROLL_BAR_WIDTH; rect.bottom -= height + 12; fAccountsListView = new AccountsListView(rect); view->AddChild(new BScrollView(NULL, fAccountsListView, B_FOLLOW_ALL, 0, false, true)); rect.right += B_V_SCROLL_BAR_WIDTH; rect.top = rect.bottom + 8; rect.bottom = rect.top + height; BRect sizeRect = rect; sizeRect.right = sizeRect.left + 30 + view->StringWidth( B_TRANSLATE("Add")); view->AddChild(new BButton(sizeRect, NULL, B_TRANSLATE("Add"), new BMessage(kMsgAddAccount), B_FOLLOW_BOTTOM)); sizeRect.left = sizeRect.right+3; sizeRect.right = sizeRect.left + 30 + view->StringWidth( B_TRANSLATE("Remove")); view->AddChild(fRemoveButton = new BButton( sizeRect, NULL, B_TRANSLATE("Remove"), new BMessage(kMsgRemoveAccount), B_FOLLOW_BOTTOM)); // accounts config view rect = view->Bounds(); rect.left = fAccountsListView->Frame().right + B_V_SCROLL_BAR_WIDTH + 16; rect.right -= 10; view->AddChild(fConfigView = new CenterContainer(rect)); MakeHowToView(); // general settings rect = tabView->Bounds(); rect.bottom -= tabView->TabHeight() + 4; tabView->AddTab(view = new CenterContainer(rect)); tabView->TabAt(1)->SetLabel(B_TRANSLATE("Settings")); rect = view->Bounds().InsetByCopy(8, 8); rect.right -= 1; rect.bottom = rect.top + height * 5 + 15; BBox *box = new BBox(rect); box->SetLabel(B_TRANSLATE("Mail checking")); view->AddChild(box); rect = box->Bounds().InsetByCopy(8, 8); rect.top += 7; rect.bottom = rect.top + height + 5; BRect tile = rect.OffsetByCopy(0, 1); int32 labelWidth = (int32)view->StringWidth(B_TRANSLATE("Check every")) + 6; tile.right = 80 + labelWidth; fIntervalControl = new BTextControl(tile, "time", B_TRANSLATE("Check every"), NULL, NULL); fIntervalControl->SetDivider(labelWidth); box->AddChild(fIntervalControl); BPopUpMenu *frequencyPopUp = new BPopUpMenu(B_EMPTY_STRING); const char *frequencyStrings[] = { B_TRANSLATE("never"), B_TRANSLATE("minutes"), B_TRANSLATE("hours"), B_TRANSLATE("days") }; BMenuItem *item; for (int32 i = 0; i < 4; i++) { frequencyPopUp->AddItem(item = new BMenuItem(frequencyStrings[i], new BMessage(kMsgIntervalUnitChanged))); if (i == 1) item->SetMarked(true); } tile.left = tile.right + 5; tile.right = rect.right; tile.OffsetBy(0,-1); fIntervalUnitField = new BMenuField(tile, "frequency", B_EMPTY_STRING, frequencyPopUp); fIntervalUnitField->SetDivider(0.0); box->AddChild(fIntervalUnitField); rect.OffsetBy(0,height + 9); rect.bottom -= 2; fPPPActiveCheckBox = new BCheckBox(rect, "ppp active", B_TRANSLATE("Only when dial-up is connected"), NULL); box->AddChild(fPPPActiveCheckBox); rect.OffsetBy(0,height + 9); rect.bottom -= 2; fPPPActiveSendCheckBox = new BCheckBox(rect, "ppp activesend", B_TRANSLATE("Schedule outgoing mail when dial-up is disconnected"), NULL); box->AddChild(fPPPActiveSendCheckBox); // Miscellaneous settings box rect = box->Frame(); rect.bottom = rect.top + 3 * height + 30; box = new BBox(rect); box->SetLabel(B_TRANSLATE("Miscellaneous")); view->AddChild(box); BPopUpMenu *statusPopUp = new BPopUpMenu(B_EMPTY_STRING); const char *statusModes[] = { B_TRANSLATE("Never"), B_TRANSLATE("While sending"), B_TRANSLATE("While sending and receiving"), B_TRANSLATE("Always") }; BMessage *msg; for (int32 i = 0; i < 4; i++) { statusPopUp->AddItem(item = new BMenuItem(statusModes[i], msg = new BMessage(kMsgShowStatusWindowChanged))); msg->AddInt32("ShowStatusWindow", i); if (i == 0) item->SetMarked(true); } rect = box->Bounds().InsetByCopy(8,8); rect.top += 7; rect.bottom = rect.top + height + 5; labelWidth = (int32)view->StringWidth( B_TRANSLATE("Show connection status window:")) + 8; fStatusModeField = new BMenuField(rect, "show status", B_TRANSLATE("Show connection status window:"), statusPopUp); fStatusModeField->SetDivider(labelWidth); box->AddChild(fStatusModeField); rect = fStatusModeField->Frame();; rect.OffsetBy(0, rect.Height() + 10); BButton *button = new BButton(rect, B_EMPTY_STRING, B_TRANSLATE("Edit mailbox menu…"), msg = new BMessage(B_REFS_RECEIVED)); button->ResizeToPreferred(); box->AddChild(button); button->SetTarget(BMessenger("application/x-vnd.Be-TRAK")); BPath path; find_directory(B_USER_SETTINGS_DIRECTORY, &path); path.Append("Mail/Menu Links"); BEntry entry(path.Path()); if (entry.InitCheck() == B_OK && entry.Exists()) { entry_ref ref; entry.GetRef(&ref); msg->AddRef("refs", &ref); } else button->SetEnabled(false); rect = button->Frame(); rect.OffsetBy(rect.Width() + 30,0); fAutoStartCheckBox = new BCheckBox(rect, "start daemon", B_TRANSLATE("Start mail services on startup"), NULL); fAutoStartCheckBox->ResizeToPreferred(); box->AddChild(fAutoStartCheckBox); // save/revert buttons top->AddChild(tabView); rect = tabView->Frame(); rect.top = rect.bottom + 5; rect.bottom = rect.top + height + 5; BButton *saveButton = new BButton(rect, "apply", B_TRANSLATE("Apply"), new BMessage(kMsgSaveSettings)); float w,h; saveButton->GetPreferredSize(&w, &h); saveButton->ResizeTo(w, h); saveButton->MoveTo(rect.right - w, rect.top); top->AddChild(saveButton); BButton *revertButton = new BButton(rect, "revert", B_TRANSLATE("Revert"), new BMessage(kMsgRevertSettings)); revertButton->GetPreferredSize(&w, &h); revertButton->ResizeTo(w,h); revertButton->MoveTo(saveButton->Frame().left - 25 - w, rect.top); top->AddChild(revertButton); LoadSettings(); // this will also move our window to the stored position fAccountsListView->SetSelectionMessage(new BMessage(kMsgAccountSelected)); fAccountsListView->MakeFocus(true); }
// When this is running, no member variable should be accessed // from other threads status_t MovieEncoder::_EncoderThread() { int32 framesLeft = fFileList->CountItems(); int32 framesWritten = 0; if (framesLeft <= 0) { DisposeData(); BMessage message(kEncodingFinished); message.AddInt32("status", (int32)B_ERROR); fMessenger.SendMessage(&message); return B_ERROR; } // Create movie entry_ref movieRef; get_ref_for_path(fOutputFile.Path(), &movieRef); BitmapEntry* entry = fFileList->ItemAt(0); BBitmap* bitmap = entry->Bitmap(); BRect sourceFrame = bitmap->Bounds(); delete bitmap; if (!fDestFrame.IsValid()) fDestFrame = sourceFrame.OffsetToCopy(B_ORIGIN); // Calc the average time difference between the first 100 frames, // and use it to calculate the framerate. // TODO: Actually we could just calculate the number of frames and // the time difference between the first and the last one. /*int32 maxTimeStampNum = std::min((int32)100, fFileList->CountItems()); bigtime_t previousFrameTime = entry->TimeStamp(); bigtime_t diffSum = 0; for (int32 i = 0; i < maxTimeStampNum; i++) { BitmapEntry* entry = fFileList->ItemAt(i); bigtime_t currentFrameTime = entry->TimeStamp(); diffSum += currentFrameTime - previousFrameTime; previousFrameTime = currentFrameTime; } float medianDiffTime = diffSum / maxTimeStampNum; */ int32 numFrames = fFileList->CountItems(); BitmapEntry* firstEntry = fFileList->ItemAt(0); BitmapEntry* lastEntry = fFileList->ItemAt(numFrames - 1); int frameSeconds = (1000000 * numFrames) / (lastEntry->TimeStamp() - firstEntry->TimeStamp()); media_format inputFormat = fFormat; inputFormat.u.raw_video.field_rate = frameSeconds; status_t status = _CreateFile(movieRef, fFileFormat, inputFormat, fCodecInfo); if (status < B_OK) { DisposeData(); BMessage message(kEncodingFinished); message.AddInt32("status", (int32)status); fMessenger.SendMessage(&message); return status; } // Bitmap and view used to convert the source bitmap // to the correct size and depth BBitmap* destBitmap = new BBitmap(fDestFrame, fColorSpace, true); BView* destDrawer = new BView(fDestFrame, "drawing view", B_FOLLOW_NONE, 0); if (destBitmap->Lock()) { destBitmap->AddChild(destDrawer); destBitmap->Unlock(); } const uint32 keyFrameFrequency = 10; // TODO: Make this tunable BMessage progressMessage(B_UPDATE_STATUS_BAR); progressMessage.AddFloat("delta", 1.0); destBitmap->Bounds().PrintToStream(); PrintMediaFormat(inputFormat); status = B_OK; while (BitmapEntry* entry = const_cast<FileList*>(fFileList)->Pop()) { if (fKillThread) break; bool keyFrame = (framesWritten % keyFrameFrequency == 0); BBitmap* frame = entry->Bitmap(); if (frame == NULL) { // TODO: What to do here ? Exit with an error ? std::cerr << "Error while loading bitmap entry" << std::endl; delete entry; continue; } // Draw scaled if (status == B_OK) { destBitmap->Lock(); destDrawer->DrawBitmap(frame, frame->Bounds(), destDrawer->Bounds()); destDrawer->Sync(); destBitmap->Unlock(); } delete frame; delete entry; if (status == B_OK) status = _WriteFrame(destBitmap, keyFrame); if (status != B_OK) break; framesWritten++; if (fMessenger.IsValid()) fMessenger.SendMessage(new BMessage(progressMessage)); else { // BMessenger is no longer valid. This means that the application // has been closed or it has crashed. break; } } delete destBitmap; DisposeData(); if (fMessenger.IsValid()) { BMessage message(kEncodingFinished); message.AddInt32("status", (int32)status); message.AddInt32("frames", (int32)framesWritten); fMessenger.SendMessage(&message); } return status; }
/*! Message must contain an archivable view for later rehydration. This function takes over ownership of the provided message on success only. Returns the current replicant ID. */ status_t TReplicantTray::AddIcon(BMessage* archive, int32* id, const entry_ref* addOn) { if (archive == NULL || id == NULL) return B_ERROR; // find entry_ref entry_ref ref; if (addOn) { // Use it if we got it ref = *addOn; } else { const char* signature; status_t status = archive->FindString("add_on", &signature); if (status == B_OK) { BRoster roster; status = roster.FindApp(signature, &ref); } if (status < B_OK) return status; } BFile file; status_t status = file.SetTo(&ref, B_READ_ONLY); if (status < B_OK) return status; node_ref nodeRef; status = file.GetNodeRef(&nodeRef); if (status < B_OK) return status; BEntry entry(&ref, true); // TODO: this resolves an eventual link for the item being added - this // is okay for now, but in multi-user environments, one might want to // have links that carry the be:deskbar_item_status attribute status = entry.InitCheck(); if (status != B_OK) return status; *id = 999; if (archive->what == B_ARCHIVED_OBJECT) archive->what = 0; BRect originalBounds = archive->FindRect("_frame"); // this is a work-around for buggy replicants that change their size in // AttachedToWindow() (such as "SVM") // TODO: check for name collisions? status = fShelf->AddReplicant(archive, BPoint(1, 1)); if (status != B_OK) return status; int32 count = fShelf->CountReplicants(); BView* view; fShelf->ReplicantAt(count - 1, &view, (uint32*)id, NULL); if (originalBounds != view->Bounds()) { // The replicant changed its size when added to the window, so we need // to recompute all over again (it's already done once via // BShelf::AddReplicant() and TReplicantShelf::CanAcceptReplicantView()) RealignReplicants(); } float oldWidth = Bounds().Width(); float oldHeight = Bounds().Height(); float width, height; GetPreferredSize(&width, &height); if (oldWidth != width || oldHeight != height) AdjustPlacement(); // add the item to the add-on list AddItem(*id, nodeRef, entry, addOn != NULL); return B_OK; }
BRect GetBounds() { return BRect(0, 0, fView->Bounds().Width(), fBounds.top); }
void BeKESAMainWindow::initTab4(BTabView *tv) { BTab *tab; BBox *box; BRect r,s,sl,sr; r = tv->Bounds(); r.InsetBy(5,10); BView *view = new BView(r, "viewtab4", B_FOLLOW_ALL_SIDES, 0); view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); tab = new BTab(view); tv->AddTab(view, tab); tab->SetLabel("Teren/Gleba"); r = view->Bounds(); r.top = 10; r.left = 10; r.right -= 10; r.bottom = r.top + 140; box = new BBox(r, "box4x1"); box->SetLabel("Dostępność terenu"); view->AddChild(box); sl = box->Bounds(); sl.InsetBy(10,20); sl.right = sl.left + sl.Width()/2; sl.bottom = sl.top + 20; BPopUpMenu *menu; BMenuItem *item; BMessage *msg; menu = new BPopUpMenu("t3mzabudowa"); msg = new BMessage(TC4Z); msg->AddInt32("_item", 0); item = new BMenuItem("[brak]", msg); item->SetMarked(true); menu->AddItem(item); t3zabitems[0] = item; msg = new BMessage(TC4Z); msg->AddInt32("_item", 1); item = new BMenuItem("niezabudowany", msg); menu->AddItem(item); t3zabitems[1] = item; msg = new BMessage(TC4Z); msg->AddInt32("_item", 2); item = new BMenuItem("średniozabudowany", msg); menu->AddItem(item); t3zabitems[2] = item; msg = new BMessage(TC4Z); msg->AddInt32("_item", 3); item = new BMenuItem("zabudowany", msg); menu->AddItem(item); t3zabitems[3] = item; BMenuField *t3zabudowa = new BMenuField(sl, "t3zabudowa", "Dostępność", menu, B_FOLLOW_LEFT, B_WILL_DRAW); t3zabudowa->SetDivider(100); box->AddChild(t3zabudowa); s = box->Bounds(); s.InsetBy(10,20); s.top = s.top + sl.Height() + 5; s.right = s.left + s.Width()/3; s.bottom = s.top + 20; sl = s; s.OffsetBy(s.Width(), 0); sr = s; sr.OffsetBy(s.Width(), 0); t3tl = new BCheckBox(sl, "t3tl", "las", new BMessage(TC4)); t3ts = new BCheckBox(s, "t3ts", "sad", new BMessage(TC4)); t3tp = new BCheckBox(sr, "t3tp", "park", new BMessage(TC4)); sl.OffsetBy(0,20); s.OffsetBy(0,20); sr.OffsetBy(0,20); t3to = new BCheckBox(sl, "t3to", "pole orne", new BMessage(TC4)); t3ta = new BCheckBox(s, "t3ta", "łąka", new BMessage(TC4)); t3tr = new BCheckBox(sr, "t3tr", "ter. roln. prywatny", new BMessage(TC4)); sl.OffsetBy(0,20); s.OffsetBy(0,20); sr.OffsetBy(0,20); t3te = new BCheckBox(sl, "t3te", "ter. roln. społeczny", new BMessage(TC4)); t3tz = new BCheckBox(s, "t3tz", "teren przemysłowy", new BMessage(TC4)); box->AddChild(t3tl); box->AddChild(t3ts); box->AddChild(t3tp); box->AddChild(t3to); box->AddChild(t3ta); box->AddChild(t3tr); box->AddChild(t3te); box->AddChild(t3tz); s = box->Bounds(); s.InsetBy(10,20); sl.right = sl.left + s.Width(); sl.OffsetBy(0,25); t3tokr = new BTextControl(sl, "t3tokr", "Okr. bliższe", NULL, new BMessage(TC4)); t3tokr->SetDivider(100); box->AddChild(t3tokr); r.top += 145; r.bottom += 100; box = new BBox(r, "box4x2"); box->SetLabel("Gleba"); view->AddChild(box); sl = box->Bounds(); sl.InsetBy(10,20); sl.right = sl.left + sl.Width()/3; sl.bottom = sl.top + 20; s = sl; s.OffsetBy(sl.Width(),0); sr = s; sr.OffsetBy(sl.Width(),0); sl.OffsetBy(0,10); sr.OffsetBy(0,10); menu = new BPopUpMenu("t3mkam"); msg = new BMessage(TC4K); msg->AddInt32("_item", 0); item = new BMenuItem("[brak]", msg); item->SetMarked(true); menu->AddItem(item); t3kamitems[0] = item; msg = new BMessage(TC4K); msg->AddInt32("_item", 1); item = new BMenuItem("mała", msg); menu->AddItem(item); t3kamitems[1] = item; msg = new BMessage(TC4K); msg->AddInt32("_item", 2); item = new BMenuItem("średnia", msg); menu->AddItem(item); t3kamitems[2] = item; msg = new BMessage(TC4K); msg->AddInt32("_item", 3); item = new BMenuItem("duża", msg); menu->AddItem(item); t3kamitems[3] = item; BMenuField *t3kamienie = new BMenuField(sl, "t3kamienie", "Kamienistość", menu, B_FOLLOW_LEFT, B_WILL_DRAW); t3kamienie->SetDivider(70); box->AddChild(t3kamienie); t3gp = new BCheckBox(s, "t3gp", "piaszczysta", new BMessage(TC4)); s.OffsetBy(0,20); t3gg = new BCheckBox(s, "t3gg", "gliniasta", new BMessage(TC4)); t3gt = new BCheckBox(sr, "t3gt", "torfowo-bagnista", new BMessage(TC4)); box->AddChild(t3gp); box->AddChild(t3gg); box->AddChild(t3gt); s = box->Bounds(); s.InsetBy(10,20); sl.right = sl.left + s.Width(); sl.OffsetBy(0,35); t3gokr = new BTextControl(sl, "t3gokr", "Okr. specj.", NULL, new BMessage(TC4)); t3gokr->SetDivider(100); box->AddChild(t3gokr); updateTab4(); }
// MouseMoved void ObjectView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage) { // BRect dirty(where, where); // dirty.InsetBy(-10, -10); // Invalidate(dirty); if (dragMessage) { //printf("ObjectView::MouseMoved(BPoint(%.1f, %.1f)) - DRAG MESSAGE\n", where.x, where.y); //Window()->CurrentMessage()->PrintToStream(); } else { //printf("ObjectView::MouseMoved(BPoint(%.1f, %.1f))\n", where.x, where.y); } if (fScrolling) { BCursor cursor(kGrabCursor); SetViewCursor(&cursor); BPoint offset = fLastMousePos - where; ScrollBy(offset.x, offset.y); fLastMousePos = where + offset; } else if (fInitiatingDrag) { BPoint offset = fLastMousePos - where; if (sqrtf(offset.x * offset.x + offset.y * offset.y) > 5.0) { BMessage newDragMessage('drag'); BBitmap* dragBitmap = new BBitmap(BRect(0, 0, 40, 40), B_RGBA32, true); if (dragBitmap->Lock()) { BView* helper = new BView(dragBitmap->Bounds(), "offscreen view", B_FOLLOW_ALL, B_WILL_DRAW); dragBitmap->AddChild(helper); helper->SetDrawingMode(B_OP_ALPHA); helper->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE); BRect r(helper->Bounds()); helper->SetHighColor(0, 0, 0, 128); helper->StrokeRect(r); helper->SetHighColor(200, 200, 200, 100); r.InsetBy(1, 1); helper->FillRect(r); helper->SetHighColor(0, 0, 0, 255); const char* text = B_TRANSLATE("Test"); float pos = (r.Width() - helper->StringWidth(text)) / 2; helper->DrawString(text, BPoint(pos, 25)); helper->Sync(); } DragMessage(&newDragMessage, dragBitmap, B_OP_ALPHA, B_ORIGIN, this); fInitiatingDrag = false; } } else { BCursor cursor(kMoveCursor); SetViewCursor(&cursor); if (fState && fState->IsTracking()) { BRect before = fState->Bounds(); fState->MouseMoved(where); BRect after = fState->Bounds(); BRect invalid(before | after); Invalidate(invalid); } } // SetViewCursor(); }
ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entry) : BWindow(BRect(0.0f, 0.0f, 250.0f, 340.0f).OffsetBySelf(position), "Application Type", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS), fChangedProperties(0) { // add the menu BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), NULL); AddChild(menuBar); BMenu* menu = new BMenu("File"); fSaveMenuItem = new BMenuItem("Save", new BMessage(kMsgSave), 'S'); fSaveMenuItem->SetEnabled(false); menu->AddItem(fSaveMenuItem); BMenuItem* item; menu->AddItem(item = new BMenuItem("Save into resource file" B_UTF8_ELLIPSIS, NULL)); item->SetEnabled(false); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED), 'W', B_COMMAND_KEY)); menuBar->AddItem(menu); // Top view and signature BRect rect = Bounds(); rect.top = menuBar->Bounds().Height() + 1.0f; BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW); topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(topView); rect = topView->Bounds().InsetByCopy(8.0f, 8.0f); fSignatureControl = new BTextControl(rect, "signature", "Signature:", NULL, new BMessage(kMsgSignatureChanged), B_FOLLOW_LEFT_RIGHT); fSignatureControl->SetModificationMessage( new BMessage(kMsgSignatureChanged)); fSignatureControl->SetDivider(fSignatureControl->StringWidth( fSignatureControl->Label()) + 4.0f); float width, height; fSignatureControl->GetPreferredSize(&width, &height); fSignatureControl->ResizeTo(rect.Width(), height); topView->AddChild(fSignatureControl); // filter out invalid characters that can't be part of a MIME type name BTextView* textView = fSignatureControl->TextView(); textView->SetMaxBytes(B_MIME_TYPE_LENGTH); const char* disallowedCharacters = "<>@,;:\"()[]?="; for (int32 i = 0; disallowedCharacters[i]; i++) { textView->DisallowChar(disallowedCharacters[i]); } // "Application Flags" group BFont font(be_bold_font); font_height fontHeight; font.GetHeight(&fontHeight); width = font.StringWidth("Icon") + 16.0f; if (width < B_LARGE_ICON + 16.0f) width = B_LARGE_ICON + 16.0f; rect.top = fSignatureControl->Frame().bottom + 4.0f; rect.bottom = rect.top + 100.0f; rect.right -= width + 8.0f; BBox* box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); topView->AddChild(box); fFlagsCheckBox = new BCheckBox(rect, "flags", "Application flags", new BMessage(kMsgToggleAppFlags)); fFlagsCheckBox->SetValue(B_CONTROL_ON); fFlagsCheckBox->ResizeToPreferred(); box->SetLabel(fFlagsCheckBox); rect.top = fFlagsCheckBox->Bounds().Height() + 4.0f; fSingleLaunchButton = new BRadioButton(rect, "single", "Single launch", new BMessage(kMsgAppFlagsChanged)); fSingleLaunchButton->ResizeToPreferred(); box->AddChild(fSingleLaunchButton); rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f); fMultipleLaunchButton = new BRadioButton(rect, "multiple", "Multiple launch", new BMessage(kMsgAppFlagsChanged)); fMultipleLaunchButton->ResizeToPreferred(); box->AddChild(fMultipleLaunchButton); rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f); fExclusiveLaunchButton = new BRadioButton(rect, "exclusive", "Exclusive launch", new BMessage(kMsgAppFlagsChanged)); fExclusiveLaunchButton->ResizeToPreferred(); box->AddChild(fExclusiveLaunchButton); rect.top = fSingleLaunchButton->Frame().top; rect.left = fExclusiveLaunchButton->Frame().right + 4.0f; fArgsOnlyCheckBox = new BCheckBox(rect, "args only", "Args only", new BMessage(kMsgAppFlagsChanged)); fArgsOnlyCheckBox->ResizeToPreferred(); box->AddChild(fArgsOnlyCheckBox); rect.top += fArgsOnlyCheckBox->Bounds().Height(); fBackgroundAppCheckBox = new BCheckBox(rect, "background", "Background app", new BMessage(kMsgAppFlagsChanged)); fBackgroundAppCheckBox->ResizeToPreferred(); box->AddChild(fBackgroundAppCheckBox); box->ResizeTo(box->Bounds().Width(), fExclusiveLaunchButton->Frame().bottom + 8.0f); // "Icon" group rect = box->Frame(); #ifdef __ANTARES__ rect.top += box->TopBorderOffset(); #endif rect.left = rect.right + 8.0f; rect.right += width + 8.0f; float iconBoxWidth = rect.Width(); box = new BBox(rect, NULL, B_FOLLOW_RIGHT | B_FOLLOW_TOP); box->SetLabel("Icon"); #ifdef __ANTARES__ box->MoveBy(0.0f, -box->TopBorderOffset()); box->ResizeBy(0.0f, box->TopBorderOffset()); #endif topView->AddChild(box); rect = BRect(8.0f, 0.0f, 7.0f + B_LARGE_ICON, B_LARGE_ICON - 1.0f); #ifdef __ANTARES__ rect.OffsetBy(0.0f, (box->Bounds().Height() + box->TopBorderOffset() - rect.Height()) / 2.0f); #else rect.OffsetBy(0.0f, (box->Bounds().Height() - rect.Height()) / 2.0f); #endif if (rect.top < fontHeight.ascent + fontHeight.descent + 4.0f) rect.top = fontHeight.ascent + fontHeight.descent + 4.0f; fIconView = new IconView(rect, "icon"); fIconView->SetModificationMessage(new BMessage(kMsgIconChanged)); box->AddChild(fIconView); // "Supported Types" group rect.top = box->Frame().bottom + 8.0f; rect.bottom = rect.top + box->Bounds().Height(); rect.left = 8.0f; rect.right = Bounds().Width() - 8.0f; BBox* typeBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); typeBox->SetLabel("Supported types"); topView->AddChild(typeBox); rect = typeBox->Bounds().InsetByCopy(8.0f, 6.0f); rect.top += ceilf(fontHeight.ascent); fAddTypeButton = new BButton(rect, "add type", "Add" B_UTF8_ELLIPSIS, new BMessage(kMsgAddType), B_FOLLOW_RIGHT); fAddTypeButton->ResizeToPreferred(); fAddTypeButton->MoveBy(rect.right - fAddTypeButton->Bounds().Width() - B_LARGE_ICON - 16.0f, 0.0f); typeBox->AddChild(fAddTypeButton); rect = fAddTypeButton->Frame(); rect.OffsetBy(0, rect.Height() + 4.0f); fRemoveTypeButton = new BButton(rect, "remove type", "Remove", new BMessage(kMsgRemoveType), B_FOLLOW_RIGHT); typeBox->AddChild(fRemoveTypeButton); rect.right = rect.left - 10.0f - B_V_SCROLL_BAR_WIDTH; rect.left = 10.0f; rect.top = 8.0f + ceilf(fontHeight.ascent); rect.bottom -= 2.0f; // take scrollview border into account fTypeListView = new SupportedTypeListView(rect, "type listview", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL); fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected)); BScrollView* scrollView = new BScrollView("type scrollview", fTypeListView, B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW, false, true); typeBox->ResizeTo(typeBox->Bounds().Width(), fRemoveTypeButton->Frame().bottom + 8.0f); typeBox->AddChild(scrollView); rect.left = fRemoveTypeButton->Frame().right + 8.0f; #ifdef __ANTARES__ rect.top = (box->Bounds().Height() + box->TopBorderOffset() - B_LARGE_ICON) / 2.0f; #else rect.top = (box->Bounds().Height() - B_LARGE_ICON) / 2.0f; #endif rect.right = rect.left + B_LARGE_ICON - 1.0f; rect.bottom = rect.top + B_LARGE_ICON - 1.0f; fTypeIconView = new IconView(rect, "type icon", B_FOLLOW_RIGHT | B_FOLLOW_TOP); fTypeIconView->SetModificationMessage(new BMessage(kMsgTypeIconsChanged)); typeBox->AddChild(fTypeIconView); // "Version Info" group rect.top = typeBox->Frame().bottom + 8.0f; rect.bottom = rect.top + typeBox->Bounds().Height(); rect.left = 8.0f; rect.right = Bounds().Width() - 8.0f; box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); // the resizing mode will later also be set to B_FOLLOW_BOTTOM box->SetLabel("Version info"); topView->AddChild(box); BMenuField* menuField; #if 0 BPopUpMenu *popUpMenu = new BPopUpMenu("version info", true, true); item = new BMenuItem("Version Info", NULL); item->SetMarked(true); popUpMenu->AddItem(item); item = new BMenuItem("System Version Info", NULL); popUpMenu->AddItem(item); menuField = new BMenuField(BRect(0, 0, 100, 15), "version kind", NULL, popUpMenu, true); menuField->ResizeToPreferred(); box->SetLabel(menuField); #endif rect.top = 4.0f + ceilf(fontHeight.ascent + fontHeight.descent); rect.bottom = rect.top + height; fMajorVersionControl = new BTextControl(rect, "major", "Version:", NULL, NULL); fMajorVersionControl->SetDivider(fMajorVersionControl->StringWidth( fMajorVersionControl->Label()) + 4.0f); fMajorVersionControl->GetPreferredSize(&width, &height); width = 12.0f + fMajorVersionControl->StringWidth("99"); fMajorVersionControl->ResizeTo(fMajorVersionControl->Divider() + width, height); _MakeNumberTextControl(fMajorVersionControl); box->AddChild(fMajorVersionControl); rect.left = fMajorVersionControl->Frame().right + 1.0f; fMiddleVersionControl = new BTextControl(rect, "middle", ".", NULL, NULL); fMiddleVersionControl->SetDivider(fMiddleVersionControl->StringWidth( fMiddleVersionControl->Label()) + 4.0f); fMiddleVersionControl->ResizeTo(fMiddleVersionControl->Divider() + width, height); _MakeNumberTextControl(fMiddleVersionControl); box->AddChild(fMiddleVersionControl); rect.left = fMiddleVersionControl->Frame().right + 1.0f; fMinorVersionControl = new BTextControl(rect, "middle", ".", NULL, NULL); fMinorVersionControl->SetDivider(fMinorVersionControl->StringWidth( fMinorVersionControl->Label()) + 4.0f); fMinorVersionControl->ResizeTo(fMinorVersionControl->Divider() + width, height); _MakeNumberTextControl(fMinorVersionControl); box->AddChild(fMinorVersionControl); fVarietyMenu = new BPopUpMenu("variety", true, true); fVarietyMenu->AddItem(new BMenuItem("Development", NULL)); fVarietyMenu->AddItem(new BMenuItem("Alpha", NULL)); fVarietyMenu->AddItem(new BMenuItem("Beta", NULL)); fVarietyMenu->AddItem(new BMenuItem("Gamma", NULL)); fVarietyMenu->AddItem(item = new BMenuItem("Golden master", NULL)); item->SetMarked(true); fVarietyMenu->AddItem(new BMenuItem("Final", NULL)); rect.top--; // BMenuField oddity rect.left = fMinorVersionControl->Frame().right + 6.0f; menuField = new BMenuField(rect, "variety", NULL, fVarietyMenu, true); menuField->ResizeToPreferred(); box->AddChild(menuField); rect.top++; rect.left = menuField->Frame().right; rect.right = rect.left + 30.0f; fInternalVersionControl = new BTextControl(rect, "internal", "/", NULL, NULL); fInternalVersionControl->SetDivider(fInternalVersionControl->StringWidth( fInternalVersionControl->Label()) + 4.0f); fInternalVersionControl->ResizeTo(fInternalVersionControl->Divider() + width, height); box->AddChild(fInternalVersionControl); rect = box->Bounds().InsetByCopy(8.0f, 0.0f); rect.top = fInternalVersionControl->Frame().bottom + 8.0f; fShortDescriptionControl = new BTextControl(rect, "short desc", "Short description:", NULL, NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); float labelWidth = fShortDescriptionControl->StringWidth( fShortDescriptionControl->Label()) + 4.0f; fShortDescriptionControl->SetDivider(labelWidth); fShortDescriptionControl->GetPreferredSize(&width, &height); fShortDescriptionControl->ResizeTo(rect.Width(), height); // TODO: workaround for a GCC 4.1.0 bug? Or is that really what the standard says? version_info versionInfo; fShortDescriptionControl->TextView()->SetMaxBytes(sizeof(versionInfo.short_info)); box->AddChild(fShortDescriptionControl); rect.OffsetBy(0.0f, fShortDescriptionControl->Bounds().Height() + 5.0f); rect.right = rect.left + labelWidth; StringView* label = new StringView(rect, NULL, "Long description:", NULL); label->SetDivider(labelWidth); box->AddChild(label); rect.left = rect.right + 3.0f; rect.top += 1.0f; rect.right = box->Bounds().Width() - 10.0f - B_V_SCROLL_BAR_WIDTH; rect.bottom = rect.top + fShortDescriptionControl->Bounds().Height() * 3.0f - 1.0f; fLongDescriptionView = new TabFilteringTextView(rect, "long desc", rect.OffsetToCopy(B_ORIGIN), B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE); fLongDescriptionView->SetMaxBytes(sizeof(versionInfo.long_info)); scrollView = new BScrollView("desc scrollview", fLongDescriptionView, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_FRAME_EVENTS | B_WILL_DRAW, false, true); box->ResizeTo(box->Bounds().Width(), scrollView->Frame().bottom + 8.0f); box->AddChild(scrollView); // Adjust window size and limits width = fInternalVersionControl->Frame().right + 16.0f; float minWidth = fBackgroundAppCheckBox->Frame().right + iconBoxWidth + 32.0f; if (width > minWidth) minWidth = width; ResizeTo(Bounds().Width() > minWidth ? Bounds().Width() : minWidth, box->Frame().bottom + topView->Frame().top + 8.0f); SetSizeLimits(minWidth, 32767.0f, Bounds().Height(), 32767.0f); typeBox->SetResizingMode(B_FOLLOW_ALL); box->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM); fSignatureControl->MakeFocus(true); BMimeType::StartWatching(this); _SetTo(entry); }
status_t BIconButton::SetIcon(const unsigned char* bitsFromQuickRes, uint32 width, uint32 height, color_space format, bool convertToBW) { status_t status = B_BAD_VALUE; if (bitsFromQuickRes && width > 0 && height > 0) { BBitmap* quickResBitmap = new(std::nothrow) BBitmap(BRect(0.0, 0.0, width - 1.0, height - 1.0), format); status = quickResBitmap ? quickResBitmap->InitCheck() : B_ERROR; if (status >= B_OK) { // It doesn't look right to copy BitsLength() bytes, but bitmaps // exported from QuickRes still contain their padding, so it is // all right. memcpy(quickResBitmap->Bits(), bitsFromQuickRes, quickResBitmap->BitsLength()); if (format != B_RGB32 && format != B_RGBA32 && format != B_RGB32_BIG && format != B_RGBA32_BIG) { // colorspace needs conversion BBitmap* bitmap = new(std::nothrow) BBitmap( quickResBitmap->Bounds(), B_RGB32, true); if (bitmap && bitmap->IsValid()) { BView* helper = new BView(bitmap->Bounds(), "helper", B_FOLLOW_NONE, B_WILL_DRAW); if (bitmap->Lock()) { bitmap->AddChild(helper); helper->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); helper->FillRect(helper->Bounds()); helper->SetDrawingMode(B_OP_OVER); helper->DrawBitmap(quickResBitmap, BPoint(0.0, 0.0)); helper->Sync(); bitmap->Unlock(); } status = _MakeBitmaps(bitmap); } else { printf("BIconButton::SetIcon() - B_RGB32 bitmap is not " "valid\n"); } delete bitmap; } else { // native colorspace (32 bits) if (convertToBW) { // convert to gray scale icon uint8* bits = (uint8*)quickResBitmap->Bits(); uint32 bpr = quickResBitmap->BytesPerRow(); for (uint32 y = 0; y < height; y++) { uint8* handle = bits; uint8 gray; for (uint32 x = 0; x < width; x++) { gray = uint8((116 * handle[0] + 600 * handle[1] + 308 * handle[2]) / 1024); handle[0] = gray; handle[1] = gray; handle[2] = gray; handle += 4; } bits += bpr; } } status = _MakeBitmaps(quickResBitmap); } } else { printf("BIconButton::SetIcon() - error allocating bitmap: " "%s\n", strerror(status)); } delete quickResBitmap; } return status; }
SudokuWindow::SudokuWindow() : BWindow(BRect(100, 100, 500, 520), B_TRANSLATE_SYSTEM_NAME("Sudoku"), B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE), fGenerator(NULL), fStoredState(NULL), fExportFormat(kExportAsText) { BMessage settings; _LoadSettings(settings); BRect frame; if (settings.FindRect("window frame", &frame) == B_OK) { MoveTo(frame.LeftTop()); ResizeTo(frame.Width(), frame.Height()); frame.OffsetTo(B_ORIGIN); } else frame = Bounds(); if (settings.HasMessage("stored state")) { fStoredState = new BMessage; if (settings.FindMessage("stored state", fStoredState) != B_OK) { delete fStoredState; fStoredState = NULL; } } int32 level = 0; settings.FindInt32("level", &level); // create GUI BMenuBar* menuBar = new BMenuBar(Bounds(), "menu"); AddChild(menuBar); frame.top = menuBar->Frame().bottom; BView* top = new BView(frame, NULL, B_FOLLOW_ALL, B_WILL_DRAW); top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(top); fSudokuView = new SudokuView( top->Bounds().InsetByCopy(10, 10).OffsetToSelf(0, 0), "sudoku view", settings, B_FOLLOW_NONE); CenteredViewContainer* container = new CenteredViewContainer(fSudokuView, top->Bounds().InsetByCopy(10, 10), "center", B_FOLLOW_ALL); container->SetHighColor(top->ViewColor()); top->AddChild(container); // add menu // "File" menu BMenu* menu = new BMenu(B_TRANSLATE("File")); fNewMenu = new BMenu(B_TRANSLATE("New")); menu->AddItem(new BMenuItem(fNewMenu, new BMessage(kMsgGenerateSudoku))); fNewMenu->Superitem()->SetShortcut('N', B_COMMAND_KEY); BMessage* message = new BMessage(kMsgGenerateSudoku); message->AddInt32("level", kEasyLevel); fNewMenu->AddItem(new BMenuItem(B_TRANSLATE("Easy"), message)); message = new BMessage(kMsgGenerateSudoku); message->AddInt32("level", kAdvancedLevel); fNewMenu->AddItem(new BMenuItem(B_TRANSLATE("Advanced"), message)); message = new BMessage(kMsgGenerateSudoku); message->AddInt32("level", kHardLevel); fNewMenu->AddItem(new BMenuItem(B_TRANSLATE("Hard"), message)); fNewMenu->AddSeparatorItem(); fNewMenu->AddItem(new BMenuItem(B_TRANSLATE("Blank"), new BMessage(kMsgNewBlank))); menu->AddItem(new BMenuItem(B_TRANSLATE("Start again"), new BMessage(kMsgStartAgain))); menu->AddSeparatorItem(); BMenu* recentsMenu = BRecentFilesList::NewFileListMenu( B_TRANSLATE("Open file" B_UTF8_ELLIPSIS), NULL, NULL, this, 10, false, NULL, kSignature); BMenuItem *item; menu->AddItem(item = new BMenuItem(recentsMenu, new BMessage(kMsgOpenFilePanel))); item->SetShortcut('O', B_COMMAND_KEY); menu->AddSeparatorItem(); BMenu* subMenu = new BMenu(B_TRANSLATE("Export as" B_UTF8_ELLIPSIS)); message = new BMessage(kMsgExportAs); message->AddInt32("as", kExportAsText); subMenu->AddItem(new BMenuItem(B_TRANSLATE("Text"), message)); message= new BMessage(kMsgExportAs); message->AddInt32("as", kExportAsHTML); subMenu->AddItem(new BMenuItem(B_TRANSLATE("HTML"), message)); menu->AddItem(subMenu); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Copy"), new BMessage(B_COPY), 'C')); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED), 'Q')); menu->SetTargetForItems(this); item->SetTarget(be_app); menuBar->AddItem(menu); // "View" menu menu = new BMenu(B_TRANSLATE("View")); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Mark invalid values"), new BMessage(kMsgMarkInvalid))); if ((fSudokuView->HintFlags() & kMarkInvalid) != 0) item->SetMarked(true); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Mark valid hints"), new BMessage(kMsgMarkValidHints))); if ((fSudokuView->HintFlags() & kMarkValidHints) != 0) item->SetMarked(true); menu->SetTargetForItems(this); menuBar->AddItem(menu); // "Help" menu menu = new BMenu(B_TRANSLATE("Help")); menu->AddItem(fUndoItem = new BMenuItem(B_TRANSLATE("Undo"), new BMessage(B_UNDO), 'Z')); fUndoItem->SetEnabled(false); menu->AddItem(fRedoItem = new BMenuItem(B_TRANSLATE("Redo"), new BMessage(B_REDO), 'Z', B_SHIFT_KEY)); fRedoItem->SetEnabled(false); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Snapshot current"), new BMessage(kMsgStoreState))); menu->AddItem(fRestoreStateItem = new BMenuItem( B_TRANSLATE("Restore snapshot"), new BMessage(kMsgRestoreState))); fRestoreStateItem->SetEnabled(fStoredState != NULL); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Set all hints"), new BMessage(kMsgSetAllHints))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Solve"), new BMessage(kMsgSolveSudoku))); menu->AddItem(new BMenuItem(B_TRANSLATE("Solve single field"), new BMessage(kMsgSolveSingle))); menu->SetTargetForItems(fSudokuView); menuBar->AddItem(menu); fOpenPanel = new BFilePanel(B_OPEN_PANEL); fOpenPanel->SetTarget(this); fSavePanel = new BFilePanel(B_SAVE_PANEL); fSavePanel->SetTarget(this); _SetLevel(level); fSudokuView->StartWatching(this, kUndoRedoChanged); // we like to know whenever the undo/redo state changes fProgressWindow = new ProgressWindow(this, new BMessage(kMsgAbortSudokuGenerator)); if (fSudokuView->Field()->IsEmpty()) PostMessage(kMsgGenerateSudoku); }