BooleanEditor::BooleanEditor(BRect rect, DataEditor &editor) : TypeEditorView(rect, B_TRANSLATE("Boolean editor"), B_FOLLOW_NONE, 0, editor) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BPopUpMenu *menu = new BPopUpMenu("bool"); BMessage *message; menu->AddItem(fFalseMenuItem = new BMenuItem("false", new BMessage(kMsgValueChanged))); menu->AddItem(fTrueMenuItem = new BMenuItem("true", message = new BMessage(kMsgValueChanged))); message->AddInt8("value", 1); BMenuField *menuField = new BMenuField(rect.InsetByCopy(5, 5), B_EMPTY_STRING, B_TRANSLATE("Boolean value:"), menu, B_FOLLOW_LEFT_RIGHT); menuField->SetDivider(StringWidth(menuField->Label()) + 8); menuField->ResizeToPreferred(); ResizeTo(menuField->Bounds().Width() + 10, menuField->Bounds().Height() + 10); _UpdateMenuField(); AddChild(menuField); }
FindWindow::FindWindow(BRect _rect, BMessage& previous, BMessenger& target, const BMessage* settings) : BWindow(_rect, B_TRANSLATE("Find"), B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_CLOSE_ON_ESCAPE), fTarget(target) { BView* view = new BView(Bounds(), "main", B_FOLLOW_ALL, 0); view->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); AddChild(view); int8 mode = kAsciiMode; if (previous.FindInt8("find_mode", &mode) != B_OK && settings != NULL) settings->FindInt8("find_mode", &mode); // add the top widgets fMenu = new BPopUpMenu("mode"); BMessage* message; BMenuItem* item; fMenu->AddItem(item = new BMenuItem(B_TRANSLATE("Text"), message = new BMessage(kMsgFindMode))); message->AddInt8("mode", kAsciiMode); if (mode == kAsciiMode) item->SetMarked(true); fMenu->AddItem(item = new BMenuItem(B_TRANSLATE_COMMENT("Hexadecimal", "A menu item, as short as possible, noun is recommended if it is " "shorter than adjective."), message = new BMessage(kMsgFindMode))); message->AddInt8("mode", kHexMode); if (mode == kHexMode) item->SetMarked(true); BRect rect = Bounds().InsetByCopy(5, 5); BMenuField* menuField = new BMenuField(rect, B_EMPTY_STRING, B_TRANSLATE("Mode:"), fMenu, B_FOLLOW_LEFT | B_FOLLOW_TOP); menuField->SetDivider(menuField->StringWidth(menuField->Label()) + 8); menuField->ResizeToPreferred(); view->AddChild(menuField); // add the bottom widgets BButton* button = new BButton(rect, B_EMPTY_STRING, B_TRANSLATE("Find"), new BMessage(kMsgStartFind), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); button->MakeDefault(true); button->ResizeToPreferred(); button->MoveTo(rect.right - button->Bounds().Width(), rect.bottom - button->Bounds().Height()); view->AddChild(button); fCaseCheckBox = new BCheckBox(rect, B_EMPTY_STRING, B_TRANSLATE("Case sensitive"), NULL, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); fCaseCheckBox->ResizeToPreferred(); fCaseCheckBox->MoveTo(5, button->Frame().top); bool caseSensitive; if (previous.FindBool("case_sensitive", &caseSensitive) != B_OK) { if (settings == NULL || settings->FindBool("case_sensitive", &caseSensitive) != B_OK) caseSensitive = true; } fCaseCheckBox->SetValue(caseSensitive); view->AddChild(fCaseCheckBox); // and now those inbetween rect.top = menuField->Frame().bottom + 5; rect.bottom = fCaseCheckBox->Frame().top - 8; rect.InsetBy(2, 2); fTextView = new FindTextView(rect, B_EMPTY_STRING, rect.OffsetToCopy(B_ORIGIN).InsetByCopy(3, 3), B_FOLLOW_ALL); fTextView->SetWordWrap(true); fTextView->SetMode((find_mode)mode); fTextView->SetData(previous); BScrollView* scrollView = new BScrollView("scroller", fTextView, B_FOLLOW_ALL, B_WILL_DRAW, false, false); view->AddChild(scrollView); ResizeTo(290, button->Frame().Height() * 3 + 30); SetSizeLimits(fCaseCheckBox->Bounds().Width() + button->Bounds().Width() + 20, 32768, button->Frame().Height() * 3 + 10, 32768); }
void CPrefsDialog::PostInit() { BAutolock lock(this); strcpy(fNewFontFamily, gPrefs->GetPrefString("defdoc font family", NULL)); fNewFontSize = gPrefs->GetPrefDouble("defdoc font size", 0.0); strcpy(fNewBFontFamily, gPrefs->GetPrefString("border font family", NULL)); fNewBFontSize = gPrefs->GetPrefDouble("border font size", 0.0); CellStyle cs; font_style style; fOwner->GetCellView()->GetContainer()->GetDefaultCellStyle(cs); try { gFontSizeTable.GetFontInfo(cs.fFont, &fDocFontFamily, &style, &fDocFontSize); gFontSizeTable.GetFontInfo(fOwner->GetCellView()->BorderFontID(), &fDocBFontFamily, &style, &fDocBFontSize); } catch (CErr& e) { e.DoError(); } BMenuField *mf = dynamic_cast<BMenuField*>(FindView("docfont")); fDocFont = mf->Menu(); if (fDocFont) { for (long i = 0; i < count_font_families(); i++) { font_family ff; get_font_family(i, &ff); fDocFont->AddItem(new BMenuItem(ff, new BMessage(msg_Changed))); } fDocFont->SetRadioMode(TRUE); } mf = dynamic_cast<BMenuField*>(FindView("borderfont")); fBorderFont = mf->Menu(); for (long i = 0; i < count_font_families(); i++) { font_family ff; get_font_family(i, &ff); fBorderFont->AddItem(new BMenuItem(ff, new BMessage(msg_Changed))); } fBorderFont->SetRadioMode(TRUE); mf = dynamic_cast<BMenuField*>(FindView("dateorder")); fDMY = mf->Menu(); fDMY->AddItem(new BMenuItem("dmy", new BMessage(msg_Changed))); fDMY->AddItem(new BMenuItem("dym", new BMessage(msg_Changed))); fDMY->AddItem(new BMenuItem("mdy", new BMessage(msg_Changed))); fDMY->AddItem(new BMenuItem("myd", new BMessage(msg_Changed))); fDMY->AddItem(new BMenuItem("ydm", new BMessage(msg_Changed))); fDMY->AddItem(new BMenuItem("ymd", new BMessage(msg_Changed))); mf = dynamic_cast<BMenuField*>(FindView("neworcur")); if (mf) { fNewOrCur = mf->Menu(); fNewOrCur->AddItem(new BMenuItem("New Documents", new BMessage(msg_ChangeTarget))); if (fOwner) { char s[32]; fDocFont->FindItem(fDocFontFamily)->SetMarked(true); ftoa(fDocFontSize, s); SetText("docsize", s); fBorderFont->FindItem(fDocBFontFamily)->SetMarked(true); ftoa(fDocBFontSize, s); SetText("bordersize", s); fNewOrCur->AddItem(new BMenuItem(fOwner->Title(), new BMessage(msg_ChangeTarget))); fNewOrCur->ItemAt(1)->SetMarked(true); } else fNewOrCur->ItemAt(0)->SetMarked(true); mf->SetDivider(be_plain_font->StringWidth(mf->Label()) + 4); } BBox *b; BView *v; v = FindView("prgrid"); b = dynamic_cast<BBox*>(v->Parent()); if (b) { char t[256]; sprintf(t, b->Label(), fOwner->Title()); b->SetLabel(t); } fAutoRecalc = fOwner->GetCellView()->DoesAutoRecalc(); fDisplayZero = fOwner->GetCellView()->DoesDisplayZero(); fPrGrid = fOwner->GetCellView()->PrintsGrid(); fPrBorders = fOwner->GetCellView()->PrintsBorders(); fShGrid = fOwner->GetCellView()->ShowsGrid(); fShBorders = fOwner->GetCellView()->ShowsBorders(); CancelClicked(); Show(); } /* CPrefsDialog::PostInit */
tabTowar::tabTowar(BTabView *tv, sqlite *db, BHandler *hr) : beFakTab(tv, db, hr) { curdata = new towardat(db); this->dirty = false; this->tab->SetLabel("Towary [F3]"); BRect r; r = this->view->Bounds(); // columnlistview r.left = 5; r.right = 160; r.top = 30; r.bottom = 490; CLVContainerView *containerView; list = new ColumnListView(r, &containerView, NULL, B_FOLLOW_LEFT|B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW|B_FRAME_EVENTS|B_NAVIGABLE, B_SINGLE_SELECTION_LIST, false, true, true, true, B_FANCY_BORDER); list->AddColumn(new CLVColumn("Symbol", 54, CLV_TELL_ITEMS_WIDTH|CLV_HEADER_TRUNCATE|CLV_SORT_KEYABLE)); list->AddColumn(new CLVColumn("Nazwa", 100, CLV_TELL_ITEMS_WIDTH|CLV_HEADER_TRUNCATE|CLV_SORT_KEYABLE)); list->SetSortFunction(CLVEasyItem::CompareItems); this->view->AddChild(containerView); list->SetInvocationMessage(new BMessage(LIST_INV)); list->SetSelectionMessage(new BMessage(LIST_SEL)); // buttons but_new = new BButton(BRect(30,0,140,24), "tt_but_new", "Nowy towar [F5]", new BMessage(BUT_NEW), B_FOLLOW_LEFT|B_FOLLOW_TOP); but_del = new BButton(BRect(30,510,140,534), "tt_but_del", "Usuń zaznaczone [F8]", new BMessage(BUT_DEL), B_FOLLOW_LEFT|B_FOLLOW_BOTTOM); but_restore = new BButton(BRect(235,510,325,534), "tt_but_restore", "Przywróć [F6]", new BMessage(BUT_RESTORE), B_FOLLOW_LEFT|B_FOLLOW_BOTTOM); but_save = new BButton(BRect(580,510,670,534), "tt_but_save", "Zapisz", new BMessage(BUT_SAVE), B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM); this->view->AddChild(but_new); this->view->AddChild(but_del); this->view->AddChild(but_restore); this->view->AddChild(but_save); but_new->ResizeToPreferred(); but_del->ResizeToPreferred(); but_restore->ResizeToPreferred(); but_save->ResizeToPreferred(); // box1 box1 = new BBox(BRect(230,30,710,140), "tt_box1"); box1->SetLabel("Dane towaru"); this->view->AddChild(box1); // box1-stuff data[0] = new BTextControl(BRect(10,15,270,35), "ttd0", "Nazwa", NULL, new BMessage(DC)); data[1] = new BTextControl(BRect(280,15,420,35), "ttd1", "Symbol", NULL, new BMessage(DC)); data[2] = new BTextControl(BRect(10,50,150,65), "ttd2", "PKWiU", NULL, new BMessage(DC)); data[3] = new BTextControl(BRect(160,50,270,65), "ttd3", "j.m.", NULL, new BMessage(DC)); box1->AddChild(data[0]); box1->AddChild(data[1]); box1->AddChild(data[2]); box1->AddChild(data[3]); usluga = new BCheckBox(BRect(350,50,420,65), "ttdo", "Usługa", new BMessage(DC)); box1->AddChild(usluga); dodany = new BStringView(BRect(280,80,340,95), "tts0", "Dodano:"); dodany->SetAlignment(B_ALIGN_RIGHT); box1->AddChild(dodany); dodany = new BStringView(BRect(350,80,420,95), "ttsd", ""); box1->AddChild(dodany); // box1-menu BMenu *menujm = new BMenu(""); BMessage *msg; int j=0; while (jmiary[j] != NULL) { msg = new BMessage(MENUJM); msg->AddString("_jm",jmiary[j]); menujm->AddItem(new BMenuItem(jmiary[j], msg)); j++; } BMenuField *menujmField = new BMenuField(BRect(280,50,340,65), "ttmf", NULL, menujm); box1->AddChild(menujmField); // box2 box2 = new BBox(BRect(230,150,710,300), "tt_box2"); box2->SetLabel("Ceny"); this->view->AddChild(box2); // box2-stuff ceny[0] = new BTextControl(BRect(10,15,190,35), "ttc0", "Cena netto (zł)", NULL, new BMessage(DC)); ceny[1] = new BTextControl(BRect(10,50,190,65), "ttc1", "Netto zakupu", NULL, new BMessage(DC)); ceny[2] = new BTextControl(BRect(10,80,190,95), "ttc2", "Marża (%)", NULL, new BMessage(DC)); ceny[3] = new BTextControl(BRect(200,50,310,65), "ttc3", "Rabat (%)", NULL, new BMessage(DC)); ceny[4] = new BTextControl(BRect(10,110,190,125), "ttc4", "Kurs waluty", "1", new BMessage(DC)); ceny[5] = new BTextControl(BRect(200,110,310,125), "ttc5", "Cło (%)", NULL, new BMessage(DC)); box2->AddChild(ceny[0]); box2->AddChild(ceny[1]); box2->AddChild(ceny[2]); box2->AddChild(ceny[3]); box2->AddChild(ceny[4]); box2->AddChild(ceny[5]); but_sell = new BButton(BRect(340,50,420,65), "tt_but_sell", "Cena sprzedaży", new BMessage(BUT_SELL)); but_marza = new BButton(BRect(340,80,420,95), "tt_but_marza", "Marża", new BMessage(BUT_MARZA)); but_import = new BButton(BRect(340,110,420,125), "tt_but_import", "Import", new BMessage(BUT_IMPORT)); box2->AddChild(but_sell); box2->AddChild(but_marza); box2->AddChild(but_import); but_sell->ResizeToPreferred(); but_marza->ResizeToPreferred(); but_import->ResizeToPreferred(); brutto = new BStringView(BRect(330,15,390,35), "ttb0", "Cena brutto:"); box2->AddChild(brutto); brutto = new BStringView(BRect(400,15,475,35), "ttbr", NULL); box2->AddChild(brutto); // box2-menu menuvat = new BPopUpMenu("[wybierz]"); vatRows = 0; vatIds = NULL; RefreshVatSymbols(); BMenuField *menuvatField = new BMenuField(BRect(200,15,330,35), "ttmv", "VAT", menuvat); menuvatField->SetDivider(be_plain_font->StringWidth(menuvatField->Label())+15); box2->AddChild(menuvatField); // box3 box3 = new BBox(BRect(230,310,710,390), "tt_box3"); box3->SetLabel("Magazyn"); this->view->AddChild(box3); // box3-stuff magazyn = new BTextControl(BRect(10,30,250,40), "ttm0", "Stan:", NULL, new BMessage(DC)); magzmiana = new BStringView(BRect(230,30,370,45), "ttm1", "Ostatnia zmiana:"); magzmiana->SetAlignment(B_ALIGN_RIGHT); box3->AddChild(magzmiana); magzmiana = new BStringView(BRect(380,35,470,45), "ttm2", NULL); box3->AddChild(magzmiana); box3->AddChild(magazyn); // box4 box4 = new BBox(BRect(230,400,710,480), "tt_box4"); box4->SetLabel("Notatki"); this->view->AddChild(box4); // box4-stuff r = box4->Bounds(); r.InsetBy(10,15); BRect s = r; s.OffsetTo(0,0); notatki = new BTextView(r, "ttno", s, B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW); box4->AddChild(notatki); // fix widths int i; // first set them to be enough for (i=0;i<=3;i++) { data[i]->SetDivider(be_plain_font->StringWidth(data[i]->Label())+5); } for (i=0;i<=5;i++) { ceny[i]->SetDivider(be_plain_font->StringWidth(ceny[i]->Label())+5); } magazyn->SetDivider(be_plain_font->StringWidth(magazyn->Label())+5); // align in columns float d; d = max(data[0]->Divider(), data[2]->Divider()); data[0]->SetDivider(d); data[2]->SetDivider(d); d = max(ceny[0]->Divider(), ceny[1]->Divider()); d = max(ceny[2]->Divider(), d); d = max(ceny[4]->Divider(), d); ceny[0]->SetDivider(d); ceny[1]->SetDivider(d); ceny[2]->SetDivider(d); ceny[4]->SetDivider(d); // but_save->MakeDefault(true); updateTab(); RefreshIndexList(); }