Author Topic: confirmreplacedlg sizing.  (Read 4038 times)

devilsclaw

  • Guest
confirmreplacedlg sizing.
« on: March 31, 2007, 06:52:27 am »
Currently the Replace file dialog is messed up.


with the code im posting it now looks like this.


when I had to do a VB project for school I figured out how to
dynamically figure out how many spaces are needed to make all
text aligned which right now im converting into c++

what that would allow the program to do is instead of just
figuring out what the height is needed I could figure out
what width is needed.

I was wondering if you guys would even care or want a function
that could figure that out for fonts that are not fix size.

if not let me know so then i wont convert the code over.


Code
void ConfirmReplaceDlg::CalcPosition()
{
    int w = 0, h = 0;
    GetSize(&w,&h);

    wxString msg = XRCCTRL(*this, "lblMessage", wxStaticText)->GetLabel();

    int screenW = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
    int screenH = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);
    wxFont sfont = wxSystemSettingsNative::GetFont(wxSYS_SYSTEM_FONT);
    wxSize fsize = sfont.GetPixelSize();
    int fwidth = fsize.GetWidth();
    int fheight = fsize.GetHeight();


    int counter = 0;
    int counter2 = 0;
    for(int i = 0; i < msg.length();i++)
    {
        if(msg.GetChar(i) == '\n')
        {
            counter++;
            counter2 = 0;
        }
        else
        {
            counter2++;
        }

        if(counter2 >= (screenW/fwidth))
        {
            counter++;
            counter2=0;
        }
    }
    SetSize(w, h+(counter*fheight));
}

the code above goes into confirmreplacedlg.cpp

then i added
Code
  void CalcPosition();

to the header in public.
   
and added.
Code
    if(label)CalcPosition();

to the bottem of the constructor