@@ -82,46 +82,42 @@ CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name
82
82
static NSMutableDictionary *windows = nil ;
83
83
static bool wasInitialized = false ;
84
84
85
- @interface CVView : NSView
86
- {
87
- NSImage *_image;
85
+ @interface CVView : NSView {
86
+ NSImage *image;
88
87
}
89
- @property (strong ) NSImage *image;
88
+ @property (retain ) NSImage *image;
90
89
- (void )setImageData : (CvArr *)arr ;
91
90
@end
92
91
93
- @interface CVSlider : NSView
94
- {
95
- NSSlider *_slider;
96
- NSTextField *_name;
97
- int *_value;
98
- void *_userData;
99
- CvTrackbarCallback _callback;
100
- CvTrackbarCallback2 _callback2;
92
+ @interface CVSlider : NSView {
93
+ NSSlider *slider;
94
+ NSTextField *name;
95
+ int *value;
96
+ void *userData;
97
+ CvTrackbarCallback callback;
98
+ CvTrackbarCallback2 callback2;
101
99
}
102
-
103
- @property (strong ) NSSlider *slider;
104
- @property (strong ) NSTextField *name;
100
+ @property (retain ) NSSlider *slider;
101
+ @property (retain ) NSTextField *name;
105
102
@property (assign ) int *value;
106
103
@property (assign ) void *userData;
107
104
@property (assign ) CvTrackbarCallback callback;
108
105
@property (assign ) CvTrackbarCallback2 callback2;
109
106
@end
110
107
111
- @interface CVWindow : NSWindow
112
- {
113
- CvMouseCallback _mouseCallback;
114
- void *_mouseParam;
115
- BOOL _autosize;
116
- BOOL _firstContent;
117
- NSMutableDictionary *_sliders;
118
- int _status;
108
+ @interface CVWindow : NSWindow {
109
+ NSMutableDictionary *sliders;
110
+ CvMouseCallback mouseCallback;
111
+ void *mouseParam;
112
+ BOOL autosize;
113
+ BOOL firstContent;
114
+ int status;
119
115
}
120
116
@property (assign ) CvMouseCallback mouseCallback;
121
117
@property (assign ) void *mouseParam;
122
118
@property (assign ) BOOL autosize;
123
119
@property (assign ) BOOL firstContent;
124
- @property (strong ) NSMutableDictionary *sliders;
120
+ @property (retain ) NSMutableDictionary *sliders;
125
121
@property (readwrite ) int status;
126
122
- (CVView *)contentView ;
127
123
- (void )cvSendMouseEvent : (NSEvent *)event type : (int )type flags : (int )flags ;
@@ -701,21 +697,14 @@ void cvSetModeWindow_COCOA( const char* name, double prop_value )
701
697
}
702
698
703
699
@implementation CVWindow
704
- # if defined(__LP64__)
700
+
705
701
@synthesize mouseCallback;
706
702
@synthesize mouseParam;
707
703
@synthesize autosize;
708
704
@synthesize firstContent;
709
705
@synthesize sliders;
710
706
@synthesize status;
711
- #else // 32-bit Obj-C does not have automatic synthesize
712
- @synthesize mouseCallback = _mouseCallback;
713
- @synthesize mouseParam = _mouseParam;
714
- @synthesize autosize = _autosize;
715
- @synthesize firstContent = _firstContent;
716
- @synthesize sliders = _sliders;
717
- @synthesize status = _status;
718
- #endif
707
+
719
708
- (void )cvSendMouseEvent : (NSEvent *)event type : (int )type flags : (int )flags {
720
709
(void )event;
721
710
// cout << "cvSendMouseEvent" << endl;
@@ -740,13 +729,12 @@ - (void)cvSendMouseEvent:(NSEvent *)event type:(int)type flags:(int)flags {
740
729
mp.y = mp.y * imageSize.height / std::max (viewHeight, 1 .);
741
730
742
731
if ( mp.x >= 0 && mp.y >= 0 && mp.x < imageSize.width && mp.y < imageSize.height )
743
- _mouseCallback (type, mp.x , mp.y , flags, _mouseParam );
732
+ mouseCallback (type, mp.x , mp.y , flags, mouseParam );
744
733
}
745
734
746
735
- (void )cvMouseEvent : (NSEvent *)event {
747
736
// cout << "cvMouseEvent" << endl;
748
-
749
- if ([self mouseCallback ] == nil )
737
+ if (!mouseCallback)
750
738
return ;
751
739
752
740
int flags = 0 ;
@@ -806,13 +794,13 @@ - (void)mouseDown:(NSEvent *)theEvent {
806
794
807
795
- (void )createSliderWithName : (const char *)name maxValue : (int )max value : (int *)value callback : (CvTrackbarCallback)callback {
808
796
// cout << "createSliderWithName" << endl;
809
- if (_sliders == nil )
810
- _sliders = [[NSMutableDictionary alloc ] init ];
797
+ if (sliders == nil )
798
+ sliders = [[NSMutableDictionary alloc ] init ];
811
799
812
800
NSString *cvname = [NSString stringWithFormat: @" %s " , name];
813
801
814
802
// Avoid overwriting slider
815
- if ([_sliders valueForKey: cvname]!=nil )
803
+ if ([sliders valueForKey: cvname]!=nil )
816
804
return ;
817
805
818
806
// Create slider
@@ -831,11 +819,11 @@ - (void)createSliderWithName:(const char *)name maxValue:(int)max value:(int *)v
831
819
[slider setCallback: callback];
832
820
833
821
// Save slider
834
- [_sliders setValue: slider forKey: cvname];
822
+ [sliders setValue: slider forKey: cvname];
835
823
[[self contentView ] addSubview: slider];
836
824
837
825
838
- // update contentView size to contain _sliders
826
+ // update contentView size to contain sliders
839
827
NSSize viewSize=[[self contentView ] frame ].size ,
840
828
sliderSize=[slider frame ].size ;
841
829
viewSize.height += sliderSize.height ;
@@ -845,7 +833,7 @@ - (void)createSliderWithName:(const char *)name maxValue:(int)max value:(int *)v
845
833
[[self contentView ] setFrameSize: viewSize];
846
834
[[self contentView ] setNeedsDisplay: YES ];
847
835
848
- // update window size to contain _sliders
836
+ // update window size to contain sliders
849
837
NSRect rect = [self frame ];
850
838
rect.size .height += [slider frame ].size .height ;
851
839
rect.size .width = std::max<int >(rect.size .width , MIN_SLIDER_WIDTH);
@@ -862,16 +850,13 @@ - (CVView *)contentView {
862
850
@end
863
851
864
852
@implementation CVView
865
- # if defined(__LP64__)
853
+
866
854
@synthesize image;
867
- #else // 32-bit Obj-C does not have automatic synthesize
868
- @synthesize image = _image;
869
- #endif
870
855
871
856
- (id )init {
872
857
// cout << "CVView init" << endl;
873
858
[super init ];
874
- _image = [[NSImage alloc ] init ];
859
+ image = [[NSImage alloc ] init ];
875
860
return self;
876
861
}
877
862
@@ -926,11 +911,11 @@ - (void)setImageData:(CvArr *)arr {
926
911
dst[i * 4 + 2 ] = src[i * 3 + 2 ];
927
912
}
928
913
929
- if ( _image )
930
- [_image release ];
914
+ if ( image )
915
+ [image release ];
931
916
932
- _image = [[NSImage alloc ] init ];
933
- [_image addRepresentation: bitmap];
917
+ image = [[NSImage alloc ] init ];
918
+ [image addRepresentation: bitmap];
934
919
[bitmap release ];
935
920
936
921
/* CGColorSpaceRelease(colorspace);
@@ -951,7 +936,7 @@ - (void)setFrameSize:(NSSize)size {
951
936
int height = size.height ;
952
937
953
938
CVWindow *cvwindow = (CVWindow *)[self window ];
954
- if ([cvwindow respondsToSelector: @selector (_sliders )]) {
939
+ if ([cvwindow respondsToSelector: @selector (sliders )]) {
955
940
for (NSString *key in [cvwindow sliders ]) {
956
941
NSSlider *slider = [[cvwindow sliders ] valueForKey: key];
957
942
NSRect r = [slider frame ];
@@ -971,17 +956,17 @@ - (void)drawRect:(NSRect)rect {
971
956
NSAutoreleasePool * localpool = [[NSAutoreleasePool alloc ] init ];
972
957
CVWindow *cvwindow = (CVWindow *)[self window ];
973
958
int height = 0 ;
974
- if ([cvwindow respondsToSelector: @selector (_sliders )]) {
959
+ if ([cvwindow respondsToSelector: @selector (sliders )]) {
975
960
for (NSString *key in [cvwindow sliders ]) {
976
961
height += [[[cvwindow sliders ] valueForKey: key] frame ].size .height ;
977
962
}
978
963
}
979
964
980
965
981
- NSRect imageRect = {{0 ,0 }, {[_image size ].width , [_image size ].height }};
966
+ NSRect imageRect = {{0 ,0 }, {[image size ].width , [image size ].height }};
982
967
983
- if (_image != nil ) {
984
- [_image drawInRect: imageRect
968
+ if (image != nil ) {
969
+ [image drawInRect: imageRect
985
970
fromRect: NSZeroRect
986
971
operation: NSCompositeSourceOver
987
972
fraction: 1.0 ];
@@ -993,47 +978,40 @@ - (void)drawRect:(NSRect)rect {
993
978
@end
994
979
995
980
@implementation CVSlider
996
- # if defined(__LP64__)
981
+
997
982
@synthesize slider;
998
983
@synthesize name;
999
984
@synthesize value;
1000
985
@synthesize userData;
1001
986
@synthesize callback;
1002
987
@synthesize callback2;
1003
- #else // 32-bit Obj-C does not have automatic synthesize
1004
- @synthesize slider = _slider;
1005
- @synthesize name = _name;
1006
- @synthesize value = _value;
1007
- @synthesize userData = _userData;
1008
- @synthesize callback = _callback;
1009
- @synthesize callback2 = _callback2;
1010
- #endif
988
+
1011
989
- (id )init {
1012
990
[super init ];
1013
991
1014
- _callback = NULL ;
1015
- _value = NULL ;
1016
- _userData = NULL ;
992
+ callback = NULL ;
993
+ value = NULL ;
994
+ userData = NULL ;
1017
995
1018
996
[self setFrame: NSMakeRect (0 ,0 ,200 ,30 )];
1019
997
1020
- _name = [[NSTextField alloc ] initWithFrame: NSMakeRect (10 , 0 ,110 , 25 )];
1021
- [_name setEditable: NO ];
1022
- [_name setSelectable: NO ];
1023
- [_name setBezeled: NO ];
1024
- [_name setBordered: NO ];
1025
- [_name setDrawsBackground: NO ];
1026
- [[_name cell ] setLineBreakMode: NSLineBreakByTruncatingTail];
1027
- [self addSubview: _name ];
1028
-
1029
- _slider = [[NSSlider alloc ] initWithFrame: NSMakeRect (120 , 0 , 70 , 25 )];
1030
- [_slider setAutoresizingMask: NSViewWidthSizable];
1031
- [_slider setMinValue: 0 ];
1032
- [_slider setMaxValue: 100 ];
1033
- [_slider setContinuous: YES ];
1034
- [_slider setTarget: self ];
1035
- [_slider setAction: @selector (sliderChanged: )];
1036
- [self addSubview: _slider ];
998
+ name = [[NSTextField alloc ] initWithFrame: NSMakeRect (10 , 0 ,110 , 25 )];
999
+ [name setEditable: NO ];
1000
+ [name setSelectable: NO ];
1001
+ [name setBezeled: NO ];
1002
+ [name setBordered: NO ];
1003
+ [name setDrawsBackground: NO ];
1004
+ [[name cell ] setLineBreakMode: NSLineBreakByTruncatingTail];
1005
+ [self addSubview: name ];
1006
+
1007
+ slider = [[NSSlider alloc ] initWithFrame: NSMakeRect (120 , 0 , 70 , 25 )];
1008
+ [slider setAutoresizingMask: NSViewWidthSizable];
1009
+ [slider setMinValue: 0 ];
1010
+ [slider setMaxValue: 100 ];
1011
+ [slider setContinuous: YES ];
1012
+ [slider setTarget: self ];
1013
+ [slider setAction: @selector (sliderChanged: )];
1014
+ [self addSubview: slider ];
1037
1015
1038
1016
[self setAutoresizingMask: NSViewWidthSizable];
1039
1017
@@ -1044,13 +1022,13 @@ - (id)init {
1044
1022
1045
1023
- (void )sliderChanged : (NSNotification *)notification {
1046
1024
(void )notification;
1047
- int pos = [_slider intValue ];
1048
- if (_value )
1049
- *_value = pos;
1050
- if (_callback )
1051
- _callback (pos);
1052
- if (_callback2 )
1053
- _callback2 (pos, _userData );
1025
+ int pos = [slider intValue ];
1026
+ if (value )
1027
+ *value = pos;
1028
+ if (callback )
1029
+ callback (pos);
1030
+ if (callback2 )
1031
+ callback2 (pos, userData );
1054
1032
}
1055
1033
1056
1034
@end
0 commit comments