/* Implementation of TextField class
 *
 * Copyright (C)  1993  The Board of Trustees of  
 * The Leland Stanford Junior University.  All Rights Reserved.
 *
 * Authors: Scott Francis, Paul Kunz, Imran Qureshi, and Libing Wang (SLAC)
 *	    Mike L. Kienenberger (Alaska)
 *
 * This file is part of an Objective-C class library for a window system
 *
 * TextField.m,v 1.38 1995/12/13 22:33:21 fedor Exp
 */

 
#include "TextField.h"

#include "TextFieldCell.h"
#include "stdmacros.h"

@implementation TextField : Control

+ setCellClass:factoryId
{
  [self notImplemented:_cmd];
  return 0;
}

- initFrame:(const NXRect *)frameRect
{
    if ( !cell )
        cell = [[TextFieldCell alloc] init]; 
    [super initFrame:frameRect];
    instancename = "TextField";
    return self;
}

- sizeTo:(float)width :(float)height
{
  [self notImplemented:_cmd];
  return 0;
}

- setBackgroundGray:(float)value
{
  [self notImplemented:_cmd];
  return 0;
}

- (float)backgroundGray
{
  [self notImplemented:_cmd];
  return 0;
}

- setTextGray:(float)value
{
    if (nil != cell)  [(TextFieldCell *)cell setTextGray:value];

    return self;
}

- (float)textGray
{
  [self notImplemented:_cmd];
  return 0;
}

- setBackgroundColor:(NXColor)color
{
  [self notImplemented:_cmd];
  return 0;
}

- (NXColor)backgroundColor
{
  NXColor color;
  [self notImplemented:_cmd];
  return color;
}

- setBackgroundTransparent:(BOOL)flag
{
  [self notImplemented:_cmd];
  return 0;
}

- (BOOL)isBackgroundTransparent
{
  [self notImplemented:_cmd];
  return 0;
}

- setTextColor:(NXColor)color
{
  [self notImplemented:_cmd];
  return 0;
}

- (NXColor)textColor
{
  NXColor color;
  [self notImplemented:_cmd];
  return color;
}

- drawCellInside:aCell
{
  [self notImplemented:_cmd];
  return 0;
}

- setEnabled:(BOOL)flag
{
  return [super setEnabled: flag];
}

- (BOOL)isBordered
{
  return [cell isBordered];
}

- setBordered:(BOOL)flag
{
  [cell setBordered: flag];
  return self;
}

- (BOOL)isBezeled
{
  return [cell isBezeled];
}

- setBezeled:(BOOL)flag
{
  [cell setBezeled: flag];
  return self;
}

- (BOOL)isEditable
{
  [self notImplemented:_cmd];
  return 0;
}

- setEditable:(BOOL)flag
{
  [self notImplemented:_cmd];
  return 0;
}

- (BOOL)isSelectable
{
  [self notImplemented:_cmd];
  return 0;
}

- setSelectable:(BOOL)flag
{
  [self notImplemented:_cmd];
  return 0;
}

- setPreviousText:anObject
{
  [self notImplemented:_cmd];
  return 0;
}

- previousText
{
  [self notImplemented:_cmd];
  return 0;
}

- setNextText:anObject
{
  [self notImplemented:_cmd];
  return 0;
}

- nextText
{
  [self notImplemented:_cmd];
  return 0;
}

- mouseDown:(NXEvent *)theEvent
{
  [self notImplemented:_cmd];
  return 0;
}

- (SEL)errorAction
{
  [self notImplemented:_cmd];
  return 0;
}

- setErrorAction:(SEL)aSelector
{
  [self notImplemented:_cmd];
  return 0;
}

- selectText:sender
{
    if (cell) {
	[(TextFieldCell *)cell _selectText];
    }
    return self;
}

- textDelegate
{
  [self notImplemented:_cmd];
  return 0;
}

- setTextDelegate:anObject
{
  [self notImplemented:_cmd];
  return 0;
}

- (BOOL)textWillEnd:textObject
{
  [self notImplemented:_cmd];
  return 0;
}

- textDidEnd:textObject endChar:(unsigned short)whyEnd
{
  [self notImplemented:_cmd];
  return 0;
}

- (BOOL)textWillChange:textObject
{
  [self notImplemented:_cmd];
  return 0;
}

- textDidChange:textObject
{
  [self notImplemented:_cmd];
  return 0;
}

- textDidGetKeys:textObject isEmpty:(BOOL)flag
{
  [self notImplemented:_cmd];
  return 0;
}

- (BOOL)acceptsFirstResponder
{
  [self notImplemented:_cmd];
  return 0;
}

- _initAsLabel
{
    if (!cell) {
	cell = [[TextFieldCell alloc] _initAsLabel];
    } else {
        [(TextFieldCell *)cell _initAsLabel];
    }
    return self;
}

- read:(TypedStream *)ts
{
    int		edit, select, bezel, border;
    BOOL	label;

    [super read:ts];

    objc_read_types(ts, "iiii", &edit, &select, &bezel, &border);
    label = (!(edit || select || bezel || border));
  /* Normally we don't message another object from -read:, 
   * but we know that cell has been read by us 
   */
    [(TextFieldCell *)cell _setAsLabel:label];
    instancename = "TextField";
    return self;
}

- write:(TypedStream *)ts
{
  return self;
}

@end
