]> uap-core.de Git - note.git/commitdiff
remove old toolkit files
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 6 Mar 2025 18:03:03 +0000 (19:03 +0100)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 6 Mar 2025 18:03:03 +0000 (19:03 +0100)
17 files changed:
ui/cocoa/graphics.h [deleted file]
ui/cocoa/graphics.m [deleted file]
ui/cocoa/menu.h [deleted file]
ui/cocoa/menu.m [deleted file]
ui/cocoa/resource.h [deleted file]
ui/cocoa/resource.m [deleted file]
ui/cocoa/stock.h [deleted file]
ui/cocoa/stock.m [deleted file]
ui/cocoa/text.h [deleted file]
ui/cocoa/text.m [deleted file]
ui/cocoa/toolbar.h [deleted file]
ui/cocoa/toolbar.m [deleted file]
ui/cocoa/tree.h [deleted file]
ui/cocoa/tree.m [deleted file]
ui/motif/text.c
ui/motif/tree.c [deleted file]
ui/motif/tree.h [deleted file]

diff --git a/ui/cocoa/graphics.h b/ui/cocoa/graphics.h
deleted file mode 100644 (file)
index 3f593d7..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2014 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "../ui/graphics.h"
-#import "toolkit.h"
-
-
-@interface UiCanvas : NSView {
-    UiObject            *object;
-    ui_drawfunc         callback;
-    void                *userdata;
-}
-
-- (UiObject*) object;
-- (void) setObject:(void*)obj;
-
-- (void*) userdata;
-- (void) setUserdata:(void*)d;
-
-- (ui_drawfunc) callback;
-- (void) setCallback: (ui_drawfunc)f;
-
-
-- (void)drawRect:(NSRect)rect;
-
-@end
-
diff --git a/ui/cocoa/graphics.m b/ui/cocoa/graphics.m
deleted file mode 100644 (file)
index 062163b..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2014 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <stdio.h>
-#import <stdlib.h>
-#import <string.h>
-
-#import "graphics.h"
-#import "container.h"
-#import "../common/context.h"
-
-
-
-@implementation UiCanvas
-
-- (UiObject*) object {
-    return object;
-}
-
-- (void) setObject:(void*)obj {
-    object = obj;
-}
-
-- (void*) userdata {
-    return userdata;
-}
-
-- (void) setUserdata:(void*)d {
-    userdata = d;
-}
-
-- (ui_drawfunc) callback {
-    return callback;
-}
-- (void) setCallback: (ui_drawfunc)f {
-    callback = f;
-}
-
-- (void) drawRect:(NSRect)rect {
-    UiGraphics g;
-    NSRect bounds = [self bounds];
-    g.width = bounds.size.width;
-    g.height = bounds.size.height;
-    
-    UiEvent ev;
-    ev.obj = object;
-    ev.window = object->window;
-    ev.document = object->ctx->document;
-    
-    callback(&ev, &g, userdata);
-}
-
-@end
-
-
-UIWIDGET ui_drawingarea(UiObject *obj, ui_drawfunc f, void *userdata) {
-    UiContainer *ct = uic_get_current_container(obj);
-    
-    NSRect frame = ct->getframe(ct);
-    
-    UiCanvas *canvas = [[UiCanvas alloc]initWithFrame:frame];
-    [canvas setObject: obj];
-    [canvas setCallback: f];
-    [canvas setUserdata: userdata];
-    ct->add(ct, canvas);
-    
-    return canvas;
-}
-
-
-// drawing functions
-void ui_graphics_color(UiGraphics *gr, int red, int green, int blue) {
-    float r = ((float)red) / 255.f;
-    float g = ((float)green) / 255.f;
-    float b = ((float)blue) / 255.f;
-    
-    NSColor *color = [NSColor colorWithCalibratedRed:r green:g blue:b alpha:1];
-    [color set];
-}
-
-void ui_draw_rect(UiGraphics *g, int x, int y, int w, int h, int fill) {
-    // translate y
-    y = g->height - y - h;
-    
-    NSRect bounds;
-    bounds.origin.x = x;
-    bounds.origin.y = y;
-    bounds.size.width = w;
-    bounds.size.height = h;
-    
-    if(fill) {
-        NSRectFill(bounds);
-    } else {
-        NSFrameRect(bounds);
-    }
-}
-
-
-
diff --git a/ui/cocoa/menu.h b/ui/cocoa/menu.h
deleted file mode 100644 (file)
index 0f7cb8e..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2014 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "../ui/menu.h"
-#import "toolkit.h"
-#import <ucx/list.h>
-
-typedef struct UiAbstractMenuItem {
-    int  (*update)(id window, void *item);
-    void *item_data;
-} UiAbstractMenuItem;
-
-typedef struct UiMenuItem {
-    NSMenuItem  *item;
-    int         state;
-} UiMenuItem;
-
-typedef struct UiStateItem {
-    NSMenuItem  *item;
-    char        *var;
-} UiStateItem;
-
-typedef struct UiMenuItemList {
-    NSMenu      *menu;
-    NSMenuItem  *first;
-    UiList      *list;
-    int         index;
-    int         oldcount;
-    ui_callback callback;
-    void        *data;
-} UiMenuItemList;
-
-@interface UiMenuDelegate : NSObject <NSMenuDelegate> {
-    UcxList *items; // UiStateItem*
-    UcxList *itemlists; // UiMenuItemList*
-}
-
-- (void) menuNeedsUpdate:(NSMenu*) menu;
-
-- (void) addItem:(NSMenuItem*) item var: (char*)name;
-
-- (void) addList:(UiList*) list menu:(NSMenu*)menu index: (int)i callback: (ui_callback)f data:(void*) data;
-
-- (UcxList*) items;
-
-- (UcxList*) lists;
-
-@end
-
-@interface UiGroupMenuItem : NSMenuItem {
-    NSMutableArray *groups;
-}
-
-- (id)initWithTitle:(NSString*)title action:(SEL)action keyEquivalent:(NSString*)s;
-
-- (void) addGroup:(int)group;
-
-- (void) checkGroups:(int*)g count:(int)n;
-
-@end
-
-void ui_menu_init();
-UiMenuDelegate* ui_menu_delegate();
-
-int ui_menuitem_get(UiInteger *i);
-void ui_menuitem_set(UiInteger *i, int value);
-
-int ui_update_item(id window, void *data);
-int ui_update_item_list(id window, void *data);
diff --git a/ui/cocoa/menu.m b/ui/cocoa/menu.m
deleted file mode 100644 (file)
index c286ef7..0000000
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2014 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <stdio.h>
-#import <stdlib.h>
-#import <string.h>
-#import <stdarg.h>
-
-#import "menu.h"
-#import "window.h"
-#import "stock.h"
-
-@implementation UiMenuDelegate 
-
-- (UiMenuDelegate*) init {
-    items = NULL;
-    itemlists = NULL;
-    return self;
-}
-
-- (void) menuNeedsUpdate:(NSMenu *) menu {
-    NSWindow *activeWindow = [NSApp keyWindow];
-    [(UiCocoaWindow*)activeWindow updateMenu: menu];
-}
-
-- (void) addItem:(NSMenuItem*) item var: (char*)name {
-    UiStateItem *i = malloc(sizeof(UiStateItem));
-    i->item = item;
-    i->var = name;
-    items = ucx_list_append(items, i);
-}
-
-- (void) addList:(UiList*) list menu:(NSMenu*)menu index: (int)i callback: (ui_callback)f data:(void*) data {
-    UiMenuItemList *itemList = malloc(sizeof(UiMenuItemList));
-    itemList->list = list;
-    itemList->menu = menu;
-    itemList->first = NULL;
-    itemList->index = i;
-    itemList->oldcount = 0;
-    itemList->callback = f;
-    itemList->data = data;
-    itemlists = ucx_list_append(itemlists, itemList);
-}
-
-- (UcxList*) items {
-    return items;
-}
-
-- (UcxList*) lists {
-    return itemlists;
-    
-}
-
-@end
-
-
-@implementation UiGroupMenuItem
-
-- (id)initWithTitle:(NSString*)title action:(SEL)action keyEquivalent:(NSString*)s {
-    [super initWithTitle:title action:action keyEquivalent:s];
-    groups = [[NSMutableArray alloc]initWithCapacity: 8];
-    return self;
-}
-
-- (void) addGroup:(int)group {
-    NSNumber *groupNumber = [NSNumber numberWithInteger:group];
-    [groups addObject:groupNumber];
-}
-
-- (void) checkGroups:(int*)g count:(int)n {
-    int c = [groups count];
-    
-    char *check = calloc(1, c);
-    for(int i=0;i<n;i++) {
-        for(int k=0;k<c;k++) {
-            NSNumber *groupNumber = [groups objectAtIndex:k];
-            if([groupNumber intValue] == g[i]) {
-                check[k] = 1;
-                break;
-            }
-        }
-    }
-    
-    for(int j=0;j<c;j++) {
-        if(check[j] == 0) {
-            [self setEnabled:NO];
-            return;
-        }
-    }
-    [self setEnabled:YES];
-}
-
-@end
-
-
-//static NSMenu *currentMenu = NULL;
-
-static UcxList *current;
-
-static int currentItemIndex = 0;
-static UiMenuDelegate *delegate;
-
-void ui_menu_init() {
-    delegate = [[UiMenuDelegate alloc]init];
-}
-
-UiMenuDelegate* ui_menu_delegate() {
-    return delegate;
-}
-
-
-void ui_menu(char *title) {
-    NSString *str = [[NSString alloc] initWithUTF8String:title];
-    
-    NSMenu *menu = [[NSMenu alloc] initWithTitle: str];
-    NSMenuItem *menuItem = [[NSApp mainMenu] addItemWithTitle:str
-                                                       action:nil keyEquivalent:@""];
-    [menu setDelegate: delegate];
-    [menu setAutoenablesItems:NO];
-    
-    [[NSApp mainMenu] setSubmenu:menu forItem:menuItem];
-    //currentMenu = menu;
-    currentItemIndex = 0;
-    
-    current = ucx_list_prepend(NULL, menu);
-}
-
-void ui_submenu(char *title) {
-    NSString *str = [[NSString alloc] initWithUTF8String:title];
-    NSMenu *currentMenu = current->data;
-    
-    NSMenu *menu = [[NSMenu alloc] initWithTitle: str];
-    NSMenuItem *menuItem = [currentMenu addItemWithTitle:str
-                                                       action:nil keyEquivalent:@""];
-    [menu setDelegate: delegate];
-    [menu setAutoenablesItems:NO];
-    
-    [currentMenu setSubmenu:menu forItem:menuItem];
-    //currentMenu = menu;
-    currentItemIndex = 0;
-    
-    current = ucx_list_prepend(current, menu);
-}
-
-void ui_submenu_end() {
-    if(ucx_list_size(current) < 2) {
-        return;
-    }
-    current = ucx_list_remove(current, current);
-}
-
-void ui_menuitem(char *label, ui_callback f, void *data) {
-    ui_menuitem_gr(label, f, data, -1);
-}
-
-void ui_menuitem_st(char *stockid, ui_callback f, void *data) {
-    ui_menuitem_stgr(stockid, f, data, -1);
-}
-
-void ui_menuitem_gr(char *label, ui_callback f, void *userdata, ...) {
-    // create menu item
-    EventWrapper *event = [[EventWrapper alloc]initWithData:userdata callback:f];
-    NSString *title = [[NSString alloc] initWithUTF8String:label];
-    UiGroupMenuItem *item = [[UiGroupMenuItem alloc]initWithTitle:title action:@selector(handleEvent:) keyEquivalent:@""];
-    [item setTarget:event];
-    
-    // add groups
-    va_list ap;
-    va_start(ap, userdata);
-    int group;
-    while((group = va_arg(ap, int)) != -1) {
-        [item addGroup: group];
-    }
-    va_end(ap);
-    
-    NSMenu *currentMenu = current->data;
-    [currentMenu addItem:item];
-    
-    currentItemIndex++;
-}
-
-void ui_menuitem_stgr(char *stockid, ui_callback f, void *userdata, ...) {
-    // create menu item
-    EventWrapper *event = [[EventWrapper alloc]initWithData:userdata callback:f];
-    UiStockItem *si = ui_get_stock_item(stockid);
-    UiGroupMenuItem *item = [[UiGroupMenuItem alloc]initWithTitle:si->label
-                                action:@selector(handleEvent:)
-                                keyEquivalent:si->keyEquivalent];
-    [item setTarget:event];
-    
-    // add groups
-    va_list ap;
-    va_start(ap, userdata);
-    int group;
-    while((group = va_arg(ap, int)) != -1) {
-        [item addGroup: group];
-    }
-    va_end(ap);
-    
-    NSMenu *currentMenu = current->data;
-    [currentMenu addItem:item];
-    
-    currentItemIndex++;
-}
-
-void ui_checkitem(char *label, ui_callback f, void *data) {
-    EventWrapper *event = [[EventWrapper alloc]initWithData:data callback:f];
-    NSString *str = [[NSString alloc] initWithUTF8String:label];
-    
-    NSMenu *currentMenu = current->data;
-    NSMenuItem *item = [currentMenu addItemWithTitle:str
-                                              action:@selector(handleStateEvent:) keyEquivalent:@""];
-    [item setTarget:event];
-    
-    [delegate addItem: item var:NULL];
-    currentItemIndex++;
-}
-
-void ui_checkitem_nv(char *label, char *vname) {
-    EventWrapper *event = [[EventWrapper alloc]initWithData:NULL callback:NULL];
-    NSString *str = [[NSString alloc] initWithUTF8String:label];
-    
-    NSMenu *currentMenu = current->data;
-    NSMenuItem *item = [currentMenu addItemWithTitle:str
-                                              action:@selector(handleStateEvent:) keyEquivalent:@""];
-    [item setTarget:event];
-    
-    [delegate addItem: item var:vname];
-    currentItemIndex++;
-}
-
-void ui_menuseparator() {
-    NSMenu *currentMenu = current->data;
-    [currentMenu addItem: [NSMenuItem separatorItem]];
-    currentItemIndex++;
-}
-
-void ui_menuitem_list (UiList *items, ui_callback f, void *data) {
-    NSMenu *currentMenu = current->data;
-    [delegate addList:items menu:currentMenu index:currentItemIndex callback:f data:data];
-}
-
-
-
-int ui_menuitem_get(UiInteger *i) {
-    UiMenuItem *item = i->obj;
-    i->value = [item->item state];
-    return i->value;
-}
-
-void ui_menuitem_set(UiInteger *i, int value) {
-    UiMenuItem *item = i->obj;
-    [item->item setState: value];
-    i->value = value;
-    item->state = value;
-}
-
-
-int ui_update_item(UiCocoaWindow *window, void *data) {
-    UiMenuItem *item = data;
-    [item->item setState: item->state];
-    return 0;
-}
-
-int ui_update_item_list(UiCocoaWindow *window, void *data) {
-    UiMenuItemList *itemList = data;
-    UiList *list = itemList->list;
-    
-    for(int r=0;r<itemList->oldcount;r++) {
-        [itemList->menu removeItemAtIndex:itemList->index];
-    }
-    
-    char *str = ui_list_first(list);
-    int i = itemList->index;
-    [itemList->menu insertItem: [NSMenuItem separatorItem] atIndex: i];
-    i++;
-    while(str) {
-        EventWrapper *event = [[EventWrapper alloc]initWithData:itemList->data callback:itemList->callback];
-        [event setIntval: i - itemList->index - 1];
-        
-        NSString *title = [[NSString alloc] initWithUTF8String:str];
-        NSMenuItem *item = [[NSMenuItem alloc]initWithTitle:title action:@selector(handleEvent:) keyEquivalent:@""];
-        [item setTarget:event];
-        
-        [itemList->menu insertItem:item atIndex:i];
-        
-        str = ui_list_next(list);
-        i++;
-    }
-    
-    itemList->oldcount = i - itemList->index;
-    
-    return 0;
-}
diff --git a/ui/cocoa/resource.h b/ui/cocoa/resource.h
deleted file mode 100644 (file)
index 0dd0c66..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2012 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "../ui/toolkit.h"
-#import "../ui/properties.h"
-
-
diff --git a/ui/cocoa/resource.m b/ui/cocoa/resource.m
deleted file mode 100644 (file)
index afb9410..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2012 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <stdio.h>
-#import <stdlib.h>
-#import <string.h>
-
-#import "resource.h"
-#import "../common/properties.h"
-
-
-
-void ui_load_lang_def(char *locale, char *default_locale) {
-    NSString *localeString = nil;
-    char tmp[6];
-    if(!locale) {
-        NSString* lang = [[NSLocale currentLocale] localeIdentifier];
-        if(lang) {
-            localeString = lang;
-        } else {
-            [[NSString alloc]initWithUTF8String:default_locale];
-        }
-    } else {
-        localeString = [[NSString alloc]initWithUTF8String:locale];
-    }
-    
-    NSString *path = [[NSBundle mainBundle] pathForResource:localeString ofType:@"properties" inDirectory:@"locales"];
-    
-    const char *p = [path UTF8String];
-    
-    if(uic_load_language_file((char*)p)) {
-        if(default_locale) {
-            ui_load_lang_def(default_locale, NULL);
-        } else {
-            // cannot find any language file
-            fprintf(stderr, "Ui Error: Cannot load language.\n");
-            exit(-1);
-        }
-    }
-}
-
-void ui_locales_dir(char *path) {
-    // empty
-}
-
-void ui_pixmaps_dir(char *path) {
-    // empty
-}
\ No newline at end of file
diff --git a/ui/cocoa/stock.h b/ui/cocoa/stock.h
deleted file mode 100644 (file)
index 2568aaf..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2012 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "toolkit.h"
-#import "../ui/stock.h"
-#import <ucx/map.h>
-
-typedef struct UiStockItem {
-    NSString *label;
-    NSString *keyEquivalent;
-    NSImage  *image;
-} UiStockItem;
-
-void ui_stock_init();
-
-void ui_add_stock_item(char *stock_id, NSString *label, NSString *keyEquivalent, NSImage *image);
-
-UiStockItem* ui_get_stock_item(char *stock_id);
diff --git a/ui/cocoa/stock.m b/ui/cocoa/stock.m
deleted file mode 100644 (file)
index 227e3bc..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2012 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <stdio.h>
-#import <stdlib.h>
-
-#import "stock.h"
-#import "../common/properties.h"
-
-static UcxMap *stock_items;
-
-void ui_stock_init() {
-    stock_items = ucx_map_new(64);
-    
-    ui_add_stock_item(UI_STOCK_NEW, @"New", @"n", nil);
-    ui_add_stock_item(UI_STOCK_OPEN, @"Open", @"o", nil);
-    ui_add_stock_item(UI_STOCK_SAVE, @"Save", @"s", nil);
-    ui_add_stock_item(UI_STOCK_SAVE_AS, @"Save as ...", @"", nil);
-    ui_add_stock_item(UI_STOCK_CLOSE, @"Close", @"w", nil);
-    ui_add_stock_item(UI_STOCK_UNDO, @"Undo", @"z", nil);
-    ui_add_stock_item(UI_STOCK_REDO, @"Redo", @"", nil);
-    ui_add_stock_item(UI_STOCK_CUT, @"Cut", @"x", nil);
-    ui_add_stock_item(UI_STOCK_COPY, @"Copy", @"c", nil);
-    ui_add_stock_item(UI_STOCK_PASTE, @"Paste", @"v", nil);
-    ui_add_stock_item(UI_STOCK_DELETE, @"Delete", @"", nil);
-    
-    ui_add_stock_item(UI_STOCK_GO_BACK, @"Back", @"", [NSImage imageNamed: NSImageNameGoLeftTemplate]);
-    ui_add_stock_item(UI_STOCK_GO_FORWARD, @"Forward", @"", [NSImage imageNamed: NSImageNameGoRightTemplate]);
-}
-
-void ui_add_stock_item(char *stock_id, NSString *label, NSString *keyEquivalent, NSImage *image) {
-    UiStockItem *i = malloc(sizeof(UiStockItem));
-    i->label = label;
-    i->keyEquivalent = keyEquivalent;
-    i->image = image;
-    
-    ucx_map_cstr_put(stock_items, stock_id, i);
-}
-
-UiStockItem* ui_get_stock_item(char *stock_id) {
-    UiStockItem *item = ucx_map_cstr_get(stock_items, stock_id);
-    if(item) {
-        char *label = uistr_n(stock_id);
-        if(label) {
-            NSString *str = [[NSString alloc]initWithUTF8String:label];
-            item->label = str;
-        }
-    }
-    return item;
-}
diff --git a/ui/cocoa/text.h b/ui/cocoa/text.h
deleted file mode 100644 (file)
index ba0f1c5..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2014 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "../ui/text.h"
-#import "toolkit.h"
-#import <ucx/list.h>
-
-@interface TextChangeMgr : NSObject<NSTextViewDelegate> {
-    UiContext *context;
-    UiText    *value;
-    int       last_length;
-}
-
-- (TextChangeMgr*)initWithValue:(UiText*)text context:(UiContext*)ctx;
-
-- (NSUndoManager*)undoManagerForTextView:(NSTextView*)textview;
-
-@end
-
-#define UI_TEXTBUF_INSERT 0
-#define UI_TEXTBUF_DELETE 1
-typedef struct UiTextBufOp {
-    int  type; // UI_TEXTBUF_INSERT, UI_TEXTBUF_DELETE
-    int  start;
-    int  end;
-    int  len;
-    char *text;
-} UiTextBufOp;
-
-
-
-char* ui_textarea_get(UiText *text);
-void ui_textarea_set(UiText *text, char *str);
-char* ui_textarea_getsubstr(UiText *text, int begin, int end);
-void ui_textarea_insert(UiText *text, int pos, char *str);
-int  ui_textarea_position(UiText *text);
-void ui_textarea_selection(UiText *text, int *begin, int *end);
-int ui_textarea_length(UiText *text);
diff --git a/ui/cocoa/text.m b/ui/cocoa/text.m
deleted file mode 100644 (file)
index bc92f1a..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2014 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <stdio.h>
-#import <stdlib.h>
-#import <string.h>
-
-#import "text.h"
-#import "container.h"
-
-@implementation TextChangeMgr
-
-- (TextChangeMgr*)initWithValue:(UiText*)text context:(UiContext*)ctx {
-    value = text;
-    context = ctx;
-    last_length = 0;
-    return self;
-}
-
-- (NSUndoManager*)undoManagerForTextView:(NSTextView*)textview {
-    return (NSUndoManager*)value->undomgr;
-}
-
-- (NSRange)textView:(NSTextView *)textview
-       willChangeSelectionFromCharacterRange:(NSRange)oldrange
-       toCharacterRange:(NSRange)newrange
-{
-    if(newrange.length != last_length) {
-        if(newrange.length == 0) {
-            ui_unset_group(context, UI_GROUP_SELECTION);
-        } else {
-            ui_set_group(context, UI_GROUP_SELECTION);
-        }
-    }
-    
-    last_length = newrange.length;
-    return newrange;
-}
-
-@end
-
-
-UIWIDGET ui_textarea(UiObject *obj, UiText *value) {
-    UiContainer *ct = uic_get_current_container(obj);
-    
-    NSRect frame = ct->getframe(ct);
-    
-    NSScrollView *scrollview = [[NSScrollView alloc] initWithFrame:frame];
-    [scrollview setHasVerticalScroller:YES];
-    //[scrollvew setHasHorizontalScroller:YES];
-    [scrollview setBorderType:NSNoBorder];
-    //[scrollview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
-    
-    //frame.size.width = frame.size.width - 15;
-    NSTextView *textview = [[NSTextView alloc]initWithFrame:frame];
-    [textview setAllowsUndo:TRUE];
-    [textview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
-    
-    [textview setFont:[NSFont fontWithName:@"Menlo" size:12]];
-    
-    [scrollview setDocumentView:textview];
-    
-    ct->add(ct, scrollview);
-    
-    // bind value
-    if(value) {
-        value->get = ui_textarea_get;
-        value->set = ui_textarea_set;
-        value->getsubstr = ui_textarea_getsubstr;
-        value->insert = ui_textarea_insert;
-        value->position = ui_textarea_position;
-        value->selection = ui_textarea_selection;
-        value->length = ui_textarea_length;
-        value->value = NULL;
-        value->obj = textview;
-        
-        TextChangeMgr *delegate = [[TextChangeMgr alloc]initWithValue:value context:obj->ctx];
-        [textview setDelegate:delegate];
-        
-        NSUndoManager *undomgr = [[NSUndoManager alloc]init];
-        value->undomgr = undomgr;
-    }
-    
-    return textview;
-}
-
-char* ui_textarea_get(UiText *text) {
-    if(text->value) {
-        free(text->value);
-    }
-    NSTextView *textview = (NSTextView*)text->obj;
-    NSString *str = [[textview textStorage]string];
-    size_t length = [str lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
-    const char *cstr = [str UTF8String];
-    char *value = malloc(length + 1);
-    memcpy(value, cstr, length);
-    value[length] = '\0';
-    text->value = value;
-    return value;
-}
-
-void ui_textarea_set(UiText *text, char *str) {
-    if(text->value) {
-        free(text->value);
-    }
-    NSTextView *textview = (NSTextView*)text->obj;
-    NSString *s = [[NSString alloc]initWithUTF8String:str];
-    NSAttributedString *as = [[NSAttributedString alloc]initWithString:s];
-    [[textview textStorage] setAttributedString:as];
-    text->value = NULL;
-}
-
-char* ui_textarea_getsubstr(UiText *text, int begin, int end) {
-    if(text->value) {
-        free(text->value);
-    }
-    NSTextView *textview = (NSTextView*)text->obj;
-    NSString *str = [[textview textStorage]string];
-    NSRange range;
-    range.location = begin;
-    range.length = end - begin;
-    
-    NSString *substr = [str substringWithRange:range];
-    size_t length = [substr lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
-    const char *cstr = [substr UTF8String];
-    char *value = malloc(length + 1);
-    memcpy(value, cstr, length);
-    value[length] = '\0';
-    text->value = value;
-    return value;
-}
-
-void ui_textarea_insert(UiText *text, int pos, char *str) {
-    if(text->value) {
-        free(text->value);
-    }
-    NSTextView *textview = (NSTextView*)text->obj;
-    NSString *s = [[NSString alloc]initWithUTF8String:str];
-    NSAttributedString *as = [[NSAttributedString alloc]initWithString:s];
-    [[textview textStorage] insertAttributedString:as atIndex: pos];
-    text->value = NULL;
-}
-
-int ui_textarea_position(UiText *text) {
-    return [[[(NSTextView*)text->obj selectedRanges] objectAtIndex:0] rangeValue].location;
-}
-
-void ui_textarea_selection(UiText *text, int *begin, int *end) {
-    NSRange range = [[[(NSTextView*)text->obj selectedRanges] objectAtIndex:0] rangeValue];
-    *begin = range.location;
-    *end = range.location + range.length;
-}
-
-int ui_textarea_length(UiText *text) {
-    return [[(NSTextView*)text->obj textStorage] length];
-}
-
-void ui_text_undo(UiText *text) {
-    [(NSUndoManager*)text->undomgr undo];
-}
-
-void ui_text_redo(UiText *text) {
-    [(NSUndoManager*)text->undomgr redo];
-}
-
diff --git a/ui/cocoa/toolbar.h b/ui/cocoa/toolbar.h
deleted file mode 100644 (file)
index 95fd967..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2014 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "../ui/toolbar.h"
-#import "toolkit.h"
-#import <stdarg.h>
-
-
-@protocol UiToolItem
-- (NSToolbarItem *) createItem:(NSToolbar*)toolbar
-                    identifier:(NSString*)identifier
-                        object:(UiObject*)obj;
-
-- (void) addGroup:(int)group;
-
-- (UcxList*) groups;
-
-@end
-
-
-/*
- * UiToolbarStockItem
- *
- * creates a toolbar item from stock description
- */
-@interface UiToolbarStockItem : NSObject <UiToolItem> {
-    char           *name;
-    char           *stockid;
-    ui_callback    callback;
-    void           *userdata;
-    UcxList        *groups;
-    BOOL           isToggleButton;
-}
-
-- (UiToolbarStockItem*) initWithIdentifier:(char*)identifier
-                             stockID:(char*)sid
-                            callback:(ui_callback)f
-                            userdata:(void*)data;
-
-- (void) setIsToggleButton:(BOOL)t;
-
-
-@end
-
-/*
- * UiToolbarItem
- *
- * toolbar item with label and icon
- */
-@interface UiToolbarItem : NSObject <UiToolItem> {
-    char           *name;
-    char           *label;
-    // icon
-    ui_callback    callback;
-    void           *userdata;
-    UcxList        *groups;
-    BOOL           isToggleButton;
-}
-
-- (UiToolbarItem*) initWithIdentifier:(char*)identifier
-                                     label:(char*)lbl
-                                  callback:(ui_callback)f
-                                  userdata:(void*)data;
-
-- (void) setIsToggleButton:(BOOL)t;
-
-
-@end
-
-
-
-/*
- * UiToolbarDelegate
- */
-@interface UiToolbarDelegate : NSObject <NSToolbarDelegate> {
-    NSMutableArray      *allowedItems;
-    NSMutableArray      *defaultItems;
-    NSMutableDictionary *items;
-}
-
-- (UiToolbarDelegate*) init;
-
-- (void) addDefault:(NSString*)identifier;
-
-- (void) addItem: (NSString*) identifier
-            item: (NSObject<UiToolItem>*) item;
-
-@end
-
-
-/*
- * UiToolbar
- */
-@interface UiToolbar : NSToolbar {
-    UiObject *obj;
-}
-
-- (UiToolbar*) initWithObject:(UiObject*)object;
-
-- (UiObject*) object;
-
-@end
-
-void ui_toolbar_init();
-void ui_toolbar_stock_button(char *name, char *stockid, BOOL toggle, ui_callback f, void *udata, va_list ap);
-NSToolbar* ui_create_toolbar(UiObject *obj);
diff --git a/ui/cocoa/toolbar.m b/ui/cocoa/toolbar.m
deleted file mode 100644 (file)
index 4a044ac..0000000
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2014 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <stdio.h>
-#import <stdlib.h>
-#import <string.h>
-#import <inttypes.h>
-#import <stdarg.h>
-
-#import "toolbar.h"
-#import "window.h"
-#import "stock.h"
-
-
-static UiToolbarDelegate* toolbar_delegate;
-
-/* ---------------------      UiToolbarStockItem     --------------------- */
-
-@implementation UiToolbarStockItem
-
-- (UiToolbarStockItem*) initWithIdentifier:(char*)identifier
-                                   stockID:(char*)sid
-                                  callback:(ui_callback)f
-                                  userdata:(void*)data
-{
-    name = identifier;
-    stockid = sid;
-    callback = f;
-    userdata = data;
-    groups = NULL;
-    isToggleButton = NO;
-    return self;
-}
-
-- (void) setIsToggleButton:(BOOL)t {
-    isToggleButton = t;
-}
-
-- (void) addGroup:(int)group {
-    groups = ucx_list_append(groups, (void*)(intptr_t)group);
-}
-
-
-- (NSToolbarItem *) createItem:(NSToolbar*)toolbar
-                    identifier:(NSString*)identifier
-                        object:(UiObject*)obj
-{
-    UiStockItem *s = ui_get_stock_item(stockid);
-    if(s == nil) {
-        printf("cannot find stock item\n");
-        return nil;
-    }
-    
-    NSToolbarItem *item = [[[NSToolbarItem alloc] initWithItemIdentifier:
-                            identifier] autorelease];
-    //[item setLabel:[s label]];
-    //[item setPaletteLabel:[s label]];
-    [item setLabel:s->label];
-    [item setPaletteLabel:@"Operation"];
-    
-    // create button ...
-    NSRect frame = NSMakeRect(0, 0, 40, 22);
-    //NSSearchField *sf = [[NSSearchField alloc]initWithFrame:frame];
-    NSButton *button = [[NSButton alloc]initWithFrame:frame];
-    //[button setImage:[s buttonImage]];
-    //[button setImage:[NSImage imageNamed: NSImageNameAddTemplate]];
-    if(s->image) {
-        [button setImage:s->image];
-    } else {
-        [button setImage:[NSImage imageNamed: NSImageNameRemoveTemplate]];
-    }
-    [button setBezelStyle: NSTexturedRoundedBezelStyle];
-    
-    // event
-    EventWrapper *event = [[EventWrapper alloc]
-                           initWithData:userdata callback:callback];
-    if(isToggleButton) {
-        [button setButtonType: NSPushOnPushOffButton];
-        [button setAction:@selector(handleToggleEvent:)];
-    } else {
-        [button setAction:@selector(handleEvent:)];
-    }
-    [button setTarget:event];
-    
-    if(groups) {
-        uic_add_group_widget(obj->ctx, item, groups);
-    }
-    
-    [item setView:button];
-    return item;
-}
-
-- (UcxList*) groups {
-    return groups;
-}
-
-@end
-
-
-/* ---------------------      UiToolbarItem     --------------------- */
-
-@implementation UiToolbarItem
-
-- (UiToolbarItem*) initWithIdentifier:(char*)identifier
-                                     label:(char*)lbl
-                                  callback:(ui_callback)f
-                                  userdata:(void*)data
-{
-    name = identifier;
-    label = lbl;
-    callback = f;
-    userdata = data;
-    groups = NULL;
-    isToggleButton = NO;
-    return self;
-}
-
-- (void) setIsToggleButton:(BOOL)t {
-    isToggleButton = t;
-}
-
-- (void) addGroup:(int)group {
-    groups = ucx_list_append(groups, (void*)(intptr_t)group);
-}
-
-
-- (NSToolbarItem *) createItem:(NSToolbar*)toolbar
-                    identifier:(NSString*)identifier
-                        object:(UiObject*)obj
-{
-    NSToolbarItem *item = [[[NSToolbarItem alloc] initWithItemIdentifier:
-                            identifier] autorelease];
-    //[item setLabel:[s label]];
-    //[item setPaletteLabel:[s label]];
-    NSString *l = [[NSString alloc]initWithUTF8String:label];
-    [item setLabel:l];
-    [item setPaletteLabel:@"Operation"];
-    
-    // create button ...
-    NSRect frame = NSMakeRect(0, 0, 40, 22);
-    //NSSearchField *sf = [[NSSearchField alloc]initWithFrame:frame];
-    NSButton *button = [[NSButton alloc]initWithFrame:frame];
-    //[button setImage:[s buttonImage]];
-    //[button setImage:[NSImage imageNamed: NSImageNameAddTemplate]];
-    
-    // TODO: image
-    [button setImage:[NSImage imageNamed: NSImageNameRemoveTemplate]];
-    
-    [button setBezelStyle: NSTexturedRoundedBezelStyle];
-    
-    // event
-    EventWrapper *event = [[EventWrapper alloc]
-                           initWithData:userdata callback:callback];
-    if(isToggleButton) {
-        [button setButtonType: NSPushOnPushOffButton];
-        [button setAction:@selector(handleToggleEvent:)];
-    } else {
-        [button setAction:@selector(handleEvent:)];
-    }
-    [button setTarget:event];
-    
-    if(groups) {
-        uic_add_group_widget(obj->ctx, item, groups);
-    }
-    
-    [item setView:button];
-    return item;
-}
-
-- (UcxList*) groups {
-    return groups;
-}
-
-@end
-
-
-/* ---------------------      UiToolbarDelegate      --------------------- */
-
-@implementation UiToolbarDelegate
-
-- (UiToolbarDelegate*) init {
-    allowedItems = [[NSMutableArray alloc]initWithCapacity: 16];
-    defaultItems = [[NSMutableArray alloc]initWithCapacity: 16];
-    items = [[NSMutableDictionary alloc] init];
-    return self;
-}
-
-- (void) addDefault:(NSString*)identifier {
-    [defaultItems addObject: identifier];
-}
-
-- (void) addItem: (NSString*) identifier
-            item: (NSObject<UiToolItem>*) item
-{
-    [allowedItems addObject: identifier];
-    [items setObject: item forKey:identifier];
-}
-
-/*
-- (void) addStockItem:(char*)name
-              stockID:(char*)sid
-             callback:(ui_callback)f
-                 data:(void*)userdata
-{
-    UiToolbarStockItem *item = [[UiToolbarStockItem alloc]initWithData:name
-                                                               stockID:sid callback:f data:userdata];
-    
-    NSString *s = [[NSString alloc]initWithUTF8String:name];
-    [allowedItems addObject: s];
-    [items setObject: item forKey:s];
-}
-*/
-
-// implementation of NSToolbarDelegate methods
-- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar {
-    NSMutableArray *i = [[NSMutableArray alloc]
-                         initWithCapacity:[allowedItems count] + 3];
-    [i addObject: NSToolbarFlexibleSpaceItemIdentifier];
-    [i addObject: NSToolbarSpaceItemIdentifier];
-    [i addObject: NSToolbarSeparatorItemIdentifier];
-    for(id item in allowedItems) {
-        [i addObject: item];
-    }
-    
-    return i;
-}
-
-- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar {
-    return defaultItems;
-}
-
-- (NSToolbarItem *) toolbar:(NSToolbar*)toolbar
-         itemForItemIdentifier:(NSString*)identifier
-     willBeInsertedIntoToolbar:(BOOL)flag
-{
-    Protocol *item = @protocol(UiToolItem);
-    item = [items objectForKey: identifier];
-    
-    // get UiObject from toolbar
-    UiObject *obj = [(UiToolbar*)toolbar object];
-    
-    // create new NSToolbarItem
-    return [item createItem:toolbar identifier:identifier object:obj];
-}
-
-@end
-
-
-@implementation UiToolbar
-
-- (UiToolbar*) initWithObject:(UiObject*)object {
-    [self initWithIdentifier: @"MainToolbar"];
-    obj = object;
-    return self;
-}
-
-- (UiObject*) object {
-    return obj;
-}
-
-@end
-
-
-/* ---------------------          functions          --------------------- */
-
-void ui_toolbar_init() {
-    toolbar_delegate = [[UiToolbarDelegate alloc]init];
-}
-
-void ui_toolitem(char *name, char *label, ui_callback f, void *udata) {
-    UiToolbarItem *item = [[UiToolbarItem alloc]
-                                initWithIdentifier: name
-                                label: label
-                                callback: f
-                                userdata: udata];
-    
-    NSString *identifier = [[NSString alloc]initWithUTF8String:name];
-    [toolbar_delegate addItem: identifier item: item];
-}
-
-void ui_toolitem_st(char *name, char *stockid, ui_callback f, void *udata) {
-    ui_toolitem_stgr(name, stockid, f, udata, -1);
-}
-
-void ui_toolitem_stgr(char *name, char *stockid, ui_callback f, void *udata, ...) {
-    va_list ap;
-    va_start(ap, udata);
-    ui_toolbar_stock_button(name, stockid, NO, f, udata, ap);
-    va_end(ap);
-}
-
-void ui_toolitem_toggle_st(char *name, char *stockid, ui_callback f, void *udata) {
-    ui_toolitem_toggle_stgr(name, stockid, f, udata, -1);
-}
-
-void ui_toolitem_toggle_stgr(char *name, char *stockid, ui_callback f, void *udata, ...) {
-    va_list ap;
-    va_start(ap, udata);
-    ui_toolbar_stock_button(name, stockid, YES, f, udata, ap);
-    va_end(ap);
-}
-
-
-void ui_toolbar_stock_button(char *name, char *stockid, BOOL toggle, ui_callback f, void *udata, va_list ap) {
-    UiToolbarStockItem *item = [[UiToolbarStockItem alloc]
-                                initWithIdentifier: name
-                                stockID: stockid
-                                callback: f
-                                userdata: udata];
-    [item setIsToggleButton: toggle];
-    NSString *identifier = [[NSString alloc]initWithUTF8String:name];
-    [toolbar_delegate addItem: identifier item: item];
-    
-    // add groups
-    int group;
-    while((group = va_arg(ap, int)) != -1) {
-        [item addGroup: group];
-    }
-}
-
-
-void ui_toolbar_add_default(char *name) {
-    NSString *identifier = [[NSString alloc]initWithUTF8String:name];
-    [toolbar_delegate addDefault: identifier];
-}
-
-NSToolbar* ui_create_toolbar(UiObject *obj) {
-    UiToolbar *toolbar = [[UiToolbar alloc] initWithObject:obj];
-    [toolbar setDelegate: toolbar_delegate];
-    [toolbar setAllowsUserCustomization: true];
-    return toolbar;
-}
-
diff --git a/ui/cocoa/tree.h b/ui/cocoa/tree.h
deleted file mode 100644 (file)
index 66ee899..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2012 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
- #import "../ui/tree.h"
- #import "toolkit.h"
-@interface UiTableDataSource : NSObject<NSTableViewDataSource, NSTableViewDelegate> {
-    UiList          *data;
-    UiModelInfo     *info;
-    UiListSelection *lastSelection;
-}
-
-- (id)initWithData:(UiList*)list modelInfo:(UiModelInfo*)modelinfo;
-
-- (void)handleDoubleAction:(id)sender;
-
-@end
-
-
-char* ui_type_to_string(UiModelType type, void *data, BOOL *free);
-
diff --git a/ui/cocoa/tree.m b/ui/cocoa/tree.m
deleted file mode 100644 (file)
index 63a6525..0000000
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2012 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#import <stdio.h>
-#import <stdlib.h>
-#import "tree.h"
-#import "container.h"
-#import "window.h"
-#import "../common/context.h"
-#import <ucx/utils.h>
-
-@implementation UiTableDataSource
-
-- (id)initWithData:(UiList*)list modelInfo:(UiModelInfo*)modelinfo {
-    data = list;
-    info = modelinfo;
-    lastSelection = NULL;
-    return self;
-}
-
-- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableview {
-    return data->count(data);
-}
-
-- (id)tableView:                  (NSTableView*)tableview
-        objectValueForTableColumn:(NSTableColumn*)column
-                              row:(NSInteger)row
-{
-    int column_index = [[column identifier]intValue];
-    
-    void *row_data = data->get(data, row);
-    void *cell_data = info->getvalue(row_data, column_index);
-    
-    BOOL f = false;
-    char *str = ui_type_to_string(info->types[column_index], cell_data, &f);
-    NSString *s = [[NSString alloc]initWithUTF8String:str];
-    return s;
-}
-
-- (void)tableView:(NSTableView *)tableview
-        setObjectValue:(id)object
-        forTableColumn:(NSTableColumn *)column
-                   row:(NSInteger)row
-{
-    int column_index = [[column identifier]intValue];
-    
-    // TODO
-}
-
-- (void)tableViewSelectionDidChange:(NSNotification *)notification {
-    NSTableView *tableview = (NSTableView*)notification.object;
-    
-    // create selection object
-    UiListSelection *selection = malloc(sizeof(UiListSelection));
-    selection->count = [tableview numberOfSelectedRows];
-    
-    selection->rows = calloc(selection->count, sizeof(int));
-    NSIndexSet *indices = [tableview selectedRowIndexes];
-    NSUInteger index = [indices firstIndex];
-    int i=0;
-    while (index!=NSNotFound) {
-        selection->rows[i] = index;
-        index = [indices indexGreaterThanIndex:index];
-        i++;
-    }
-    
-    // create event object
-    UiEvent event;
-    NSWindow *activeWindow = [NSApp keyWindow];
-    if([activeWindow class] == [UiCocoaWindow class]) {
-        event.obj = [(UiCocoaWindow*)activeWindow object];
-        event.window = event.obj->window;
-        event.document = event.obj->ctx->document;
-    } else {
-        event.window = NULL;
-        event.document = NULL;
-    }
-    event.eventdata = selection;
-    event.intval = selection->count == 0 ? -1 : selection->rows[0];
-    
-    // callback
-    info->selection(&event, info->userdata);
-    
-    // cleanup
-    if(lastSelection) {
-        free(lastSelection->rows);
-        free(lastSelection);
-    }
-    lastSelection = selection;
-}
-
-- (void)handleDoubleAction:(id)sender {
-    // create event object
-    UiEvent event;
-    NSWindow *activeWindow = [NSApp keyWindow];
-    if([activeWindow class] == [UiCocoaWindow class]) {
-        event.obj = [(UiCocoaWindow*)activeWindow object];
-        event.window = event.obj->window;
-        event.document = event.obj->ctx->document;
-    } else {
-        event.window = NULL;
-        event.document = NULL;
-    }
-    event.eventdata = lastSelection;
-    event.intval = lastSelection->count == 0 ? -1 : lastSelection->rows[0];
-    
-    info->activate(&event, info->userdata);
-}
-
-- (BOOL)tableView:(NSTableView *)tableview isGroupRow:(NSInteger)row {
-    return NO;
-}
-
-@end
-
-
-UIWIDGET ui_table(UiObject *obj, UiList *model, UiModelInfo *modelinfo) {
-    UiContainer *ct = uic_get_current_container(obj);
-    NSRect frame = ct->getframe(ct);
-    
-    NSScrollView *scrollview = [[NSScrollView alloc] initWithFrame:frame];
-    [scrollview setHasVerticalScroller:YES];
-    //[scrollvew setHasHorizontalScroller:YES];
-    [scrollview setBorderType:NSNoBorder];
-    //[scrollview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
-    
-    NSTableView *tableview = [[NSTableView alloc]initWithFrame:frame];
-    [scrollview setDocumentView:tableview];
-    [tableview setAllowsMultipleSelection: YES];
-    //[tableview setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList];
-    
-    // add columns
-    for(int i=0;i<modelinfo->columns;i++) {
-        NSString *cid = [[NSString alloc]initWithFormat: @"%d", i];
-        NSTableColumn *column = [[NSTableColumn alloc]initWithIdentifier:cid];
-        
-        NSString *title = [[NSString alloc]initWithUTF8String: modelinfo->titles[i]];
-        [[column headerCell] setStringValue:title];
-        
-        [tableview addTableColumn:column];
-    }
-    
-    UiTableDataSource *source = [[UiTableDataSource alloc]initWithData:model modelInfo:modelinfo];
-    [tableview setDataSource:source];
-    [tableview setDelegate:source];
-
-    [tableview setDoubleAction:@selector(handleDoubleAction:)];
-    [tableview setTarget:source];
-    
-    
-    ct->add(ct, scrollview);
-    return scrollview;
-}
-
-
-UIWIDGET ui_listview_var(UiObject *obj, UiListPtr *list, ui_model_getvalue_f getvalue, ui_callback f, void *udata) {
-    UiContainer *ct = uic_get_current_container(obj);
-    NSRect frame = ct->getframe(ct);
-    
-    NSScrollView *scrollview = [[NSScrollView alloc] initWithFrame:frame];
-    [scrollview setHasVerticalScroller:YES];
-    
-    [scrollview setBorderType:NSNoBorder];
-    
-    NSTableView *tableview = [[NSTableView alloc]initWithFrame:frame];
-    [scrollview setDocumentView:tableview];
-    [tableview setAllowsMultipleSelection: NO];
-    
-    // add single column
-    NSTableColumn *column = [[NSTableColumn alloc]initWithIdentifier:@"c"];
-    [tableview addTableColumn:column];
-    
-    // create model info
-    UiModelInfo *modelinfo = ui_model_info(obj->ctx, UI_STRING, -1);
-    
-    // add source
-    UiTableDataSource *source = [[UiTableDataSource alloc]initWithData:list->list modelInfo:modelinfo];
-    
-    [tableview setDataSource:source];
-    [tableview setDelegate:source];
-
-    [tableview setDoubleAction:@selector(handleDoubleAction:)];
-    [tableview setTarget:source];
-    
-    ct->add(ct, scrollview);
-    return scrollview;
-}
-
-UIWIDGET ui_listview(UiObject *obj, UiList *list, ui_model_getvalue_f getvalue, ui_callback f, void *udata) {
-    UiListPtr *listptr = ucx_mempool_malloc(obj->ctx->mempool, sizeof(UiListPtr));
-    listptr->list = list;
-    return ui_listview_var(obj, listptr, getvalue, f, udata);
-}
-
-UIWIDGET ui_listview_nv(UiObject *obj, char *varname, ui_model_getvalue_f getvalue, ui_callback f, void *udata) {
-    UiVar *var = uic_connect_var(obj->ctx, varname, UI_VAR_LIST);
-    if(var) {
-        UiListVar *value = var->value;
-        return ui_listview_var(obj, value->listptr, getvalue, f, udata);
-    } else {
-        // TODO: error
-    }
-    return NULL;
-}
-
-
-// TODO: motif code duplicate
-char* ui_type_to_string(UiModelType type, void *data, BOOL *free) {
-    switch(type) {
-        case UI_STRING: *free = FALSE; return data;
-        case UI_INTEGER: {
-            *free = TRUE;
-            int *val = data;
-            sstr_t str = ucx_asprintf(ucx_default_allocator(), "%d", *val);
-            return str.ptr;
-        }
-    }
-    *free = FALSE;
-    return NULL;
-}
index 87b5d6e7df216c6ce40fc8f66b953e73f7e24be7..82d75fc6f27e86c9d7039b63af11dce0d9787beb 100644 (file)
@@ -793,11 +793,12 @@ void PathBarChangeDir(Widget w, PathBar *bar, XtPointer c)
     }
     
     UiPathElm elm = bar->current_pathelms[i];
-    cxmutstr name = cx_strdup(cx_strn(elm.name, elm.name_len));
+    cxmutstr path = cx_strdup(cx_strn(elm.path, elm.path_len));
     if(bar->updateDir) {
-        bar->updateDir(bar->updateDirData, name.ptr, i);
+        XNETextSetString(bar->textfield, path.ptr);
+        bar->updateDir(bar->updateDirData, path.ptr, i);
     }
-    free(name.ptr);
+    free(path.ptr);
 }
 
 static void ui_pathelm_destroy(UiPathElm *elms, size_t nelm) {
diff --git a/ui/motif/tree.c b/ui/motif/tree.c
deleted file mode 100644 (file)
index 1cac8a9..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2014 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
-
-#include "tree.h"
-
-#include "container.h"
-#include "../common/object.h"
-#include "../common/context.h"
-#include <cx/utils.h>
-#include <cx/compare.h>
-#include <cx/printf.h>
-
-UIWIDGET ui_table_var(UiObject *obj, UiVar *var, UiModel *model, UiListCallbacks cb) {
-    // TODO: check if modelinfo is complete
-    
-    Arg args[32];
-    int n = 0;
-    
-    // create scrolled window
-    UiContainer *ct = uic_get_current_container(obj);
-    Widget parent = ct->prepare(ct, args, &n, TRUE);
-    
-    XtSetArg(args[n], XmNscrollingPolicy, XmAUTOMATIC);
-    n++;
-    XtSetArg(args[n], XmNshadowThickness, 0);
-    n++;
-    Widget scrollw = XmCreateScrolledWindow(parent, "scroll_win", args, n);
-    ct->add(ct, scrollw);
-    XtManageChild(scrollw);
-    
-    // create table headers
-    XmStringTable header = (XmStringTable)XtMalloc(
-            model->columns * sizeof(XmString));
-    for(int i=0;i<model->columns;i++) {
-        header[i] = XmStringCreateLocalized(model->titles[i]);
-    }
-    n = 0;
-    XtSetArg(args[n], XmNdetailColumnHeading, header);
-    n++;
-    XtSetArg(args[n], XmNdetailColumnHeadingCount, model->columns);
-    n++;
-    
-    // set res
-    XtSetArg(args[n], XmNlayoutType, XmDETAIL);
-    n++;
-    XtSetArg(args[n], XmNentryViewType, XmSMALL_ICON);
-    n++;
-    XtSetArg(args[n], XmNselectionPolicy, XmSINGLE_SELECT);
-    n++;
-    XtSetArg(args[n], XmNwidth, 600);
-    n++;
-    
-    // create widget
-    //UiContainer *ct = uic_get_current_container(obj);
-    //Widget parent = ct->add(ct, args, &n);
-    
-    Widget container = XmCreateContainer(scrollw, "table", args, n);
-    XtManageChild(container);
-    
-    // add callbacks
-    UiTreeEventData *event = ui_malloc(obj->ctx, sizeof(UiTreeEventData));
-    event->obj = obj;
-    event->activate = cb.activate;
-    event->selection = cb.selection;
-    event->userdata = cb.userdata;
-    event->last_selection = NULL;
-    if(cb.selection) {
-        XtAddCallback(
-                container,
-                XmNselectionCallback,
-                (XtCallbackProc)ui_table_select_callback,
-                event);
-    }
-    if(cb.activate) {
-        XtAddCallback(
-                container,
-                XmNdefaultActionCallback,
-                (XtCallbackProc)ui_table_action_callback,
-                event);
-    }
-    
-    // add initial data
-    UiList *list = var->value;
-    void *data = list->first(list);
-    int width = 0;
-    while(data) {
-        int w = ui_add_icon_gadget(container, model, data);
-        if(w > width) {
-            width = w;
-        }
-        data = list->next(list);
-    }
-    
-    UiTableView *tableview = cxMalloc(obj->ctx->allocator, sizeof(UiTableView));
-    tableview->widget = container;
-    tableview->var = var;
-    tableview->model = model;
-    
-    // set new XmContainer width
-    XtVaSetValues(container, XmNwidth, width, NULL);
-    
-    // cleanup
-    for(int i=0;i<model->columns;i++) {
-        XmStringFree(header[i]);
-    }
-    XtFree((char*)header);
-    
-    return scrollw;
-}
-
-UIWIDGET ui_table(UiObject *obj, UiList *data, UiModel *model, UiListCallbacks cb) {
-    UiVar *var = malloc(sizeof(UiVar));
-    var->value = data;
-    var->type = UI_VAR_SPECIAL;
-    return ui_table_var(obj, var, model, cb);
-}
-
-void ui_table_update(UiEvent *event, UiTableView *view) {
-    // clear container
-    Widget *children;
-    int nc;
-
-    XtVaGetValues(
-            view->widget,
-            XmNchildren,
-            &children,
-            XmNnumChildren,
-            &nc,
-            NULL);
-
-    for(int i=0;i<nc;i++) {
-        XtDestroyWidget(children[i]);
-    }
-    
-    UiList *list = view->var->value;
-    
-    void *data = list->first(list);
-    int width = 0;
-    while(data) {
-        int w = ui_add_icon_gadget(view->widget, view->model, data);
-        if(w > width) {
-            width = w;
-        }
-        data = list->next(list);
-    }
-    
-}
-
-#define UI_COL_CHAR_WIDTH 12
-
-int ui_add_icon_gadget(Widget container, UiModel *model, void *data) {
-    int width = 50;
-    
-    if(model->columns == 0) {
-        return width;
-    }
-    
-    XmString label = NULL;
-    Arg args[8];
-    Boolean f;
-    // first column
-    if(model->types[0] != 12345678) { // TODO: icon/label type
-        char *str = ui_type_to_string(
-                model->types[0],
-                model->getvalue(data, 0),
-                &f);
-        
-        // column width
-        width += strlen(str) * UI_COL_CHAR_WIDTH;
-        
-        
-        XmString label = XmStringCreateLocalized(str);
-        XtSetArg(args[0], XmNlabelString, label);
-        if(f) {
-            free(str);
-        }
-    } else {
-        // TODO
-    }
-            
-    // remaining columns are the icon gadget details
-    XmStringTable details = (XmStringTable)XtMalloc(
-            (model->columns - 1) * sizeof(XmString));
-    for(int i=1;i<model->columns;i++) {
-        char *str = ui_type_to_string(
-                model->types[i],
-                model->getvalue(data, i),
-                &f);
-        
-        // column width
-        width += strlen(str) * UI_COL_CHAR_WIDTH;
-        
-        details[i - 1] = XmStringCreateLocalized(str);
-        if(f) {
-            free(str);
-        }
-    }
-    XtSetArg(args[1], XmNdetail, details);
-    XtSetArg(args[2], XmNdetailCount, model->columns - 1);
-    XtSetArg(args[3], XmNshadowThickness, 0); 
-    // create widget
-    Widget item = XmCreateIconGadget(container, "table_item", args, 4);
-    XtManageChild(item);
-    
-    // cleanup
-    XmStringFree(label);
-    for(int i=0;i<model->columns-1;i++) {
-        XmStringFree(details[i]);
-    }
-    XtFree((char*)details);
-    
-    return width;
-}
-
-char* ui_type_to_string(UiModelType type, void *data, Boolean *free) {
-    switch(type) {
-        case UI_STRING: *free = FALSE; return data;
-        case UI_INTEGER: {
-            *free = TRUE;
-            int *val = data;
-            cxmutstr str = cx_asprintf("%d", *val);
-            return str.ptr;
-        }
-        case UI_ICON: break; // TODO
-        case UI_ICON_TEXT: break; // TODO
-    }
-    *free = FALSE;
-    return NULL;
-}
-
-void ui_table_action_callback(
-        Widget widget,
-        UiTreeEventData *event,
-        XmContainerSelectCallbackStruct *sel)
-{ 
-    UiListSelection *selection = ui_list_selection(sel);
-    
-    UiEvent e;
-    e.obj = event->obj;
-    e.window = event->obj->window;
-    e.document = event->obj->ctx->document;
-    e.eventdata = selection;
-    e.intval = selection->count > 0 ? selection->rows[0] : -1;
-    event->activate(&e, event->userdata);
-    
-    free(event->last_selection->rows);
-    free(event->last_selection);
-    event->last_selection = selection;
-}
-
-void ui_table_select_callback(
-        Widget widget,
-        UiTreeEventData *event,
-        XmContainerSelectCallbackStruct *sel)
-{ 
-    UiListSelection *selection = ui_list_selection(sel);
-    if(!ui_compare_list_selection(selection, event->last_selection)) {
-        UiEvent e;
-        e.obj = event->obj;
-        e.window = event->obj->window;
-        e.document = event->obj->ctx->document;
-        e.eventdata = selection;
-        e.intval = selection->count > 0 ? selection->rows[0] : -1;
-        event->selection(&e, event->userdata);
-    }
-    if(event->last_selection) {
-        free(event->last_selection->rows);
-        free(event->last_selection);
-    }
-    event->last_selection = selection;
-}
-
-UiListSelection* ui_list_selection(XmContainerSelectCallbackStruct *xs) {
-    UiListSelection *selection = malloc(sizeof(UiListSelection));
-    selection->count = xs->selected_item_count;
-    selection->rows = calloc(selection->count, sizeof(int));
-    for(int i=0;i<selection->count;i++) {
-        int index;
-        XtVaGetValues(xs->selected_items[i], XmNpositionIndex, &index, NULL);
-        selection->rows[i] = index;
-    }
-    return selection;
-}
-
-Boolean ui_compare_list_selection(UiListSelection *s1, UiListSelection *s2) {
-    if(!s1 || !s2) {
-        return FALSE;
-    } 
-    if(s1->count != s2->count) {
-        return FALSE;
-    }
-    for(int i=0;i<s1->count;i++) {
-        if(s1->rows[i] != s2->rows[i]) {
-            return FALSE;
-        }
-    }
-    return TRUE;
-}
diff --git a/ui/motif/tree.h b/ui/motif/tree.h
deleted file mode 100644 (file)
index 68e5b06..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2014 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TREE_H
-#define        TREE_H
-
-#include "../ui/tree.h"
-#include "../common/context.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct UiTreeEventData {
-    UiObject        *obj;
-    ui_callback     activate;
-    ui_callback     selection;
-    void            *userdata;
-    UiListSelection *last_selection;
-} UiTreeEventData;    
-
-typedef struct UiTableView {
-    Widget      widget;
-    UiVar       *var;
-    UiModel     *model;
-} UiTableView;
-
-void ui_table_update(UiEvent *event, UiTableView *view);
-int ui_add_icon_gadget(Widget container, UiModel *model, void *data);
-char* ui_type_to_string(UiModelType type, void *data, Boolean *free);
-
-void ui_table_action_callback(
-        Widget widget,
-        UiTreeEventData *event,
-        XmContainerSelectCallbackStruct *sel);
-void ui_table_select_callback(
-        Widget widget,
-        UiTreeEventData *event,
-        XmContainerSelectCallbackStruct *sel);
-
-UiListSelection* ui_list_selection(XmContainerSelectCallbackStruct *xs);
-
-Boolean ui_compare_list_selection(UiListSelection *s1, UiListSelection *s2);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* TREE_H */
-