Search
lxdream.org :: lxdream/src/cocoaui/cocoa_gd.m
lxdream 0.9.1
released Jun 29
Download Now
filename src/cocoaui/cocoa_gd.m
changeset 1040:9e3e41eab2db
prev964:f2f3c7612d06
author nkeynes
date Wed Feb 15 17:54:51 2012 +1000 (10 years ago)
permissions -rw-r--r--
last change Use GL_TEXTURE_2D instead of GL_TEXTURE_RECTANGLE_ARB for frame buffers, for
systems that don't provide the latter (and there's not really much
difference anyway).
Add macro wrangling for GL_DEPTH24_STENCIL8 format
view annotate diff log raw
     1 /**
     2  * $Id$
     3  *
     4  * Management of the GDRom menu under cocoa
     5  * 
     6  * Copyright (c) 2005 Nathan Keynes.
     7  *
     8  * This program is free software; you can redistribute it and/or modify
     9  * it under the terms of the GNU General Public License as published by
    10  * the Free Software Foundation; either version 2 of the License, or
    11  * (at your option) any later version.
    12  *
    13  * This program is distributed in the hope that it will be useful,
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  * GNU General Public License for more details.
    17  */
    20 #include <AppKit/AppKit.h>
    21 #include <stdio.h>
    22 #include <stdlib.h>
    23 #include <string.h>
    24 #include <sys/time.h>
    25 #include "lxdream.h"
    26 #include "dreamcast.h"
    27 #include "dream.h"
    28 #include "gdlist.h"
    29 #include "cocoaui/cocoaui.h"
    31 void cocoa_gdrom_menu_build( NSMenu *menu )
    32 {
    33     int i,len = gdrom_list_size();
    34     for( i=0; i<len; i++ ) {
    35         const gchar *entry = gdrom_list_get_display_name(i);
    36         if( entry[0] == '\0' ) {
    37             [menu addItem: [NSMenuItem separatorItem]];
    38         } else {
    39             NSString *keyEquiv = @"";
    40             if( i == 0 ) {
    41                 keyEquiv = @"e";
    42             }
    43             [[menu addItemWithTitle: [NSString stringWithCString: entry] 
    44                                       action: @selector(gdrom_list_action:) keyEquivalent: keyEquiv]
    45                                       setTag: i];
    46         }
    47     }
    48     [menu addItem: [NSMenuItem separatorItem]];
    49     [menu addItemWithTitle: NS_("Open image file...") action: @selector(mount_action:)
    50      keyEquivalent: @"i"];
    51 }
    53 void cocoa_gdrom_menu_rebuild( NSMenu *menu )
    54 {
    55     while( [menu numberOfItems] > 0  ) {
    56         [ menu removeItemAtIndex: 0 ];
    57     }
    59     cocoa_gdrom_menu_build( menu );
    60 }
    62 gboolean cocoa_gdrom_menu_update( gboolean list_changed, int selection, void *user_data )
    63 {
    64     // Create an auto-release pool - we may be called outside of the GUI main loop
    65     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    66     NSMenu *menu = (NSMenu *)user_data;
    67     int i;
    69     if( list_changed ) {
    70         cocoa_gdrom_menu_rebuild(menu);
    71     }
    73     for( i=0; i< [menu numberOfItems]; i++ ) {
    74         if( i == selection ) {
    75             [[menu itemAtIndex: i] setState: NSOnState];
    76         } else {
    77             [[menu itemAtIndex: i] setState: NSOffState];
    78         }
    79     }
    80     [pool release];
    81     return TRUE;
    82 }
    84 NSMenu *cocoa_gdrom_menu_new()
    85 {
    86     NSMenu *menu = [[NSMenu alloc] initWithTitle: @"GD-Rom Settings"];
    87     cocoa_gdrom_menu_build(menu);
    89     register_gdrom_list_change_hook(cocoa_gdrom_menu_update, menu);
    90     cocoa_gdrom_menu_update( FALSE, gdrom_list_get_selection(), menu );    
    91     return menu;
    92 }
.