From 11f9f5a153ca055e4f104dc6494745e1c4f38518 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Thu, 16 Sep 2010 10:45:35 +0000 Subject: =?UTF-8?q?=E2=80=A2=20finished=20and=20enabled=20the=20new=20BIT?= =?UTF-8?q?=20field=20editor=20sheet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/FieldEditorSheet.xib | 38 ++--- Source/SPFieldEditorController.m | 192 +++++++++++++++++++------- 2 files changed, 160 insertions(+), 70 deletions(-) diff --git a/Interfaces/English.lproj/FieldEditorSheet.xib b/Interfaces/English.lproj/FieldEditorSheet.xib index 07dcbe45..8e440290 100644 --- a/Interfaces/English.lproj/FieldEditorSheet.xib +++ b/Interfaces/English.lproj/FieldEditorSheet.xib @@ -13,7 +13,7 @@ YES - + YES @@ -2241,7 +2241,7 @@ 266 - {{19, 104}, {82, 14}} + {{5, 104}, {90, 14}} YES @@ -2257,7 +2257,7 @@ 266 - {{20, 85}, {82, 14}} + {{5, 85}, {91, 14}} YES @@ -2273,12 +2273,12 @@ 268 - {{106, 102}, {96, 16}} + {{96, 102}, {138, 16}} YES -1804468671 - 272892928 + 71566336 @@ -2295,12 +2295,12 @@ 268 - {{106, 84}, {96, 16}} + {{96, 84}, {138, 16}} YES - -1804468671 - 272892928 + -1803944383 + 71566336 @@ -2312,7 +2312,7 @@ 266 - {{20, 67}, {82, 14}} + {{5, 67}, {91, 14}} YES @@ -2328,12 +2328,12 @@ 268 - {{106, 66}, {96, 16}} + {{96, 66}, {138, 16}} YES - -1804468671 - 272892928 + -2075001280 + 71566336 @@ -2597,7 +2597,7 @@ 268 - {{230, 103}, {39, 15}} + {{245, 103}, {39, 15}} YES @@ -2617,7 +2617,7 @@ 268 - {{322, 103}, {39, 15}} + {{337, 103}, {39, 15}} 4 YES @@ -2638,7 +2638,7 @@ 268 - {{276, 103}, {39, 15}} + {{291, 103}, {39, 15}} 3 YES @@ -2659,7 +2659,7 @@ 268 - {{230, 85}, {39, 15}} + {{245, 85}, {39, 15}} 1 YES @@ -2680,7 +2680,7 @@ 268 - {{230, 67}, {39, 15}} + {{245, 67}, {39, 15}} 2 YES @@ -2701,7 +2701,7 @@ 268 - {{322, 85}, {39, 15}} + {{337, 85}, {39, 15}} 6 YES @@ -2722,7 +2722,7 @@ 268 - {{276, 85}, {39, 15}} + {{291, 85}, {39, 15}} 5 YES diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m index fe3ae80f..fc3f6eec 100644 --- a/Source/SPFieldEditorController.m +++ b/Source/SPFieldEditorController.m @@ -154,18 +154,35 @@ _isEditable = isEditable; - if(NO && [fieldType length] && [fieldType isEqualToString:@"BIT"]) { + // Set field label + NSMutableString *label = [NSMutableString string]; + [label appendFormat:@"“%@”", fieldName]; + if([fieldType length] || maxTextLength > 0 || [fieldEncoding length]) + [label appendString:@" – "]; + if([fieldType length]) + [label appendString:fieldType]; + if(maxTextLength > 0) + [label appendFormat:@"(%ld) ", maxTextLength]; + if([fieldEncoding length]) + [label appendString:fieldEncoding]; + + if([fieldType length] && [fieldType isEqualToString:@"BIT"]) { sheetEditData = [(NSString*)data retain]; + [bitSheetFieldName setStringValue:label]; + + // Init according bit check boxes NSInteger i = 0; - NSInteger maxBit = (maxTextLength > 63) ? 63 : maxTextLength; + NSInteger maxBit = (maxTextLength > 64) ? 64 : maxTextLength; for(i=0; i 0 || [fieldEncoding length]) - [label appendString:@" – "]; - if([fieldType length]) - [label appendString:fieldType]; - if(maxTextLength > 0) - [label appendFormat:@"(%ld) ", maxTextLength]; - if([fieldEncoding length]) - [label appendString:fieldEncoding]; - [editSheetFieldName setStringValue:[NSString stringWithFormat:@"%@: %@%", NSLocalizedString(@"Field", @"Field"), label]]; // hide all views in editSheet @@ -902,19 +907,25 @@ - (void)updateBitSheet { NSInteger i = 0; - NSInteger maxBit = (maxTextLength > 63) ? 63 : maxTextLength; + NSInteger maxBit = (maxTextLength > 64) ? 64 : maxTextLength; NSMutableString *bitString = [NSMutableString string]; [bitString setString:@""]; + for(i=0; i 63) ? 63 : maxTextLength; + NSInteger aBit; + NSInteger maxBit = (maxTextLength > 64) ? 64 : maxTextLength; switch([sender tag]) { - case 0: + case 0: // all to 1 for(i=0; i0; i--) { + [[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i]] setState:[[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i-1]] state]]; + } + [[self valueForKeyPath:@"bitSheetBitButton0"] setState:NSOffState]; + break; + case 4: // shift right + for(i=0; i0; i--) { + [[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i]] setState:[[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i-1]] state]]; + } + [[self valueForKeyPath:@"bitSheetBitButton0"] setState:aBit]; + break; + case 6: // rotate right + aBit = [[self valueForKeyPath:@"bitSheetBitButton0"] state]; + for(i=0; i 64) ? 64 : maxTextLength; + + NSUInteger intValue = strtoull([[bitSheetIntegerTextField stringValue] UTF8String], NULL, 0); + + for(i=0; i>= 1; + i++; + } + [self updateBitSheet]; + } + else if (object == bitSheetHexTextField) { + + NSInteger i = 0; + NSInteger maxBit = (maxTextLength > 64) ? 64 : maxTextLength; + + NSUInteger intValue; + + [[NSScanner scannerWithString:[bitSheetHexTextField stringValue]] scanHexLongLong: &intValue]; + + for(i=0; i>= 1; + i++; + } + [self updateBitSheet]; + } + +} + /* Validate editTextView for max text length except for NULL value string */ @@ -1053,26 +1141,28 @@ - (void)textViewDidChangeSelection:(NSNotification *)notification { - // Do nothing if user really didn't changed text (e.g. for font size changing return) - if(!editTextViewWasChanged && (editSheetWillBeInitialized - || (([[[notification object] textStorage] editedRange].length == 0) - && ([[[notification object] textStorage] changeInLength] == 0)))) { - // Inform the undo-grouping about the caret movement - selectionChanged = YES; - return; - } + if([notification object] == editTextView) { + // Do nothing if user really didn't changed text (e.g. for font size changing return) + if(!editTextViewWasChanged && (editSheetWillBeInitialized + || (([[[notification object] textStorage] editedRange].length == 0) + && ([[[notification object] textStorage] changeInLength] == 0)))) { + // Inform the undo-grouping about the caret movement + selectionChanged = YES; + return; + } - // clear the image and hex (since i doubt someone can "type" a gif) - [editImage setImage:nil]; - [hexTextView setString:@""]; + // clear the image and hex (since i doubt someone can "type" a gif) + [editImage setImage:nil]; + [hexTextView setString:@""]; - // free old data - if ( sheetEditData != nil ) { - [sheetEditData release]; - } + // free old data + if ( sheetEditData != nil ) { + [sheetEditData release]; + } - // set edit data to text - sheetEditData = [[NSString stringWithString:[editTextView string]] retain]; + // set edit data to text + sheetEditData = [[NSString stringWithString:[editTextView string]] retain]; + } } -- cgit v1.2.3