Ticket #2827: 2827.diff

File 2827.diff, 4.1 KB (added by maxime.simon, 15 years ago)
  • Sources/CDoc.cpp

     
    261261void CDoc::SaveACopy()
    262262{
    263263    if (!fSavePanel)
    264         fSavePanel = new BFilePanel(B_SAVE_PANEL);
     264        CreateFilePanel();
    265265
    266     FailNil(fSavePanel);
    267 
    268266    BWindow *w = fSavePanel->Window();
    269267    w->Lock();
    270268
  • Sources/PDoc.cpp

     
    866866{
    867867    inherited::CreateFilePanel();
    868868
    869     BWindow *w = fSavePanel->Window();
    870     BAutolock lock(w);
     869    BWindow *savePanel = fSavePanel->Window();
     870    BAutolock lock(savePanel);
    871871
    872872    if (lock.IsLocked())
    873873    {
    874         BView *vw = w->ChildAt(0);
    875         FailNilMsg(vw, "Error building FilePanel");
     874        BView *background = savePanel->ChildAt(0);
     875        FailNilMsg(background, "Error building FilePanel");
     876       
     877        BButton *cancel = dynamic_cast<BButton*>(background->FindView("cancel button"));
     878        FailNilMsg(cancel, "Error building FilePanel");
     879       
     880        BView *textview = background->FindView("text view");
     881        FailNilMsg(textview, "Error building FilePanel");
    876882
    877         BMenu *m = HResources::GetMenu(rid_Menu_FpMimetypes, true);
    878         FailNilMsg(m, "Error building FilePanel");
    879         m->SetFont(be_plain_font);
    880         m->SetRadioMode(true);
     883        BMenu *menu = HResources::GetMenu(rid_Menu_FpMimetypes, true);
     884        FailNilMsg(menu, "Error building FilePanel");
     885        menu->SetFont(be_plain_font);
     886        menu->SetRadioMode(true);
    881887
    882         BView *v = vw->FindView("text view");
    883         FailNilMsg(v, "Error building FilePanel");
    884         BRect r = v->Frame();
    885         v->ResizeTo(r.Width() - 50, r.Height());
     888        BRect rect = textview->Frame();
     889        rect.top = cancel->Frame().top;
     890        font_height fh;
     891        rect.bottom = rect.top + fh.descent + fh.ascent + 5.0;
    886892
    887         r.left = r.right - 45;
    888         r.right = r.left + 100;
    889         r.top += (r.Height() - 20) / 2;
     893        BMenuField *menuField = new BMenuField(rect, "mime", "Type:",
     894            menu, B_FOLLOW_BOTTOM | B_FOLLOW_LEFT);
     895        FailNilMsg(menuField, "Error building FilePanel");
     896        menuField->SetDivider(be_plain_font->StringWidth("Type:") + 7);
     897        menuField->MenuBar()->ResizeToPreferred();
     898        menuField->ResizeToPreferred();
    890899
    891         BMenuField *mf = new BMenuField(r, "mime", "Type:",
    892             m, B_FOLLOW_BOTTOM | B_FOLLOW_LEFT);
    893         FailNilMsg(mf, "Error building FilePanel");
    894         vw->AddChild(mf);
    895         mf->SetDivider(be_plain_font->StringWidth("Type:") + 4);
     900        float height = menuField->Bounds().Height() + 8.0;
    896901
     902        // find all the views that are in the way and
     903        // move up them up the height of the menu field
     904        BView *poseview = background->FindView("PoseView");
     905        if (poseview)
     906            poseview->ResizeBy(0, -height);
     907
     908        BScrollBar *hscrollbar = (BScrollBar *)background->FindView("HScrollBar");
     909        if (hscrollbar)
     910            hscrollbar->MoveBy(0, -height);
     911
     912        BScrollBar *vscrollbar = (BScrollBar *)background->FindView("VScrollBar");
     913        if (vscrollbar)
     914            vscrollbar->ResizeBy(0, -height);
     915
     916        BView *countvw = (BView *)background->FindView("CountVw");
     917        if (countvw)
     918            countvw->MoveBy(0, -height);
     919
     920        textview->MoveBy(0, -height);
     921        textview->ResizeTo(textview->Bounds().Width() * 1.5,
     922                            textview->Bounds().Height());
     923
     924        background->AddChild(menuField);
     925
     926        // make sure the smallest window won't draw the "Type" menu over anything else
     927        // we suppose the "Save" button to have the same width as the "Cancel" button
     928        float minWindowWidth = textview->Bounds().Width()
     929                                + cancel->Bounds().Width() * 2
     930                                + 50;
     931        savePanel->SetSizeLimits(minWindowWidth, 10000, 250, 10000);
     932
    897933        int i = 0;
    898934        const char *p;
    899935
    900936        while ((p = gPrefs->GetIxPrefString(prf_X_Mimetype, i++)) != NULL)
    901             m->AddItem(new BMenuItem(p, NULL));
     937            menu->AddItem(new BMenuItem(p, NULL));
    902938
    903         BMenuItem *item = m->FindItem(MimeType());
     939        BMenuItem *item = menu->FindItem(MimeType());
    904940        if (item)
    905941            item->SetMarked(true);
    906942        else
     
    908944            p = MimeType();
    909945            if (!p || !p[0])
    910946                p = "<undefined>";
    911             m->AddItem(item = new BMenuItem(p, NULL));
     947            menu->AddItem(item = new BMenuItem(p, NULL));
    912948            item->SetMarked(true);
    913949        }
    914950    }