gwenhywfar 4.0.3
|
00001 // 00002 // CocoaLineTextField.m 00003 // 00004 // 00005 // Created by Samuel Strupp on 10.08.10. 00006 // 00007 00008 #ifdef HAVE_CONFIG_H 00009 # include <config.h> 00010 #endif 00011 00012 00013 #import "CocoaLineTextField.h" 00014 00015 #ifndef COCOA_LINE_TEXTFIELD_MM 00016 #define COCOA_LINE_TEXTFIELD_MM 00017 00018 @implementation CocoaLineTextField 00019 00020 - (id)initWithFrame:(NSRect)frame { 00021 self = [super initWithFrame:frame]; 00022 if (self) { 00023 [self setTarget:self]; 00024 [self setAction:@selector(textChanged:)]; 00025 c_actionPtr = nil; 00026 c_actionData = nil; 00027 00028 minWidth = 32.0; 00029 00030 c_textChangedActionPtr = nil; 00031 c_textChangedActionData = nil; 00032 } 00033 return self; 00034 } 00035 00036 -(void) dealloc { 00037 [super dealloc]; 00038 } 00039 00040 -(void) computeMinWidth { 00041 NSSize size = [self neededTextSize]; 00042 if (size.width > 32.0) 00043 minWidth = size.width; 00044 else minWidth = 32.0; 00045 } 00046 00047 -(void) setC_ActionPtr:(gwenTextFieldActionPtr)ptr Data:(void*)data { 00048 c_actionPtr = ptr; 00049 c_actionData = data; 00050 } 00051 00052 -(void) setC_TextChanged_ActionPtr:(gwenTextFieldActionPtr)ptr Data:(void*)data { 00053 c_textChangedActionPtr = ptr; 00054 c_textChangedActionData = data; 00055 } 00056 00057 -(void) textChanged:(id)sender { 00058 if (c_actionPtr) { 00059 c_actionPtr(self, c_actionData); 00060 } 00061 } 00062 00063 - (void)textDidChange:(NSNotification *)aNotification { 00064 //NSLog(@"textDidChange"); 00065 if (c_textChangedActionPtr) { 00066 c_textChangedActionPtr(self, c_textChangedActionData); 00067 } 00068 [super textDidChange:aNotification]; 00069 } 00070 00071 - (void)setStringValue:(NSString *)aString { 00072 [super setStringValue:aString]; //damit hebeln wir die automatische Größen Berechnung vom CocoaLabel aus. 00073 } 00074 00075 #pragma mark Protocoll Methods 00076 00077 - (NSSize) minSize { 00078 return NSMakeSize(minWidth, 22.0); 00079 } 00080 00081 @end 00082 00083 #endif