~ubuntu-branches/ubuntu/maverick/wxwidgets2.8/maverick-proposed

« back to all changes in this revision

Viewing changes to src/html/htmlcell.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Devid Filoni
  • Date: 2007-11-06 18:25:13 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20071106182513-809agqds6igh7mqo
Tags: 2.8.6.1-0ubuntu1
* New upstream version, based on the upstream tarball
  wxPython-src-2.8.6.1.tar.bz2, renamed debian to debian-upstream.
* Provide a get-orig-source target to do the repackaging.
* Fix "substvar-source-version-is-deprecated" lintian warnings.
* Remove duplicate Description field in debian/control.
* Add "\" at the end of line 8 in debian/python-wxtools.menu to fix
  "bad-test-in-menu-item" lintian error.
* Provide .xpm icons to fix "menu-icon-not-in-xpm-format" lintian errors,
  changed Icon field in debian/python-wxtools.menu.
* Fix "wrong-name-for-upstream-changelog" lintian warnings.
* Remove "Application;" from Categories field in debian/pycrust.desktop,
  debian/pyshell.desktop, debian/xrced.desktop.
* Switch "Apps" to "Applications" in debian/python-wxtools.menu to fix
  "menu-item-uses-apps-section" lintian warnings.
* Drop the icon extension from debian/pycrust.desktop,
  debian/pyshell.desktop, debian/xrced.desktop.
* Add dpatch support.
* Add "WX_CONFIG" patch.
* debian/rules:
  - added .xpm icons to install-gtk-py-tools target
  - added "docs/changes.txt" to dh_installchangelogs in binary-common target
  - added "\" at the end of "install-examples install-msw-dev
    install-msw-dbg install-headers-msw" line in .PHONY

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
// Name:        src/html/htmlcell.cpp
3
3
// Purpose:     wxHtmlCell - basic element of HTML output
4
4
// Author:      Vaclav Slavik
5
 
// RCS-ID:      $Id: htmlcell.cpp,v 1.113.4.1 2007/03/17 16:41:37 VZ Exp $
 
5
// RCS-ID:      $Id: htmlcell.cpp 46507 2007-06-17 17:58:20Z VS $
6
6
// Copyright:   (c) 1999 Vaclav Slavik
7
7
// Licence:     wxWindows licence
8
8
/////////////////////////////////////////////////////////////////////////////
381
381
    wxPoint pt2 = (selTo == wxDefaultPosition) ?
382
382
                   wxPoint(m_Width, wxDefaultCoord) : selTo - GetAbsPos();
383
383
 
 
384
    // if the selection is entirely within this cell, make sure pt1 < pt2 in
 
385
    // order to make the rest of this function simpler:
 
386
    if ( selFrom != wxDefaultPosition && selTo != wxDefaultPosition &&
 
387
         selFrom.x > selTo.x )
 
388
    {
 
389
        wxPoint tmp = pt1;
 
390
        pt1 = pt2;
 
391
        pt2 = tmp;
 
392
    }
 
393
 
384
394
    unsigned len = m_Word.length();
385
395
    unsigned i = 0;
386
396
    pos1 = 0;
393
403
        pt2.x = m_Width;
394
404
 
395
405
    // before selection:
 
406
    // (include character under caret only if in first half of width)
396
407
#ifdef __WXMAC__
397
408
    // implementation using PartialExtents to support fractional widths
398
409
    wxArrayInt widths ;
399
410
    dc.GetPartialTextExtents(m_Word,widths) ;
400
411
    while( i < len && pt1.x >= widths[i] )
401
412
        i++ ;
402
 
#else // __WXMAC__
 
413
    if ( i < len )
 
414
    {
 
415
        int charW = (i > 0) ? widths[i] - widths[i-1] : widths[i];
 
416
        if ( widths[i] - pt1.x < charW/2 )
 
417
            i++;
 
418
    }
 
419
#else // !__WXMAC__
403
420
    wxCoord charW, charH;
404
421
    while ( pt1.x > 0 && i < len )
405
422
    {
406
423
        dc.GetTextExtent(m_Word[i], &charW, &charH);
407
424
        pt1.x -= charW;
408
 
        if ( pt1.x >= 0 )
 
425
        if ( pt1.x >= -charW/2 )
409
426
        {
410
427
            pos1 += charW;
411
428
            i++;
414
431
#endif // __WXMAC__/!__WXMAC__
415
432
 
416
433
    // in selection:
 
434
    // (include character under caret only if in first half of width)
417
435
    unsigned j = i;
418
436
#ifdef __WXMAC__
419
437
    while( j < len && pt2.x >= widths[j] )
420
438
        j++ ;
421
 
#else // __WXMAC__
 
439
    if ( j < len )
 
440
    {
 
441
        int charW = (j > 0) ? widths[j] - widths[j-1] : widths[j];
 
442
        if ( widths[j] - pt2.x < charW/2 )
 
443
            j++;
 
444
    }
 
445
#else // !__WXMAC__
422
446
    pos2 = pos1;
423
447
    pt2.x -= pos2;
424
448
    while ( pt2.x > 0 && j < len )
425
449
    {
426
450
        dc.GetTextExtent(m_Word[j], &charW, &charH);
427
451
        pt2.x -= charW;
428
 
        if ( pt2.x >= 0 )
 
452
        if ( pt2.x >= -charW/2 )
429
453
        {
430
454
            pos2 += charW;
431
455
            j++;
1496
1520
        c = c->GetParent();
1497
1521
    }
1498
1522
 
1499
 
    ((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty);
1500
 
    m_Wnd->SetSize(absx - wxHTML_SCROLL_STEP * stx, absy  - wxHTML_SCROLL_STEP * sty, m_Width, m_Height);
 
1523
    wxScrolledWindow *scrolwin =
 
1524
        wxDynamicCast(m_Wnd->GetParent(), wxScrolledWindow);
 
1525
    wxCHECK_RET( scrolwin,
 
1526
                 _T("widget cells can only be placed in wxHtmlWindow") );
 
1527
 
 
1528
    scrolwin->GetViewStart(&stx, &sty);
 
1529
    m_Wnd->SetSize(absx - wxHTML_SCROLL_STEP * stx,
 
1530
                   absy  - wxHTML_SCROLL_STEP * sty,
 
1531
                   m_Width, m_Height);
1501
1532
}
1502
1533
 
1503
1534