Changeset 3031


Ignore:
Timestamp:
Sep 10, 2007, 6:39:54 PM (15 years ago)
Author:
livings124
Message:

stage one of the updated message viewer

Location:
trunk/macosx
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/English.lproj/MessageWindow.nib/classes.nib

    r842 r3031  
    1010                fDebugWarningIcon = NSImageView;
    1111                fLevelButton = NSPopUpButton;
     12                fMessageView = NSTableView;
    1213                fScrollView = NSScrollView;
    13                 fTextView = NSTextView;
    1414            };
    1515            SUPERCLASS = NSWindowController;
  • trunk/macosx/English.lproj/MessageWindow.nib/info.nib

    r1846 r3031  
    44<dict>
    55        <key>IBDocumentLocation</key>
    6         <string>25 72 356 240 0 0 1152 842 </string>
     6        <string>42 94 356 240 0 0 1680 1028 </string>
    77        <key>IBFramework Version</key>
    88        <string>446.1</string>
     
    1212        </array>
    1313        <key>IBSystem Version</key>
    14         <string>8P135</string>
     14        <string>8R4031</string>
    1515</dict>
    1616</plist>
  • trunk/macosx/MessageWindowController.h

    r1645 r3031  
    2727@interface MessageWindowController : NSWindowController
    2828{
    29     IBOutlet NSTextView * fTextView;
     29    //IBOutlet NSTextView * fTextView;
     30    IBOutlet NSTableView * fMessageView;
    3031    IBOutlet NSScrollView * fScrollView;
    3132   
    3233    IBOutlet NSPopUpButton * fLevelButton;
    3334   
     35    NSMutableArray * fMessages;
     36   
    3437    NSTimer * fTimer;
    35     NSDictionary * fAttributes;
    36    
    37     int fLines;
    3838   
    3939    IBOutlet NSTextField * fDebugWarningField;
  • trunk/macosx/MessageWindowController.m

    r1645 r3031  
    3131
    3232#define UPDATE_SECONDS  0.6
    33 #define MAX_LINES       2500
     33//#define MAX_LINES       2500
    3434
    3535@interface MessageWindowController (Private)
     
    4545    if ((self = [super initWithWindowNibName: name]))
    4646    {
    47         NSMutableParagraphStyle * paragraph = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
    48         [paragraph setHeadIndent: 20.0];
    49        
    50         fAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
    51                         [NSFont fontWithName: @"Monaco" size: 10], NSFontAttributeName,
    52                         paragraph, NSParagraphStyleAttributeName, nil];
    53         [paragraph release];
    54        
    55         fLines = 0;
     47        fMessages = [[NSMutableArray alloc] init];
    5648       
    5749        fTimer = [NSTimer scheduledTimerWithTimeInterval: UPDATE_SECONDS target: self
    5850                    selector: @selector(updateLog:) userInfo: nil repeats: YES];
    5951       
    60         [[self window] update]; //make sure nib is loaded right away
     52        int level = [[NSUserDefaults standardUserDefaults] integerForKey: @"MessageLevel"];
     53        if (level == TR_MSG_ERR)
     54            [fLevelButton selectItemAtIndex: LEVEL_ERROR];
     55        else if (level == TR_MSG_INF)
     56            [fLevelButton selectItemAtIndex: LEVEL_INFO];
     57        else if (level == TR_MSG_DBG)
     58            [fLevelButton selectItemAtIndex: LEVEL_DEBUG];
     59        else
     60        {
     61            level = TR_MSG_ERR;
     62            [fLevelButton selectItemAtIndex: LEVEL_ERROR];
     63            [[NSUserDefaults standardUserDefaults] setInteger: level forKey: @"MessageLevel"];
     64        }
     65       
     66        tr_setMessageLevel(level);
     67        tr_setMessageQueuing(1);
    6168    }
    6269    return self;
     
    6673{
    6774    [fTimer invalidate];
    68     [fAttributes release];
     75    [fMessages release];
    6976   
    7077    [super dealloc];
     
    7582    [[self window] center];
    7683   
    77     int level = [[NSUserDefaults standardUserDefaults] integerForKey: @"MessageLevel"];
     84    int level = tr_getMessageLevel();
    7885    if (level == TR_MSG_ERR)
    7986        [fLevelButton selectItemAtIndex: LEVEL_ERROR];
     
    9097   
    9198    [self setDebugWarningHidden: level != TR_MSG_DBG];
    92    
    93     tr_setMessageLevel(level);
    94     tr_setMessageQueuing(1);
    9599}
    96100
     
    118122            levelString = @"???";
    119123       
    120         dateString = [[NSDate dateWithTimeIntervalSince1970: currentMessage->when]
    121                             descriptionWithCalendarFormat: @"%1m/%d %H:%M:%S" timeZone: nil locale: nil];
    122         messageString = [NSString stringWithFormat: @"%s%@ %@ %s",
    123                             fLines > 0 ? "\n" : "", dateString, levelString, currentMessage->message];
    124        
    125124        //remove the first line if at max number of lines
    126         if (fLines == MAX_LINES)
     125        /*if (fLines == MAX_LINES)
    127126        {
    128127            unsigned int loc = [[fTextView string] rangeOfString: @"\n"].location;
     
    134133       
    135134        [[fTextView textStorage] appendAttributedString: [[[NSAttributedString alloc] initWithString:
    136                                         messageString attributes: fAttributes] autorelease]];
    137     }
     135                                        messageString attributes: fAttributes] autorelease]];*/
     136       
     137        #warning remove old messages?
     138       
     139        [fMessages addObject: [NSDictionary dictionaryWithObjectsAndKeys:
     140                                [NSString stringWithUTF8String: currentMessage->message], @"Message",
     141                                [NSDate dateWithTimeIntervalSince1970: currentMessage->when], @"Date",
     142                                levelString, @"Level", nil]];
     143    }
     144   
     145    [fMessageView reloadData];
    138146   
    139147    tr_freeMessageList(messages);
    140148   
    141     if (shouldScroll)
    142         [fTextView scrollRangeToVisible: NSMakeRange([[fTextView string] length], 0)];
     149    /*if (shouldScroll)
     150        [fTextView scrollRangeToVisible: NSMakeRange([[fTextView string] length], 0)];*/
     151}
     152
     153- (int) numberOfRowsInTableView: (NSTableView *) tableView
     154{
     155    return [fMessages count];
     156}
     157
     158- (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) column row: (int) row
     159{
     160    NSString * ident = [column identifier];
     161    NSDictionary * message = [fMessages objectAtIndex: row];
     162
     163    if ([ident isEqualToString: @"Date"])
     164        return [message objectForKey: @"Date"];
     165    else if ([ident isEqualToString: @"Level"])
     166        return [message objectForKey: @"Level"];
     167    else
     168        return [message objectForKey: @"Message"];
    143169}
    144170
     
    163189- (void) clearLog: (id) sender
    164190{
    165     [fTextView setString: @""];
    166     fLines = 0;
     191    [fMessages removeAllObjects];
     192    [fMessageView reloadData];
    167193}
    168194
    169195- (void) writeToFile: (id) sender
    170196{
    171     NSString * string = [[fTextView string] retain];
     197    /*NSString * string = [[fTextView string] retain];
    172198   
    173199    NSSavePanel * panel = [NSSavePanel savePanel];
     
    177203    [panel beginSheetForDirectory: nil file: NSLocalizedString(@"untitled", "Save log panel -> default file name")
    178204            modalForWindow: [self window] modalDelegate: self
    179             didEndSelector: @selector(writeToFileSheetClosed:returnCode:contextInfo:) contextInfo: string];
     205            didEndSelector: @selector(writeToFileSheetClosed:returnCode:contextInfo:) contextInfo: string];*/
    180206}
    181207
    182208- (void) writeToFileSheetClosed: (NSSavePanel *) panel returnCode: (int) code contextInfo: (NSString *) string
    183209{
    184     if (code == NSOKButton)
     210    /*if (code == NSOKButton)
    185211    {
    186212        if (![string writeToFile: [panel filename] atomically: YES encoding: NSUTF8StringEncoding error: nil])
     
    200226    }
    201227   
    202     [string release];
     228    [string release];*/
    203229}
    204230
Note: See TracChangeset for help on using the changeset viewer.