This is TestControl.m in view mode; [Download] [Up]
// TestControl.m
//
// by Mike Ferris
// Part of MOKit
// Copyright 1993, all rights reserved.
// ABOUT MOKit
// by Mike Ferris (mike@lorax.com)
//
// MOKit is a collection of useful and general objects. Permission is
// granted by the author to use MOKit in your own programs in any way
// you see fit. All other rights pertaining to the kit are reserved by the
// author including the right to sell these objects as objects, as part
// of a LIBRARY, or as SOURCE CODE. In plain English, I wish to retain
// rights to these objects as objects, but allow the use of the objects
// as pieces in a fully functional program. Permission is also granted to
// redistribute the source code of MOKit for FREE as long as this copyright
// notice is left intact and unchanged. NO WARRANTY is expressed or implied.
// The author will under no circumstances be held responsible for ANY
// consequences from the use of these objects. Since you don't have to pay
// for them, and full source is provided, I think this is perfectly fair.
#import "TestControl.h"
#import "MOKit/MOMatrix.h"
@implementation TestControl
- appDidInit:sender
// Set up the matrix's
{
NXRect frm = {{10.0, 135.0}, {0.0, 0.0}};
NXRect frm2 = {{10.0, 335.0}, {0.0, 0.0}};
id cell;
NXSize ic = {4.0, 4.0};
int aMode;
// Chose one of the next four sections. Comment out the rest.
// **1** Test for Buttons (NX_HIGHLIGHTMODE)
/* cell = [mOfButton cellAt:0:0];
ic.width = 4.0;
ic.height = 4.0;
aMode = NX_HIGHLIGHTMODE;
*/
// **2** Test for Buttons (NX_RADIOMODE)
/* cell = [mOfRadio cellAt:0:0];
ic.width = 4.0;
ic.height = 4.0;
aMode = NX_RADIOMODE;
*/
// **3** Test for Buttons (NX_LISTMODE)
/* cell = [listMatrix cellAt:0:0];
ic.width = 0.0;
ic.height = 0.0;
aMode = NX_LISTMODE;
*/
// **4** Test for Editable TextFieldCells (NX_TRACKMODE)
cell = [[TextFieldCell allocFromZone:[self zone]] initTextCell:"Testing"];
[cell setTextGray:NX_BLACK];
[cell setBezeled:YES];
[cell setEditable:YES];
ic.width = 4.0;
ic.height = 4.0;
aMode = NX_TRACKMODE;
momatrix = [[MOMatrix allocFromZone:[self zone]] initFrame:&frm
mode:aMode prototype:cell numRows:0 numCols:0];
matrix = [[Matrix allocFromZone:[self zone]] initFrame:&frm2
mode:aMode prototype:cell numRows:0 numCols:0];
[momatrix setIntercell:&ic];
[matrix setIntercell:&ic];
[momatrix renewRows:5 cols:6];
[matrix renewRows:5 cols:6];
[momatrix sizeToCells];
[matrix sizeToCells];
[[window contentView] setAutodisplay:YES];
[[window contentView] addSubview:matrix];
[[window contentView] addSubview:momatrix];
[[window contentView] display];
return self;
}
- doColumnSize:sender
// Resize a column
{
const char *cStr = [columnForm stringValueAt:0];
const char *wStr = [widthForm stringValueAt:0];
if ((cStr) && (*cStr) && (wStr) && (*wStr)) {
int c = [columnForm intValueAt:0];
float w = [widthForm floatValueAt:0];
[momatrix setWidth:w ofCol:c];
[momatrix sizeToCells];
[[[momatrix superview] opaqueAncestor] display];
}
return self;
}
- doRowSize:sender
// Resize a row
{
const char *rStr = [rowForm stringValueAt:0];
const char *hStr = [heightForm stringValueAt:0];
if ((rStr) && (*rStr) && (hStr) && (*hStr)) {
int r = [rowForm intValueAt:0];
float h = [heightForm floatValueAt:0];
[momatrix setHeight:h ofRow:r];
[momatrix sizeToCells];
[[[momatrix superview] opaqueAncestor] display];
}
return self;
}
- doIntercell:sender
// Change cell spacing
{
const char *wStr = [intercellForm stringValueAt:0];
const char *hStr = [intercellForm stringValueAt:1];
if ((wStr) && (*wStr) && (hStr) && (*hStr)) {
NXSize aSize;
aSize.width = [intercellForm floatValueAt:0];
aSize.height = [intercellForm floatValueAt:1];
[momatrix setIntercell:&aSize];
[momatrix sizeToCells];
[matrix setIntercell:&aSize];
[matrix sizeToCells];
[[[momatrix superview] opaqueAncestor] display];
}
return self;
}
- doInsertRow:sender
{
const char *rStr = [insertRowForm stringValueAt:0];
if ((rStr) && (*rStr)) {
[momatrix insertRowAt:[insertRowForm intValueAt:0]];
[momatrix sizeToCells];
[matrix insertRowAt:[insertRowForm intValueAt:0]];
[matrix sizeToCells];
[[[momatrix superview] opaqueAncestor] display];
}
return self;
}
- doInsertCol:sender
{
const char *cStr = [insertColForm stringValueAt:0];
if ((cStr) && (*cStr)) {
[momatrix insertColAt:[insertColForm intValueAt:0]];
[momatrix sizeToCells];
[matrix insertColAt:[insertColForm intValueAt:0]];
[matrix sizeToCells];
[[[momatrix superview] opaqueAncestor] display];
}
return self;
}
- doRemoveRow:sender
{
const char *rStr = [removeRowForm stringValueAt:0];
if ((rStr) && (*rStr)) {
[momatrix removeRowAt:[removeRowForm intValueAt:0] andFree:YES];
[momatrix sizeToCells];
[matrix removeRowAt:[removeRowForm intValueAt:0] andFree:YES];
[matrix sizeToCells];
[[[momatrix superview] opaqueAncestor] display];
}
return self;
}
- doRemoveCol:sender
{
const char *cStr = [removeColForm stringValueAt:0];
if ((cStr) && (*cStr)) {
[momatrix removeColAt:[removeColForm intValueAt:0] andFree:YES];
[momatrix sizeToCells];
[matrix removeColAt:[removeColForm intValueAt:0] andFree:YES];
[matrix sizeToCells];
[[[momatrix superview] opaqueAncestor] display];
}
return self;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.