~ubuntu-branches/ubuntu/oneiric/opencv/oneiric

« back to all changes in this revision

Viewing changes to src/highgui/window_carbon.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Nobuhiro Iwamatsu
  • Date: 2010-07-16 13:12:28 UTC
  • mfrom: (4.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100716131228-95963rebybpghxef
Tags: 2.1.0-1
* New upstream release. (Closes: #577594, #587232, #563717)
* Update debian/rules.
  - Update build-system to debhelper v7.
* Update debian/control.
  - Bumped standards-version to 3.9.0. No changes needed.
  - library package name update.
    Soname of opencv library changed from 4 to 2.1.
  - Add cmake, liblapack-dev, texlive-fonts-extra, texlive-latex-extra,
    texlive-latex-recommended, latex-xcolor and  texlive-fonts-recommended
    to Build-depends.
  - Add arch depends to libraw1394-dev and libdc1394-22-dev.
    Thanks to Pino Toscano. (Closes: #581210)
* Add opencv-doc.lintian-overrides.
  opencv-doc has some sample program of python.
* Update man files.
* Update patches
  - Update and rename 500_remove_bashism.patch.
    And rename to remove_bashism.patch.
* Add new patches.
  - Enable build static library.
    enable_static.patch
  - Disable build 3rd party library.
    Use zlib and lapack in debian package.
    fix_3rdparty_build.patch
  - Fix build pdf.
    fix_build_pdf.patch
  - Remove cvconfig.h
    remove_cvconfig.h.patch
* Remove some patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
#include "_highgui.h"
43
43
 
44
44
#include <Carbon/Carbon.h>
 
45
#include <Quicktime/Quicktime.h>//YV
45
46
 
46
47
#include <unistd.h>
47
48
#include <cstdio>
69
70
    int* data;
70
71
    int pos;
71
72
    int maxval;
 
73
        int labelSize;//Yannick Verdie
72
74
    CvTrackbarCallback notify;
73
75
    CvTrackbarCallback2 notify2;
74
76
    void* userdata;
85
87
    CvWindow* next;
86
88
    
87
89
    WindowRef window;
 
90
    WindowRef oldwindow;//YV
88
91
    CGImageRef imageRef;
89
92
    int imageWidth;//FD
90
93
    int imageHeight;//FD
94
97
    int converted;
95
98
    int last_key;
96
99
    int flags;
 
100
    int status;//YV
 
101
    Ptr restoreState;//YV
97
102
    
98
103
    CvMouseCallback on_mouse;
99
104
    void* on_mouse_param;
221
226
    
222
227
        GetWindowPortBounds(window->window, &portrect);
223
228
    
224
 
    if( window->flags & CV_WINDOW_AUTOSIZE ) 
 
229
    if(!( window->flags & CV_WINDOW_AUTOSIZE) ) //YV
225
230
        { 
226
231
        CGPoint origin = {0,0}; 
227
232
        CGSize size = {portrect.right-portrect.left, portrect.bottom-portrect.top-window->trackbarheight};
325
330
        if (window->imageRef != NULL)
326
331
        CGImageRelease(window->imageRef);
327
332
    
 
333
        DisposeWindow (window->window);//YV
 
334
        
328
335
    cvFree( (void**)&window );
329
336
}
330
337
 
474
481
            trackbar->notify(pos);
475
482
        else if ( trackbar->notify2 )
476
483
            trackbar->notify2(pos, trackbar->userdata);
 
484
                
 
485
                //--------YV---------------------------
 
486
                CFStringEncoding encoding = kCFStringEncodingASCII;
 
487
                CFAllocatorRef alloc_default = kCFAllocatorDefault;  // = NULL;
 
488
                
 
489
                char valueinchar[20];
 
490
                sprintf(valueinchar, " (%d)",  *trackbar->data);        
 
491
                
 
492
                // create an empty CFMutableString
 
493
                CFIndex maxLength = 256;
 
494
                CFMutableStringRef cfstring = CFStringCreateMutable(alloc_default,maxLength);
 
495
                
 
496
                // append some c strings into it.
 
497
                CFStringAppendCString(cfstring,trackbar->name,encoding);
 
498
                CFStringAppendCString(cfstring,valueinchar,encoding);
 
499
                
 
500
                SetControlData(trackbar->label, kControlEntireControl,kControlStaticTextCFStringTag, sizeof(cfstring), &cfstring);
 
501
                DrawControls(trackbar->parent->window);
 
502
                //-----------------------------------------
477
503
    }
478
504
}
479
505
 
534
560
        
535
561
        trackbar->maxval = count;
536
562
        
 
563
                //----------- YV ----------------------
 
564
                //get nb of digits
 
565
                int nbDigit = 0;
 
566
                while((count/=10)>10){
 
567
                        nbDigit++;
 
568
                }
 
569
                
 
570
                //pad size maxvalue in pixel
 
571
                Point   qdSize;
 
572
                char valueinchar[strlen(trackbar_name)+1 +1 +1+nbDigit+1];//lenght+\n +space +(+nbDigit+)
 
573
                sprintf(valueinchar, "%s (%d)",trackbar_name, trackbar->maxval);
 
574
                SInt16  baseline;
 
575
                CFStringRef text = CFStringCreateWithCString(NULL,valueinchar,kCFStringEncodingASCII);
 
576
                GetThemeTextDimensions( text, kThemeCurrentPortFont, kThemeStateActive, false, &qdSize, &baseline );
 
577
                trackbar->labelSize = qdSize.h;
 
578
                //--------------------------------------
 
579
                
537
580
        int c = icvCountTrackbarInWindow(window);               
538
581
        
539
582
        GetWindowBounds(window->window,kWindowContentRgn,&bounds);
544
587
        stboundsRect.right = stboundsRect.left+LABELWIDTH;
545
588
        
546
589
        //fprintf(stdout,"create trackabar bounds (%d %d %d %d)\n",stboundsRect.top,stboundsRect.left,stboundsRect.bottom,stboundsRect.right);
547
 
        CreateStaticTextControl (window->window,&stboundsRect,CFStringCreateWithCString(NULL,trackbar_name,kCFStringEncodingASCII),NULL,&stoutControl);
548
 
        
 
590
         //----------- YV ----------------------
 
591
         sprintf(valueinchar, "%s (%d)",trackbar_name, trackbar->pos);
 
592
        CreateStaticTextControl (window->window,&stboundsRect,CFStringCreateWithCString(NULL,valueinchar,kCFStringEncodingASCII),NULL,&stoutControl);
 
593
        //--------------------------------------
 
594
                
549
595
        stboundsRect.top = (INTERWIDGETSPACE +WIDGETHEIGHT)* (c-1)+INTERWIDGETSPACE;
550
596
        stboundsRect.left = INTERWIDGETSPACE*2+LABELWIDTH;
551
597
        stboundsRect.bottom = stboundsRect.top + WIDGETHEIGHT;
711
757
    return window_name;
712
758
}
713
759
 
 
760
double cvGetMode_QT(const char* name)//YV
 
761
{
 
762
        double result = -1;
 
763
        
 
764
        CV_FUNCNAME( "cvGetMode_QT" );
 
765
 
 
766
    __BEGIN__;
 
767
 
 
768
    CvWindow* window;
 
769
 
 
770
    if(!name)
 
771
        CV_ERROR( CV_StsNullPtr, "NULL name string" );
 
772
 
 
773
    window = icvFindWindowByName( name );
 
774
    if( !window )
 
775
        CV_ERROR( CV_StsNullPtr, "NULL window" );
 
776
        
 
777
    result = window->status;
 
778
        
 
779
    __END__;
 
780
    return result;   
 
781
}
 
782
 
 
783
void cvChangeMode_QT( const char* name, double prop_value)//Yannick Verdie
 
784
{
 
785
        OSStatus err = noErr;
 
786
        
 
787
        
 
788
        CV_FUNCNAME( "cvChangeMode_QT" );
 
789
 
 
790
    __BEGIN__;
 
791
 
 
792
    CvWindow* window;
 
793
 
 
794
    if(!name)
 
795
        CV_ERROR( CV_StsNullPtr, "NULL name string" );
 
796
 
 
797
    window = icvFindWindowByName( name );
 
798
    if( !window )
 
799
        CV_ERROR( CV_StsNullPtr, "NULL window" );
 
800
 
 
801
        if(window->flags & CV_WINDOW_AUTOSIZE)//if the flag CV_WINDOW_AUTOSIZE is set
 
802
        EXIT;
 
803
        
 
804
        if (window->status==CV_WINDOW_FULLSCREEN && prop_value==CV_WINDOW_NORMAL)
 
805
        {
 
806
                err = EndFullScreen(window->restoreState,0);
 
807
                if (err != noErr)
 
808
                        fprintf(stdout,"Error EndFullScreen\n");
 
809
                window->window = window->oldwindow;
 
810
                ShowWindow( window->window );
 
811
        
 
812
                window->status=CV_WINDOW_NORMAL;
 
813
                EXIT;
 
814
        }
 
815
        
 
816
        if (window->status==CV_WINDOW_NORMAL && prop_value==CV_WINDOW_FULLSCREEN)
 
817
        {
 
818
                GDHandle device;
 
819
                err = GetWindowGreatestAreaDevice(window->window, kWindowTitleBarRgn, &device, NULL);
 
820
                if (err != noErr)
 
821
                        fprintf(stdout,"Error GetWindowGreatestAreaDevice\n");
 
822
                
 
823
                HideWindow(window->window);
 
824
                window->oldwindow = window->window;
 
825
                err = BeginFullScreen(&(window->restoreState), device, 0, 0, &window->window, 0, fullScreenAllowEvents | fullScreenDontSwitchMonitorResolution);
 
826
                if (err != noErr)
 
827
                        fprintf(stdout,"Error BeginFullScreen\n");
 
828
        
 
829
                window->status=CV_WINDOW_FULLSCREEN;
 
830
                EXIT;
 
831
        }
 
832
        
 
833
    __END__;
 
834
}
714
835
 
715
836
CV_IMPL int cvNamedWindow( const char* name, int flags )
716
837
{
772
893
    window->name = (char*)(window + 1);
773
894
    memcpy( window->name, name, len + 1 );
774
895
    window->flags = flags;
 
896
    window->status = CV_WINDOW_NORMAL;//YV
775
897
    window->signature = CV_WINDOW_MAGIC_VAL;
776
898
    window->image = 0;
777
899
    window->last_key = 0;
785
907
    hg_windows = window;
786
908
    wAttributes =  kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute | kWindowLiveResizeAttribute;
787
909
    
 
910
     
 
911
        if (window->flags & CV_WINDOW_AUTOSIZE)//Yannick verdie, remove the handler at the bottom-right position of the window in AUTORESIZE mode
 
912
        {
 
913
        wAttributes = 0;        
 
914
        wAttributes = kWindowCloseBoxAttribute | kWindowFullZoomAttribute | kWindowCollapseBoxAttribute | kWindowStandardHandlerAttribute  |  kWindowLiveResizeAttribute;
 
915
        }
 
916
        
788
917
    err = CreateNewWindow ( kDocumentWindowClass,wAttributes,&contentBounds,&outWindow);
789
918
    if (err != noErr)
790
919
        fprintf(stderr,"Error while creating the window\n");
794
923
        fprintf(stdout,"Error SetWindowTitleWithCFString\n");
795
924
    
796
925
    window->window = outWindow;
797
 
    
 
926
        window->oldwindow = 0;//YV
 
927
        
798
928
    err = InstallWindowEventHandler(outWindow, NewEventHandlerUPP(windowEventHandler), GetEventTypeCount(genericWindowEventHandler), genericWindowEventHandler, outWindow, NULL);
799
929
    
800
930
    ShowWindow( outWindow );