PersonWindow* TPeopleApp::_NewWindow(const entry_ref* ref, BFile* file) { BRawContact* rawContact; if (file == NULL) rawContact = new BRawContact(B_CONTACT_FORMAT); else rawContact = new BRawContact(B_CONTACT_ANY, file); BContact* contact = new BContact(rawContact); if (contact->InitCheck() != B_OK) { BAlert *alert = new BAlert("Alert", B_TRANSLATE("Contact initialization failed!."),"OK"); alert->Go(); return NULL; } PersonWindow* window = new PersonWindow(fPosition, B_TRANSLATE("New contact"), ref, file, contact); window->Show(); window->Activate(true); fWindowCount++; // Offset the position for the next window which will be opened and // reset it if it would open outside the screen bounds. fPosition.OffsetBy(20, 20); BScreen screen(window); if (fPosition.bottom > screen.Frame().bottom) fPosition.OffsetTo(fPosition.left, TITLE_BAR_HEIGHT); if (fPosition.right > screen.Frame().right) fPosition.OffsetTo(6, fPosition.top); return window; }
PersonWindow* TPeopleApp::_NewWindow(const entry_ref* ref, BFile* file) { BRawContact* rawContact; if (file == NULL) rawContact = new BRawContact(B_CONTACT_FORMAT, NULL); else rawContact = new BRawContact(B_CONTACT_ANY, file); BContact* contact = new BContact(rawContact); //ObjectDeleter<BContact> deleter(contact); if (contact->InitCheck() != B_OK) { printf("BContact initcheck error\n"); // BAlert here return NULL; } PersonWindow* window = new PersonWindow(BRect(50, 50, 300, 400), B_TRANSLATE("New contact"), ref, contact); window->Show(); fWindowCount++; // Offset the position for the next window which will be opened and // reset it if it would open outside the screen bounds. /*fPosition.OffsetBy(20, 20); BScreen screen(window); if (fPosition.bottom > screen.Frame().bottom) fPosition.OffsetTo(fPosition.left, TITLE_BAR_HEIGHT); if (fPosition.right > screen.Frame().right) fPosition.OffsetTo(6, fPosition.top);*/ return window; }