Exemple #1
0
//Fill array with file passed
bool wxFixWidthImportCtrl::LoadFile(const wxString& filename, const wxMBConv& conv)
{
    wxTextFile file;
    if (!file.Open(filename, conv) )
        return false;

    m_Lines.Clear();
    wxString str;
    m_maxLen = 0;
    size_t i = 0;
    size_t nto = file.GetLineCount();
    if (nto > 0)
    {   m_Lines.Alloc(nto);
        for ( i=0; i < nto; i++ )
        {   str = file.GetLine(i);

            if (m_tabSize > -1) //replace tabs with needed spaces
                str = TabsToSpaces(str);

            if (str.Len() > m_maxLen)
                m_maxLen = str.Len();

            m_Lines.Add(str);
        }
    }

    m_Lines.Shrink();

    m_curposX = m_curposL = m_markedL = m_LAct = 0;
    AdjustScrollbars();
    Refresh();
    FireEvent();
    return true;
}
Exemple #2
0
void UppPackageViewWindow::UpdateBitmap(const wxSize& sz)
{
    // initialize the bitmap
    if (!m_bmp.Create(sz))
    {
        wxLogError(_("Can't create the package bitmap!"));
        return;
    }
    wxMemoryDC dc(m_bmp);
    if (!dc.IsOk())
    {
        wxLogError(_("Can't draw the PIC package!"));
        return;
    }

    // clear the bitmap
    dc.SetBackground(*wxWHITE);
    dc.SetBrush(*wxWHITE);
    dc.Clear();
    
    // draw the package on the bitmap
    m_pkg.Draw(dc, sz, m_name);
    dc.SelectObject(wxNullBitmap);
    
    {
        // NOTE: on wxMSW setting the virtual size triggers a size event
        //       and thus our OnSize() would be called with an outdated
        //       m_fitting variable; to avoid this we temporarily block
        //       event generation
        wxEventBlocker nul(this);
        SetVirtualSize(sz);
    }
    AdjustScrollbars();
    Refresh();
}
Exemple #3
0
void wxScrolledWindow::DoSetVirtualSize( int x, int y )
{
    wxPanel::DoSetVirtualSize( x, y );
    AdjustScrollbars();

    if (GetAutoLayout())
        Layout();
}
Exemple #4
0
void ColorDialog::SelectedColorID::set(int value) {
    if (pSelectedColorID == value) return;
    if ((value < 0) || (value >= GTA::ColorIndex::colary->Length)) return;
    pSelectedColorID = value;
    pSelectedColorRGB = Drawing::Color::FromArgb(GTA::ColorIndex::colary[value] | 0xFF000000);
    AdjustScrollbars();
    OnSelectedColorChanged(EventArgs::Empty);
}
Exemple #5
0
// Default OnSize resets scrollbars, if any
void wxScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event))
{
    if ( m_targetWindow->GetAutoLayout() )
    {
        wxSize size = m_targetWindow->GetBestVirtualSize();
        
        // This will call ::Layout() and ::AdjustScrollbars()
        SetVirtualSize( size );
    }
    else
    {
        AdjustScrollbars();
    }
}
Exemple #6
0
void wxScrolledWindow::SetScrollRate( int xstep, int ystep )
{
    int old_x = m_xScrollPixelsPerLine * m_xScrollPosition;
    int old_y = m_yScrollPixelsPerLine * m_yScrollPosition;

    m_xScrollPixelsPerLine = xstep;
    m_yScrollPixelsPerLine = ystep;

    int new_x = m_xScrollPixelsPerLine * m_xScrollPosition;
    int new_y = m_yScrollPixelsPerLine * m_yScrollPosition;

    m_targetWindow->ScrollWindow( old_x - new_x, old_y - new_y );

    AdjustScrollbars();
}
Exemple #7
0
void wxScrollHelperNative::SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
                                         int noUnitsX, int noUnitsY,
                                         int xPos, int yPos,
                                         bool noRefresh)
{
    int xs, ys;
    GetViewStart(& xs, & ys);

    int old_x = m_xScrollPixelsPerLine * xs;
    int old_y = m_yScrollPixelsPerLine * ys;

    m_xScrollPixelsPerLine = pixelsPerUnitX;
    m_yScrollPixelsPerLine = pixelsPerUnitY;

    m_win->m_scrollBar[wxWindow::ScrollDir_Horz]->adjustment->value =
    m_xScrollPosition = xPos;
    m_win->m_scrollBar[wxWindow::ScrollDir_Vert]->adjustment->value =
    m_yScrollPosition = yPos;

    // Setting hints here should arguably be deprecated, but without it
    // a sizer might override this manual scrollbar setting in old code.
    // m_targetWindow->SetVirtualSizeHints( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY );

    int w = noUnitsX * pixelsPerUnitX;
    int h = noUnitsY * pixelsPerUnitY;
    m_targetWindow->SetVirtualSize( w ? w : wxDefaultCoord,
                                    h ? h : wxDefaultCoord);

    // If the target is not the same as the window with the scrollbars,
    // then we need to update the scrollbars here, since they won't have
    // been updated by SetVirtualSize().
    if (m_targetWindow != m_win)
    {
        AdjustScrollbars();
    }

    if (!noRefresh)
    {
        int new_x = m_xScrollPixelsPerLine * m_xScrollPosition;
        int new_y = m_yScrollPixelsPerLine * m_yScrollPosition;

        m_targetWindow->ScrollWindow( old_x - new_x, old_y - new_y );
    }
}
Exemple #8
0
void wxFixWidthImportCtrl::DoSetSize(int x, int y,
                               int width, int height,
                               int sizeFlags)
{
    wxControl::DoSetSize(x, y, width, height, sizeFlags);

    if ( m_scrbarH )
    {
        m_scrbarH->SetSize(m_margin, height - m_sbHheigth - 2 * m_margin,
                           width - m_sbVwidth - 3 * m_margin, m_sbHheigth);
    }
    if ( m_scrbarV )
    {
        m_scrbarV->SetSize(width - m_sbVwidth - 2 * m_margin,
                           FWIMARGIN + FWISCALEH - m_margin,
                           m_sbVwidth,
                           height - FWIMARGIN - FWISCALEH - m_sbHheigth - 2 * m_margin);
    }
    AdjustScrollbars();
    Refresh();
}
Exemple #9
0
//Fill array with string passed
void wxFixWidthImportCtrl::LoadText(const wxString& textInside)
{
    wxString singleLine, tabRep;
    wxChar ch;
    bool at_eol = false;
    size_t pos = 0;
    size_t nSp = 0;

    m_Lines.Clear();
    m_maxLen = 0;

    //Use code similar to wxTextBuffer::Translate
    wxChar chLast = 0;
    for ( wxString::const_iterator i = textInside.begin(); i != textInside.end(); ++i )
    {
        ch = *i;
        if ( ch == wxT('\n') )
        {
            at_eol = true;
            chLast = 0;
        }
        else if (ch == wxT('\r') )
        {
            if ( chLast == wxT('\r') )
            {// Mac empty line
                at_eol = true;
            }
            else
            {// just remember it: we don't know whether it is just "\r" or "\r\n" yet
                chLast = wxT('\r');
            }
        }
        else
        {
            if ( chLast == wxT('\r') )
            {// Mac line termination
                at_eol = true;
                chLast = 0;
            }
        }
        if ( at_eol )
        {
            if (singleLine.Len() > m_maxLen)
                m_maxLen = singleLine.Len();

            m_Lines.Add(singleLine);
            singleLine = wxT("");
            at_eol = false;
            pos = 0;
        }
        if ( ch != wxT('\n') && ch != wxT('\r') )
        {
            if (m_tabSize > -1 && ch == wxT('\t') )
            {//insert needed spaces so text becomes 'tabulated'
                if ( m_tabSize > 0) //m_tabSize=0 means 'erase this TAB'
                {   tabRep = wxT("");
                    nSp = (size_t)m_tabSize - (pos % (size_t)m_tabSize);
                    tabRep.Append(wxChar(' '), nSp);
                    singleLine += tabRep;
                    pos += nSp;
                }
            }
            else
            {
                singleLine += ch;
                pos++;
            }
        }
    }
    //Check if we are at a last Mac line
    if (chLast == wxT('\r') )
    {
        m_Lines.Add(singleLine);
        if (singleLine.Len() > m_maxLen)
            m_maxLen = singleLine.Len();
        singleLine = wxT("");
    }
    if (singleLine.Len() > 0) //pending line
    {   m_Lines.Add(singleLine);
        if (singleLine.Len() > m_maxLen)
            m_maxLen = singleLine.Len();
    }

    m_curposX = m_curposL = m_markedL = m_LAct = 0;
    AdjustScrollbars();
    Refresh();
    FireEvent();
}