From 6efe8c59807518f19380e87f0173eb6fb51ab3a7 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Sun, 18 Nov 2007 09:39:49 +0000 Subject: [PATCH] Monotone-Parent: fdaa9bb9f2456732024f9c342a2ebc46376564c1 Monotone-Revision: 28b77f21d4bb7c941a2ab46340a22efd022cde3d Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-11-18T09:39:49 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 10 + UI/Common/UIxAppNavView.m | 101 ----- UI/Common/UIxPrintPageFrame.m | 53 --- UI/Common/UIxTabItem.m | 475 ----------------------- UI/Common/UIxTabView.h | 133 ------- UI/Common/UIxTabView.m | 684 ---------------------------------- 6 files changed, 10 insertions(+), 1446 deletions(-) delete mode 100644 UI/Common/UIxAppNavView.m delete mode 100644 UI/Common/UIxPrintPageFrame.m delete mode 100644 UI/Common/UIxTabItem.m delete mode 100644 UI/Common/UIxTabView.h delete mode 100644 UI/Common/UIxTabView.m diff --git a/ChangeLog b/ChangeLog index 44d3cd86a..acfa980ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-11-18 Wolfgang Sourdeau + + * UI/Common/UIxTabItem.m: removed useless class module. + + * UI/Common/UIxTabView.[hm]: removed useless class module. + + * UI/Common/UIxPrintPageFrame.m: removed useless class module. + + * UI/Common/UIxAppNavView.m: removed useless class module. + 2007-11-16 Ludovic Marcotte * SoObjects/Mailer/SOGoMailBaseObject.m diff --git a/UI/Common/UIxAppNavView.m b/UI/Common/UIxAppNavView.m deleted file mode 100644 index 87dfc0983..000000000 --- a/UI/Common/UIxAppNavView.m +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright (C) 2004 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#import -#import - -#import - -@interface UIxAppNavView : UIxComponent -{ - id element; - id lastElement; -} - -@end - -@implementation UIxAppNavView - -- (void)dealloc { - [element release]; - [lastElement release]; - [super dealloc]; -} - -/* accessors */ - -- (void)setElement:(id)_element { - ASSIGN(element, _element); -} -- (id)element { - return element; -} - -- (void)setLastElement:(id)_element { - ASSIGN(lastElement, _element); -} -- (id)lastElement { - return lastElement; -} - -/* navigation */ - -- (NSArray *)navPathElements { - NSArray *traversalObjects; - NSMutableArray *navPathComponents; - unsigned int i, count; - - traversalObjects = [[self context] objectTraversalStack]; - count = ([traversalObjects count] - 1); /* remove SoPageInvocation */ - - navPathComponents = [[NSMutableArray alloc] initWithCapacity:count]; - for (i = 0; i < count; i++) { - NSString *name; - id obj; - - obj = [traversalObjects objectAtIndex:i]; - - name = [obj davDisplayName]; - if ([name length] == 0) - name = NSStringFromClass([obj class]); - name = [self labelForKey:name]; - - if (![name hasPrefix:@"sogod"]) { - NSMutableDictionary *c; - NSString *url; - - url = [obj baseURLInContext:[self context]]; - if (![url hasSuffix:@"/"]) - url = [url stringByAppendingString:@"/"]; - - c = [[NSMutableDictionary alloc] initWithCapacity:2]; - [c setObject:name forKey:@"name"]; - [c setObject:url forKey:@"url"]; - [navPathComponents addObject:c]; - [c release]; - } - } - - [self setLastElement:[navPathComponents lastObject]]; - return [navPathComponents autorelease]; -} - -@end /* UIxAppNavView */ diff --git a/UI/Common/UIxPrintPageFrame.m b/UI/Common/UIxPrintPageFrame.m deleted file mode 100644 index 48bb2da7b..000000000 --- a/UI/Common/UIxPrintPageFrame.m +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright (C) 2000-2005 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#import - -@class NSString; - -@interface UIxPrintPageFrame : SoComponent -{ - NSString *title; -} - -@end - -@implementation UIxPrintPageFrame - -- (void) dealloc -{ - [title release]; - [super dealloc]; -} - -/* accessors */ - -- (void)setTitle: (NSString *) _value -{ - ASSIGNCOPY (title, _value); -} - -- (NSString *) title -{ - return title; -} - -@end /* UIxPrintPageFrame */ diff --git a/UI/Common/UIxTabItem.m b/UI/Common/UIxTabItem.m deleted file mode 100644 index 28f408893..000000000 --- a/UI/Common/UIxTabItem.m +++ /dev/null @@ -1,475 +0,0 @@ -/* - Copyright (C) 2000-2005 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#include "UIxTabView.h" -#include "common.h" - -#if DEBUG -# define DEBUG_JS 1 -#endif - -/* context keys */ -extern NSString *UIxTabView_HEAD; -extern NSString *UIxTabView_BODY; -extern NSString *UIxTabView_KEYS; -extern NSString *UIxTabView_SCRIPT; -extern NSString *UIxTabView_ACTIVEKEY; -extern NSString *UIxTabView_COLLECT; - -@implementation UIxTabItem - -static Class StrClass = Nil; - -+ (int)version { - return [super version] + 0; -} -+ (void)initialize { - StrClass = [NSString class]; -} - -static NSString *retStrForInt(int i) { - switch(i) { - case 0: return @"0"; - case 1: return @"1"; - case 2: return @"2"; - case 3: return @"3"; - case 4: return @"4"; - case 5: return @"5"; - case 6: return @"6"; - case 7: return @"7"; - case 8: return @"8"; - case 9: return @"9"; - case 10: return @"10"; - // TODO: find useful count! - default: - return [[StrClass alloc] initWithFormat:@"%i", i]; - } -} - -- (id)initWithName:(NSString *)_name - associations:(NSDictionary *)_config - template:(WOElement *)_subs -{ - if ((self = [super initWithName:_name associations:_config template:_subs])) { - self->key = WOExtGetProperty(_config, @"key"); - self->label = WOExtGetProperty(_config, @"label"); - - self->isScript = WOExtGetProperty(_config, @"isScript"); - self->href = WOExtGetProperty(_config, @"href"); - - self->icon = WOExtGetProperty(_config, @"icon"); - self->action = WOExtGetProperty(_config, @"action"); - - self->tabStyle = WOExtGetProperty(_config, @"tabStyle"); - self->selectedTabStyle = WOExtGetProperty(_config, @"selectedTabStyle"); - - self->tabIcon = WOExtGetProperty(_config, @"tabIcon"); - self->leftTabIcon = WOExtGetProperty(_config, @"leftTabIcon"); - self->selectedTabIcon = WOExtGetProperty(_config, @"selectedTabIcon"); - - self->asBackground = WOExtGetProperty(_config, @"asBackground"); - self->width = WOExtGetProperty(_config, @"width"); - self->height = WOExtGetProperty(_config, @"height"); - self->activeBgColor = WOExtGetProperty(_config, @"activeBgColor"); - self->inactiveBgColor = WOExtGetProperty(_config, @"inactiveBgColor"); - - self->template = [_subs retain]; - } - return self; -} - -- (void)dealloc { - [self->key release]; - [self->label release]; - - [self->href release]; - - [self->action release]; - - [self->isScript release]; - [self->template release]; - - [self->tabStyle release]; - [self->selectedTabStyle release]; - - [self->icon release]; - [self->leftTabIcon release]; - [self->selectedTabIcon release]; - [self->tabIcon release]; - - [self->asBackground release]; - [self->width release]; - [self->height release]; - - [self->activeBgColor release]; - [self->inactiveBgColor release]; - - [super dealloc]; -} - -/* responder */ - -- (void)takeValuesFromRequest:(WORequest *)_rq inContext:(WOContext *)_ctx { - NSString *activeTabKey; - NSString *myTabKey; - BOOL doCheck; - - if ([_ctx objectForKey:UIxTabView_HEAD]) { - /* head clicks */ - [[_ctx component] debugWithFormat: - @"UIxTabItem: head takes (no) values, eid='%@'", - [_ctx elementID]]; - return; - } - - if ((activeTabKey = [_ctx objectForKey:UIxTabView_BODY]) == nil) { - [[_ctx component] debugWithFormat:@"UIxTabItem: invalid state"]; - [self->template takeValuesFromRequest:_rq inContext:_ctx]; - return; - } - - myTabKey = [self->key stringValueInComponent:[_ctx component]]; - doCheck = [self->isScript boolValueInComponent:[_ctx component]]; - - if ([activeTabKey isEqualToString:myTabKey] || doCheck) { -#if ADD_OWN_ELEMENTIDS - [_ctx appendElementIDComponent:activeTabKey]; -#endif - -#if DEBUG_TAKEVALUES - [[_ctx component] debugWithFormat: - @"UIxTabItem: body takes values, eid='%@'", - [_ctx elementID]]; -#endif - - [self->template takeValuesFromRequest:_rq inContext:_ctx]; -#if ADD_OWN_ELEMENTIDS - [_ctx deleteLastElementIDComponent]; -#endif - } -#if DEBUG_TAKEVALUES - else { - [[_ctx component] debugWithFormat: - @"UIxTabItem: body takes no values, eid='%@'", - [_ctx elementID]]; - } -#endif -} - -- (id)invokeActionForRequest:(WORequest *)_req inContext:(WOContext *)_ctx { - id result; - WOAssociation *tmp; - NSString *activeTabKey; - - if ((tmp = [_ctx objectForKey:UIxTabView_HEAD])) { - /* click on tab icon */ - NSString *tabkey; - - tabkey = [_ctx currentElementID]; - [_ctx consumeElementID]; - [_ctx appendElementIDComponent:tabkey]; - - if ([tmp isValueSettable]) - [tmp setValue:tabkey inComponent:[_ctx component]]; - -#if 0 - result = [self->action valueInComponent:[_ctx component]]; -#endif - - [_ctx deleteLastElementIDComponent]; - } - else if ((activeTabKey = [_ctx objectForKey:UIxTabView_BODY])) { - /* clicked somewhere in the (active) body */ - result = [self->template invokeActionForRequest:_req inContext:_ctx]; - } - else { - [[_ctx component] logWithFormat:@"UIxTabItem: invalid invoke state"]; - result = [self->template invokeActionForRequest:_req inContext:_ctx]; - } - - return result; -} - -/* info collection */ - -- (void)_collectInContext:(WOContext *)_ctx key:(NSString *)k { - BOOL isLeft = NO; - NSMutableArray *keys; - UIxTabItemInfo *info; - WOComponent *cmp; - - cmp = [_ctx component]; - keys = [_ctx objectForKey:UIxTabView_KEYS]; - if (keys == nil) { - keys = [[[NSMutableArray alloc] init] autorelease]; - [_ctx setObject:keys forKey:UIxTabView_KEYS]; - isLeft = YES; - } - - if (k == nil) { - /* auto-assign a key */ - k = retStrForInt([keys count]); - } - else - k = [k retain]; - [_ctx appendElementIDComponent:k]; - - info = [[UIxTabItemInfo alloc] init]; - info->key = [k copy]; - info->label = [[self->label stringValueInComponent:cmp] copy]; - info->icon = [[self->icon stringValueInComponent:cmp] copy]; -#if 0 - info->uri = [[_ctx componentActionURL] copy]; -#else - info->uri = [[self->href stringValueInComponent:cmp] copy]; -#endif - info->isScript = [self->isScript boolValueInComponent:cmp]; - info->tabIcon = [[self->tabIcon stringValueInComponent:cmp] copy]; - info->leftIcon = [[self->leftTabIcon stringValueInComponent:cmp] copy]; - info->selIcon = [[self->selectedTabIcon stringValueInComponent:cmp] - copy]; - info->tabStyle = [[self->tabStyle stringValueInComponent:cmp] copy]; - info->selectedTabStyle = [[self->selectedTabStyle stringValueInComponent:cmp] - copy]; - - if (self->asBackground == nil) - info->asBackground = 0; - else { - info->asBackground - = ([self->asBackground boolValueInComponent:cmp]) ? 1 : -1; - } - info->width = [[self->width stringValueInComponent:cmp] copy]; - info->height = [[self->height stringValueInComponent:cmp] copy]; - info->activeBg = [[self->activeBgColor stringValueInComponent:cmp] - copy]; - info->inactiveBg = [[self->inactiveBgColor stringValueInComponent:cmp] - copy]; - - if (info->leftIcon == nil) info->leftIcon = [info->tabIcon copy]; - - [keys addObject:info]; - [info release]; - [k release]; - - [_ctx deleteLastElementIDComponent]; -} - -/* header generation */ - -- (void)_appendHeadToResponse:(WOResponse *)_response - inContext:(WOContext *)_ctx - activeKey:(NSString *)activeKey - key:(NSString *)k -{ - /* head is currently generated in UIxTabView */ -#if 0 - // note: some associations can be inherited by UIxTabView ! - BOOL doImages; - WOComponent *comp; - BOOL doBgIcon; - NSString *label; - NSString *w, *h; - - doImages = ![[[_ctx request] clientCapabilities] isTextModeBrowser]; - comp = [_ctx component]; - - doBgIcon = self->asBackground && doImages - ? [self->asBackground boolValueInComponent:comp] ? YES : NO - : NO; - - if ((label = [self->label stringValueInComponent:comp]) == nil) - label = k; - - if (doImages) { - /* lookup image */ - NSString *imgName = nil; - // ... - - imgUri = WEUriOfResource(imgName, _ctx); - if ([imgUri length] < 1) - doImages = NO; - } - - // .... _isActive -#endif -} - -/* body generation */ - -- (void)_appendBodyToResponse:(WOResponse *)_response - inContext:(WOContext *)_ctx - activeKey:(NSString *)tmp - key:(NSString *)k -{ - BOOL doScript; - BOOL isScript_; - BOOL isActive; - - doScript = [[_ctx objectForKey:UIxTabView_SCRIPT] boolValue]; - isScript_ = [self->isScript boolValueInComponent:[_ctx component]]; - isActive = [tmp isEqualToString:k]; - - if (doScript && (isActive || isScript_)) { - [_response appendContentString:@"
\n"]; - } - - if (isActive || (doScript && isScript_)) { - /* content is active or used as layer*/ -#if ADD_OWN_ELEMENTIDS - [_ctx appendElementIDComponent:k]; -#endif -#if DEBUG && 0 - NSLog(@"TAB: %@", k); -#endif - - [self->template appendToResponse:_response inContext:_ctx]; - -#if ADD_OWN_ELEMENTIDS - [_ctx deleteLastElementIDComponent]; -#endif - } - - if (doScript && (isActive || isScript_)) { - NSString *jsout; - [_response appendContentString:@"
"]; - - jsout = [NSString alloc]; - jsout = [jsout initWithFormat: - @""]; - } -} - -/* master generation method */ - -- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx { - NSString *k; - BOOL doForm; - id tmp; - - doForm = [_ctx isInForm]; - k = [self->key stringValueInComponent:[_ctx component]]; - - if ((tmp = [_ctx objectForKey:UIxTabView_HEAD])) { - if ([tmp isEqual:UIxTabView_COLLECT]) { - [self _collectInContext:_ctx key:k]; - } - else { - [self _appendHeadToResponse:_response inContext:_ctx - activeKey:tmp key:k]; - } - } - else if ((tmp = [_ctx objectForKey:UIxTabView_BODY])) { - [self _appendBodyToResponse:_response inContext:_ctx - activeKey:tmp key:k]; - } - else { - [self warnWithFormat:@"(%s): invalid UIxTabItem state !!!", - __PRETTY_FUNCTION__]; - [_response appendContentString:@"[invalid state]"]; - } -} - -@end /* UIxTabItem */ - -@implementation UIxTabItemInfo - -- (void)dealloc { - [self->uri release]; - [self->icon release]; - [self->label release]; - [self->key release]; - [self->tabStyle release]; - [self->selectedTabStyle release]; - [self->tabIcon release]; - [self->selIcon release]; - [self->leftIcon release]; - [self->width release]; - [self->height release]; - [self->activeBg release]; - [self->inactiveBg release]; - - [super dealloc]; -} - -/* accessors */ - -- (NSString *)key { - return self->key; -} -- (NSString *)label { - return self->label; -} -- (NSString *)icon { - return self->icon; -} -- (NSString *)uri { - return self->uri; -} -- (BOOL)isScript { - return self->isScript; -} - -- (int)asBackground { - return self->asBackground; -} - -- (NSString *)width { - return self->width; -} - -- (NSString *)height { - return self->height; -} - -- (NSString *)activeBg { - return self->activeBg; -} - -- (NSString *)inactiveBg { - return self->inactiveBg; -} - -@end /* UIxTabItemInfo */ diff --git a/UI/Common/UIxTabView.h b/UI/Common/UIxTabView.h deleted file mode 100644 index a2e6a1f1a..000000000 --- a/UI/Common/UIxTabView.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - Copyright (C) 2000-2005 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#ifndef __UIxTabView_H__ -#define __UIxTabView_H__ - -/* - This is a library private header ! -*/ - -#include - -/* - Does not support tab-head-creation from nested components !!! - - hh: Why not ??? -> Because selection is manipulated in sub-elements - - UIxTabView creates element-IDs like - - .h.*.$key. for the tab-items (head-mode) - .b.$key... for the tab-content (content-mode) (new, hh) - - !!! UIxTabView JavaScript can't handle duplicate tab-keys !!! -*/ - -@interface UIxTabView : WODynamicElement -{ - WOAssociation *selection; - - /* config: */ - WOAssociation *headerStyle; - WOAssociation *bodyStyle; - WOAssociation *tabStyle; - WOAssociation *selectedTabStyle; - - /* old config: */ - WOAssociation *bgColor; - WOAssociation *nonSelectedBgColor; - WOAssociation *leftCornerIcon; - WOAssociation *rightCornerIcon; - - WOAssociation *tabIcon; - WOAssociation *leftTabIcon; - WOAssociation *selectedTabIcon; - - WOAssociation *asBackground; - WOAssociation *width; - WOAssociation *height; - WOAssociation *activeBgColor; - WOAssociation *inactiveBgColor; - - WOAssociation *fontColor; - WOAssociation *fontSize; - WOAssociation *fontFace; - - id template; -} - -@end - -@interface UIxTabItem : WODynamicElement -{ - WOAssociation *key; - WOAssociation *label; - - WOAssociation *href; - WOAssociation *isScript; - - WOAssociation *action; - WOAssociation *icon; - - /* config: */ - WOAssociation *tabStyle; - WOAssociation *selectedTabStyle; - - /* old config */ - WOAssociation *tabIcon; - WOAssociation *leftTabIcon; - WOAssociation *selectedTabIcon; - - WOAssociation *asBackground; - WOAssociation *width; - WOAssociation *height; - WOAssociation *activeBgColor; - WOAssociation *inactiveBgColor; - - id template; -} - -@end - -@interface UIxTabItemInfo : NSObject -{ -@public - NSString *label; - NSString *icon; - NSString *key; - NSString *uri; - NSString *tabIcon; - NSString *leftIcon; - NSString *selIcon; - NSString *tabStyle; - NSString *selectedTabStyle; - - int asBackground; // 0 -> not set, 1 -> YES, else -> NO - NSString *width; - NSString *height; - NSString *activeBg; - NSString *inactiveBg; - - BOOL isScript; -} -@end - -#endif /* __UIxTabView_H__ */ diff --git a/UI/Common/UIxTabView.m b/UI/Common/UIxTabView.m deleted file mode 100644 index 6bc96ed64..000000000 --- a/UI/Common/UIxTabView.m +++ /dev/null @@ -1,684 +0,0 @@ -/* - Copyright (C) 2000-2004 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#include "UIxTabView.h" -#include "common.h" -#include -#include -#include -#include - -#if DEBUG -// # define DEBUG_TAKEVALUES 1 -# define DEBUG_JS 1 -#endif - -/* context keys */ -NSString *UIxTabView_HEAD = @"UIxTabView_head"; -NSString *UIxTabView_BODY = @"UIxTabView_body"; -NSString *UIxTabView_KEYS = @"UIxTabView_keys"; -NSString *UIxTabView_SCRIPT = @"UIxTabView_script"; -NSString *UIxTabView_ACTIVEKEY = @"UIxTabView_activekey"; -NSString *UIxTabView_COLLECT = @"~tv~"; - -@implementation UIxTabView - -static NSNumber *YesNumber; - -+ (void)initialize { - if (YesNumber == nil) - YesNumber = [[NSNumber numberWithBool:YES] retain]; -} - -+ (int)version { - return [super version] + 0; -} - -- (id)initWithName:(NSString *)_name - associations:(NSDictionary *)_config - template:(WOElement *)_subs -{ - if ((self = [super initWithName:_name associations:_config template:_subs])) { - self->selection = WOExtGetProperty(_config, @"selection"); - - self->headerStyle = WOExtGetProperty(_config, @"headerStyle"); - self->bodyStyle = WOExtGetProperty(_config, @"bodyStyle"); - self->tabStyle = WOExtGetProperty(_config, @"tabStyle"); - self->selectedTabStyle = WOExtGetProperty(_config, @"selectedTabStyle"); - - self->bgColor = WOExtGetProperty(_config, @"bgColor"); - self->nonSelectedBgColor = WOExtGetProperty(_config, @"nonSelectedBgColor"); - self->leftCornerIcon = WOExtGetProperty(_config, @"leftCornerIcon"); - self->rightCornerIcon = WOExtGetProperty(_config, @"rightCornerIcon"); - - self->tabIcon = WOExtGetProperty(_config, @"tabIcon"); - self->leftTabIcon = WOExtGetProperty(_config, @"leftTabIcon"); - self->selectedTabIcon = WOExtGetProperty(_config, @"selectedTabIcon"); - - self->asBackground = WOExtGetProperty(_config, @"asBackground"); - self->width = WOExtGetProperty(_config, @"width"); - self->height = WOExtGetProperty(_config, @"height"); - self->activeBgColor = WOExtGetProperty(_config, @"activeBgColor"); - self->inactiveBgColor = WOExtGetProperty(_config, @"inactiveBgColor"); - - self->fontColor = WOExtGetProperty(_config, @"fontColor"); - self->fontSize = WOExtGetProperty(_config, @"fontSize"); - self->fontFace = WOExtGetProperty(_config, @"fontFace"); - - self->template = RETAIN(_subs); - } - return self; -} - -- (void)dealloc { - [self->selection release]; - - [self->headerStyle release]; - [self->bodyStyle release]; - [self->tabStyle release]; - [self->selectedTabStyle release]; - - RELEASE(self->bgColor); - RELEASE(self->nonSelectedBgColor); - RELEASE(self->leftCornerIcon); - RELEASE(self->rightCornerIcon); - - RELEASE(self->leftTabIcon); - RELEASE(self->selectedTabIcon); - RELEASE(self->tabIcon); - - RELEASE(self->width); - RELEASE(self->height); - - RELEASE(self->activeBgColor); - RELEASE(self->inactiveBgColor); - - RELEASE(self->fontColor); - RELEASE(self->fontSize); - RELEASE(self->fontFace); - - RELEASE(self->template); - [super dealloc]; -} - -/* nesting */ - -- (id)saveNestedStateInContext:(WOContext *)_ctx { - return nil; -} -- (void)restoreNestedState:(id)_state inContext:(WOContext *)_ctx { - if (_state == nil) return; -} - -- (NSArray *)collectKeysInContext:(WOContext *)_ctx { - /* collect mode, collects all keys */ - [_ctx setObject:UIxTabView_COLLECT forKey:UIxTabView_HEAD]; - - [self->template appendToResponse:nil inContext:_ctx]; - - [_ctx removeObjectForKey:UIxTabView_HEAD]; - return [_ctx objectForKey:UIxTabView_KEYS]; -} - -/* responder */ - -- (void)takeValuesFromRequest:(WORequest *)_req inContext:(WOContext *)_ctx { - id nestedState; - NSString *activeTabKey; - - activeTabKey = [self->selection stringValueInComponent:[_ctx component]]; - NSLog(@"%s activeTabKey:%@", __PRETTY_FUNCTION__, activeTabKey); - nestedState = [self saveNestedStateInContext:_ctx]; - [_ctx appendElementIDComponent:@"b"]; - [_ctx appendElementIDComponent:activeTabKey]; - - [_ctx setObject:activeTabKey forKey:UIxTabView_BODY]; - -#if DEBUG_TAKEVALUES - [[_ctx component] debugWithFormat:@"UIxTabView: body takes values, eid='%@'", - [_ctx elementID]]; -#endif - - [self->template takeValuesFromRequest:_req inContext:_ctx]; - - [_ctx removeObjectForKey:UIxTabView_BODY]; - [_ctx deleteLastElementIDComponent]; // activeKey - [_ctx deleteLastElementIDComponent]; /* 'b' */ - [self restoreNestedState:nestedState inContext:_ctx]; -} - -- (id)invokeActionForRequest:(WORequest *)_req inContext:(WOContext *)_ctx { - NSString *key; - id result; - id nestedState; - - if ((key = [_ctx currentElementID]) == nil) - return nil; - - result = nil; - nestedState = [self saveNestedStateInContext:_ctx]; - - if ([key isEqualToString:@"h"]) { - /* header action */ - //NSString *urlKey; - - [_ctx consumeElementID]; - [_ctx appendElementIDComponent:@"h"]; -#if 0 - if ((urlKey = [_ctx currentElementID]) == nil) { - [[_ctx application] - debugWithFormat:@"missing active head tab key !"]; - } - else { - //NSLog(@"clicked: %@", urlKey); - [_ctx consumeElementID]; - [_ctx appendElementIDComponent:urlKey]; - } -#endif - - [_ctx setObject:self->selection forKey:UIxTabView_HEAD]; - result = [self->template invokeActionForRequest:_req inContext:_ctx]; - [_ctx removeObjectForKey:UIxTabView_HEAD]; - -#if 0 - if (urlKey) - [_ctx deleteLastElementIDComponent]; // active key -#endif - [_ctx deleteLastElementIDComponent]; // 'h' - } - else if ([key isEqualToString:@"b"]) { - /* body action */ - NSString *activeTabKey, *urlKey; - - [_ctx consumeElementID]; - [_ctx appendElementIDComponent:@"b"]; - - if ((urlKey = [_ctx currentElementID]) == nil) { - [[_ctx application] - debugWithFormat:@"missing active body tab key !"]; - } - else { - //NSLog(@"clicked: %@", urlKey); - [_ctx consumeElementID]; - [_ctx appendElementIDComponent:urlKey]; - } - - activeTabKey = [self->selection stringValueInComponent:[_ctx component]]; - [_ctx setObject:activeTabKey forKey:UIxTabView_BODY]; - - result = [self->template invokeActionForRequest:_req inContext:_ctx]; - - [_ctx removeObjectForKey:UIxTabView_BODY]; - - if (urlKey) - [_ctx deleteLastElementIDComponent]; // active key - [_ctx deleteLastElementIDComponent]; // 'b' - } - else { - [[_ctx application] - debugWithFormat:@"unknown tab container key '%@'", key]; - } - - [self restoreNestedState:nestedState inContext:_ctx]; - return result; -} - -- (NSString *)_tabViewCountInContext:(WOContext *)_ctx { - int count; - count = [[_ctx valueForKey:@"UIxTabViewScriptDone"] intValue]; - return [NSString stringWithFormat:@"%d",count]; -} - -- (NSString *)scriptHref:(UIxTabItemInfo *)_info - inContext:(WOContext *)_ctx - isLeft:(BOOL)_isLeft - keys:(NSArray *)_keys -{ - NSMutableString *result = [NSMutableString string]; - UIxTabItemInfo *tmp; - NSString *activeKey; - int i, cnt; - NSString *elID; - NSString *tstring; - - activeKey = [self->selection stringValueInComponent:[_ctx component]]; - [result appendString:@"JavaScript:showTab("]; - [result appendString:_info->key]; - [result appendString:@"Tab);"]; - - [result appendString:@"swapCorners("]; - tstring = (!_isLeft) - ? @"tabCorner%@,tabCornerLeft%@);" - : @"tabCornerLeft%@,tabCorner%@);"; - elID = [self _tabViewCountInContext:_ctx]; - [result appendString:[NSString stringWithFormat:tstring,elID,elID]]; - - for (i=0, cnt = [_keys count]; i < cnt; i++) { - tmp = [_keys objectAtIndex:i]; - - if ((tmp->isScript || [tmp->key isEqualToString:activeKey]) - && ![tmp->key isEqualToString:_info->key]) { - [result appendString:@"hideTab("]; - [result appendString:tmp->key]; - [result appendString:@"Tab);"]; - } - } - return result; -} - -- (void)appendLink:(UIxTabItemInfo *)_info - toResponse:(WOResponse *)_response - inContext:(WOContext *)_ctx - isActive:(BOOL)_isActive isLeft:(BOOL)_isLeft - doScript:(BOOL)_doScript keys:(NSArray *)_keys -{ - NSString *headUri = nil; - NSString *label = nil; - NSString *styleName = nil; - WEClientCapabilities *ccaps; - WOComponent *comp; - - ccaps = [[_ctx request] clientCapabilities]; - - comp = [_ctx component]; - headUri = _info->uri; - - if ((label = _info->label) == nil) - label = _info->key; - - if (_isActive) { - styleName = (_info->selectedTabStyle) - ? _info->selectedTabStyle - : [self->selectedTabStyle stringValueInComponent:comp]; - } - else { - styleName = (_info->tabStyle) - ? _info->tabStyle - : [self->tabStyle stringValueInComponent:comp]; - } - - [_response appendContentString:@"']; - - [_response appendContentString:@"key]]; - [_response appendContentString:@">"]; - - if ([label length] < 1) - label = _info->key; - [_response appendContentString:@""]; - [_response appendContentHTMLString:label]; - [_response appendContentString:@""]; - - [_response appendContentString:@""]; - - [_response appendContentString:@""]; -} - -- (void)appendSubmitButton:(UIxTabItemInfo *)_info - toResponse:(WOResponse *)_response - inContext:(WOContext *)_ctx - isActive:(BOOL)_isActive isLeft:(BOOL)_left - doScript:(BOOL)_doScript keys:(NSArray *)_keys -{ - [self appendLink:_info - toResponse:_response - inContext:_ctx - isActive:_isActive isLeft:_left - doScript:NO keys:_keys]; -} - -- (void)_appendTabViewJSScriptToResponse:(WOResponse *)_response - inContext:(WOContext *)_ctx -{ - [_response appendContentString: - @""]; -} - -- (void)_appendHeaderRowToResponse:(WOResponse *)_response - inContext:(WOContext *)_ctx - keys:(NSArray *)keys activeKey:(NSString *)activeKey - doScript:(BOOL)doScript -{ - unsigned i, count; - BOOL doForm; - NSString *styleName; - - doForm = NO; /* generate form controls ? */ - - [_response appendContentString:@""]; - - styleName = [self->headerStyle stringValueInComponent:[_ctx component]]; - if(styleName) { - [_response appendContentString: - @""]; - } - else { - [_response appendContentString: - @"
"]; - } - - for (i = 0, count = [keys count]; i < count; i++) { - UIxTabItemInfo *info; - NSString *key; - BOOL isActive; - - info = [keys objectAtIndex:i]; - key = info->key; - isActive = [key isEqualToString:activeKey]; - - [_ctx appendElementIDComponent:key]; - - if (doForm) { - /* tab is inside of a FORM, so produce submit buttons */ - [self appendSubmitButton:info - toResponse:_response - inContext:_ctx - isActive:isActive - isLeft:(i == 0) ? YES : NO - doScript:NO - keys:keys]; - } - else { - /* tab is not in a FORM, generate hyperlinks for tab */ - [self appendLink:info - toResponse:_response - inContext:_ctx - isActive:isActive - isLeft:(i == 0) ? YES : NO - doScript:NO - keys:keys]; - } - - [_ctx deleteLastElementIDComponent]; - } - // [_response appendContentString:@""]; - [_response appendContentString:@"
"]; - [_response appendContentString:@""]; -} - -- (void)_appendHeaderFootRowToResponse:(WOResponse *)_response - inContext:(WOContext *)_ctx - bgcolor:(NSString *)bgcolor - doScript:(BOOL)doScript - isLeftActive:(BOOL)isLeftActive -{ - NSString *styleName; - [_response appendContentString:@" bodyStyle stringValueInComponent:[_ctx component]]; - if(styleName) { - [_response appendContentString:@" class='"]; - [_response appendContentHTMLAttributeValue:styleName]; - [_response appendContentCharacter:'\'']; - } - if (bgcolor) { - [_response appendContentString:@" bgcolor=\""]; - [_response appendContentHTMLAttributeValue:bgcolor]; - [_response appendContentString:@"\""]; - } - [_response appendContentString:@">\n"]; - - /* left corner */ - [_response appendContentString:@" "]; - - if (isLeftActive) - [_response appendContentString:@" "]; - - if (!isLeftActive) { - NSString *uri; - - uri = [self->leftCornerIcon stringValueInComponent:[_ctx component]]; - if ((uri = WEUriOfResource(uri, _ctx))) { - [_response appendContentString:@"\"\""]; - } - else - [_response appendContentString:@" "]; - } - - [_response appendContentString:@""]; - - /* right corner */ - [_response appendContentString:@" "]; - { - NSString *uri; - - uri = [self->rightCornerIcon stringValueInComponent:[_ctx component]]; - if ((uri = WEUriOfResource(uri, _ctx))) { - [_response appendContentString:@"\"\""]; - } - else - [_response appendContentString:@" "]; - } - [_response appendContentString:@"\n"]; - - [_response appendContentString:@" \n"]; -} - -- (void)_appendBodyRowToResponse:(WOResponse *)_response - inContext:(WOContext *)_ctx - bgcolor:(NSString *)bgcolor - activeKey:(NSString *)activeKey -{ - WEClientCapabilities *ccaps; - BOOL indentContent; - NSString *styleName; - - styleName = [self->bodyStyle stringValueInComponent:[_ctx component]]; - ccaps = [[_ctx request] clientCapabilities]; - - /* put additional padding table into content ??? */ - indentContent = [ccaps isFastTableBrowser] && ![ccaps isTextModeBrowser]; - - [_response appendContentString:@"']; - - if (indentContent) { - /* start padding table */ - [_response appendContentString: - @""]; - [_response appendContentString:@"
"]; - } - - [_ctx appendElementIDComponent:@"b"]; - [_ctx appendElementIDComponent:activeKey]; - - /* generate currently active body */ - { - [_ctx setObject:activeKey forKey:UIxTabView_BODY]; - [self->template appendToResponse:_response inContext:_ctx]; - [_ctx removeObjectForKey:UIxTabView_BODY]; - } - - [_ctx deleteLastElementIDComponent]; // activeKey - [_ctx deleteLastElementIDComponent]; // 'b' - - if (indentContent) - /* close padding table */ - [_response appendContentString:@"
"]; - - [_response appendContentString:@""]; -} - -- (BOOL)isLeftActiveInKeys:(NSArray *)keys activeKey:(NSString *)activeKey{ - unsigned i, count; - BOOL isLeftActive; - - isLeftActive = NO; - - for (i = 0, count = [keys count]; i < count; i++) { - UIxTabItemInfo *info; - - info = [keys objectAtIndex:i]; - - if ((i == 0) && [info->key isEqualToString:activeKey]) - isLeftActive = YES; - } - - return isLeftActive; -} - -- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx { - WOComponent *cmp; - NSString *bgcolor; - BOOL isLeftActive; - id nestedState; - NSString *activeKey; - NSArray *keys; - int tabViewCount; /* used for image id's and writing script once */ - - tabViewCount = [[_ctx valueForKey:@"UIxTabViewScriptDone"] intValue]; - cmp = [_ctx component]; - - /* save state */ - - nestedState = [self saveNestedStateInContext:_ctx]; - - /* configure */ - - activeKey = [self->selection stringValueInComponent:cmp]; - - bgcolor = [self->bgColor stringValueInComponent:cmp]; - bgcolor = [bgcolor stringValue]; - - [_ctx appendElementIDComponent:@"h"]; - - /* collect & process keys (= available tabs) */ - - keys = [self collectKeysInContext:_ctx]; - - if (![[keys valueForKey:@"key"] containsObject:activeKey]) - /* selection is not available in keys */ - activeKey = nil; - - if ((activeKey == nil) && ([keys count] > 0)) { - /* no or invalid selection, use first key */ - activeKey = [[keys objectAtIndex:0] key]; - if ([self->selection isValueSettable]) - [self->selection setValue:activeKey inComponent:[_ctx component]]; - } - - /* start appending */ - - /* count up for unique tabCorner/tabCornerLeft images */ - [_ctx takeValue:[NSNumber numberWithInt:(tabViewCount + 1)] - forKey:@"UIxTabViewScriptDone"]; - - [_response appendContentString: - @""]; - - /* find out whether left is active */ - - isLeftActive = [self isLeftActiveInKeys:keys activeKey:activeKey]; - - /* generate header row */ - - [self _appendHeaderRowToResponse:_response inContext:_ctx - keys:keys activeKey:activeKey - doScript:NO]; - - [_ctx deleteLastElementIDComponent]; // 'h' for head - [_ctx removeObjectForKey:UIxTabView_HEAD]; - - /* body row */ - - [self _appendBodyRowToResponse:_response inContext:_ctx - bgcolor:bgcolor - activeKey:activeKey]; - - /* close table */ - - [_response appendContentString:@"
"]; - [_ctx removeObjectForKey:UIxTabView_ACTIVEKEY]; - [_ctx removeObjectForKey:UIxTabView_KEYS]; - [self restoreNestedState:nestedState inContext:_ctx]; -} - -@end /* UIxTabView */