~ubuntu-branches/ubuntu/saucy/filezilla/saucy-proposed

« back to all changes in this revision

Viewing changes to src/interface/wrapengine.cpp

  • Committer: Package Import Robot
  • Author(s): Adrien Cunin
  • Date: 2012-12-07 17:17:17 UTC
  • mfrom: (1.1.31)
  • Revision ID: package-import@ubuntu.com-20121207171717-nt6as62u4pa1uv11
Tags: 3.6.0.2-1ubuntu1
* Merge from Debian experimental. Remaining Ubuntu change:
   - Added debian/patches/11_use-decimal-si-by-default.patch in order to
     comply with UnitsPolicy

Show diffs side-by-side

added added

removed removed

Lines of Context:
199
199
        - Wrap embedded English text fragments only on spaces
200
200
 
201
201
        For this kind of languages, a different wrapping algorithm is used.
202
 
    */
 
202
        */
203
203
 
204
204
        if (!m_font.IsOk())
205
205
                m_font = parent->GetFont();
356
356
int CWrapEngine::WrapRecursive(wxWindow* wnd, wxSizer* sizer, int max)
357
357
{
358
358
        // This function auto-wraps static texts.
359
 
        
 
359
 
360
360
#if WRAPDEBUG >= 3
361
361
        static int level = 1;
362
362
        plvl printf("Enter with max = %d\n", max);
393
393
                wxASSERT(min.GetWidth() + rborder + lborder <= sizer->GetMinSize().GetWidth());
394
394
 
395
395
                if (min.GetWidth() + item->GetPosition().x + lborder + rborder <= max)
396
 
                    continue;
 
396
                        continue;
397
397
 
398
398
                wxWindow* window;
399
399
                wxSizer* subSizer = 0;
409
409
#endif
410
410
                                if (max - rect.GetLeft() - rborder - offset <= 0)
411
411
                                        continue;
412
 
                                        
 
412
 
413
413
                                wxString str = text->GetLabel();
414
414
                                if (!WrapText(text, str, max - wxMax(0, rect.GetLeft()) - rborder - offset))
415
415
                                {
416
416
#if WRAPDEBUG >= 3
417
417
                                        plvl printf("Leave: WrapText failed\n");
418
 
#endif          
 
418
#endif
419
419
                                        return result | wrap_failed;
420
420
                                }
421
421
                                text->SetLabel(str);
492
492
                        }
493
493
                }
494
494
        }
495
 
        
 
495
 
496
496
#if WRAPDEBUG >= 3
497
497
        plvl printf("Leave: Success\n");
498
498
#endif
513
513
        unsigned int i = 0;
514
514
        for (std::list<int>::const_iterator iter = wrapped.begin();
515
515
                iter != wrapped.end();
516
 
                iter++)
 
516
                ++iter)
517
517
        {
518
518
                UnwrapRecursive(windows[i], windows[i]->GetSizer());
519
519
                windows[i]->GetSizer()->Layout();
528
528
                                continue;
529
529
                        }
530
530
                }
531
 
                
 
531
 
532
532
                i++;
533
533
        }
534
534
}
538
538
        int maxWidth = GetWidthFromCache(name);
539
539
        if (maxWidth)
540
540
        {
541
 
                for (std::vector<wxWindow*>::iterator iter = windows.begin(); iter != windows.end(); iter++)
 
541
                for (std::vector<wxWindow*>::iterator iter = windows.begin(); iter != windows.end(); ++iter)
542
542
                {
543
543
                        wxSizer* pSizer = (*iter)->GetSizer();
544
544
                        if (!pSizer)
545
545
                                continue;
546
546
 
547
547
                        pSizer->Layout();
548
 
                        
 
548
 
549
549
#ifdef __WXMAC__
550
550
                        const int offset = 6;
551
551
#elif defined(__WXGTK__)
561
561
                        wxASSERT(!(res & wrap_failed));
562
562
                        pSizer->Layout();
563
563
                        pSizer->Fit(*iter);
 
564
#ifdef __WXDEBUG__
564
565
                        wxSize size = pSizer->GetMinSize();
 
566
#endif
565
567
                        wxASSERT(size.x <= maxWidth);
566
568
                }
567
569
                return true;
571
573
 
572
574
        wxSize size = minRequestedSize;
573
575
 
574
 
        for (std::vector<wxWindow*>::iterator iter = windows.begin(); iter != windows.end(); iter++)
 
576
        for (std::vector<wxWindow*>::iterator iter = windows.begin(); iter != windows.end(); ++iter)
575
577
        {
576
578
                wxSizer* pSizer = (*iter)->GetSizer();
577
579
                if (!pSizer)
599
601
 
600
602
        double bestRatioDiff = currentRatio - ratio;
601
603
        int bestWidth = max;
602
 
        
603
 
#if WRAPDEBUG > 0       
 
604
 
 
605
#if WRAPDEBUG > 0
604
606
        printf("Target ratio: %f\n", (float)ratio);
605
607
        printf("Canvas: % 4d % 4d\n", canvas.x, canvas.y);
606
608
        printf("Initial min and max: %d %d\n", min, max);
607
609
#endif
608
610
 
609
 
        while (true)
 
611
        for (;;)
610
612
        {
611
613
                std::list<int> didwrap;
612
614
 
613
615
                wxSize size = minRequestedSize;
614
 
                for (std::vector<wxWindow*>::iterator iter = windows.begin(); iter != windows.end(); iter++)
 
616
                for (std::vector<wxWindow*>::iterator iter = windows.begin(); iter != windows.end(); ++iter)
615
617
                {
616
618
                        wxSizer* pSizer = (*iter)->GetSizer();
617
619
#ifdef __WXMAC__
634
636
                }
635
637
 
636
638
#if WRAPDEBUG > 0
637
 
            printf("Current: % 4d % 4d   desiredWidth: %d, min: %d, max: %d\n", size.GetWidth(), size.GetHeight(), desiredWidth, min, max);
 
639
                printf("Current: % 4d % 4d   desiredWidth: %d, min: %d, max: %d\n", size.GetWidth(), size.GetHeight(), desiredWidth, min, max);
638
640
#endif
639
641
                if (size.GetWidth() > desiredWidth)
640
642
                {
656
658
                actualWidth = size.GetWidth();
657
659
 
658
660
                double newRatio = ((double)(size.GetWidth() + canvas.x) / (size.GetHeight() + canvas.y));
659
 
#if WRAPDEBUG > 0               
 
661
#if WRAPDEBUG > 0
660
662
                printf("Ratio: %f\n", (float)newRatio);
661
 
#endif          
 
663
#endif
662
664
 
663
665
                if (newRatio < ratio)
664
666
                {
703
705
 
704
706
                currentRatio = newRatio;
705
707
        }
706
 
#if WRAPDEBUG > 0               
 
708
#if WRAPDEBUG > 0
707
709
                printf("Performing final wrap with bestwidth %d\n", bestWidth);
708
710
#endif
709
711
#ifdef __WXMAC__
713
715
#else
714
716
                        const int offset = 0;
715
717
#endif
716
 
        for (std::vector<wxWindow*>::iterator iter = all_windows.begin(); iter != all_windows.end(); iter++)
 
718
        for (std::vector<wxWindow*>::iterator iter = all_windows.begin(); iter != all_windows.end(); ++iter)
717
719
        {
718
720
                wxSizer *pSizer = (*iter)->GetSizer();
719
721
 
796
798
                        if (text)
797
799
                        {
798
800
                                wxString unwrapped = UnwrapText(text->GetLabel());
799
 
                text->SetLabel(unwrapped);
 
801
                                text->SetLabel(unwrapped);
800
802
 
801
803
                                continue;
802
804
                        }