Filewatcher File Search
FTP Search
  
Directory 
  
Content Search 
   
pkg://swarm-cvs-latest.tar.gz:13287713/swarm/cvs-latest/swarm/swarm/src/tkobjc/Attic/XColormap.m,v  downloads

head	1.8;
access;
symbols
	Swarm-1_0_5c:1.4
	Swarm-1_0_5b:1.4
	Swarm-1_0_5a:1.4
	Swarm-1_0_5:1.3
	Swarm-1_0_4c:1.3
	Swarm-1_0_4b:1.3
	Swarm-1_0_4a:1.3
	Swarm-1_0_4:1.3
	Swarm-1_0_2:1.1.1.1
	Swarm-1_0_1-Alpha-Port:1.1.1.1
	Swarm-1_0_1:1.1.1.1
	swarm-1_0_0_p1:1.1.1.1
	swarm-1_0_0:1.1.1.1
	SwarmKernel-0_7:1.1.1.1
	SwarmKernel-0_6:1.1.1.1
	SwarmKernel-0_5:1.1.1.1
	SwarmKernel-0_4:1.1.1.1
	SwarmKernel-0_3:1.1.1.1
	Swarm-961002:1.1.1.1
	SwarmKernel-0_2:1.1.1.1
	start:1.1.1.1
	Kernel:1.1.1;
locks; strict;
comment	@// @;


1.8
date	98.01.27.23.48.33;	author mgd;	state dead;
branches;
next	1.7;

1.7
date	98.01.27.21.53.11;	author mgd;	state Exp;
branches;
next	1.6;

1.6
date	98.01.24.22.37.57;	author mgd;	state Exp;
branches;
next	1.5;

1.5
date	98.01.18.19.28.01;	author mgd;	state Exp;
branches;
next	1.4;

1.4
date	98.01.16.04.38.40;	author mgd;	state Exp;
branches;
next	1.3;

1.3
date	97.12.11.02.57.51;	author mgd;	state Exp;
branches;
next	1.2;

1.2
date	97.11.13.03.54.09;	author gepr;	state Exp;
branches;
next	1.1;

1.1
date	96.10.02.02.53.07;	author gepr;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	96.10.02.02.53.07;	author gepr;	state Exp;
branches;
next	;


desc
@@


1.8
log
@Note renaming of BLTGraph -> Graph and XColormap -> Colormap
@
text
@// Swarm library. Copyright (C) 1996-1998 Santa Fe Institute.
// This library is distributed without any warranty; without even the
// implied warranty of merchantability or fitness for a particular purpose.
// See file LICENSE for details and terms of copying.

#import <tkobjc/global.h>
#import <tkobjc/XColormap.h>
#import <gui.h>

@@implementation XColormap
// create a new colourmap. Right now we use the Tk widget name
// just to get info about the X server connection. Later, we could
// use it for private colourmap installation, etc. For now, just
// init with the widget ".", that works fine.

- createEnd
{
  int i;
  
  [super createEnd];
  
  tkwin = Tk_NameToWindow ([globalTkInterp interp], 
                           ".",
                           [globalTkInterp mainWindow]);
  display = Tk_Display (tkwin);
  xwin = Tk_WindowId (tkwin);
  white = WhitePixel (display, DefaultScreen (display));
  black = BlackPixel (display, DefaultScreen (display));
  cmap = DefaultColormap (display, DefaultScreen (display));
  
  for (i = 0; i < MAXCOLORS; i++)
    isSet[i] = NO;
  return self;
}

// The colormap is a length MAXCOLORS array of PixelValues. We fill this array
// in as people ask for it. You're welcome to read this array yourself.
- (PixelValue *)map
{
  return map;
}

// get the particular colour associated with the entry. Error if it's not set.
- (PixelValue)pixelValue: (Color)c
{
  if ([self colorIsSet: c])
    return map[c];
  else
    {
      [InvalidArgument raiseEvent: "attempted to access unset color %d\n", c];
      return (PixelValue)white;
    }
}

// set a new colormap entry to something. Error if it's already set.
// we should do something to see if the colour already has been allocated
// in our colourmap. If it has, then we should somehow persuade the client
// to reuse that entry.
- (BOOL)setColor: (Color)c ToName: (const char *)colorName
{
  if ([self colorIsSet: c])
    {
      [InvalidArgument raiseEvent: "attempted to set color %d twice\n", c];
      return NO;
    }
  else
    {
      int rc;
      XColor xc, t;				  // ignore t
      
      isSet[c] = YES;
      rc = XAllocNamedColor (display, cmap, colorName, &xc, &t);
      if (rc == 0)
        {
          [ResourceAvailability
            raiseEvent:
              "Problem allocating color %s. Substituting white.\n",
            colorName];
          map[c] = white;
          return NO;
        }
      map[c] = (Color)xc.pixel;
      return YES;
    }
}

// allocate an RGB combo. We could use XAllocColor directly,
// but that requires rewriting more code.
- (BOOL)setColor: (Color)c
           ToRed: (double)r
           Green: (double)g
            Blue: (double)b
{
  unsigned ru, gu, bu;
  char colorName[1+2+2+2+1];			  // "#rrggbb\0"

  ru = r * 0xffU;
  gu = g * 0xffU;
  bu = b * 0xffU;
  
  sprintf (colorName, "#%02x%02x%02x", ru, gu, bu);
  return [self setColor: c ToName: colorName];
}

// allocate grey: just a convenience.
- (BOOL)setColor: (Color)c ToGrey: (double)g
{
  return [self setColor: c ToRed: g Green: g Blue: g];
}

// white and black are basic colours. (Should also be entered in the map,
// reserved. Oh well.)
- (PixelValue)white
{
  return white;
}

- (PixelValue)black
{
  return black;
}

// is the colour actually set?
- (BOOL)colorIsSet: (Color)c
{
  return isSet[c];
}

@@end
@


1.7
log
@* tkobjc.m: Include internal.h and gui.h.  Don't include
tkobjc/TkExtra.h Define globalTkInterp to conform to the TkExtra
protocol.
(initTkObjc): Constify argv.  Use tkobjc_initTclInterp and
tkobjc_initTkInterp.  Set Colormap to XColormap.

* global.h: Make globalTkInterp extern conform to TkExtra
protocol, declared immediately above.  Constify argv argument to
initTkObjc declaration.

* common.m: Include defobj.h and tk.h.
(tkobjc_dragAndDropTarget, dragAndDropTargetArg,
oldSetupDragAndDrop, newSetupDragAndDrop, oldSetupDragAndDropArg,
newSetupDragAndDropArg, tkobjc_bindButton3ToSpawn,
tkobjc_bindButton3ToArgSpawn): Use getObjectName method instead of
tclObjc_objectToName.
(tkobjc_drag_and_drop_object): Use getObjectNamed function instead
of tclObjc_nameToObject.

* common.h: Use #include <objc/objc.h>, not #import <objc/objc.h>.

* ZoomRaster.m: Don't include string.h, stdio.h, stdlib.h,
tclObjc.h, tkobjc/TkExtra.h, or X11/Xutil.h.  Include
internal.h. Reformatting throughout.

* XPixmap.m ([XPixmap -setFile:]): Include internal.h.
Don't include tkobjc/TkExtra.h or X11/xpm.h.
([XPixmap -createEnd]): Use tkobjc_nameToWindow.

* XPixmap.h: Include gui.h.  Don't include tk.h.

* XColormap.m: Don't include TkInterp.h.  Include gui.h.
([XColormap -map]): Return PixelValue, again.
([XColormap -pixelValue:]): Likewise.
([XColormap -setColor:ToName:]): Use Color not GUI_Color.
([XColormap -setColor:ToRed:Green:Blue:]): Likewise.
([XColormap -setColor:ToGrey:]): Likewise.
([XColormap -white]): Return PixelValue, not GUI_PixelValue.
([XColormap -black]): Likewise.
([XColormap -colorIsSet:]): Take Color as argument, not GUI_Color.

* XColormap.h: Don't provide typedefs for PixelValue or Color,
they come from gui.h now.  map, pixelValue:, white, and black return
a PixelValue again.  The setColor methods and colorIsSet: once
again use PixelValue, not GUI_PixelValue.

* TkExtra.h: Don't include tk.h.

* SuperButton.m: Don't include tclObjc.h, tkobjc/common.h, stdlib.h,
or string.h.
(tkobjc_configureWidgetToPackBeforeAndFillLeftThenDisableAndResize):
Don't use tclObjc_objectToName, use getObjectName.

* Raster.m: Don't include string.h, stdio.h, stdlib.h, tclObjc.h,
or TkInterp.h.  Include internal.h.
([Raster -createEnd]): Use tkobjc_nameToWindow.
([Raster -setButton:Client:Message:]): Use ButtonLeft/Middle/Right
symbols instead of integers in case statement.
([Raster -handleButton:X:Y:]): Likewise.

* Raster.h: Don't include tk.h, or XColormap.h.  Don't
define ButtonLeft, ButtonMiddle, or ButtonRight, they come
from gui.h now.  Include internal.h.  Minor reformatting.

* Makefile (OBJECTS,HEADERS): Add internal.
(internal.o): Add.

* InputWidget.m:  Include internal.h.  Don't include TkInterp.h,
stding.h, or stdio.h.
([InputWidget -linkVariable:Type:]): Use tkobjc_unlinkVar and
tkobjc_linkVar.

* internal.[hm]:  New files.  These routines encapsulate
sorts of interpreter access only used internally.  The header
file loads X headers files, but keeps Colormap free.
@
text
@@


1.6
log
@Provide support for eliminating all use of Tk outside of this library.

* ClassDisplayHideButton.[hm], CompleteProbeDisplayLabel.[hm],
MessageProbeEntry.[hm], ProbeCanvas.[hm],
SimpleProbeDisplayHideButton.[hm],
SuperButton.[hm],VarProbeEntry.[hm]: New classes to encapsulate
tkobjc_* functionality and give some explict semantics.

* Histogram.[hm]:  Renamed from Histo.[hm].

* tkobjc.m (registerInterp): New static function.
(initTkObjc): Use registerInterp instead of
tkobjc_registerCommand.

* tkobjc.h: Use Histogram.h instead of Histo.h.
Add ClassDisplayHideButton.h, SimpleProbeDisplayHideButton.h,
SuperButton.h, MessageProbeEntry.h, VarProbeEntry.h, ProbeCanvas.h.
Drop DragDrop.h.

* common.[hm]: Add (remaining tkobjc_* routines from control).

* control.[hm], DragDrop.[hm]:  Remove.

* ZoomRaster.h: Reformatting throughout.

* XColormap.m ([XColormap -map], [XColormap -pixelValue:],
[XColormap -white], [XColormap -black]): Use GUI_PixelValue for
return type.
([XColormap -setColor:ToName:], [XColormap -colorIsSet:]): Use
GUI_Color for first argument.
([XColormap -setColor:ToRed:Green:Blue:]): Likewise.
([XColormap -setColor:ToGrey:]): Likewise.

* XColormap.h: Include <gui.h>
Make XColormap conform to <Colormap>.
Use GUI_PixelValue for map, pixelValue, white, black methods.
Use GUI_Color for pixelValue for colorIsSet: and setColor methods.

* Widget.m: Don't include string.h, stdio.h, stdlib.h, stdarg.h,
tclObjc.h, and TkInterp.h.  Include tkobjc/common.h.
([Widget -createEnd]): Use new method setWidgetNameFromParent:
instead of makeNameFromParentName:.
([Widget -pack]): Use tclobjc_pack instead of calling
globalTkInterp directly.
(makeWidgetName): New static function (functionality of
makeNameFromParentName).
([Widget -makeWidgetNameFor:], [Widget -setWidgetNameFromParent:],
[Widget -setWidgetNameFromParentName:], [Widget -packToRight:],
[Widget -packBeforeAndFillLeft:expand:],
[Widget -packFillLeft:], [Widget -packFill], [Widget
-packForgetAndExpand], [Widget -setActiveFlag:], [Widget
-enableRelief], [Widget -setBorderWidth:], [Widget
-setupWindowEntryColor], [Widget -setupWindowExitColor], [Widget
-focus]): New methods for tkobjc_* functionality.

* Widget.h: New methods packToRight:,
packBeforeAndFillLeft:expand:, packFillleft:, packFill,
packForgetAndExpand, setActiveFlag:, enableRelief,
setBorderWidth:, setupWindowEntryColor, setupWindowExitColor,
focus, setWidgetNameFromParent:, setWidgetNameFromParentName:,
makeWidgetNameFor:.

* Raster.m ([Raster -getColormap]): Return id <Colormap>.
([Raster -setColormap:]): Take id <Colormap>.

* Raster.h: Include gui.h.
(Raster): Make colormap an id conforming to Colormap protocol
not a XColormap *.
getColormap now returns a id <Colormap>.
setColormap takes a id <Colormap>.
drawPointX:Y:Color:, fillRectangleX0:Y0:X1:Color:  Use GUI_Color.

* Makefile (OBJECTS, HEADERS): Add ClassDisplayHideButton,
SimpleProbeDisplayHideButton, SuperButton, MessageProbeEntry,
VarProbeEntry, CompleteProbeDisplayLabel, ProbeCanvas, and common.
Drop DragDrop and control.  Change Histo to Histogram.
(OTHERCLEAN): Change testHisto to testHistogram.
(testHistogram): Change from testHisto.
(Histogram.o): Replaces Histo.o.
(DragDrop.o, control.o): Drop.
(ClassDisplayHideButton.o, SimpleProbeDisplayHideButton.o,
SuperButton.o, MessageProbeEntry.o, VarProbeEntry.o,
ProbeCanvas.o, common.o): Add.

* Label.m ([Label -anchorEast], [Label -anchorWest], [Label
-colorBlue]): New methods to replace tkobjc_* functionality.

* Label.h: Declare new methods anchorEast, anchorWest, and colorBlue.

* Frame.m: Don't include string.h, stdio.h, stdlib.h, or
TkInterp.h.  Include tkobjc/common.h.
([Frame -createEnd]): Use new method setWidgetNameFromParentName
instead of removed makeNameFromParentName.
([Frame -createEnd]): Use tkobjc_makeFrame to create a frame
instead of calling globalTkInterp directly.
([Frame -assertPosition], [Frame -assertGeometry], [Frame
-withdraw], [Frame -deiconify]): New methods replace tkobjc_*
functionality.

* Frame.h: Declare new methods assertGeometry, assertPosition,
withdraw, and deiconify.

* Entry.m: Reformatting throughout.

* Entry.h: Declare createEnd, setValue:, and setWidth:.

* CompositeItem.h: Reformatting throughout.

* ButtonPanel.m: Don't include tclObjc.h or TkInterp.h.
([ButtonPanel -setButtonTarget:]): New method, drop
setTargetName.
([ButtonPanel -addButtonName:actionName:]): Use targetName
instead of defaultTargetName.

* ButtonPanel.h: New method setButtonTarget:.
(ButtonPanel): Rename instance variable defaultTargetName to
targetName.  Drop setTargetName.

* Button.m ([Button -createEnd]): Don't include tclObjc.h or
TkInterp.h.
([Button -setButtonTarget:method:]): New method.

* Button.h: Declare new method setButtonTarget:.

* BLTGraph.m ([BLTGraph -setTitle:]): Rename from title:.
([BLTGraph -setAxisLabelsX:Y:]): Rename from axisLabelsX:Y:.

* BLTGraph.h: Rename title: to setTitle: and axisLabelsX:Y:
to setAxisLabelsX:Y:.
@
text
@d8 1
a8 1
#import <TkInterp.h>
d38 1
a38 1
- (GUI_PixelValue *)map
d44 1
a44 1
- (GUI_PixelValue)pixelValue: (GUI_Color)c
d51 1
a51 1
      return (GUI_PixelValue)white;
d59 1
a59 1
- (BOOL)setColor: (GUI_Color)c ToName: (const char *)colorName
d82 1
a82 1
      map[c] = (GUI_Color)xc.pixel;
d89 1
a89 1
- (BOOL)setColor: (GUI_Color)c
d106 1
a106 1
- (BOOL)setColor: (GUI_Color)c ToGrey: (double)g
d113 1
a113 1
- (GUI_PixelValue)white
d118 1
a118 1
- (GUI_PixelValue)black
d124 1
a124 1
- (BOOL)colorIsSet: (GUI_Color)c
@


1.5
log
@* TkExtra.h, BLTGraph.m, Button.m, ButtonPanel.m, CheckButton.m,
Entry.m, Form.m, Frame.m, Histo.m, InputWidget.m, Label.m,
Raster.m, Widget.m, XColormap.m: Tk.h changed to TkInterp.h.
@
text
@d36 1
a36 1
// the colourmap is a length MAXCOLORS array of PixelValues. We fill this array
d38 1
a38 1
- (PixelValue *)map
d44 1
a44 1
- (PixelValue)pixelValue: (Color)c
d51 1
a51 1
      return white;
d59 1
a59 1
- (BOOL)setColor: (Color)c ToName: (const char *)colorName
d82 1
a82 1
      map[c] = xc.pixel;
d89 4
a92 1
- (BOOL) setColor: (Color)c ToRed: (double)r Green: (double)g Blue: (double)b
d106 1
a106 1
- (BOOL)setColor: (Color)c ToGrey: (double)g
d113 1
a113 1
- (PixelValue)white
d118 1
a118 1
- (PixelValue)black
d124 1
a124 1
- (BOOL)colorIsSet: (Color)c
@


1.4
log
@Update copyright year.
@
text
@d8 1
a8 1
#import <Tk.h>
@


1.3
log
@* XPixmap.m ([XPixmap -setFile:]): Constify argument.
Reformatting throughout.

* XPixmap.h (XPixmap): Constify filename.
Constify argument to setFile.
Reformatting throughout.

* XColormap.m ([XColormap -setColor:ToName:]): Constify ToName
argument.  Reformatting throughout.

* XColormap.h: Constify ToName argument to setColor.
Reformatting throughout.

* Form.m ([Form -addLineName:Variable:Type:]): Constify first
argument.  Reformatting throughout.

* Form.h: Constify first argument to addLineName.
Reformatting throughout.

* CanvasItem.m: Reformatting throughout.

* CanvasItem.h (CanvasItem): Constify item.
Reformatting throughout.
@
text
@d1 1
a1 1
// Swarm library. Copyright (C) 1996-1997 Santa Fe Institute.
@


1.2
log
@Changed Copyright notice to include this year. --gepr
@
text
@d16 2
a17 1
-createEnd {
d19 1
a19 1

d22 9
a30 8
  tkwin = Tk_NameToWindow([globalTkInterp interp], ".",
			  [globalTkInterp mainWindow]);
  display = Tk_Display(tkwin);
  xwin = Tk_WindowId(tkwin);
  white = WhitePixel(display, DefaultScreen(display));
  black = BlackPixel(display, DefaultScreen(display));
  cmap = DefaultColormap(display, DefaultScreen(display));

d38 2
a39 1
-(PixelValue *) map {
d44 2
a45 1
-(PixelValue) pixelValue: (Color) c {
d48 5
a52 4
  else {
    [InvalidArgument raiseEvent: "attempted to access unset color %d\n", c];
    return white;
  }
d59 5
a63 13
-(BOOL) setColor: (Color) c ToName: (char *) colorName {
  if ([self colorIsSet: c]) {
    [InvalidArgument raiseEvent: "attempted to set color %d twice\n", c];
    return NO;
  } else {
    int rc;
    XColor xc, t;				  // ignore t
    
    isSet[c] = YES;
    rc = XAllocNamedColor(display, cmap, colorName, &xc, &t);
    if (rc == 0) {
      [ResourceAvailability raiseEvent: "Problem allocating color %s. Substituting white.\n", colorName];
      map[c] = white;
d66 19
a84 3
    map[c] = xc.pixel;
    return YES;
  }
d89 2
a90 1
-(BOOL) setColor: (Color) c ToRed: (double) r Green: (double) g Blue: (double) b {
d98 1
a98 1
  sprintf(colorName, "#%02x%02x%02x", ru, gu, bu);
d103 2
a104 1
-(BOOL) setColor: (Color) c ToGrey: (double) g {
d110 2
a111 1
-(PixelValue) white {
d115 2
a116 1
-(PixelValue) black {
d121 2
a122 1
-(BOOL) colorIsSet: (Color) c {
a124 1

@


1.1
log
@Initial revision
@
text
@d1 1
a1 1
// Swarm library. Copyright (C) 1996 Santa Fe Institute.
@


1.1.1.1
log
@Imported Swarm
@
text
@@
Results 1 - 1
Help - FTP Sites List - Software Dir.
Searching half a billion files worldwide
© 1997-2009 MARUHN Internet Solutions