delete src/clivfasd and unused files in other dirs
* src/cldai contained ErrorMap.*, ErrorRpt.*, StrUtil.*, impconv.hh, and imptypes.hh - all are unused, and all are (C)opyright "all rights reserved" (!) * src/clutils contained unused files scldir.h, stat.h, str_list.h * src/clstepcore/scl_osschema.h is for OODB and isn't used * src/clivfasd contained modified versions of files from the InterViews GUI library (which is from the early 90's). These files do not compile, apparently because InterViews has changed since then. These files were only used by dataProbe, which is broken (due to InterViews) and needs rewritten without IV. * remove these files from */CMakeLists.txt
This commit is contained in:
1 parent
704a28abac
commit
a0353bcff2
70 files changed
-9367
No files matched your search
@@ -11,10 +11,6 @@ set(LIBSTEPDAI_SRCS
|
||||
)
|
||||
|
||||
SET(LIBSTEPDAI_PRIVATE_HDRS
|
||||
ErrorMap.hh
|
||||
ErrorRpt.hh
|
||||
impconv.hh
|
||||
imptypes.hh
|
||||
sdaiApplication_instance_set.h
|
||||
sdaiDaObject.h
|
||||
sdaiEntity_extent.h
|
||||
|
||||
@@ -1,247 +0,0 @@
|
||||
//
|
||||
// File: ErrorMap.cc
|
||||
//
|
||||
// Description: Definitions for members of class ErrorMap
|
||||
//
|
||||
// Rev: $Revision: 1.1 $
|
||||
// Created: $Date: 1998/01/09 21:39:30 $
|
||||
// Author: $Author: sauderd $
|
||||
//
|
||||
// Copyright Industrial Technology Institute 1997 -- All Rights Reserved
|
||||
//
|
||||
|
||||
#include <sdai.h>
|
||||
#include "ErrorMap.hh"
|
||||
|
||||
char * ErrorMap::ServerErrorText[] = {
|
||||
"Server Error: no error",
|
||||
"Server Error: out of dynamic memory",
|
||||
"Server Error: type conversion error",
|
||||
"Server Error: event time format error",
|
||||
"Server Error: bad pointer to transaction encountered",
|
||||
"Server Error: bad pointer to database encountered",
|
||||
"Server Error: bad pointer to session encountered",
|
||||
"Server Error: bad pointer to repository contents encountered",
|
||||
"Server Error: bad pointer to repository encountered",
|
||||
"Server Error: bad pointer to set of repositories encountered",
|
||||
"Server Error: bad pointer to set of models encountered",
|
||||
"Server Error: bad pointer to model encountered",
|
||||
"Server Error: bad pointer to PID encountered",
|
||||
"Server Error: bad pointer to set of schema instances encountered",
|
||||
"Server Error: bad pointer to set of sessions encountered",
|
||||
"Server Error: bad pointer encountered",
|
||||
"Server Error: Unknown repository type",
|
||||
"Server Error: ObjectStore error",
|
||||
"Server Error: Unknown error"
|
||||
};
|
||||
|
||||
char * ErrorMap::SdaiErrorText[] = {
|
||||
"SDAI Error: (sdaiNO_ERR) No error",
|
||||
"SDAI Error: (sdaiSS_OPN) Session is already open",
|
||||
"SDAI Error: (sdaiSS_NAVL) Session is not available",
|
||||
"SDAI Error: (sdaiSS_NOPN) Session is not open",
|
||||
"SDAI Error: (sdaiRP_NEXS) Repository does not exist",
|
||||
"SDAI Error: (sdaiRP_NAVL) Repository not available",
|
||||
"SDAI Error: (sdaiRP_OPN) Repository already opened",
|
||||
"SDAI Error: (sdaiRP_NOPN) Repository is not open",
|
||||
"SDAI Error: (sdaiTR_EAB) Transaction ended abnormally so it no longer exists",
|
||||
"SDAI Error: (sdaiTR_EXS) Transaction already exists",
|
||||
"SDAI Error: (sdaiTR_NAVL) Transaction not available",
|
||||
"SDAI Error: (sdaiTR_RW) Transaction read-write",
|
||||
"SDAI Error: (sdaiTR_NRW) Transaction not read-write",
|
||||
"SDAI Error: (sdaiTR_NEXS) Transaction does not exist",
|
||||
"SDAI Error: (sdaiMO_NDEQ) SDAI-model not domain-equivalent ",
|
||||
"SDAI Error: (sdaiMO_NEXS) SDAI-model does not exist",
|
||||
"SDAI Error: (sdaiMO_NVLD) SDAI-model invalid",
|
||||
"SDAI Error: (sdaiMO_DUP) SDAI-model duplicate",
|
||||
"SDAI Error: (sdaiMX_NRW) SDAI-model access not read-write",
|
||||
"SDAI Error: (sdaiMX_NDEF) SDAI-model access is not defined",
|
||||
"SDAI Error: (sdaiMX_RW) SDAI-model access read-write",
|
||||
"SDAI Error: (sdaiMX_RO) SDAI-model access read-only",
|
||||
"SDAI Error: (sdaiSD_NDEF) Schema definition is not defined",
|
||||
"SDAI Error: (sdaiED_NDEF) Entity definition not defined",
|
||||
"SDAI Error: (sdaiED_NDEQ) Entity definition not domain equivalent",
|
||||
"SDAI Error: (sdaiED_NVLD) Entity definition invalid",
|
||||
"SDAI Error: (sdaiRU_NDEF) Rule not defined ",
|
||||
"SDAI Error: (sdaiEX_NSUP) Expression evaluation not supported ",
|
||||
"SDAI Error: (sdaiAT_NVLD) Attribute invalid",
|
||||
"SDAI Error: (sdaiAT_NDEF) Attribute not defined",
|
||||
"SDAI Error: (sdaiSI_DUP) Schema instance duplicate",
|
||||
"SDAI Error: (sdaiSI_NEXS) Schema instance does not exist",
|
||||
"SDAI Error: (sdaiEI_NEXS) Entity instance does not exist ",
|
||||
"SDAI Error: (sdaiEI_NAVL) Entity instance not available",
|
||||
"SDAI Error: (sdaiEI_NVLD) Entity instance invalid",
|
||||
"SDAI Error: (sdaiEI_NEXP) Entity instance not exported",
|
||||
"SDAI Error: (sdaiSC_NEXS) Scope does not exist ",
|
||||
"SDAI Error: (sdaiSC_EXS) Scope exists ",
|
||||
"SDAI Error: (sdaiAI_NEXS) Aggregate instance does not exist ",
|
||||
"SDAI Error: (sdaiAI_NVLD) Aggregate instance invalid ",
|
||||
"SDAI Error: (sdaiAI_NSET) Aggregate instance is empty ",
|
||||
"SDAI Error: (sdaiVA_NVLD) Value invalid",
|
||||
"SDAI Error: (sdaiVA_NEXS) Value does not exist",
|
||||
"SDAI Error: (sdaiVA_NSET) Value not set ",
|
||||
"SDAI Error: (sdaiVT_NVLD) Value type invalid",
|
||||
"SDAI Error: (sdaiIR_NEXS) Iterator does not exist ",
|
||||
"SDAI Error: (sdaiIR_NSET) Current member is not defined",
|
||||
"SDAI Error: (sdaiIX_NVLD) Index invalid",
|
||||
"SDAI Error: (sdaiER_NSET) Event recording not set",
|
||||
"SDAI Error: (sdaiOP_NVLD) Operator invalid ",
|
||||
"SDAI Error: (sdaiFN_NAVL) Function not available",
|
||||
"SDAI Error: (sdaiSY_ERR) Underlying system error "
|
||||
};
|
||||
|
||||
//
|
||||
// Return the error code of the error reported to the client
|
||||
//
|
||||
long ErrorMap::serverErrorCode( ServerError_id error_id ) {
|
||||
switch( error_id ) {
|
||||
case serverNoError:
|
||||
return ( long ) SCLP22( sdaiNO_ERR );
|
||||
case serverNoMemoryError:
|
||||
return ( long ) SCLP22( sdaiSY_ERR );
|
||||
case serverTimeFormatError:
|
||||
return ( long ) SCLP22( sdaiSY_ERR );
|
||||
case serverUnknownError:
|
||||
return ( long ) SCLP22( sdaiSY_ERR );
|
||||
default:
|
||||
return ( long ) SCLP22( sdaiSY_ERR );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Return a pointer to the string describing the server error
|
||||
//
|
||||
char * ErrorMap::serverErrorDescription( ServerError_id error_id ) {
|
||||
if( error_id >= serverNoError && error_id <= serverUnknownError ) {
|
||||
return ServerErrorText[error_id];
|
||||
} else {
|
||||
return ServerErrorText[serverUnknownError];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Return the error code of the error reported to the client
|
||||
//
|
||||
long ErrorMap::sdaiErrorCode( SCLP23( Error_id ) error_id ) {
|
||||
switch( error_id ) {
|
||||
case SCLP23( sdaiNO_ERR ):
|
||||
return SCLP22( sdaiNO_ERR );
|
||||
case SCLP23( sdaiSS_OPN ):
|
||||
return SCLP22( sdaiSS_OPN );
|
||||
case SCLP23( sdaiSS_NAVL ):
|
||||
return SCLP22( sdaiSS_NAVL );
|
||||
case SCLP23( sdaiSS_NOPN ):
|
||||
return SCLP22( sdaiSS_NOPN );
|
||||
case SCLP23( sdaiRP_NEXS ):
|
||||
return SCLP22( sdaiRP_NEXS );
|
||||
case SCLP23( sdaiRP_NAVL ):
|
||||
return SCLP22( sdaiRP_NAVL );
|
||||
case SCLP23( sdaiRP_OPN ):
|
||||
return SCLP22( sdaiRP_OPN );
|
||||
case SCLP23( sdaiRP_NOPN ):
|
||||
return SCLP22( sdaiRP_NOPN );
|
||||
case SCLP23( sdaiTR_EAB ):
|
||||
return SCLP22( sdaiTR_EAB );
|
||||
case SCLP23( sdaiTR_EXS ):
|
||||
return SCLP22( sdaiTR_EXS );
|
||||
case SCLP23( sdaiTR_NAVL ):
|
||||
return SCLP22( sdaiTR_NAVL );
|
||||
case SCLP23( sdaiTR_RW ):
|
||||
return SCLP22( sdaiTR_RW );
|
||||
case SCLP23( sdaiTR_NRW ):
|
||||
return SCLP22( sdaiTR_NRW );
|
||||
case SCLP23( sdaiTR_NEXS ):
|
||||
return SCLP22( sdaiTR_NEXS );
|
||||
case SCLP23( sdaiMO_NDEQ ):
|
||||
return SCLP22( sdaiMO_NDEQ );
|
||||
case SCLP23( sdaiMO_NEXS ):
|
||||
return SCLP22( sdaiMO_NEXS );
|
||||
case SCLP23( sdaiMO_NVLD ):
|
||||
return SCLP22( sdaiMO_NVLD );
|
||||
case SCLP23( sdaiMO_DUP ):
|
||||
return SCLP22( sdaiMO_DUP );
|
||||
case SCLP23( sdaiMX_NRW ):
|
||||
return SCLP22( sdaiMX_NRW );
|
||||
case SCLP23( sdaiMX_NDEF ):
|
||||
return SCLP22( sdaiMX_NDEF );
|
||||
case SCLP23( sdaiMX_RW ):
|
||||
return SCLP22( sdaiMX_RW );
|
||||
case SCLP23( sdaiMX_RO ):
|
||||
return SCLP22( sdaiMX_RO );
|
||||
case SCLP23( sdaiSD_NDEF ):
|
||||
return SCLP22( sdaiSD_NDEF );
|
||||
case SCLP23( sdaiED_NDEF ):
|
||||
return SCLP22( sdaiED_NDEF );
|
||||
case SCLP23( sdaiED_NDEQ ):
|
||||
return SCLP22( sdaiED_NDEQ );
|
||||
case SCLP23( sdaiED_NVLD ):
|
||||
return SCLP22( sdaiED_NVLD );
|
||||
case SCLP23( sdaiRU_NDEF ):
|
||||
return SCLP22( sdaiRU_NDEF );
|
||||
case SCLP23( sdaiEX_NSUP ):
|
||||
return SCLP22( sdaiEX_NSUP );
|
||||
case SCLP23( sdaiAT_NVLD ):
|
||||
return SCLP22( sdaiAT_NVLD );
|
||||
case SCLP23( sdaiAT_NDEF ):
|
||||
return SCLP22( sdaiAT_NDEF );
|
||||
case SCLP23( sdaiSI_DUP ):
|
||||
return SCLP22( sdaiSI_DUP );
|
||||
case SCLP23( sdaiSI_NEXS ):
|
||||
return SCLP22( sdaiSI_NEXS );
|
||||
case SCLP23( sdaiEI_NEXS ):
|
||||
return SCLP22( sdaiEI_NEXS );
|
||||
case SCLP23( sdaiEI_NAVL ):
|
||||
return SCLP22( sdaiEI_NAVL );
|
||||
case SCLP23( sdaiEI_NVLD ):
|
||||
return SCLP22( sdaiEI_NVLD );
|
||||
case SCLP23( sdaiEI_NEXP ):
|
||||
return SCLP22( sdaiEI_NEXP );
|
||||
case SCLP23( sdaiSC_NEXS ):
|
||||
return SCLP22( sdaiSC_NEXS );
|
||||
case SCLP23( sdaiSC_EXS ):
|
||||
return SCLP22( sdaiSC_EXS );
|
||||
case SCLP23( sdaiAI_NEXS ):
|
||||
return SCLP22( sdaiAI_NEXS );
|
||||
case SCLP23( sdaiAI_NVLD ):
|
||||
return SCLP22( sdaiAI_NVLD );
|
||||
case SCLP23( sdaiAI_NSET ):
|
||||
return SCLP22( sdaiAI_NSET );
|
||||
case SCLP23( sdaiVA_NVLD ):
|
||||
return SCLP22( sdaiVA_NVLD );
|
||||
case SCLP23( sdaiVA_NEXS ):
|
||||
return SCLP22( sdaiVA_NEXS );
|
||||
case SCLP23( sdaiVA_NSET ):
|
||||
return SCLP22( sdaiVA_NSET );
|
||||
case SCLP23( sdaiVT_NVLD ):
|
||||
return SCLP22( sdaiVT_NVLD );
|
||||
case SCLP23( sdaiIR_NEXS ):
|
||||
return SCLP22( sdaiIR_NEXS );
|
||||
case SCLP23( sdaiIR_NSET ):
|
||||
return SCLP22( sdaiIR_NSET );
|
||||
case SCLP23( sdaiIX_NVLD ):
|
||||
return SCLP22( sdaiIX_NVLD );
|
||||
case SCLP23( sdaiER_NSET ):
|
||||
return SCLP22( sdaiER_NSET );
|
||||
case SCLP23( sdaiOP_NVLD ):
|
||||
return SCLP22( sdaiOP_NVLD );
|
||||
case SCLP23( sdaiFN_NAVL ):
|
||||
return SCLP22( sdaiFN_NAVL );
|
||||
case SCLP23( sdaiSY_ERR ):
|
||||
return SCLP22( sdaiSY_ERR );
|
||||
default:
|
||||
return SCLP22( sdaiSY_ERR );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Return a pointer to the string describing the SDAI error
|
||||
//
|
||||
// It uses the fact the Part23 error codes are multiples of 10.
|
||||
//
|
||||
char * ErrorMap::sdaiErrorDescription( SCLP23( Error_id ) error_id ) {
|
||||
if( error_id >= SCLP23( sdaiNO_ERR ) && error_id <= SCLP23( sdaiSY_ERR ) ) {
|
||||
return SdaiErrorText[( int ) error_id / 10];
|
||||
} else {
|
||||
return SdaiErrorText[( ( int ) SCLP23( sdaiSY_ERR ) ) / 10];
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
//
|
||||
// File: ErrorMap.hh
|
||||
//
|
||||
// Description: Declaration of class ErrorMap. ErrorMap is used to
|
||||
// map internal server errors, which include Part 23
|
||||
// binding errors, into Part26 binding errors and error
|
||||
// description strings.
|
||||
//
|
||||
// Rev: $Revision: 1.1 $
|
||||
// Created: $Date: 1998/01/09 21:39:30 $
|
||||
// Author: $Author: sauderd $
|
||||
//
|
||||
// Copyright Industrial Technology Institute 1997 -- All Rights Reserved
|
||||
//
|
||||
|
||||
#ifndef ERRORMAP_HH
|
||||
#define ERRORMAP_HH
|
||||
|
||||
#include <sdai.h>
|
||||
|
||||
enum ServerError_id
|
||||
{
|
||||
serverNoError = 0,
|
||||
serverNoMemoryError = 1,
|
||||
serverTypeConversionError = 2,
|
||||
serverTimeFormatError = 3,
|
||||
serverBadTransactionPointer = 4,
|
||||
serverBadDatabasePointer = 5,
|
||||
serverBadSessionPointer = 6,
|
||||
serverBadRepositoryContentsPointer = 7,
|
||||
serverBadRepositoryPointer = 8,
|
||||
serverBadRepositorySetPointer = 9,
|
||||
serverBadModelSetPointer = 10,
|
||||
serverBadModelPointer = 11,
|
||||
serverBadPIDPointer = 12,
|
||||
serverBadSchemaSetPointer = 13,
|
||||
serverBadSessionSetPointer = 14,
|
||||
serverBadPointer = 15,
|
||||
serverUnknownRepoType = 16,
|
||||
serverObjectStoreError = 17,
|
||||
serverUnknownError = 18
|
||||
};
|
||||
|
||||
class ErrorMap
|
||||
{
|
||||
public:
|
||||
|
||||
static long serverErrorCode(ServerError_id);
|
||||
static char * serverErrorDescription(ServerError_id);
|
||||
|
||||
static long sdaiErrorCode(SCLP23(Error_id));
|
||||
static char * sdaiErrorDescription(SCLP23(Error_id));
|
||||
|
||||
private:
|
||||
|
||||
static char * ServerErrorText[];
|
||||
static char * SdaiErrorText[];
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,128 +0,0 @@
|
||||
//
|
||||
// File: ErrorRpt.cc
|
||||
//
|
||||
// Description: Implementation of global error reporting functions
|
||||
//
|
||||
// Rev: $Revision: 1.1 $
|
||||
// Created: $Date: 1998/01/09 21:39:30 $
|
||||
// Author: $Author: sauderd $
|
||||
//
|
||||
// Copyright Industrial Technology Institute 1997 -- All Rights Reserved
|
||||
//
|
||||
|
||||
#include <iostream.h>
|
||||
|
||||
#include <sdai.h>
|
||||
|
||||
//#include "sdaiimp.hh"
|
||||
#include "ErrorMap.hh"
|
||||
#include "ErrorRpt.hh"
|
||||
//#include "SessionMgr.hh"
|
||||
|
||||
//extern SessionManager SessionMgr;
|
||||
|
||||
//
|
||||
// Report a server error
|
||||
//
|
||||
// A server error is any error that is not an SDAI error
|
||||
//
|
||||
// The error is mapped into a Part 26 SDAI error.
|
||||
//
|
||||
void reportServerError( ServerError_id error_id ) {
|
||||
long error_code = 0;
|
||||
/*
|
||||
SCLP23(Session_ptr) session = SessionMgr.active_session_();
|
||||
|
||||
|
||||
if (session != SCLP23(Session)::_nil())
|
||||
{
|
||||
char * function_id = SessionMgr.function_id_();
|
||||
|
||||
error_code = ErrorMap::serverErrorCode(error_id);
|
||||
|
||||
char * description = ErrorMap::serverErrorDescription(error_id);
|
||||
|
||||
session->recordError(function_id, error_code, description);
|
||||
}
|
||||
else // there is no active session for this user
|
||||
{
|
||||
error_code = ErrorMap::sdaiErrorCode(SCLP23(sdaiSS_NOPN));
|
||||
}
|
||||
|
||||
*/
|
||||
throw SCLP22( SDAIException )( error_code );
|
||||
}
|
||||
|
||||
//
|
||||
// Report an ObjectStore error
|
||||
//
|
||||
// The error is mapped into a Part 26 SDAI error.
|
||||
//
|
||||
void reportObjectStoreError( const char * message ) {
|
||||
long error_code = 0;
|
||||
|
||||
/*
|
||||
SCLP23(Session_ptr) session = SessionMgr.active_session_();
|
||||
|
||||
long error_code;
|
||||
|
||||
if (session != SCLP23(Session)::_nil())
|
||||
{
|
||||
char * function_id = SessionMgr.function_id_();
|
||||
|
||||
error_code = ErrorMap::serverErrorCode(serverObjectStoreError);
|
||||
|
||||
char * header = "ObjectStore Error: ";
|
||||
|
||||
char * description = new char [strlen(header)+ strlen(message)+1];
|
||||
|
||||
if (description != NULL)
|
||||
{
|
||||
sprintf(description, "%s%s", header, message);
|
||||
session->recordError(function_id, error_code, description);
|
||||
}
|
||||
else
|
||||
{
|
||||
reportServerError(serverNoMemoryError);
|
||||
}
|
||||
}
|
||||
else // there is no active session for this user
|
||||
{
|
||||
error_code = ErrorMap::sdaiErrorCode(SCLP23(sdaiSS_NOPN));
|
||||
}
|
||||
*/
|
||||
throw SCLP22( SDAIException )( error_code );
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Report an SDAI error
|
||||
//
|
||||
// Part 23 binding errors are mapped into Part 26 binding errors
|
||||
//
|
||||
void reportSDAIError( SCLP23( Error_id ) error_id ) {
|
||||
long error_code = 0;
|
||||
/*
|
||||
SCLP23(Session_ptr) session = SessionMgr.active_session_();
|
||||
|
||||
long error_code;
|
||||
|
||||
if (session != SCLP23(Session)::_nil())
|
||||
{
|
||||
char * function_id = SessionMgr.function_id_();
|
||||
|
||||
error_code = ErrorMap::sdaiErrorCode(error_id);
|
||||
|
||||
char * description = ErrorMap::sdaiErrorDescription(error_id);
|
||||
|
||||
cout << "Error description: " << description << endl;
|
||||
|
||||
session->recordError(function_id, error_code, description);
|
||||
}
|
||||
else // there is no active session for this user
|
||||
{
|
||||
error_code = ErrorMap::sdaiErrorCode(SCLP23(sdaiSS_NOPN));
|
||||
}
|
||||
*/
|
||||
throw SCLP22( SDAIException )( error_code );
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// File: ErrorRpt.hh
|
||||
//
|
||||
// Description: Declaration of global error reporting functions
|
||||
//
|
||||
// Rev: $Revision: 1.1 $
|
||||
// Created: $Date: 1998/01/09 21:39:30 $
|
||||
// Author: $Author: sauderd $
|
||||
//
|
||||
// Copyright Industrial Technology Institute 1997 -- All Rights Reserved
|
||||
//
|
||||
|
||||
#ifndef ERRORRPT_HH
|
||||
#define ERRORRPT_HH
|
||||
|
||||
#include <sdai.h>
|
||||
#include "ErrorMap.hh"
|
||||
|
||||
void reportServerError(ServerError_id error_id);
|
||||
|
||||
void reportObjectStoreError(const char * message);
|
||||
|
||||
void reportSDAIError(SCLP23(Error_id) error_id);
|
||||
|
||||
#endif
|
||||
@@ -1,90 +0,0 @@
|
||||
//
|
||||
// File: StrUtil.cc
|
||||
//
|
||||
// Description: Implementation of string utility functions
|
||||
//
|
||||
// Rev: $Revision: 1.1 $
|
||||
// Created: $Date: 1998/01/09 21:39:30 $
|
||||
// Author: $Author: sauderd $
|
||||
//
|
||||
// Copyright Industrial Technology Institute 1997 -- All Rights Reserved
|
||||
//
|
||||
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
#include "StrUtil.hh"
|
||||
//#include "imppackages.hh"
|
||||
#include "ErrorRpt.hh"
|
||||
|
||||
|
||||
//
|
||||
// Duplicate a string
|
||||
//
|
||||
// Returns a pointer to a new string that is a duplicate of the string
|
||||
// pointed to by srcStr. If the destination string pointer is not NULL,
|
||||
// the memory the destination string points to is deallocated using delete().
|
||||
// The space for the new string is obtained using ::new(). If the new string
|
||||
// cannot be created, a null pointer is returned.
|
||||
//
|
||||
char * strDup( char * destStr, const char * srcStr ) {
|
||||
if( destStr != NULL ) {
|
||||
delete [] destStr;
|
||||
|
||||
destStr = NULL;
|
||||
}
|
||||
|
||||
if( srcStr != NULL ) {
|
||||
destStr = new char[strlen( srcStr ) + 1];
|
||||
|
||||
if( destStr != NULL ) {
|
||||
strcpy( destStr, srcStr );
|
||||
} else {
|
||||
reportServerError( serverNoMemoryError );
|
||||
}
|
||||
}
|
||||
|
||||
return destStr;
|
||||
}
|
||||
|
||||
//
|
||||
// Free the memory allocated to a string
|
||||
//
|
||||
void strFree( char * str ) {
|
||||
if( str != NULL ) {
|
||||
delete [] str;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Return the current date and time as a string
|
||||
//
|
||||
// It is the caller's responsibility to deallocate the memory for the string.
|
||||
//
|
||||
char * getCurrentDate( void ) {
|
||||
// need to get format of time stamp from ISO 8601
|
||||
|
||||
#define TIME_STR_LEN 256
|
||||
|
||||
char * timeStr = NULL;
|
||||
char time_buf[TIME_STR_LEN];
|
||||
char * time_format = NULL; // use default locale format for now
|
||||
struct timeval time_of_day;
|
||||
struct tm * time_struct;
|
||||
|
||||
( void ) gettimeofday( &time_of_day, ( void * ) NULL );
|
||||
|
||||
time_struct = localtime( &( time_of_day.tv_sec ) );
|
||||
|
||||
int length = strftime( time_buf, TIME_STR_LEN, time_format , time_struct );
|
||||
|
||||
if( length > 0 ) {
|
||||
timeStr = strDup( timeStr, time_buf );
|
||||
} else {
|
||||
reportServerError( serverTimeFormatError );
|
||||
}
|
||||
|
||||
return timeStr;
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
//
|
||||
// File: StrUtil.hh
|
||||
//
|
||||
// Description: Declaration of string utility functions.
|
||||
//
|
||||
// Rev: $Revision: 1.1 $
|
||||
// Created: $Date: 1998/01/09 21:39:30 $
|
||||
// Author: $Author: sauderd $
|
||||
//
|
||||
// Copyright Industrial Technology Institute 1997 -- All Rights Reserved
|
||||
//
|
||||
|
||||
#ifndef STRUTIL_HH
|
||||
#define STRUTIL_HH
|
||||
|
||||
//
|
||||
// Returns a pointer to a new string that is a duplicate of the string
|
||||
// pointed to by srcStr. If the destination string pointer is not NULL,
|
||||
// the memory the destination string points to is deallocated using delete().
|
||||
// The space for the new string is obtained using ::new(). If the new string
|
||||
// cannot be created, a null pointer is returned.
|
||||
//
|
||||
char * strDup(char *destStr, const char *srcStr);
|
||||
|
||||
//
|
||||
// Free the memory allocated for the given string
|
||||
//
|
||||
void strFree(char * str);
|
||||
|
||||
//
|
||||
// Get the current date, caller has the responsibility to deallocate
|
||||
// the returned string.
|
||||
//
|
||||
char * getCurrentDate(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,218 +0,0 @@
|
||||
//
|
||||
// File: impconv.hh
|
||||
//
|
||||
// Description: Macro definitions for type conversions between interface
|
||||
// and implementation types.
|
||||
//
|
||||
// Rev: $Revision: 1.3 $
|
||||
// Created: $Date: 1998/01/13 20:24:39 $
|
||||
// Author: $Author: sauderd $
|
||||
//
|
||||
// Copyright Industrial Technology Institute 1997 -- All Rights Reserved
|
||||
//
|
||||
#ifndef IMPCONV_HH
|
||||
#define IMPCONV_HH
|
||||
|
||||
#include <sdai.h>
|
||||
|
||||
|
||||
#ifdef PART26
|
||||
|
||||
#define P22toP23Ptr(T, X, Y) \
|
||||
SCLP23(T) * Y; \
|
||||
{ \
|
||||
if ((X)) \
|
||||
{ \
|
||||
Y = (SCLP23(T) *) DEREF((X)); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
Y = SCLP23(T)::_nil(); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define P23toP22Ptr(T, X, Y) \
|
||||
SCLP22(T) * Y; \
|
||||
{ \
|
||||
if ((X)) \
|
||||
{ \
|
||||
Y = SCLP22(T)::_duplicate(SCLP22(T)::_narrow((X)->tie_())); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
Y = SCLP22(T)::_nil(); \
|
||||
} \
|
||||
}
|
||||
|
||||
/////////////////////////
|
||||
#define myP23toP22Ptr(T, X, Y) \
|
||||
SCLP22(T) * Y; \
|
||||
{ \
|
||||
if ((X)) \
|
||||
{ \
|
||||
Y = SCLP22(T)::_duplicate(SCLP22(T)::_narrow((X)->tie_())); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
Y = SCLP22(T)::_nil(); \
|
||||
} \
|
||||
}
|
||||
#if 0
|
||||
if(X /*_containing_machine*/ != 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
const char *hostName = CORBA_REF(Orbix).myHost();
|
||||
char markerServer[64];
|
||||
sprintf(markerServer, "%d:%s", X /*_containing_machine*/->STEPfile_id, serverName);
|
||||
|
||||
cout << "*****" << markerServer << endl;
|
||||
|
||||
Machine_var x = Machine::_bind((const char *)markerServer,hostName);
|
||||
Machine::_duplicate(x);
|
||||
|
||||
cout << endl << "x->_refCount(): " << x->_refCount();
|
||||
cout << endl << "STEPfile id inside _containing_machine's get function is: "
|
||||
<< _containing_machine->STEPfile_id << endl;
|
||||
cout << "x's marker name in server's implementation object's attr _containing_machine's get function is: '"
|
||||
<< x->_marker() << "'" << endl << endl;
|
||||
return x;
|
||||
}
|
||||
catch (CORBA::SystemException &se) {
|
||||
cerr << "Unexpected system exception in _containing_machine's get funct: " << &se;
|
||||
throw;
|
||||
}
|
||||
catch(...) {
|
||||
cerr << "Caught Unknown Exception in _containing_machine's get funct!" << endl;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
cout << "nil object ref in attr _containing_machine's put funct" << endl;
|
||||
return Machine::_nil();
|
||||
/////////////////////////
|
||||
#endif
|
||||
|
||||
//
|
||||
// Convert a Part 22 (interface) set into a Part 23 (implementation) set
|
||||
//
|
||||
// Note: this macro cannot be used with nested collections.
|
||||
//
|
||||
// T is the type of the elements in the set. The straight name of the
|
||||
// type must be given, i.e., Repository instead of SCLP23(Repository).
|
||||
//
|
||||
// X is a variable (not a pointer to) of interface (Part 22) set type
|
||||
// object. It must be declared before invoking this macro.
|
||||
//
|
||||
// Y is a variable of the implementation (Part 23) set type. It is
|
||||
// declared inside this macro.
|
||||
//
|
||||
#define P22toP23Set(T, X, Y) \
|
||||
SCLP23(T##__set) Y; \
|
||||
{ \
|
||||
long length = (X).length(); \
|
||||
\
|
||||
for (long i = 0; i < length_; ++i) \
|
||||
{ \
|
||||
SCLP23(T) * x_el = (SCLP23(T) *) DEREF((&X)[i]); \
|
||||
\
|
||||
if (y_el != (SCLP22(T) *) NULL) \
|
||||
{ \
|
||||
Y.insert(y_el); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
reportServerError(serverTypeConversionError); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
//
|
||||
// Convert a Part 22 (interface) list into a Part 23 (implementation) list
|
||||
//
|
||||
// Note: this macro cannot be used with nested collections.
|
||||
//
|
||||
// T is the type of the elements in the list. The straight name of the
|
||||
// type must be given, i.e., Repository instead of SCLP23(Repository).
|
||||
//
|
||||
// X is a variable (not a pointer to) of interface (Part 22) list type
|
||||
// object. It must be declared before invoking this macro.
|
||||
//
|
||||
// Y is a variable of the implementation (Part 23) set type. It is
|
||||
// declared inside this macro.
|
||||
//
|
||||
#define P22toP23List(T, X, Y) \
|
||||
SCLP23(T##__list) Y; \
|
||||
{ \
|
||||
long length = (X).length(); \
|
||||
\
|
||||
for (long i = 0; i < length_; ++i) \
|
||||
{ \
|
||||
SCLP23(T) * x_el = (SCLP23(T) *) DEREF((&X)[i]); \
|
||||
\
|
||||
if (y_el != (SCLP22(T) *) NULL) \
|
||||
{ \
|
||||
Y.insert(y_el); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
reportServerError(serverTypeConversionError); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define P23toP22Set(T, X, Y) \
|
||||
SCLP22(T##__set) * Y = new SCLP22(T##__set); \
|
||||
{ \
|
||||
/* long length = (X)->cardinality(); */\
|
||||
/* os_Cursor<SCLP23(T) *> c(*(X)); */\
|
||||
long length = (X)->_rep.cardinality(); \
|
||||
\
|
||||
Y->length(length); \
|
||||
int i = 0; \
|
||||
\
|
||||
/* for (SCLP23(T) * x_el = c.first(); c.more(); x_el = c.next())*/ \
|
||||
for (SCLP23(T) * x_el = X->first(); X->more(); x_el = X->next()) \
|
||||
{ \
|
||||
SCLP22(T) * y_el = SCLP22(T)::_narrow(x_el->tie_()); \
|
||||
if (y_el != (SCLP22(T) *) NULL) \
|
||||
{ \
|
||||
(*Y)[i++] = y_el; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
reportServerError(serverTypeConversionError); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define P23toP22List(T, X, Y) \
|
||||
SCLP22(T##__list) * Y = new SCLP22(T##__list); \
|
||||
{ \
|
||||
long length = (X)->_rep.cardinality(); \
|
||||
/* long length = (X)->cardinality();*/ \
|
||||
/* os_Cursor<SCLP23(T) *> c(*(X));*/ \
|
||||
\
|
||||
Y->length(length); \
|
||||
int i = 0; \
|
||||
\
|
||||
/* for (SCLP23(T) * x_el = c.first(); c.more(); x_el = c.next()) */\
|
||||
for (SCLP23(T) * x_el = (X)->first(); (X)->more(); x_el = (X)->next()) \
|
||||
{ \
|
||||
SCLP22(T) * y_el = SCLP22(T)::_narrow(x_el->tie_()); \
|
||||
if (y_el != (SCLP22(T) *) NULL) \
|
||||
{ \
|
||||
(*Y)[i++] = y_el; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
reportServerError(serverTypeConversionError); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#endif // PART26
|
||||
|
||||
#endif // IMPCONV_HH
|
||||
@@ -1,91 +0,0 @@
|
||||
//
|
||||
// File: imptypes.hh
|
||||
//
|
||||
// Description: Type definitions for SDAI implementation classes
|
||||
//
|
||||
// This software was developed by NIST and the Industrial Technology Institute
|
||||
//
|
||||
|
||||
// NOTE: This header file will be included within a namespace. Do not
|
||||
// #include any headers that contain class declarations or functions
|
||||
// you don't want included in the namespace.
|
||||
// You should probably only #include sdai.h which #includes this one
|
||||
//
|
||||
|
||||
#ifndef IMPTYPES_HH
|
||||
#define IMPTYPES_HH
|
||||
|
||||
class SCLP23_NAME(Object);
|
||||
typedef SCLP23_NAME(Object)* SCLP23_NAME(Object_ptr);
|
||||
typedef SCLP23_NAME(Object_ptr) SCLP23_NAME(Object_var);
|
||||
|
||||
class SCLP23_NAME(Session_instance);
|
||||
typedef SCLP23_NAME(Session_instance)* SCLP23_NAME(Session_instance_ptr);
|
||||
typedef SCLP23_NAME(Session_instance_ptr) SCLP23_NAME(Session_instance_var);
|
||||
|
||||
typedef char * SCLP23_NAME(DAObjectID);
|
||||
|
||||
class SCLP23_NAME(PID);
|
||||
typedef SCLP23_NAME(PID)* SCLP23_NAME(PID_ptr);
|
||||
typedef SCLP23_NAME(PID_ptr) SCLP23_NAME(PID_var);
|
||||
|
||||
class SCLP23_NAME(PID_DA);
|
||||
typedef SCLP23_NAME(PID_DA)* SCLP23_NAME(PID_DA_ptr);
|
||||
typedef SCLP23_NAME(PID_DA_ptr) SCLP23_NAME(PID_DA_var);
|
||||
|
||||
class SCLP23_NAME(PID_SDAI);
|
||||
typedef SCLP23_NAME(PID_SDAI)* SCLP23_NAME(PID_SDAI_ptr);
|
||||
typedef SCLP23_NAME(PID_SDAI_ptr) SCLP23_NAME(PID_SDAI_var);
|
||||
|
||||
class SCLP23_NAME(DAObject);
|
||||
typedef SCLP23_NAME(DAObject)* SCLP23_NAME(DAObject_ptr);
|
||||
typedef SCLP23_NAME(DAObject_ptr) SCLP23_NAME(DAObject_var);
|
||||
|
||||
class SCLP23_NAME(DAObject__set);
|
||||
typedef SCLP23_NAME(DAObject__set)* SCLP23_NAME(DAObject__set_ptr);
|
||||
typedef SCLP23_NAME(DAObject__set_ptr) SCLP23_NAME(DAObject__set_var);
|
||||
|
||||
class SCLP23_NAME(DAObject_SDAI);
|
||||
typedef SCLP23_NAME(DAObject_SDAI)* SCLP23_NAME(DAObject_SDAI_ptr);
|
||||
typedef SCLP23_NAME(DAObject_SDAI_ptr) SCLP23_NAME(DAObject_SDAI_var);
|
||||
|
||||
class SCLP23_NAME(Model_contents_instances);
|
||||
typedef SCLP23_NAME(Model_contents_instances) *
|
||||
SCLP23_NAME(Model_contents_instances_ptr);
|
||||
typedef SCLP23_NAME(Model_contents_instances_ptr)
|
||||
SCLP23_NAME(Model_contents_instances_var);
|
||||
|
||||
class SCLP23_NAME(Model_contents);
|
||||
typedef SCLP23_NAME(Model_contents) * SCLP23_NAME(Model_contents_ptr);
|
||||
typedef SCLP23_NAME(Model_contents_ptr) SCLP23_NAME(Model_contents_var);
|
||||
|
||||
class SCLP23_NAME(Model_contents__list);
|
||||
typedef SCLP23_NAME(Model_contents__list)*
|
||||
SCLP23_NAME(Model_contents__list_ptr);
|
||||
typedef SCLP23_NAME(Model_contents__list_ptr)
|
||||
SCLP23_NAME(Model_contents__list_var);
|
||||
|
||||
class SCLP23_NAME(Entity_extent);
|
||||
typedef SCLP23_NAME(Entity_extent) * SCLP23_NAME(Entity_extent_ptr);
|
||||
typedef SCLP23_NAME(Entity_extent_ptr) SCLP23_NAME(Entity_extent_var);
|
||||
|
||||
class SCLP23_NAME(Entity_extent__set);
|
||||
typedef SCLP23_NAME(Entity_extent__set)* SCLP23_NAME(Entity_extent__set_ptr);
|
||||
typedef SCLP23_NAME(Entity_extent__set_ptr) SCLP23_NAME(Entity_extent__set_var);
|
||||
|
||||
class SCLP23_NAME(Application_instance);
|
||||
// current style of CORBA handles for Part 23
|
||||
typedef SCLP23_NAME(Application_instance)* SCLP23_NAME(Application_instance_ptr);
|
||||
typedef SCLP23_NAME(Application_instance_ptr) SCLP23_NAME(Application_instance_var);
|
||||
|
||||
class SCLP23_NAME(Application_instance__set);
|
||||
typedef SCLP23_NAME(Application_instance__set) *
|
||||
SCLP23_NAME(Application_instance__set_ptr);
|
||||
typedef SCLP23_NAME(Application_instance__set_ptr)
|
||||
SCLP23_NAME(Application_instance__set_var);
|
||||
|
||||
/*
|
||||
typedef SCLP23_NAME(Application_instance__list) *
|
||||
SCLP23_NAME(Application_instance__list_var);
|
||||
*/
|
||||
#endif // IMPTYPES_HH
|
||||
@@ -1,78 +0,0 @@
|
||||
|
||||
#include <ebutton.h> // ivfasd/ebutton.h
|
||||
|
||||
#include <InterViews/font.h>
|
||||
#include <InterViews/pattern.h>
|
||||
|
||||
#include <IV-2_6/InterViews/painter.h>
|
||||
#include <IV-2_6/InterViews/sensor.h>
|
||||
#include <IV-2_6/InterViews/shape.h>
|
||||
#include <IV-2_6/InterViews/subject.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
static const int pad = 5;
|
||||
|
||||
EButton::EButton( const char * c,
|
||||
ButtonState * b,
|
||||
int i,
|
||||
const int horz,
|
||||
const int vert ) : PushButton( c, b, i ) {
|
||||
_vert = vert;
|
||||
_horz = horz;
|
||||
SetClassName( "EButton" );
|
||||
Listen( noEvents );
|
||||
}
|
||||
|
||||
EButton::EButton( const char * c,
|
||||
ButtonState * b,
|
||||
int i ) : PushButton( c, b, i ) {
|
||||
_vert = -1;
|
||||
_horz = -1;
|
||||
SetClassName( "EButton" );
|
||||
Listen( noEvents );
|
||||
}
|
||||
|
||||
void EButton::Reconfig() {
|
||||
TextButton::Reconfig();
|
||||
MakeBackground();
|
||||
if( shape->Undefined() ) {
|
||||
MakeShape();
|
||||
if( _vert < 0 || _horz < 0 ) {
|
||||
_vert = ( output->GetFont()->Height() + pad * 2 ) / 2;
|
||||
_horz = ( output->GetFont()->Width( text ) + output->GetFont()->Width( " " ) ) / 2;
|
||||
}
|
||||
shape->width = 2 * _horz + 1;
|
||||
shape->height = 2 * _vert + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void EButton::Redraw( IntCoord x1, IntCoord y1, IntCoord x2, IntCoord y2 ) {
|
||||
output->ClearRect( canvas, x1, y1, x2, y2 );
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void EButton::Refresh() {
|
||||
IntCoord x, y;
|
||||
IntCoord tx, ty;
|
||||
|
||||
x = xmax / 2;
|
||||
y = ymax / 2;
|
||||
tx = ( xmax - output->GetFont()->Width( text ) ) / 2;
|
||||
ty = ( ymax - output->GetFont()->Height() ) / 2;
|
||||
if( chosen || hit ) {
|
||||
/* (Redundant casts to work around a bug in cfront 1.2 .) */
|
||||
output->FillEllipse( canvas, x, y, _horz, _vert );
|
||||
background->Text( canvas, text, tx, ty );
|
||||
} else {
|
||||
background->FillRect( canvas, x - _horz, y - _vert, x + _horz, y + _vert );
|
||||
/* (Redundant casts to work around a bug in cfront 1.2 .) */
|
||||
output->Ellipse( canvas, x, y, _horz, _vert );
|
||||
output->Text( canvas, text, tx, ty );
|
||||
}
|
||||
if( !enabled ) {
|
||||
grayout->FillRect( canvas, 0, 0, xmax, ymax );
|
||||
}
|
||||
}
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
@@ -1,20 +0,0 @@
|
||||
|
||||
#include <IV-2_6/InterViews/button.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
class EButton : public PushButton
|
||||
{
|
||||
public:
|
||||
EButton(const char*, ButtonState*, int, const int, const int);
|
||||
EButton(const char*, ButtonState*, int);
|
||||
protected:
|
||||
virtual void Reconfig();
|
||||
virtual void Refresh();
|
||||
virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord);
|
||||
private:
|
||||
int _vert;
|
||||
int _horz;
|
||||
};
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
@@ -1,19 +0,0 @@
|
||||
|
||||
#include <errordisplay.h>
|
||||
|
||||
|
||||
ErrorDisplay::~ErrorDisplay() {
|
||||
if( errorButSt != nil ) {
|
||||
errorButSt->Detach( this );
|
||||
}
|
||||
}
|
||||
|
||||
void ErrorDisplay::Update() {
|
||||
int v = 0;
|
||||
errorButSt->GetValue( v );
|
||||
if( v == 1 ) {
|
||||
errorButSt->SetValue( 0 );
|
||||
errorDisp->Message( "\0" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* ErrorDisplay - a HBox that provides a label, followed by a
|
||||
* framed stringdisplay, followed by a pushbutton.
|
||||
* Call ErrorMsg(const char *msg) to display an error, when the user
|
||||
* pushes the button the error is cleared.
|
||||
*
|
||||
*/
|
||||
#ifndef errordisplay_h
|
||||
#define errordisplay_h
|
||||
|
||||
#include <IV-2_6/InterViews/box.h>
|
||||
#include <IV-2_6/InterViews/frame.h>
|
||||
#include <IV-2_6/InterViews/glue.h>
|
||||
|
||||
#include <mybutton.h>
|
||||
|
||||
#include <strdisplay.h> // ivfasd/strdisplay.h"
|
||||
#include <variousmessage.h> // ivfasd/variousmessage.h"
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
class ErrorDisplay : public HBox
|
||||
{
|
||||
public:
|
||||
ErrorDisplay(const char *labelText = "Error Messages:",
|
||||
const char *buttonText = " Clear ", const char *initStr = "\0");
|
||||
virtual ~ErrorDisplay();
|
||||
void ErrorMsg(const char *msg) { errorDisp->Message(msg); };
|
||||
void Update();
|
||||
private:
|
||||
StringDisplay *errorDisp;
|
||||
ButtonState *errorButSt;
|
||||
MyButton *errorButton;
|
||||
};
|
||||
|
||||
inline ErrorDisplay::ErrorDisplay(const char *labelText,
|
||||
const char *buttonText, const char *initStr)
|
||||
{
|
||||
errorButSt = new ButtonState(0);
|
||||
errorButSt->Attach(this);
|
||||
errorButton = new MyPushButton(buttonText, errorButSt, 1);
|
||||
errorDisp = new StringDisplay(errorButSt, initStr);
|
||||
|
||||
Insert(new BoldMessage(labelText));
|
||||
Insert(new HGlue(round(.05*inch), 0, 0));
|
||||
Insert(new Frame(errorDisp));
|
||||
Insert(new HGlue(round(.05*inch), 0, 0));
|
||||
Insert(errorButton);
|
||||
};
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,6 +0,0 @@
|
||||
#define m_width 16
|
||||
#define m_height 16
|
||||
static char m_bits[] = {
|
||||
0xff, 0xff, 0x01, 0x80, 0x01, 0x80, 0x19, 0x98, 0x19, 0x98, 0x39, 0x9c,
|
||||
0x79, 0x9e, 0xf9, 0x9f, 0xd9, 0x9b, 0x99, 0x99, 0x19, 0x98, 0x19, 0x98,
|
||||
0x19, 0x98, 0x01, 0x80, 0x01, 0x80, 0xff, 0xff};
|
||||
@@ -1,6 +0,0 @@
|
||||
#define mHit_width 16
|
||||
#define mHit_height 16
|
||||
static char mHit_bits[] = {
|
||||
0xff, 0xff, 0xff, 0xff, 0x03, 0xc0, 0x1b, 0xd8, 0x1b, 0xd8, 0x3b, 0xdc,
|
||||
0x7b, 0xde, 0xfb, 0xdf, 0xdb, 0xdb, 0x9b, 0xd9, 0x1b, 0xd8, 0x1b, 0xd8,
|
||||
0x1b, 0xd8, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff};
|
||||
@@ -1,5 +0,0 @@
|
||||
#define menu12_width 12
|
||||
#define menu12_height 12
|
||||
static char menu12_bits[] = {
|
||||
0x00, 0x00, 0xfe, 0x03, 0x02, 0x06, 0x72, 0x06, 0x02, 0x06, 0x72, 0x06,
|
||||
0x02, 0x06, 0x72, 0x06, 0x02, 0x06, 0xfe, 0x07, 0xf8, 0x07, 0x00, 0x00};
|
||||
@@ -1,5 +0,0 @@
|
||||
#define menu12_mask_width 12
|
||||
#define menu12_mask_height 12
|
||||
static char menu12_mask_bits[] = {
|
||||
0xff, 0x07, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f,
|
||||
0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xfc, 0x0f};
|
||||
@@ -1,6 +0,0 @@
|
||||
#define menu16_width 16
|
||||
#define menu16_height 16
|
||||
static char menu16_bits[] = {
|
||||
0x00, 0x00, 0xfc, 0x1f, 0x04, 0x10, 0x04, 0x30, 0xe4, 0x33, 0x04, 0x30,
|
||||
0xe4, 0x33, 0x04, 0x30, 0xe4, 0x33, 0x04, 0x30, 0xe4, 0x33, 0x04, 0x30,
|
||||
0x04, 0x30, 0xfc, 0x3f, 0xf0, 0x3f, 0x00, 0x00};
|
||||
@@ -1,6 +0,0 @@
|
||||
#define menu16_mask_width 16
|
||||
#define menu16_mask_height 16
|
||||
static char menu16_mask_bits[] = {
|
||||
0xfe, 0x3f, 0xfe, 0x3f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
|
||||
0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
|
||||
0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfc, 0x7f};
|
||||
@@ -1,6 +0,0 @@
|
||||
#define mvmask_width 16
|
||||
#define mvmask_height 16
|
||||
static char mvmask_bits[] = {
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
@@ -1,8 +0,0 @@
|
||||
#define pin2mask_width 15
|
||||
#define pin2mask_height 15
|
||||
#define pin2mask_x_hot 7
|
||||
#define pin2mask_y_hot 7
|
||||
static char pin2mask_bits[] = {
|
||||
0xe0, 0x03, 0xf8, 0x0f, 0xfc, 0x1f, 0xfe, 0x3f, 0xfe, 0x3f, 0xff, 0x7f,
|
||||
0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xfe, 0x3f, 0xfe, 0x3f,
|
||||
0xfc, 0x1f, 0xf8, 0x0f, 0xe0, 0x03};
|
||||
@@ -1,8 +0,0 @@
|
||||
#define pinin2_width 15
|
||||
#define pinin2_height 15
|
||||
#define pinin2_x_hot 7
|
||||
#define pinin2_y_hot 7
|
||||
static char pinin2_bits[] = {
|
||||
0xe0, 0x03, 0x18, 0x0c, 0x04, 0x10, 0x02, 0x20, 0x02, 0x20, 0xc1, 0x41,
|
||||
0xe1, 0x43, 0xe1, 0x43, 0xe1, 0x43, 0xc1, 0x41, 0x02, 0x20, 0x02, 0x20,
|
||||
0x04, 0x10, 0x18, 0x0c, 0xe0, 0x03};
|
||||
@@ -1,8 +0,0 @@
|
||||
#define pinin2Hit_width 15
|
||||
#define pinin2Hit_height 15
|
||||
#define pinin2Hit_x_hot 7
|
||||
#define pinin2Hit_y_hot 7
|
||||
static char pinin2Hit_bits[] = {
|
||||
0xe0, 0x03, 0xf8, 0x0f, 0xfc, 0x1f, 0x1e, 0x3c, 0x0e, 0x38, 0xc7, 0x71,
|
||||
0xe7, 0x73, 0xe7, 0x73, 0xe7, 0x73, 0xc7, 0x71, 0x0e, 0x38, 0x1e, 0x3c,
|
||||
0xfc, 0x1f, 0xf8, 0x0f, 0xe0, 0x03};
|
||||
@@ -1,8 +0,0 @@
|
||||
#define pinout2_width 15
|
||||
#define pinout2_height 15
|
||||
#define pinout2_x_hot 7
|
||||
#define pinout2_y_hot 7
|
||||
static char pinout2_bits[] = {
|
||||
0xe0, 0x03, 0x18, 0x0c, 0x04, 0x10, 0x02, 0x20, 0x02, 0x20, 0x01, 0x42,
|
||||
0x01, 0x46, 0xe1, 0x47, 0x01, 0x46, 0x01, 0x42, 0x02, 0x20, 0x02, 0x20,
|
||||
0x04, 0x10, 0x18, 0x0c, 0xe0, 0x03};
|
||||
@@ -1,8 +0,0 @@
|
||||
#define pinout2Hit_width 15
|
||||
#define pinout2Hit_height 15
|
||||
#define pinout2Hit_x_hot 7
|
||||
#define pinout2Hit_y_hot 7
|
||||
static char pinout2Hit_bits[] = {
|
||||
0xe0, 0x03, 0xf8, 0x0f, 0xfc, 0x1f, 0x1e, 0x3c, 0x0e, 0x38, 0x07, 0x71,
|
||||
0x07, 0x73, 0xc7, 0x73, 0x07, 0x73, 0x07, 0x71, 0x0e, 0x38, 0x1e, 0x3c,
|
||||
0xfc, 0x1f, 0xf8, 0x0f, 0xe0, 0x03};
|
||||
@@ -1,6 +0,0 @@
|
||||
#define v_width 16
|
||||
#define v_height 16
|
||||
static char v_bits[] = {
|
||||
0xff, 0xff, 0x01, 0x80, 0x01, 0x80, 0x19, 0x98, 0x19, 0x98, 0x39, 0x9c,
|
||||
0x31, 0x8c, 0x31, 0x8c, 0x61, 0x86, 0x61, 0x86, 0xc1, 0x83, 0xc1, 0x83,
|
||||
0x81, 0x81, 0x01, 0x80, 0x01, 0x80, 0xff, 0xff};
|
||||
@@ -1,6 +0,0 @@
|
||||
#define vHit_width 16
|
||||
#define vHit_height 16
|
||||
static char vHit_bits[] = {
|
||||
0xff, 0xff, 0xff, 0xff, 0x03, 0xc0, 0x1b, 0xd8, 0x1b, 0xd8, 0x3b, 0xdc,
|
||||
0x33, 0xcc, 0x33, 0xcc, 0x63, 0xc6, 0x63, 0xc6, 0xc3, 0xc3, 0xc3, 0xc3,
|
||||
0x83, 0xc1, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff};
|
||||
@@ -1,298 +0,0 @@
|
||||
|
||||
// ~sauderd/src/iv/cfiles/intstreditor.c
|
||||
|
||||
/*
|
||||
* IntStringEditor - Interactive editor for character strings based on
|
||||
* on StringEditor2. This object accepts only integer
|
||||
* characters and possibly an optional sign. This is
|
||||
* done by redefining InsertValidChar(char c). It
|
||||
* performs type checking when a terminating char is
|
||||
* typed by redefining TypeCheck().
|
||||
*
|
||||
* RealStringEditor - Interactive editor for character strings based on
|
||||
* on StringEditor2. This object accepts only chars
|
||||
* that would be found in a real number
|
||||
* (i.e. 0-9, '+', '-', '.', 'e', and 'E'). This is
|
||||
* done by redefining InsertValidChar(char c).
|
||||
* It performs type checking by redefining TypeCheck().
|
||||
* Type checking is done when a terminating char is
|
||||
* typed. Valid real numbers are defined as following:
|
||||
* optional sign ,
|
||||
* zero or more decimal digits,
|
||||
* optional decimal point,
|
||||
* zero or more decimal digits,
|
||||
* then possibly:
|
||||
* the letter e or E which may be followed by
|
||||
* an optional sign and then
|
||||
* zero or more decimal digits.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <IV-2_6/InterViews/textbuffer.h>
|
||||
#include <intstreditor.h>
|
||||
|
||||
const char RingBell = '\007'; // <CNTRL> G
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IntStringEditor member functions.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
IntStringEditor::IntStringEditor(
|
||||
ButtonState * s, const char * samp, const char * Done, int width
|
||||
) : StringEditor2( s, samp, Done, width ) {
|
||||
SetClassName( "IntStringEditor" );
|
||||
acceptSigns = true;
|
||||
}
|
||||
|
||||
IntStringEditor::IntStringEditor(
|
||||
const char * name, ButtonState * s, const char * samp, const char * Done,
|
||||
int width
|
||||
) : StringEditor2( s, samp, Done, width ) {
|
||||
SetInstance( name );
|
||||
SetClassName( "IntStringEditor" );
|
||||
acceptSigns = true;
|
||||
}
|
||||
|
||||
int IntStringEditor::TypeCheck() {
|
||||
long int tmpI = 0;
|
||||
char tmpstr[3];
|
||||
int numFound = sscanf( ( char * )text->Text(), "%ld%1s", &tmpI,
|
||||
tmpstr );
|
||||
switch( numFound ) {
|
||||
case 0:
|
||||
// 0 => bogus beginning;
|
||||
fprintf( stderr, "%c invalid int attr value\n" , RingBell );
|
||||
fflush( stderr );
|
||||
return 0;
|
||||
case 2:
|
||||
// 2 => bogus ending
|
||||
fprintf( stderr, "%c invalid int attr value: '%c'\n" , RingBell,
|
||||
tmpstr[0] );
|
||||
fflush( stderr );
|
||||
return 0;
|
||||
case 1:
|
||||
case EOF:
|
||||
// 1 => success; EOF => blank field
|
||||
// printf("edit results returned %d\n", numFound);
|
||||
// printf("attr value: %ld\n", tmpI);
|
||||
// printf("term char (hex): %x, 'this' address(hex): %x\n",
|
||||
// (int)subInfo->GetValue(), subInfo->GetSubordinate());
|
||||
if( acceptSigns ) {
|
||||
return SETYPE_SIGNED_INTEGER;
|
||||
} else {
|
||||
return SETYPE_UNSIGNED_INTEGER;
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
boolean IntStringEditor::InsertValidChar( char c ) {
|
||||
switch( c ) {
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
InsertText( &c, 1 );
|
||||
return true;
|
||||
case '+':
|
||||
case '-':
|
||||
if( acceptSigns ) {
|
||||
InsertText( &c, 1 );
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
boolean IntStringEditor::HandleChar (char c) {
|
||||
if (strchr(done, c) != nil) {
|
||||
if (subject != nil) {
|
||||
subject->SetValue(c);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
switch (c) {
|
||||
case SEBeginningOfLine:
|
||||
Select(text->BeginningOfLine(left));
|
||||
break;
|
||||
case SEEndOfLine:
|
||||
Select(text->EndOfLine(right));
|
||||
break;
|
||||
case SESelectAll:
|
||||
Select(text->BeginningOfText(), text->EndOfText());
|
||||
break;
|
||||
// case SESelectWord:
|
||||
// Select(
|
||||
// text->BeginningOfWord(text->PreviousCharacter(left)), right
|
||||
// );
|
||||
// break;
|
||||
case SESelectWord:
|
||||
if(text->IsEndOfWord(right))
|
||||
Select(
|
||||
left, text->EndOfWord(text->BeginningOfNextWord(right))
|
||||
);
|
||||
else
|
||||
Select(
|
||||
left, text->EndOfWord(right)
|
||||
);
|
||||
break;
|
||||
case SEDeleteToEndOfLine:
|
||||
Select(left, text->EndOfLine(right));
|
||||
break;
|
||||
|
||||
case SEPreviousCharacter:
|
||||
Select(text->PreviousCharacter(left));
|
||||
break;
|
||||
case SENextCharacter:
|
||||
Select(text->NextCharacter(right));
|
||||
break;
|
||||
case SEDeleteNextCharacter:
|
||||
if (left == right) {
|
||||
right = text->NextCharacter(right);
|
||||
}
|
||||
InsertText("", 0);
|
||||
break;
|
||||
case SEDeletePreviousCharacter:
|
||||
case SEDeletePreviousCharacterAlt:
|
||||
if (left == right) {
|
||||
left = text->PreviousCharacter(left);
|
||||
}
|
||||
InsertText("", 0);
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (!iscntrl(c)) {
|
||||
InsertText(&c, 1);
|
||||
}
|
||||
break;
|
||||
case ESCAPE_KEY:
|
||||
meta = true;
|
||||
break;
|
||||
default:
|
||||
if(meta){
|
||||
switch(c){
|
||||
case 'f':
|
||||
Select(text->BeginningOfNextWord(right));
|
||||
break;
|
||||
case 'b':
|
||||
if(text->IsBeginningOfWord(left))
|
||||
Select(text->BeginningOfWord(
|
||||
text->PreviousCharacter(left)));
|
||||
else
|
||||
Select(text->BeginningOfWord(left));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stdout, "%c" , RingBell);
|
||||
fflush(stdout);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(meta)
|
||||
if(c != ESCAPE_KEY)
|
||||
meta = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RealStringEditor member functions.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
RealStringEditor::RealStringEditor(
|
||||
ButtonState * s, const char * samp, const char * Done, int width
|
||||
) : StringEditor2( s, samp, Done, width ) {
|
||||
SetClassName( "RealStringEditor" );
|
||||
}
|
||||
|
||||
RealStringEditor::RealStringEditor(
|
||||
const char * name, ButtonState * s, const char * samp, const char * Done,
|
||||
int width
|
||||
) : StringEditor2( s, samp, Done, width ) {
|
||||
SetInstance( name );
|
||||
SetClassName( "RealStringEditor" );
|
||||
}
|
||||
|
||||
int RealStringEditor::TypeCheck() {
|
||||
double tmpD = 0;
|
||||
char tmpstr[3];
|
||||
|
||||
int numFound = sscanf( ( char * )text->Text(), "%lf%1s", &tmpD,
|
||||
tmpstr );
|
||||
switch( numFound ) {
|
||||
case 0:
|
||||
// 0 => bogus beginning;
|
||||
fprintf( stderr, "%c invalid real attr value\n" , RingBell );
|
||||
fflush( stderr );
|
||||
return 0;
|
||||
case 2:
|
||||
// 2 => bogus ending
|
||||
fprintf( stderr, "%c invalid real attr value: '%c'\n" , RingBell,
|
||||
tmpstr[0] );
|
||||
fflush( stderr );
|
||||
return 0;
|
||||
case 1:
|
||||
case EOF:
|
||||
// 1 => success; EOF => blank field
|
||||
// printf("edit results returned %d\n", numFound);
|
||||
// printf("attr value: %e\n", tmpD);
|
||||
// printf("term char (hex): %x, 'this' address(hex): %x\n",
|
||||
// (int)subInfo->GetValue(), subInfo->GetSubordinate());
|
||||
return SETYPE_REAL;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
boolean RealStringEditor::InsertValidChar( char c ) {
|
||||
switch( c ) {
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
case 'e':
|
||||
case 'E':
|
||||
case '.':
|
||||
case '+':
|
||||
case '-':
|
||||
InsertText( &c, 1 );
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
|
||||
// ~sauderd/src/iv/hfiles/intstreditor.h
|
||||
|
||||
/*
|
||||
* IntStringEditor - Interactive editor for character strings based on
|
||||
* on StringEditor2. This object accepts only integer
|
||||
* characters and possibly an optional sign. This is
|
||||
* done by redefining InsertValidChar(char c). It
|
||||
* performs type checking when a terminating char is
|
||||
* typed by redefining TypeCheck().
|
||||
*
|
||||
* RealStringEditor - Interactive editor for character strings based on
|
||||
* on StringEditor2. This object accepts only chars
|
||||
* that would be found in a real number
|
||||
* (i.e. 0-9, '+', '-', '.', 'e', and 'E'). This is
|
||||
* done by redefining InsertValidChar(char c).
|
||||
* It performs type checking by redefining TypeCheck().
|
||||
* Type checking is done when a terminating char is
|
||||
* typed. Valid real numbers are defined as following:
|
||||
* optional sign ,
|
||||
* zero or more decimal digits,
|
||||
* optional decimal point,
|
||||
* zero or more decimal digits,
|
||||
* then possibly:
|
||||
* the letter e or E which may be followed by
|
||||
* an optional sign and then
|
||||
* zero or more decimal digits.
|
||||
*/
|
||||
|
||||
#ifndef intstreditor_h
|
||||
#define intstreditor_h
|
||||
|
||||
#include <streditor2.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IntStringEditor class definition
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class IntStringEditor : public StringEditor2 {
|
||||
public:
|
||||
IntStringEditor(ButtonState*, const char* sample,
|
||||
const char* Done = SEDone, int width = 0);
|
||||
IntStringEditor(
|
||||
const char* name, ButtonState*, const char*, const char* = SEDone,
|
||||
int width = 0
|
||||
);
|
||||
virtual ~IntStringEditor() {};
|
||||
|
||||
// decide if signs are accepted and if they pass type checking.
|
||||
void AcceptSigns(boolean boolvar = true) { acceptSigns = boolvar; };
|
||||
|
||||
// returns SETYPE_UNSIGNED_INTEGER or SETYPE_SIGNED_INTEGER if success
|
||||
// otherwise returns zero.
|
||||
virtual int TypeCheck();
|
||||
|
||||
virtual void SetSubject(int c)
|
||||
{ if (subject != nil) { subject->SetValue(c); } };
|
||||
|
||||
protected:
|
||||
virtual boolean InsertValidChar(char c);
|
||||
boolean acceptSigns;
|
||||
private:
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RealStringEditor class definition
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RealStringEditor : public StringEditor2 {
|
||||
public:
|
||||
RealStringEditor(ButtonState*, const char* sample,
|
||||
const char* Done = SEDone, int width = 0);
|
||||
RealStringEditor(
|
||||
const char* name, ButtonState*, const char*, const char* = SEDone,
|
||||
int width = 0
|
||||
);
|
||||
virtual ~RealStringEditor() {};
|
||||
|
||||
// returns SETYPE_REAL if success otherwise returns zero.
|
||||
virtual int TypeCheck();
|
||||
|
||||
virtual void SetSubject(int c)
|
||||
{ if (subject != nil) { subject->SetValue(c); } };
|
||||
|
||||
protected:
|
||||
virtual boolean InsertValidChar(char c);
|
||||
private:
|
||||
};
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,427 +0,0 @@
|
||||
|
||||
// ~sauderd/src/iv/hfiles/intstreditor2sub.h
|
||||
|
||||
/*
|
||||
* IntStringEditorSub - Interactive editor for character strings based
|
||||
* on IntStringEditor. This one is sociable with
|
||||
* a supervisor. In addition to supplying the
|
||||
* supervisor with the terminating char it also
|
||||
* returns a pointer to itself.
|
||||
* It does this by redefining SetSubject() to
|
||||
* communicate with the supervisor supplying the
|
||||
* fields contained in class SubordinateInfo.
|
||||
*
|
||||
* RealStringEditorSub - Same as above except for real numbers and based
|
||||
* on RealStringEditor.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stream.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <intstreditorsub.h>
|
||||
|
||||
#include <IV-2_6/InterViews/button.h>
|
||||
#include <IV-2_6/InterViews/textbuffer.h>
|
||||
|
||||
const char RingBell = '\007'; // <CNTRL> G
|
||||
|
||||
IntStringEditorSub::~IntStringEditorSub() {
|
||||
delete subInfo;
|
||||
}
|
||||
|
||||
void IntStringEditorSub::SetSubject( int c ) {
|
||||
if( subject != nil ) {
|
||||
subInfo->SetValue( c );
|
||||
subject->SetValue( subInfo ); // don't cast this to (void*)
|
||||
// it makes it not work.
|
||||
}
|
||||
}
|
||||
|
||||
RealStringEditorSub::~RealStringEditorSub() {
|
||||
}
|
||||
|
||||
void RealStringEditorSub::SetSubject( int c ) {
|
||||
if( subject != nil ) {
|
||||
subInfo->SetValue( c );
|
||||
subject->SetValue( subInfo ); // don't cast this to (void*)
|
||||
// it makes it not work.
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IntStringEditorSub member functions.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
define this if you want the supervisor to be notified before this
|
||||
IntStringEditorSub handles it's own event. If you do define this you will
|
||||
probably want to call StringEditor2::Handle() for this object when the
|
||||
supervisor has done what it wanted to do before this object handled it's
|
||||
event. You will need to read the event if you don't call handle for this
|
||||
object otherwise this function will cause an infinite loop (i.e. read the
|
||||
event, unread the event, read the event, unread the event, etc)
|
||||
*/
|
||||
/*
|
||||
void IntStringEditorSub::Handle(Event& e)
|
||||
{
|
||||
// if(e.eventType == 2 || e.eventType == 4)
|
||||
if(e.eventType == DownEvent || e.eventType == KeyEvent)
|
||||
{
|
||||
UnRead(e);
|
||||
subInfo->SetValue(' ');
|
||||
subject->SetValue(subInfo); // don't cast this to (void*)
|
||||
// call notify for subject (which calls see update)
|
||||
}
|
||||
else
|
||||
StringEditor2::Handle(e);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
define this if you want the supervisor to be notified before this
|
||||
RealStringEditorSub handles it's own event. If you do define this you will
|
||||
probably want to call StringEditor2::Handle() for this object when the
|
||||
supervisor has done what it wanted to do before this object handled it's
|
||||
event. You will need to read the event if you don't call handle for this
|
||||
object otherwise this function will cause an infinite loop (i.e. read the
|
||||
event, unread the event, read the event, unread the event, etc)
|
||||
*/
|
||||
/*
|
||||
void RealStringEditorSub::Handle(Event& e)
|
||||
{
|
||||
// if(e.eventType == 2 || e.eventType == 4)
|
||||
if(e.eventType == DownEvent || e.eventType == KeyEvent)
|
||||
{
|
||||
UnRead(e);
|
||||
subInfo->SetValue(' ');
|
||||
subject->SetValue(subInfo); // don't cast this to (void*)
|
||||
// call notify for subject (which calls see update)
|
||||
StringEditor2::Handle(e);
|
||||
}
|
||||
else
|
||||
StringEditor2::Handle(e);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
IntStringEditorSub::IntStringEditorSub (
|
||||
ButtonState* s, const char* samp, const char* done, int width
|
||||
) : (s, samp, done, width)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
IntStringEditorSub::IntStringEditorSub (
|
||||
const char* name, ButtonState* s, const char* samp, const char* done,
|
||||
int width
|
||||
) : ( s, samp, done, width)
|
||||
{
|
||||
SetInstance(name);
|
||||
Init();
|
||||
}
|
||||
|
||||
void IntStringEditorSub::Init()
|
||||
{
|
||||
SetClassName("IntStringEditorSub");
|
||||
subInfo = new SubordinateInfo(0, this);
|
||||
}
|
||||
|
||||
void IntStringEditorSub::SetSubject(char c)
|
||||
{
|
||||
if (subject != nil) {
|
||||
subInfo->SetValue(c);
|
||||
subject->SetValue(subInfo); // don't cast this to (void*)
|
||||
// it makes it not work.
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
boolean IntStringEditorSub::HandleChar (char c) {
|
||||
if (strchr(done, c) != nil) {
|
||||
if (subject != nil) {
|
||||
subInfo->SetValue(c);
|
||||
subject->SetValue(subInfo); // don't cast this to (void*)
|
||||
// it makes it not work.
|
||||
long int tmpI = 0;
|
||||
char tmpstr[3];
|
||||
int numFound = sscanf((char *)text->Text(),"%ld%1s", &tmpI,
|
||||
tmpstr);
|
||||
if(numFound == 0 || numFound == 2){
|
||||
// 0 => bogus beginning; 2 => bogus ending
|
||||
fprintf(stderr, "%c bogus int attr value\n" , RingBell);
|
||||
fflush(stderr);
|
||||
}
|
||||
else if(numFound == 1 || numFound == EOF){
|
||||
// 1 => success; EOF => blank field
|
||||
printf("edit results returned %d\n", numFound);
|
||||
printf("attr value: %ld\n", tmpI);
|
||||
printf("term char (hex): %x, 'this' address(hex): %x\n",
|
||||
(int)subInfo->GetValue(), subInfo->GetSubordinate());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch (c) {
|
||||
case SEBeginningOfLine:
|
||||
Select(text->BeginningOfLine(left));
|
||||
break;
|
||||
case SEEndOfLine:
|
||||
Select(text->EndOfLine(right));
|
||||
break;
|
||||
case SESelectAll:
|
||||
Select(text->BeginningOfText(), text->EndOfText());
|
||||
break;
|
||||
// case SESelectWord:
|
||||
// Select(
|
||||
// text->BeginningOfWord(text->PreviousCharacter(left)), right
|
||||
// );
|
||||
// break;
|
||||
case SESelectWord:
|
||||
if(text->IsEndOfWord(right))
|
||||
Select(
|
||||
left, text->EndOfWord(text->BeginningOfNextWord(right))
|
||||
);
|
||||
else
|
||||
Select(
|
||||
left, text->EndOfWord(right)
|
||||
);
|
||||
break;
|
||||
case SEDeleteToEndOfLine:
|
||||
Select(left, text->EndOfLine(right));
|
||||
break;
|
||||
|
||||
case SEPreviousCharacter:
|
||||
Select(text->PreviousCharacter(left));
|
||||
break;
|
||||
case SENextCharacter:
|
||||
Select(text->NextCharacter(right));
|
||||
break;
|
||||
case SEDeleteNextCharacter:
|
||||
if (left == right) {
|
||||
right = text->NextCharacter(right);
|
||||
}
|
||||
InsertText("", 0);
|
||||
break;
|
||||
case SEDeletePreviousCharacter:
|
||||
case SEDeletePreviousCharacterAlt:
|
||||
if (left == right) {
|
||||
left = text->PreviousCharacter(left);
|
||||
}
|
||||
InsertText("", 0);
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
InsertText(&c, 1);
|
||||
break;
|
||||
case '+':
|
||||
case '-':
|
||||
if (acceptSigns)
|
||||
InsertText(&c, 1);
|
||||
else {
|
||||
fprintf(stdout, "%c" , RingBell);
|
||||
fflush(stdout);
|
||||
}
|
||||
break;
|
||||
case ESCAPE_KEY:
|
||||
meta = true;
|
||||
break;
|
||||
default:
|
||||
if(meta){
|
||||
switch(c){
|
||||
case 'f':
|
||||
Select(text->BeginningOfNextWord(right));
|
||||
break;
|
||||
case 'b':
|
||||
if(text->IsBeginningOfWord(left))
|
||||
Select(text->BeginningOfWord(
|
||||
text->PreviousCharacter(left)));
|
||||
else
|
||||
Select(text->BeginningOfWord(left));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stdout, "%c" , RingBell);
|
||||
fflush(stdout);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(meta)
|
||||
if(c != ESCAPE_KEY)
|
||||
meta = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RealStringEditorSub member functions.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
RealStringEditorSub::RealStringEditorSub (
|
||||
ButtonState* s, const char* samp, const char* done, int width
|
||||
) : (s, samp, done, width)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
RealStringEditorSub::RealStringEditorSub (
|
||||
const char* name, ButtonState* s, const char* samp, const char* done,
|
||||
int width
|
||||
) : ( s, samp, done, width)
|
||||
{
|
||||
SetInstance(name);
|
||||
Init();
|
||||
}
|
||||
|
||||
void RealStringEditorSub::Init()
|
||||
{
|
||||
SetClassName("RealStringEditorSub");
|
||||
subInfo = new SubordinateInfo(0, this);
|
||||
printf("se this: %d\n", this);
|
||||
}
|
||||
|
||||
void RealStringEditorSub::SetSubject(char c)
|
||||
{
|
||||
if (subject != nil) {
|
||||
subInfo->SetValue(c);
|
||||
subject->SetValue(subInfo); // don't cast this to (void*)
|
||||
// it makes it not work.
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
boolean RealStringEditorSub::HandleChar (char c) {
|
||||
if (strchr(done, c) != nil) {
|
||||
if (subject != nil) {
|
||||
subInfo->SetValue(c);
|
||||
subject->SetValue(subInfo); // don't cast this to (void*)
|
||||
// it makes it not work.
|
||||
double tmpD = 0;
|
||||
char tmpstr[3];
|
||||
int numFound = sscanf((char *)text->Text(),"%lf%1s", &tmpD,
|
||||
tmpstr);
|
||||
if(numFound == 0 || numFound == 2){
|
||||
// 0 => bogus beginning; 2 => bogus ending
|
||||
fprintf(stderr, "%c bogus real attr value\n" , RingBell);
|
||||
fflush(stderr);
|
||||
}
|
||||
else if(numFound == 1 || numFound == EOF){
|
||||
// 1 => success; EOF => blank field
|
||||
printf("edit results returned %d\n", numFound);
|
||||
printf("attr value: %e\n", tmpD);
|
||||
printf("term char (hex): %x, this address(hex): %x\n",
|
||||
(int)subInfo->GetValue(), subInfo->GetSubordinate());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch (c) {
|
||||
case SEBeginningOfLine:
|
||||
Select(text->BeginningOfLine(left));
|
||||
break;
|
||||
case SEEndOfLine:
|
||||
Select(text->EndOfLine(right));
|
||||
break;
|
||||
case SESelectAll:
|
||||
Select(text->BeginningOfText(), text->EndOfText());
|
||||
break;
|
||||
// case SESelectWord:
|
||||
// Select(
|
||||
// text->BeginningOfWord(text->PreviousCharacter(left)), right
|
||||
// );
|
||||
// break;
|
||||
case SESelectWord:
|
||||
if(text->IsEndOfWord(right))
|
||||
Select(
|
||||
left, text->EndOfWord(text->BeginningOfNextWord(right))
|
||||
);
|
||||
else
|
||||
Select(
|
||||
left, text->EndOfWord(right)
|
||||
);
|
||||
break;
|
||||
case SEDeleteToEndOfLine:
|
||||
Select(left, text->EndOfLine(right));
|
||||
break;
|
||||
|
||||
case SEPreviousCharacter:
|
||||
Select(text->PreviousCharacter(left));
|
||||
break;
|
||||
case SENextCharacter:
|
||||
Select(text->NextCharacter(right));
|
||||
break;
|
||||
case SEDeleteNextCharacter:
|
||||
if (left == right) {
|
||||
right = text->NextCharacter(right);
|
||||
}
|
||||
InsertText("", 0);
|
||||
break;
|
||||
case SEDeletePreviousCharacter:
|
||||
case SEDeletePreviousCharacterAlt:
|
||||
if (left == right) {
|
||||
left = text->PreviousCharacter(left);
|
||||
}
|
||||
InsertText("", 0);
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
case 'e':
|
||||
case 'E':
|
||||
case '.':
|
||||
case '+':
|
||||
case '-':
|
||||
if (!iscntrl(c)) {
|
||||
InsertText(&c, 1);
|
||||
}
|
||||
break;
|
||||
case ESCAPE_KEY:
|
||||
meta = true;
|
||||
break;
|
||||
default:
|
||||
if(meta){
|
||||
switch(c){
|
||||
case 'f':
|
||||
Select(text->BeginningOfNextWord(right));
|
||||
break;
|
||||
case 'b':
|
||||
if(text->IsBeginningOfWord(left))
|
||||
Select(text->BeginningOfWord(
|
||||
text->PreviousCharacter(left)));
|
||||
else
|
||||
Select(text->BeginningOfWord(left));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stdout, "%c" , RingBell);
|
||||
fflush(stdout);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(meta)
|
||||
if(c != ESCAPE_KEY)
|
||||
meta = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,136 +0,0 @@
|
||||
|
||||
// ~sauderd/src/iv/hfiles/intstreditor2sub.h
|
||||
|
||||
/*
|
||||
* IntStringEditorSub - Interactive editor for character strings based
|
||||
* on IntStringEditor. This one is sociable with
|
||||
* a supervisor. In addition to supplying the
|
||||
* supervisor with the terminating char it also
|
||||
* returns a pointer to itself.
|
||||
* It does this by redefining SetSubject() to
|
||||
* communicate with the supervisor supplying the
|
||||
* fields contained in class SubordinateInfo.
|
||||
*
|
||||
* RealStringEditorSub - Same as above except for real numbers and based
|
||||
* on RealStringEditor.
|
||||
*/
|
||||
|
||||
#ifndef intstreditorsub_h
|
||||
#define intstreditorsub_h
|
||||
|
||||
#include <InterViews/event.h>
|
||||
#include <intstreditor.h>
|
||||
#include <subinfo.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IntStringEditorSub class definition
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class IntStringEditorSub : public IntStringEditor {
|
||||
public:
|
||||
IntStringEditorSub(ButtonState*, const char* sample,
|
||||
const char* donechars = SEDone, int width = 0);
|
||||
IntStringEditorSub(
|
||||
const char* name, ButtonState*, const char*, const char* = SEDone,
|
||||
int width = 0
|
||||
);
|
||||
~IntStringEditorSub();
|
||||
|
||||
virtual void SetSubject(int c);
|
||||
|
||||
protected:
|
||||
SubordinateInfo *subInfo;
|
||||
|
||||
private:
|
||||
void Init();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RealStringEditorSub class definition
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RealStringEditorSub : public RealStringEditor {
|
||||
public:
|
||||
RealStringEditorSub(ButtonState*, const char* sample,
|
||||
const char* donechars = SEDone, int width = 0);
|
||||
RealStringEditorSub(
|
||||
const char* name, ButtonState*, const char*, const char* = SEDone,
|
||||
int width = 0
|
||||
);
|
||||
virtual ~RealStringEditorSub();
|
||||
|
||||
virtual void SetSubject(int c);
|
||||
|
||||
protected:
|
||||
// virtual boolean HandleChar(char);
|
||||
SubordinateInfo *subInfo;
|
||||
|
||||
private:
|
||||
void Init();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IntStringEditorSub class inline member functions
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline void IntStringEditorSub::Init()
|
||||
{
|
||||
SetClassName("IntStringEditorSub");
|
||||
subInfo = new SubordinateInfo(0, this);
|
||||
}
|
||||
|
||||
inline IntStringEditorSub::IntStringEditorSub (
|
||||
ButtonState* s, const char* samp, const char* donechars, int width
|
||||
) : IntStringEditor(s, samp, donechars, width)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
inline IntStringEditorSub::IntStringEditorSub (
|
||||
const char* name, ButtonState* s, const char* samp, const char* donechars,
|
||||
int width
|
||||
) : IntStringEditor( s, samp, donechars, width)
|
||||
{
|
||||
SetInstance(name);
|
||||
Init();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RealStringEditorSub class inline member functions
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline void RealStringEditorSub::Init()
|
||||
{
|
||||
SetClassName("RealStringEditorSub");
|
||||
subInfo = new SubordinateInfo(0, this);
|
||||
}
|
||||
|
||||
inline RealStringEditorSub::RealStringEditorSub (
|
||||
ButtonState* s, const char* samp, const char* donechars, int width
|
||||
) : RealStringEditor(s, samp, donechars, width)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
inline RealStringEditorSub::RealStringEditorSub (
|
||||
const char* name, ButtonState* s, const char* samp, const char* donechars,
|
||||
int width
|
||||
) : RealStringEditor( s, samp, donechars, width)
|
||||
{
|
||||
SetInstance(name);
|
||||
Init();
|
||||
}
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* myLabel class implementation.
|
||||
*/
|
||||
|
||||
#define iv2_6_compatible
|
||||
|
||||
#include <label.h>
|
||||
|
||||
#include <InterViews/font.h>
|
||||
|
||||
#include <IV-2_6/InterViews/painter.h>
|
||||
#include <IV-2_6/InterViews/shape.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void myLabel::Init( Alignment a, int width, int p,
|
||||
int hstr, int vstr ) {
|
||||
SetClassName( "myLabel" );
|
||||
alignment = a;
|
||||
textWidth = width;
|
||||
pad = p;
|
||||
shape->hstretch = hstr;
|
||||
shape->vstretch = vstr;
|
||||
highlighted = false;
|
||||
}
|
||||
|
||||
myLabel::myLabel( const char * msg, Alignment al, int width, int pad_,
|
||||
int hstr, int vstr ) {
|
||||
text = msg;
|
||||
Init( al, width, pad_, hstr, vstr );
|
||||
}
|
||||
|
||||
myLabel::myLabel( char * msg, Alignment al, int width, int pad_,
|
||||
int hstr, int vstr ) {
|
||||
text = new char[strlen( msg ) + 1];
|
||||
strncpy( ( char * )text, msg, strlen( msg ) + 1 );
|
||||
Init( al, width, pad_, hstr, vstr );
|
||||
}
|
||||
|
||||
myLabel::myLabel(
|
||||
const char * name,
|
||||
const char * msg, Alignment al, int width, int pad_, int hstr, int vstr
|
||||
) : Interactor( name ) {
|
||||
text = msg;
|
||||
Init( al, width, pad_, hstr, vstr );
|
||||
}
|
||||
|
||||
myLabel::myLabel(
|
||||
const char * name,
|
||||
char * msg, Alignment al, int width, int pad_, int hstr, int vstr
|
||||
) : Interactor( name ) {
|
||||
text = new char[strlen( msg ) + 1];
|
||||
strncpy( ( char * )text, msg, strlen( msg ) + 1 );
|
||||
Init( al, width, pad_, hstr, vstr );
|
||||
}
|
||||
|
||||
void myLabel::Reconfig() {
|
||||
const char * a = GetAttribute( "text" );
|
||||
if( a != nil ) {
|
||||
text = a;
|
||||
}
|
||||
a = GetAttribute( "padding" );
|
||||
if( a != nil ) {
|
||||
pad = atoi( a );
|
||||
}
|
||||
const Font * f = output->GetFont();
|
||||
if( textWidth ) {
|
||||
shape->width = pad + f->Width( "n" ) * textWidth + pad;
|
||||
} else {
|
||||
shape->width = pad + f->Width( text ) + pad;
|
||||
}
|
||||
shape->height = pad + f->Height() + pad;
|
||||
shape->hshrink = pad + pad;
|
||||
shape->vshrink = pad + pad;
|
||||
}
|
||||
|
||||
void myLabel::Realign( Alignment a ) {
|
||||
alignment = a;
|
||||
Draw();
|
||||
}
|
||||
|
||||
void myLabel::Redraw( IntCoord l, IntCoord b, IntCoord r, IntCoord t ) {
|
||||
IntCoord x = 0, y = 0;
|
||||
Align( alignment, shape->width, shape->height, x, y );
|
||||
output->Clip( canvas, l, b, r, t );
|
||||
if( highlighted ) {
|
||||
output->SetColors( output->GetBgColor(), output->GetFgColor() );
|
||||
}
|
||||
output->ClearRect( canvas, l, b, r, t );
|
||||
const Font * f = output->GetFont();
|
||||
if( textWidth - strlen( text ) > 0 ) {
|
||||
if( alignment == Right ) {
|
||||
output->Text( canvas, text,
|
||||
x + ( ( textWidth - strlen( text ) ) * f->Width( "n" ) ) + pad,
|
||||
y + pad );
|
||||
} else if( alignment == Center ) {
|
||||
output->Text( canvas, text,
|
||||
x + ( ( textWidth - strlen( text ) ) * f->Width( "n" ) ) / 2 + pad,
|
||||
y + pad );
|
||||
} else {
|
||||
output->Text( canvas, text, x + pad, y + pad );
|
||||
}
|
||||
} else {
|
||||
output->Text( canvas, text, x + pad, y + pad );
|
||||
}
|
||||
if( highlighted ) {
|
||||
output->SetColors( output->GetBgColor(), output->GetFgColor() );
|
||||
}
|
||||
output->NoClip();
|
||||
}
|
||||
|
||||
void myLabel::Highlight( boolean b ) {
|
||||
if( highlighted != b ) {
|
||||
highlighted = b;
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* myLabel - display a string of text
|
||||
*/
|
||||
|
||||
#ifndef mylabel_h
|
||||
#define mylabel_h
|
||||
|
||||
#include <IV-2_6/InterViews/interactor.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
class myLabel : public Interactor {
|
||||
public:
|
||||
myLabel(
|
||||
const char* msg, Alignment al = Center, int width = 0, int pad_ = 0,
|
||||
int hstretch = 0, int vstretch = 0
|
||||
);
|
||||
myLabel(
|
||||
char* msg, Alignment al = Center, int width = 0, int pad_ = 0,
|
||||
int hstretch = 0, int vstretch = 0
|
||||
);
|
||||
myLabel(
|
||||
const char* name,
|
||||
const char* msg, Alignment al = Center, int width = 0, int pad_ = 0,
|
||||
int hstretch = 0, int vstretch = 0
|
||||
);
|
||||
myLabel(
|
||||
const char* name,
|
||||
char* msg, Alignment al = Center, int width = 0, int pad_ = 0,
|
||||
int hstretch = 0, int vstretch = 0
|
||||
);
|
||||
|
||||
virtual void Highlight(boolean);
|
||||
virtual void Realign(Alignment);
|
||||
protected:
|
||||
const char* text;
|
||||
Alignment alignment : 16;
|
||||
unsigned pad : 15;
|
||||
boolean highlighted : 1;
|
||||
int textWidth;
|
||||
|
||||
virtual void Reconfig();
|
||||
virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord);
|
||||
private:
|
||||
void Init(Alignment, int width, int pad,
|
||||
int hstretch, int vstretch);
|
||||
};
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,176 +0,0 @@
|
||||
/*
|
||||
* FileChooser implementation.
|
||||
*/
|
||||
|
||||
#include <InterViews/event.h>
|
||||
|
||||
#include <IV-2_6/InterViews/adjuster.h>
|
||||
#include <IV-2_6/InterViews/border.h>
|
||||
#include <IV-2_6/InterViews/box.h>
|
||||
#include <IV-2_6/InterViews/button.h>
|
||||
#include <IV-2_6/InterViews/filechooser.h>
|
||||
#include <IV-2_6/InterViews/frame.h>
|
||||
#include <IV-2_6/InterViews/glue.h>
|
||||
#include <IV-2_6/InterViews/message.h>
|
||||
#include <IV-2_6/InterViews/scroller.h>
|
||||
#include <IV-2_6/InterViews/sensor.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <listitemchooser.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
void ListItemChooser::Init( ButtonState * bs, const char * boxtitle,
|
||||
int r, int c, const char * acptLbl ) {
|
||||
input = new Sensor;
|
||||
input->Reference();
|
||||
// input->Catch(DownEvent);
|
||||
input->Catch( KeyEvent );
|
||||
|
||||
state = bs;
|
||||
if( *boxtitle == '\0' ) {
|
||||
title = new MarginFrame( new VGlue( 0, 0 ) );
|
||||
} else {
|
||||
title = new MarginFrame( new Message( boxtitle ) );
|
||||
}
|
||||
_browser = new MyStringBrowser( bs, r, c );
|
||||
_cancelBut = new PushButton( "Cancel", state, CANCEL_VAL );
|
||||
_acceptBut = new PushButton( acptLbl, state, '\r' );
|
||||
}
|
||||
|
||||
ListItemChooser::ListItemChooser(
|
||||
ButtonState * bs, const char * boxtitle, int r, int c,
|
||||
const char * acceptLabel, Alignment a ) : Dialog( bs, nil, a ) {
|
||||
Init( bs, boxtitle, r, c, acceptLabel );
|
||||
Scene::Insert( Interior() );
|
||||
}
|
||||
|
||||
ListItemChooser::ListItemChooser(
|
||||
const char * name, ButtonState * bs, const char * boxtitle,
|
||||
int r, int c, const char * acceptLabel, Alignment a )
|
||||
: Dialog( name, bs, nil, a ) {
|
||||
SetInstance( name );
|
||||
Init( bs, boxtitle, r, c, acceptLabel );
|
||||
Scene::Insert( Interior() );
|
||||
|
||||
}
|
||||
|
||||
ListItemChooser::~ListItemChooser() {
|
||||
input->unref();
|
||||
};
|
||||
|
||||
// loop until an item is chosen
|
||||
boolean ListItemChooser::Accept() {
|
||||
Event e;
|
||||
int v;
|
||||
|
||||
state->SetValue( 0 );
|
||||
v = 0;
|
||||
do {
|
||||
Read( e );
|
||||
// this dialog box will hog probe input until a selection is made
|
||||
// (either select or quit) so check to see if an event
|
||||
// happened that this dialog box cares about. i.e. did anything
|
||||
// inside the dialog box receive an event. I added the Movers and
|
||||
// the VScroller to this list since before they were being ignored.
|
||||
if( ( e.target == _cancelBut ) ||
|
||||
( e.target == _acceptBut ) ||
|
||||
( e.target == _upMover ) ||
|
||||
( e.target == _downMover ) ||
|
||||
( e.target == _vScroller )
|
||||
) {
|
||||
e.target->Handle( e );
|
||||
} else if( ( e.eventType == KeyEvent ) ||
|
||||
( e.target == _browser ) ) {
|
||||
_browser->Handle( e );
|
||||
}
|
||||
/*
|
||||
if(e.target == _browser)
|
||||
_browser->Handle(e);
|
||||
else if(e.target == _cancelBut)
|
||||
_cancelBut->Handle(e);
|
||||
else if(e.target == _acceptBut)
|
||||
_acceptBut->Handle(e);
|
||||
*/
|
||||
state->GetValue( v );
|
||||
} while( v == 0 && e.target != nil );
|
||||
return ( v && v != CANCEL_VAL ) || e.target == nil;
|
||||
/*
|
||||
boolean accepted, dirSelected;
|
||||
do {
|
||||
accepted = StringChooser::Accept();
|
||||
dirSelected = Browser()->IsADirectory(Choice());
|
||||
} while (accepted && dirSelected);
|
||||
return accepted;
|
||||
*/
|
||||
}
|
||||
|
||||
static void ChangeMsg( const char * name, MarginFrame * frame ) {
|
||||
Interactor * msg;
|
||||
|
||||
if( *name == '\0' ) {
|
||||
msg = new VGlue( 0, 0 );
|
||||
} else {
|
||||
msg = new Message( name );
|
||||
}
|
||||
frame->Insert( msg );
|
||||
frame->Change( msg );
|
||||
}
|
||||
|
||||
void ListItemChooser::SetTitle( const char * name ) {
|
||||
ChangeMsg( name, title );
|
||||
}
|
||||
|
||||
Interactor * ListItemChooser::AddScroller( Interactor * i ) {
|
||||
return new HBox(
|
||||
new MarginFrame( i, 2 ),
|
||||
new VBorder,
|
||||
new VBox(
|
||||
new UpMover( i, 1 ),
|
||||
new HBorder,
|
||||
new VScroller( i ),
|
||||
new HBorder,
|
||||
new DownMover( i, 1 )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Interactor * ListItemChooser::Interior() {
|
||||
const int space = round( .5 * cm );
|
||||
HBox * titleblock = new HBox( title, new HGlue );
|
||||
|
||||
_upMover = new UpMover( _browser, 1 );
|
||||
_vScroller = new VScroller( _browser );
|
||||
_downMover = new DownMover( _browser, 1 );
|
||||
|
||||
return new MarginFrame(
|
||||
new VBox(
|
||||
titleblock,
|
||||
new VGlue( space, 0 ),
|
||||
// new Frame(AddScroller(_browser)),
|
||||
new Frame(
|
||||
new HBox(
|
||||
new MarginFrame( _browser, 2 ),
|
||||
new VBorder,
|
||||
new VBox(
|
||||
_upMover,
|
||||
new HBorder,
|
||||
_vScroller,
|
||||
new HBorder,
|
||||
_downMover
|
||||
)
|
||||
)
|
||||
),
|
||||
new VGlue( space, 0 ),
|
||||
new HBox(
|
||||
// new VGlue(space, 0),
|
||||
new HGlue,
|
||||
_cancelBut,
|
||||
new HGlue( space, 0 ),
|
||||
_acceptBut
|
||||
)
|
||||
), space, space / 2, 0
|
||||
);
|
||||
}
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* ListItemChooser - a StringChooser for choosing an item from a list.
|
||||
*/
|
||||
|
||||
#ifndef listitemchooser_h
|
||||
#define listitemchooser_h
|
||||
|
||||
#include <IV-2_6/InterViews/button.h>
|
||||
#include <IV-2_6/InterViews/dialog.h>
|
||||
#include <IV-2_6/InterViews/frame.h>
|
||||
#include <IV-2_6/InterViews/scroller.h>
|
||||
#include <mystrbrowser.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
#define CANCEL_VAL ('\007')
|
||||
|
||||
class UpMover;
|
||||
class DownMover;
|
||||
class Vscroller;
|
||||
|
||||
class ListItemChooser : public Dialog {
|
||||
public:
|
||||
ListItemChooser(ButtonState* bs,
|
||||
const char* boxtitle = "Please select one of the following:",
|
||||
int rows = 10, int cols = 24,
|
||||
const char* acceptLabel = " Choose ", Alignment = Center
|
||||
);
|
||||
ListItemChooser(const char* name, ButtonState* bs,
|
||||
const char* boxtitle = "Please select one of the following:",
|
||||
int rows = 10, int cols = 24,
|
||||
const char* acceptLabel = " Choose ", Alignment = Center
|
||||
);
|
||||
virtual ~ListItemChooser();
|
||||
|
||||
void SetTitle(const char*);
|
||||
|
||||
virtual boolean Accept(); // loop until an item is chosen
|
||||
int Choice(); // return the index of the selected line
|
||||
char* String(int index); // return the text for the line at index
|
||||
int Count() // return the num of entries in the browser
|
||||
{ return _browser->Count(); }
|
||||
void Select(int index); // select one of the entries in the list
|
||||
void Browse(); // initiate the selecting process for the user
|
||||
|
||||
void Insert(const char* line, int index);
|
||||
void Append(const char* line);
|
||||
void Remove(int index);
|
||||
MyStringBrowser* Browser();
|
||||
|
||||
protected:
|
||||
void Init (ButtonState* bs, const char* title, int r, int c,
|
||||
const char* acptlbl);
|
||||
Interactor* Interior();
|
||||
Interactor* AddScroller(Interactor*);
|
||||
|
||||
protected:
|
||||
MarginFrame* title;
|
||||
MyStringBrowser* _browser;
|
||||
PushButton *_cancelBut;
|
||||
PushButton *_acceptBut;
|
||||
|
||||
UpMover *_upMover;
|
||||
DownMover *_downMover;
|
||||
VScroller *_vScroller;
|
||||
};
|
||||
|
||||
inline MyStringBrowser* ListItemChooser::Browser () { return _browser; }
|
||||
|
||||
// return the index of the selected line
|
||||
inline int ListItemChooser::Choice()
|
||||
{ return _browser->Selection(); }
|
||||
|
||||
// return the text for the line at index
|
||||
inline char* ListItemChooser::String(int index)
|
||||
{ return _browser->String(index); }
|
||||
|
||||
// initiate the selecting process for the user
|
||||
inline void ListItemChooser::Browse()
|
||||
{ _browser->Browse(); }
|
||||
|
||||
// select one of the entries in the list
|
||||
inline void ListItemChooser::Select(int index)
|
||||
{ _browser->Select(index); }
|
||||
|
||||
inline void ListItemChooser::Insert(const char* line, int index)
|
||||
{ _browser->Insert(line, index); }
|
||||
|
||||
inline void ListItemChooser::Append(const char* line)
|
||||
{ _browser->Append(line); }
|
||||
|
||||
inline void ListItemChooser::Remove(int index)
|
||||
{ _browser->Remove(index); }
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,181 +0,0 @@
|
||||
|
||||
/* ivfasd/listmgrcore.c */
|
||||
|
||||
|
||||
/*
|
||||
* ListMgrCore - an object that let's you manage a list. Meaning that you
|
||||
* can mark an entry on the list for:
|
||||
* 1) v(iew) or m(odify)
|
||||
* 2) r(eplicate) or d(elete)
|
||||
* 3) p(rint)
|
||||
* 4) c(hoose)
|
||||
* 5) h(ide)
|
||||
* 6) s(ave complete)
|
||||
* 7) i(save incomplete)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
|
||||
#include <listmgrcore.h> // ivfasd/listmgrcore.h
|
||||
|
||||
|
||||
void ListMgrCore::WriteChar( char c, int col, int index ) {
|
||||
strbuf[index][col] = c;
|
||||
display->ReplaceText( index, strbuf[index], strlen( strbuf[index] ) );
|
||||
display->Style( index, 0, index, columns, Plain );
|
||||
};
|
||||
//////////////////////////////////////////
|
||||
|
||||
void ListMgrCore::Insert( const char * s, int index ) {
|
||||
int len = strlen( s ) + 1 + opColumns;
|
||||
char * sCopy = new char[len];
|
||||
|
||||
memset( sCopy, ' ', opColumns );
|
||||
// memset(sCopy, ' ', opColumns);
|
||||
// bcopy(s, sCopy + opColumns, strlen(s) + 1); // non ANSI
|
||||
// the 1st two operands are reversed from bcopy. memcpy() is ANSI
|
||||
// memcpy is o.k. since memory areas do not overlap - DAS
|
||||
memcpy( sCopy + opColumns, s, strlen( s ) + 1 );
|
||||
MyStringBrowser::Insert( sCopy, index );
|
||||
|
||||
delete [] sCopy;
|
||||
}
|
||||
//////////////////////////////////////////
|
||||
|
||||
void ListMgrCore::Append( const char * s ) {
|
||||
Insert( s, strcount );
|
||||
}
|
||||
//////////////////////////////////////////
|
||||
|
||||
void ListMgrCore::ReplaceText( const char * s, int index ) {
|
||||
int len = strlen( s ) + 1 + opColumns;
|
||||
char * sCopy = new char[len];
|
||||
|
||||
// memset(sCopy, ' ', opColumns);
|
||||
strncpy( sCopy, MyStringBrowser::String( index ), opColumns );
|
||||
// sCopy[opColumns] = '\0';
|
||||
// bcopy(s, sCopy + opColumns, strlen(s) + 1); // non ANSI
|
||||
// the 1st two operands are reversed from bcopy. memcpy() is ANSI
|
||||
// memcpy is o.k. since memory areas do not overlap - DAS
|
||||
memcpy( sCopy + opColumns, s, strlen( s ) + 1 );
|
||||
MyStringBrowser::ReplaceText( sCopy, index );
|
||||
|
||||
delete [] sCopy;
|
||||
}
|
||||
//////////////////////////////////////////
|
||||
|
||||
char * ListMgrCore::String( int index ) {
|
||||
return MyStringBrowser::String( index ) + opColumns;
|
||||
}
|
||||
|
||||
char * ListMgrCore::CmdString( int index, char * str, int strSize ) {
|
||||
if( strSize > opColumns ) {
|
||||
strncpy( str, MyStringBrowser::String( index ), opColumns );
|
||||
str[opColumns] = '\0';
|
||||
} else {
|
||||
strncpy( str, MyStringBrowser::String( index ), strSize );
|
||||
str[strSize - 1] = '\0';
|
||||
}
|
||||
return str;
|
||||
}
|
||||
//////////////////////////////////////////
|
||||
|
||||
// if found, returns the position of 'ch' in the cmd string at 'index'
|
||||
// otherwise returns -1
|
||||
|
||||
int ListMgrCore::InCmdString( char ch, int index ) {
|
||||
int len = opColumns + 1;
|
||||
char * str = new char[len];
|
||||
|
||||
CmdString( index, str, opColumns + 1 );
|
||||
char * strptr = strchr( str, ch );
|
||||
|
||||
if( strptr ) {
|
||||
int rindex = strptr - str;
|
||||
delete [] str;
|
||||
return rindex;
|
||||
}
|
||||
delete [] str;
|
||||
return -1;
|
||||
}
|
||||
//////////////////////////////////////////
|
||||
|
||||
void ListMgrCore::Init( lmCommand * CmdArray, int arraySize ) {
|
||||
SetClassName( "ListMgrCore" );
|
||||
opColumns = 0;
|
||||
|
||||
lmCmdArray = CmdArray;
|
||||
lmCmdStr = new char[arraySize + 1];
|
||||
int i;
|
||||
for( i = 0; i < arraySize; i++ ) {
|
||||
lmCmdStr[i] = lmCmdArray[i].cmdChar;
|
||||
opColumns = max( opColumns, lmCmdArray[i].cmdCol );
|
||||
}
|
||||
lmCmdStr[i] = '\0';
|
||||
opColumns++; // cols start at zero, so add 1 to total columns
|
||||
}
|
||||
//////////////////////////////////////////
|
||||
|
||||
boolean ListMgrCore::HandleCharExtra( char c ) {
|
||||
int index = Selection();
|
||||
if( index >= 0 ) {
|
||||
// since g++ is missing strpos() use strchr() work around.
|
||||
char * cmdIndexPtr = strchr( ( const char * )lmCmdStr, c );
|
||||
int cmdIndex = -1;
|
||||
if( cmdIndexPtr ) {
|
||||
cmdIndex = cmdIndexPtr - lmCmdStr;
|
||||
}
|
||||
|
||||
if( cmdIndex >= 0 ) {
|
||||
DoCommand( lmCmdArray[cmdIndex], index );
|
||||
return true;
|
||||
} else {
|
||||
if( strchr( done, c ) == nil ) {
|
||||
printf( "index %d invalid char '%c'\n", index, c );
|
||||
}
|
||||
}
|
||||
|
||||
// char* copy = new char[strlen(s)+1];
|
||||
// strcpy(copy, s);
|
||||
|
||||
// display->ReplaceText(index, s, strlen(s));
|
||||
|
||||
} else {
|
||||
printf( "no Selections\n" );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//////////////////////////////////////////
|
||||
|
||||
void ListMgrCore::DoCommand( lmCommand lm, int index ) {
|
||||
printf( "ListMgrCore doCommand() - char '%c', col: %d, index: %d\n",
|
||||
lm.cmdChar, lm.cmdCol, index );
|
||||
};
|
||||
|
||||
/*
|
||||
void ListMgrCore::Save(int index)
|
||||
{
|
||||
}
|
||||
|
||||
void ListMgrCore::Delete(int index)
|
||||
{
|
||||
}
|
||||
|
||||
void ListMgrCore::Print(int index)
|
||||
{
|
||||
}
|
||||
|
||||
void ListMgrCore::Unmark(int index)
|
||||
{
|
||||
}
|
||||
|
||||
void ListMgrCore::Choose(int index)
|
||||
{
|
||||
}
|
||||
|
||||
void ListMgrCore::
|
||||
{
|
||||
}
|
||||
*/
|
||||
@@ -1,123 +0,0 @@
|
||||
|
||||
/* ivfasd/listmgrcore.c */
|
||||
|
||||
/*
|
||||
* ListMgrCore - an object that let's you manage a list. Meaning that you
|
||||
* can mark an entry on the list for:
|
||||
* 1) v(iew) or m(odify)
|
||||
* 2) r(eplicate) or d(elete)
|
||||
* 3) p(rint)
|
||||
* 4) c(hoose)
|
||||
* 5) h(ide)
|
||||
* 6) s(ave complete)
|
||||
* 7) i(save incomplete)
|
||||
*/
|
||||
|
||||
#ifndef listmgrcore_h
|
||||
#define listmgrcore_h
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <IV-2_6/InterViews/button.h>
|
||||
#include <IV-2_6/InterViews/interactor.h>
|
||||
|
||||
#include <mystrbrowser.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
//typedef void (*ListMgrCore::lmFunc)();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// lmCommand class
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class lmCommand {
|
||||
public:
|
||||
lmCommand(char ch, int col) { cmdChar = ch; cmdCol = col; }
|
||||
~lmCommand() {};
|
||||
|
||||
char cmdChar;
|
||||
int cmdCol;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ListMgrCore class
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ListMgrCore : public MyStringBrowser {
|
||||
public:
|
||||
ListMgrCore(ButtonState* bs, int Rows, int Cols,
|
||||
lmCommand *CmdArray, int arraySize,
|
||||
const char* Done = mySBDone);
|
||||
ListMgrCore (const char* name, ButtonState* bs, int Rows, int Cols,
|
||||
lmCommand *CmdArray, int arraySize,
|
||||
const char* Done = mySBDone);
|
||||
virtual ~ListMgrCore() { };
|
||||
|
||||
virtual void Insert(const char*, int index);
|
||||
virtual void Append(const char*);
|
||||
virtual void ReplaceText(const char* s, int index);
|
||||
virtual char* String(int index); // returns the data portion of the line
|
||||
// returns the command portion of the line
|
||||
virtual char* CmdString(int index, char *str, int strSize);
|
||||
virtual int InCmdString(char ch, int index);
|
||||
|
||||
virtual void DoCommand(lmCommand lm, int index) ;
|
||||
virtual void WriteChar(char c, int col, int index);
|
||||
virtual int MaxIndex() { return strcount - 1; }
|
||||
virtual int Count() { return strcount; }
|
||||
|
||||
protected:
|
||||
// used to implement extra char bindings in subclasses
|
||||
virtual boolean HandleCharExtra(char);
|
||||
void DoNothing() { printf("did nothing\n"); };
|
||||
|
||||
protected:
|
||||
// the number of columns in Cmd portion of the display
|
||||
int opColumns;
|
||||
// a string that has all the keystrokes accepted as commands;
|
||||
// it's used for querying for valid keystrokes on key events;
|
||||
// the position of the char in this string corresponds to the
|
||||
// position of the corresponding lmCommand in lmCmdArray
|
||||
char *lmCmdStr;
|
||||
// an array of entries containing valid keystrokes and where
|
||||
// they will be written in the Cmd portion of the display
|
||||
lmCommand *lmCmdArray;
|
||||
private:
|
||||
void Init(lmCommand *CmdArray, int arraySize);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ListMgrCore inline member functions
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline ListMgrCore::ListMgrCore(
|
||||
ButtonState* bs, int Rows, int Cols,
|
||||
lmCommand *LmCmdArray, int arraySize, const char* Done) :
|
||||
MyStringBrowser(bs, Rows, Cols, true, Reversed, Done)
|
||||
{
|
||||
Init(LmCmdArray, arraySize);
|
||||
}
|
||||
//////////////////////////////////////////
|
||||
|
||||
inline ListMgrCore::ListMgrCore (
|
||||
const char* name, ButtonState* bs, int Rows, int Cols,
|
||||
lmCommand *LmCmdArray, int arraySize, const char* Done) :
|
||||
MyStringBrowser(bs, Rows, Cols, true, Reversed, Done)
|
||||
{
|
||||
SetInstance(name);
|
||||
Init(LmCmdArray, arraySize);
|
||||
}
|
||||
//////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,909 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Button management.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <InterViews/bitmap.h>
|
||||
#include <InterViews/cursor.h>
|
||||
#include <InterViews/font.h>
|
||||
#include <InterViews/pattern.h>
|
||||
|
||||
#include <IV-2_6/InterViews/button.h>
|
||||
#include <IV-2_6/InterViews/painter.h>
|
||||
#include <IV-2_6/InterViews/sensor.h>
|
||||
#include <IV-2_6/InterViews/shape.h>
|
||||
#include <IV-2_6/InterViews/subject.h>
|
||||
|
||||
#include <OS/math.h>
|
||||
|
||||
#include <mybutton.h>
|
||||
|
||||
static Cursor * origCursor = 0;
|
||||
static Cursor * handCursor = 0;
|
||||
|
||||
#include <InterViews/Bitmaps/radioBoth.bm>
|
||||
#include <InterViews/Bitmaps/radioChosen.bm>
|
||||
#include <InterViews/Bitmaps/radioHit.bm>
|
||||
#include <InterViews/Bitmaps/radioMask.bm>
|
||||
#include <InterViews/Bitmaps/radio.bm>
|
||||
|
||||
#include <InterViews/Bitmaps/hand.bm>
|
||||
#include <InterViews/Bitmaps/handMask.bm>
|
||||
|
||||
#include <fasdBitmaps/m.bm>
|
||||
#include <fasdBitmaps/mHit.bm>
|
||||
#include <fasdBitmaps/v.bm>
|
||||
#include <fasdBitmaps/vHit.bm>
|
||||
#include <fasdBitmaps/mvmask.bm>
|
||||
|
||||
#include <fasdBitmaps/pin2mask.bm> // mask
|
||||
// not hit, not pinned - hollow circle with tack
|
||||
#include <fasdBitmaps/pinout2.bm>
|
||||
// hit & not pinned - thick hollow circle with tack
|
||||
#include <fasdBitmaps/pinout2Hit.bm>
|
||||
// not hit, pinned - hollow circle with tack pushed in
|
||||
#include <fasdBitmaps/pinin2.bm>
|
||||
// hit & pinned - thick hollow circle with tack pushed in
|
||||
#include <fasdBitmaps/pinin2Hit.bm>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
static const int sep = 3;
|
||||
static const int pad = 3;
|
||||
|
||||
inline int HalfRadioButtonSize( int h ) {
|
||||
return Math::round( .4 * h );
|
||||
}
|
||||
inline int HalfCheckBoxSize( int h ) {
|
||||
return Math::round( .4 * h );
|
||||
}
|
||||
|
||||
/*
|
||||
* A mybutton has a ButtonState subject that it modifies when pressed.
|
||||
* Also, a mybutton may have associated buttons that are enabled/disabled
|
||||
* when it is chosen/unchosen.
|
||||
*/
|
||||
|
||||
void MyButton::Init() {
|
||||
SetClassName( "MyButton" );
|
||||
}
|
||||
|
||||
MyButton::MyButton( ButtonState * s, void * v ) : Button( s, v ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyButton::MyButton( const char * name, ButtonState * s, void * v ) : Button( s, v ) {
|
||||
SetInstance( name );
|
||||
Init();
|
||||
}
|
||||
|
||||
/*
|
||||
MyButton::MyButton (Painter* out, ButtonState* s, void* v) : Button(out, s, v)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
*/
|
||||
|
||||
MyButton::~MyButton() {
|
||||
}
|
||||
|
||||
void MyButton::Handle( register Event & e ) {
|
||||
if( !origCursor ) {
|
||||
origCursor = GetCursor();
|
||||
}
|
||||
if( handCursor == nil ) {
|
||||
int handHotx = 7; // The Bitmap object seems to have changed how the
|
||||
int handHoty = 1; // coords for hot spot is calculated. DAS
|
||||
// Used to be x = 7, y = 14. i.e. 0,0 is bottom left.
|
||||
// now 0,0 seems to be top left. bm is 16x16
|
||||
|
||||
handCursor = new Cursor(
|
||||
new Bitmap(
|
||||
/* put the hot spot at the finger tip */
|
||||
hand_bits, hand_width, hand_height, handHotx, handHoty
|
||||
// hand_bits, hand_width, hand_height, hand_x_hot, hand_y_hot
|
||||
),
|
||||
new Bitmap( hand_mask_bits, hand_mask_width, hand_mask_height ),
|
||||
output->GetFgColor(), output->GetBgColor()
|
||||
);
|
||||
}
|
||||
if( e.eventType == EnterEvent ) {
|
||||
SetCursor( handCursor );
|
||||
this->Flush();
|
||||
}
|
||||
// else (e.eventType == LeaveEvent)
|
||||
// SetCursor(origCursor);
|
||||
if( e.eventType == DownEvent && e.target == this ) {
|
||||
boolean inside = true;
|
||||
do {
|
||||
if( enabled && e.target == this ) {
|
||||
if( e.eventType == EnterEvent ) {
|
||||
SetCursor( handCursor );
|
||||
inside = true;
|
||||
} else if( e.eventType == LeaveEvent ) {
|
||||
SetCursor( origCursor );
|
||||
inside = false;
|
||||
}
|
||||
if( inside ) {
|
||||
if( !hit ) {
|
||||
hit = true;
|
||||
Refresh();
|
||||
}
|
||||
} else {
|
||||
if( hit ) {
|
||||
hit = false;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
Read( e );
|
||||
} while( e.eventType != UpEvent );
|
||||
if( hit ) {
|
||||
hit = false;
|
||||
Refresh();
|
||||
}
|
||||
if( enabled && inside ) {
|
||||
Press();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void MyTextButton::Init( const char * str ) {
|
||||
SetClassName( "MyTextButton" );
|
||||
if( str == nil ) {
|
||||
text = nil;
|
||||
} else {
|
||||
text = new char[strlen( str ) + 1];
|
||||
strcpy( text, str );
|
||||
}
|
||||
background = nil;
|
||||
grayout = nil;
|
||||
}
|
||||
|
||||
MyTextButton::MyTextButton( const char * str, ButtonState * s, void * v )
|
||||
: MyButton( s, v ) {
|
||||
Init( str );
|
||||
}
|
||||
|
||||
MyTextButton::MyTextButton(
|
||||
const char * name, const char * str, ButtonState * s, void * v )
|
||||
: MyButton( name, s, v ) {
|
||||
Init( str );
|
||||
}
|
||||
|
||||
/*
|
||||
MyTextButton::MyTextButton (
|
||||
const char* str, ButtonState* s, void* v, Painter* out)
|
||||
: MyButton(out, s, v)
|
||||
{
|
||||
Init(str);
|
||||
}
|
||||
*/
|
||||
|
||||
void MyTextButton::Reconfig() {
|
||||
const char * a = GetAttribute( "text" );
|
||||
if( a != nil ) {
|
||||
delete text;
|
||||
text = new char[strlen( a ) + 1];
|
||||
strcpy( text, a );
|
||||
}
|
||||
}
|
||||
|
||||
void MyTextButton::MakeBackground() {
|
||||
Unref( background );
|
||||
background = new Painter( output );
|
||||
background->Reference();
|
||||
background->SetColors( output->GetBgColor(), output->GetFgColor() );
|
||||
|
||||
static Pattern * gray_pat;
|
||||
if( gray_pat == nil ) {
|
||||
gray_pat = new Pattern( Pattern::gray );
|
||||
gray_pat->Reference();
|
||||
}
|
||||
Unref( grayout );
|
||||
grayout = new Painter( background );
|
||||
grayout->Reference();
|
||||
grayout->SetPattern( gray_pat );
|
||||
grayout->FillBg( false );
|
||||
}
|
||||
|
||||
void MyTextButton::MakeShape() {
|
||||
if( text != nil ) {
|
||||
const Font * f = output->GetFont();
|
||||
shape->width += f->Width( text );
|
||||
shape->height += f->Height();
|
||||
}
|
||||
shape->Rigid();
|
||||
}
|
||||
|
||||
MyTextButton::~MyTextButton() {
|
||||
delete text;
|
||||
Unref( background );
|
||||
Unref( grayout );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void MyPushButton::Init() {
|
||||
SetClassName( "MyPushButton" );
|
||||
}
|
||||
|
||||
MyPushButton::MyPushButton(
|
||||
const char * str, ButtonState * s, int v ) : MyTextButton( str, s, ( void * )v ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyPushButton::MyPushButton(
|
||||
const char * str, ButtonState * s, void * v ) : MyTextButton( str, s, v ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyPushButton::MyPushButton(
|
||||
const char * name, const char * str, ButtonState * s, int v )
|
||||
: MyTextButton( name, str, s, ( void * )v ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyPushButton::MyPushButton(
|
||||
const char * name, const char * str, ButtonState * s, void * v )
|
||||
: MyTextButton( name, str, s, v ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
/*
|
||||
MyPushButton::MyPushButton (
|
||||
const char* str, ButtonState* s, int v, Painter* out)
|
||||
: MyTextButton(str, s, (void*)v, out)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
MyPushButton::MyPushButton (
|
||||
const char* str, ButtonState* s, void* v, Painter* out)
|
||||
: MyTextButton(str, s, v, out)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
*/
|
||||
|
||||
MyPushButton::~MyPushButton() { }
|
||||
|
||||
void MyPushButton::Reconfig() {
|
||||
MyTextButton::Reconfig();
|
||||
MakeBackground();
|
||||
if( shape->Undefined() ) {
|
||||
MakeShape();
|
||||
shape->width += output->GetFont()->Width( " " );
|
||||
shape->height += 2 * pad;
|
||||
}
|
||||
}
|
||||
|
||||
void MyPushButton::Redraw( IntCoord x1, IntCoord y1,
|
||||
IntCoord x2, IntCoord y2 ) {
|
||||
output->ClearRect( canvas, x1, y1, x2, y2 );
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void MyPushButton::Refresh() {
|
||||
register int r;
|
||||
IntCoord x[16], y[16];
|
||||
IntCoord tx, ty;
|
||||
|
||||
r = Math::min( 10 * pixels, Math::min( xmax + 1, ymax + 1 ) / 6 );
|
||||
x[0] = 0;
|
||||
y[0] = r;
|
||||
x[1] = 0;
|
||||
y[1] = r + r;
|
||||
x[2] = 0;
|
||||
y[2] = ymax - r - r;
|
||||
x[3] = 0;
|
||||
y[3] = ymax - r;
|
||||
x[4] = r;
|
||||
y[4] = ymax;
|
||||
x[5] = r + r;
|
||||
y[5] = ymax;
|
||||
x[6] = xmax - r - r;
|
||||
y[6] = ymax;
|
||||
x[7] = xmax - r;
|
||||
y[7] = ymax;
|
||||
x[8] = xmax;
|
||||
y[8] = ymax - r;
|
||||
x[9] = xmax;
|
||||
y[9] = ymax - r - r;
|
||||
x[10] = xmax;
|
||||
y[10] = r + r;
|
||||
x[11] = xmax;
|
||||
y[11] = r;
|
||||
x[12] = xmax - r;
|
||||
y[12] = 0;
|
||||
x[13] = xmax - r - r;
|
||||
y[13] = 0;
|
||||
x[14] = r + r;
|
||||
y[14] = 0;
|
||||
x[15] = r;
|
||||
y[15] = 0;
|
||||
tx = ( xmax - output->GetFont()->Width( text ) ) / 2;
|
||||
ty = pad;
|
||||
if( chosen || hit ) {
|
||||
output->FillBSpline( canvas, x, y, 16 );
|
||||
background->Text( canvas, text, tx, ty );
|
||||
} else {
|
||||
background->FillRect( canvas, 0, 0, xmax, ymax );
|
||||
output->ClosedBSpline( canvas, x, y, 16 );
|
||||
output->Text( canvas, text, tx, ty );
|
||||
}
|
||||
if( !enabled ) {
|
||||
grayout->FillRect( canvas, 0, 0, xmax, ymax );
|
||||
}
|
||||
}
|
||||
|
||||
static Bitmap * myRadioMask;
|
||||
static Bitmap * myRadioPlain;
|
||||
static Bitmap * myRadioHit;
|
||||
static Bitmap * myRadioChosen;
|
||||
static Bitmap * myRadioBoth;
|
||||
|
||||
void MyRadioButton::Init() {
|
||||
SetClassName( "MyRadioButton" );
|
||||
}
|
||||
|
||||
MyRadioButton::MyRadioButton(
|
||||
const char * str, ButtonState * s, int v ) : MyTextButton( str, s, ( void * )v ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyRadioButton::MyRadioButton(
|
||||
const char * str, ButtonState * s, void * v ) : MyTextButton( str, s, v ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyRadioButton::MyRadioButton(
|
||||
const char * name, const char * str, ButtonState * s, int v )
|
||||
: MyTextButton( name, str, s, ( void * )v ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyRadioButton::MyRadioButton(
|
||||
const char * name, const char * str, ButtonState * s, void * v )
|
||||
: MyTextButton( name, str, s, v ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
/*
|
||||
MyRadioButton::MyRadioButton (
|
||||
const char* str, ButtonState* s, int v, Painter* out)
|
||||
: MyTextButton(str, s, (void*)v, out)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
MyRadioButton::MyRadioButton (
|
||||
const char* str, ButtonState* s, void* v, Painter* out)
|
||||
: MyTextButton(str, s, v, out)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
*/
|
||||
|
||||
MyRadioButton::~MyRadioButton() { }
|
||||
|
||||
void MyRadioButton::Reconfig() {
|
||||
MyTextButton::Reconfig();
|
||||
MakeBackground();
|
||||
if( shape->Undefined() ) {
|
||||
MakeShape();
|
||||
shape->width += shape->height + sep;
|
||||
}
|
||||
if( myRadioMask == nil ) {
|
||||
myRadioMask = new Bitmap(
|
||||
radio_mask_bits, radio_mask_width, radio_mask_height
|
||||
);
|
||||
myRadioMask->Reference();
|
||||
myRadioPlain = new Bitmap(
|
||||
radio_plain_bits, radio_plain_width, radio_plain_height
|
||||
);
|
||||
myRadioPlain->Reference();
|
||||
myRadioHit = new Bitmap(
|
||||
radio_hit_bits, radio_hit_width, radio_hit_height
|
||||
);
|
||||
myRadioHit->Reference();
|
||||
myRadioChosen = new Bitmap(
|
||||
radio_chosen_bits, radio_chosen_width, radio_chosen_height
|
||||
);
|
||||
myRadioChosen->Reference();
|
||||
myRadioBoth = new Bitmap(
|
||||
radio_both_bits, radio_both_width, radio_both_height
|
||||
);
|
||||
myRadioBoth->Reference();
|
||||
}
|
||||
}
|
||||
|
||||
void MyRadioButton::Redraw( IntCoord x1, IntCoord y1,
|
||||
IntCoord x2, IntCoord y2 ) {
|
||||
int h = output->GetFont()->Height();
|
||||
int r = radio_plain_width;
|
||||
output->ClearRect( canvas, x1, y1, x2, y2 );
|
||||
Coord tx = r + sep;
|
||||
Coord ty = ( ymax + 1 - h ) / 2;
|
||||
output->Text( canvas, text, tx, ty );
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void MyRadioButton::Refresh() {
|
||||
IntCoord x = 0;
|
||||
IntCoord y = ( ymax + 1 - radio_plain_height ) / 2;
|
||||
if( !hit && !chosen ) {
|
||||
output->Stencil( canvas, x, y, myRadioPlain, myRadioMask );
|
||||
} else if( hit && !chosen ) {
|
||||
output->Stencil( canvas, x, y, myRadioHit, myRadioMask );
|
||||
} else if( !hit && chosen ) {
|
||||
output->Stencil( canvas, x, y, myRadioChosen, myRadioMask );
|
||||
} else if( hit && chosen ) {
|
||||
output->Stencil( canvas, x, y, myRadioBoth, myRadioMask );
|
||||
}
|
||||
if( !enabled ) {
|
||||
grayout->FillRect( canvas, 0, 0, xmax, ymax );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
static Bitmap* myCheckBoxMask;
|
||||
static Bitmap* myCheckBoxPlain;
|
||||
static Bitmap* myCheckBoxHit;
|
||||
static Bitmap* myCheckBoxChosen;
|
||||
static Bitmap* myCheckBoxBoth;
|
||||
*/
|
||||
|
||||
void MyCheckBox::Init( void * v ) {
|
||||
SetClassName( "MyCheckBox" );
|
||||
offvalue = v;
|
||||
}
|
||||
|
||||
MyCheckBox::MyCheckBox(
|
||||
const char * str, ButtonState * s, int on, int off )
|
||||
: MyTextButton( str, s, ( void * )on ) {
|
||||
Init( ( void * )off );
|
||||
}
|
||||
|
||||
MyCheckBox::MyCheckBox(
|
||||
const char * str, ButtonState * s, void * on, void * off )
|
||||
: MyTextButton( str, s, on ) {
|
||||
Init( off );
|
||||
}
|
||||
|
||||
MyCheckBox::MyCheckBox(
|
||||
const char * name, const char * str, ButtonState * s, int on, int off )
|
||||
: MyTextButton( name, str, s, ( void * )on ) {
|
||||
Init( ( void * )off );
|
||||
}
|
||||
|
||||
MyCheckBox::MyCheckBox(
|
||||
const char * name, const char * str, ButtonState * s, void * on, void * off )
|
||||
: MyTextButton( name, str, s, on ) {
|
||||
Init( off );
|
||||
}
|
||||
|
||||
/*
|
||||
MyCheckBox::MyCheckBox (
|
||||
const char* str, ButtonState* s, int on, int off, Painter* out)
|
||||
: MyTextButton(str, s, (void*)on, out)
|
||||
{
|
||||
Init((void*)off);
|
||||
}
|
||||
|
||||
MyCheckBox::MyCheckBox (
|
||||
const char* str, ButtonState* s, void* on, void* off, Painter* out)
|
||||
: MyTextButton(str, s, on, out)
|
||||
{
|
||||
Init(off);
|
||||
}
|
||||
*/
|
||||
|
||||
MyCheckBox::~MyCheckBox() { }
|
||||
|
||||
void MyCheckBox::Reconfig() {
|
||||
MyTextButton::Reconfig();
|
||||
MakeBackground();
|
||||
if( shape->Undefined() ) {
|
||||
MakeShape();
|
||||
shape->width += shape->height + sep;
|
||||
}
|
||||
Update();
|
||||
/*
|
||||
MakeBackground();
|
||||
if (shape->Undefined()) {
|
||||
MakeShape();
|
||||
shape->width += shape->height + sep;
|
||||
}
|
||||
if (myCheckBoxMask == nil) {
|
||||
myCheckBoxMask = new Bitmap(radio_mask_bits, radio_mask_width,
|
||||
radio_mask_height);
|
||||
myCheckBoxMask->Reference();
|
||||
myCheckBoxPlain = new Bitmap(
|
||||
radio_plain_bits, radio_plain_width, radio_plain_height
|
||||
);
|
||||
myCheckBoxPlain->Reference();
|
||||
myCheckBoxHit = new Bitmap(
|
||||
radio_hit_bits, radio_hit_width, radio_hit_height
|
||||
);
|
||||
myCheckBoxHit->Reference();
|
||||
myCheckBoxChosen = new Bitmap(
|
||||
radio_chosen_bits, radio_chosen_width, radio_chosen_height
|
||||
);
|
||||
myCheckBoxChosen->Reference();
|
||||
myCheckBoxBoth = new Bitmap(
|
||||
radio_both_bits, radio_both_width, radio_both_height
|
||||
);
|
||||
myCheckBoxBoth->Reference();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void MyCheckBox::Press() {
|
||||
if( chosen ) {
|
||||
subject->GetValue( value );
|
||||
subject->SetValue( offvalue );
|
||||
} else {
|
||||
subject->SetValue( value );
|
||||
}
|
||||
}
|
||||
|
||||
void MyCheckBox::Update() {
|
||||
void * v;
|
||||
|
||||
subject->GetValue( v );
|
||||
if( v != offvalue ) {
|
||||
Choose();
|
||||
value = v;
|
||||
} else {
|
||||
UnChoose();
|
||||
}
|
||||
}
|
||||
|
||||
void MyCheckBox::Redraw( IntCoord x1, IntCoord y1, IntCoord x2, IntCoord y2 ) {
|
||||
int h = output->GetFont()->Height();
|
||||
int t = HalfCheckBoxSize( h );
|
||||
output->ClearRect( canvas, x1, y1, x2, y2 );
|
||||
IntCoord tx = 2 * t + sep;
|
||||
IntCoord ty = ( ymax + 1 - h ) / 2;
|
||||
output->Text( canvas, text, tx, ty );
|
||||
Refresh();
|
||||
/*
|
||||
int h = output->GetFont()->Height();
|
||||
int r = radio_plain_width;
|
||||
output->ClearRect(canvas, x1, y1, x2, y2);
|
||||
Coord tx = r + sep;
|
||||
Coord ty = (ymax + 1 - h) / 2;
|
||||
output->Text(canvas, text, tx, ty);
|
||||
Refresh();
|
||||
*/
|
||||
}
|
||||
|
||||
void MyCheckBox::Refresh() {
|
||||
int h = output->GetFont()->Height();
|
||||
int t = HalfCheckBoxSize( h );
|
||||
IntCoord cx = t;
|
||||
IntCoord cy = ( ymax + 1 ) / 2;
|
||||
IntCoord left = cx - t;
|
||||
IntCoord right = cx + t;
|
||||
IntCoord bottom = cy - t;
|
||||
IntCoord top = cy + t;
|
||||
output->Rect( canvas, left, bottom, right, top );
|
||||
background->FillRect( canvas, left + 1, bottom + 1, right - 1, top - 1 );
|
||||
if( hit ) {
|
||||
output->Rect( canvas, left + 1, bottom + 1, right - 1, top - 1 );
|
||||
}
|
||||
if( chosen ) {
|
||||
output->Line( canvas, left, bottom, right, top );
|
||||
output->Line( canvas, left, top, right, bottom );
|
||||
}
|
||||
if( !enabled ) {
|
||||
grayout->FillRect( canvas, 0, 0, xmax, ymax );
|
||||
}
|
||||
/*
|
||||
Coord x = 0;
|
||||
Coord y = (ymax+1 - radio_plain_height)/2;
|
||||
if (!hit && !chosen) {
|
||||
output->Stencil(canvas, x, y, myCheckBoxPlain, myCheckBoxMask);
|
||||
} else if (hit && !chosen) {
|
||||
output->Stencil(canvas, x, y, myCheckBoxHit, myCheckBoxMask);
|
||||
} else if (!hit && chosen) {
|
||||
output->Stencil(canvas, x, y, myCheckBoxChosen, myCheckBoxMask);
|
||||
} else if (hit && chosen) {
|
||||
output->Stencil(canvas, x, y, myCheckBoxBoth, myCheckBoxMask);
|
||||
}
|
||||
if (!enabled) {
|
||||
grayout->FillRect(canvas, 0, 0, xmax, ymax);
|
||||
}
|
||||
*/
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static Bitmap * pin2mask;
|
||||
static Bitmap * pinin2;
|
||||
static Bitmap * pinin2Hit;
|
||||
static Bitmap * pinout2;
|
||||
static Bitmap * pinout2Hit;
|
||||
|
||||
void PinCheckBox::Init() {
|
||||
SetClassName( "PinCheckBox" );
|
||||
}
|
||||
|
||||
PinCheckBox::PinCheckBox(
|
||||
const char * str, ButtonState * s, int on, int off )
|
||||
: MyCheckBox( str, s, ( void * )on, ( void * )off ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
PinCheckBox::PinCheckBox(
|
||||
const char * str, ButtonState * s, void * on, void * off )
|
||||
: MyCheckBox( str, s, on, off ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
PinCheckBox::PinCheckBox(
|
||||
const char * name, const char * str, ButtonState * s, int on, int off )
|
||||
: MyCheckBox( name, str, s, ( void * )on, ( void * )off ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
PinCheckBox::PinCheckBox(
|
||||
const char * name, const char * str, ButtonState * s, void * on, void * off )
|
||||
: MyCheckBox( name, str, s, on, off ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
/*
|
||||
PinCheckBox::PinCheckBox (
|
||||
const char* str, ButtonState* s, int on, int off, Painter* out)
|
||||
: MyCheckBox(str, s, (void*)on, (void*)off, out)
|
||||
{
|
||||
Init ();
|
||||
}
|
||||
|
||||
PinCheckBox::PinCheckBox (
|
||||
const char* str, ButtonState* s, void* on, void* off, Painter* out)
|
||||
: MyCheckBox(str, s, on, off, out)
|
||||
{
|
||||
Init ();
|
||||
}
|
||||
*/
|
||||
|
||||
PinCheckBox::~PinCheckBox() { }
|
||||
|
||||
void PinCheckBox::Reconfig() {
|
||||
MyTextButton::Reconfig();
|
||||
MakeBackground();
|
||||
if( shape->Undefined() ) {
|
||||
MakeShape();
|
||||
// shape->width += shape->height + sep;
|
||||
shape->width += pinin2_width + sep;
|
||||
shape->height = pinin2_height;
|
||||
}
|
||||
if( pin2mask == nil ) {
|
||||
pin2mask = new Bitmap( pin2mask_bits, pin2mask_width,
|
||||
pin2mask_height );
|
||||
pin2mask->Reference();
|
||||
pinout2 = new Bitmap(
|
||||
pinout2_bits, pinout2_width, pinout2_height
|
||||
);
|
||||
pinout2->Reference();
|
||||
pinout2Hit = new Bitmap(
|
||||
pinout2Hit_bits, pinout2Hit_width, pinout2Hit_height
|
||||
);
|
||||
pinout2Hit->Reference();
|
||||
pinin2 = new Bitmap(
|
||||
pinin2_bits, pinin2_width, pinin2_height
|
||||
);
|
||||
pinin2->Reference();
|
||||
pinin2Hit = new Bitmap(
|
||||
pinin2Hit_bits, pinin2Hit_width, pinin2Hit_height
|
||||
);
|
||||
pinin2Hit->Reference();
|
||||
}
|
||||
MakeBackground();
|
||||
Update();
|
||||
}
|
||||
|
||||
void PinCheckBox::Redraw( IntCoord x1, IntCoord y1, IntCoord x2, IntCoord y2 ) {
|
||||
// int h = output->GetFont()->Height();
|
||||
int h = pinout2_height;
|
||||
int r = pinout2_width;
|
||||
output->ClearRect( canvas, x1, y1, x2, y2 );
|
||||
IntCoord tx = r + sep;
|
||||
IntCoord ty = ( ymax + 1 - h ) / 2;
|
||||
output->Text( canvas, text, tx, ty );
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void PinCheckBox::Refresh() {
|
||||
IntCoord x = 0;
|
||||
IntCoord y = ( ymax + 1 - pinout2_height ) / 2;
|
||||
if( !hit && !chosen ) {
|
||||
output->Stencil( canvas, x, y, pinout2, pin2mask );
|
||||
} else if( hit && !chosen ) {
|
||||
output->Stencil( canvas, x, y, pinin2Hit, pin2mask );
|
||||
// output->Stencil(canvas, x, y, pinout2Hit, pin2mask);
|
||||
} else if( !hit && chosen ) {
|
||||
output->Stencil( canvas, x, y, pinin2, pin2mask );
|
||||
} else if( hit && chosen ) {
|
||||
output->Stencil( canvas, x, y, pinout2Hit, pin2mask );
|
||||
// output->Stencil(canvas, x, y, pinin2Hit, pin2mask);
|
||||
}
|
||||
if( !enabled ) {
|
||||
grayout->FillRect( canvas, 0, 0, xmax, ymax );
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static Bitmap * MVCheckBoxMask;
|
||||
static Bitmap * ViewCheckBox;
|
||||
static Bitmap * ViewCheckBoxHit;
|
||||
static Bitmap * ModifyCheckBox;
|
||||
static Bitmap * ModifyCheckBoxHit;
|
||||
|
||||
void ModifyViewCheckBox::Init() {
|
||||
SetClassName( "ModifyViewCheckBox" );
|
||||
}
|
||||
|
||||
ModifyViewCheckBox::ModifyViewCheckBox(
|
||||
const char * str, ButtonState * s, int on, int off )
|
||||
: MyCheckBox( str, s, ( void * )on, ( void * )off ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
ModifyViewCheckBox::ModifyViewCheckBox(
|
||||
const char * str, ButtonState * s, void * on, void * off )
|
||||
: MyCheckBox( str, s, on, off ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
ModifyViewCheckBox::ModifyViewCheckBox(
|
||||
const char * name, const char * str, ButtonState * s, int on, int off )
|
||||
: MyCheckBox( name, str, s, ( void * )on, ( void * )off ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
ModifyViewCheckBox::ModifyViewCheckBox(
|
||||
const char * name, const char * str, ButtonState * s, void * on, void * off )
|
||||
: MyCheckBox( name, str, s, on, off ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
/*
|
||||
ModifyViewCheckBox::ModifyViewCheckBox (
|
||||
const char* str, ButtonState* s, int on, int off, Painter* out)
|
||||
: MyCheckBox(str, s, (void*)on, (void*)off, out)
|
||||
{
|
||||
Init ();
|
||||
}
|
||||
|
||||
ModifyViewCheckBox::ModifyViewCheckBox (
|
||||
const char* str, ButtonState* s, void* on, void* off, Painter* out)
|
||||
: MyCheckBox(str, s, on, off, out)
|
||||
{
|
||||
Init ();
|
||||
}
|
||||
*/
|
||||
|
||||
ModifyViewCheckBox::~ModifyViewCheckBox() { }
|
||||
|
||||
void ModifyViewCheckBox::Reconfig() {
|
||||
MyTextButton::Reconfig();
|
||||
MakeBackground();
|
||||
if( shape->Undefined() ) {
|
||||
MakeShape();
|
||||
// shape->width += shape->height + sep;
|
||||
shape->width += m_width + sep;
|
||||
shape->height = m_height;
|
||||
}
|
||||
// printf("shape: \nwidth: %d height: %d \n", shape->width, shape->height);
|
||||
|
||||
if( MVCheckBoxMask == nil ) {
|
||||
|
||||
MVCheckBoxMask = new Bitmap( mvmask_bits, mvmask_width, mvmask_height );
|
||||
MVCheckBoxMask->Reference();
|
||||
ViewCheckBox = new Bitmap( v_bits, v_width, v_height );
|
||||
ViewCheckBox->Reference();
|
||||
ViewCheckBoxHit = new Bitmap( vHit_bits, vHit_width, vHit_height );
|
||||
ViewCheckBoxHit->Reference();
|
||||
ModifyCheckBox = new Bitmap( m_bits, m_width, m_height );
|
||||
ModifyCheckBox->Reference();
|
||||
ModifyCheckBoxHit = new Bitmap( mHit_bits, mHit_width, mHit_height );
|
||||
ModifyCheckBoxHit->Reference();
|
||||
}
|
||||
MakeBackground();
|
||||
/*
|
||||
if (shape->Undefined()) {
|
||||
MakeShape();
|
||||
shape->width += shape->height + sep;
|
||||
}
|
||||
*/
|
||||
Update();
|
||||
}
|
||||
|
||||
void ModifyViewCheckBox::Redraw( IntCoord x1, IntCoord y1,
|
||||
IntCoord x2, IntCoord y2 ) {
|
||||
// int h = output->GetFont()->Height();
|
||||
int h = m_height;
|
||||
int r = m_width;
|
||||
output->ClearRect( canvas, x1, y1, x2, y2 );
|
||||
IntCoord tx = r + sep;
|
||||
IntCoord ty = ( ymax + 1 - h ) / 2;
|
||||
output->Text( canvas, text, tx, ty );
|
||||
Refresh();
|
||||
/*
|
||||
int h = output->GetFont()->Height();
|
||||
int t = HalfCheckBoxSize(h);
|
||||
output->ClearRect(canvas, x1, y1, x2, y2);
|
||||
Coord tx = 2*t + sep;
|
||||
Coord ty = (ymax + 1 - h) / 2;
|
||||
output->Text(canvas, text, tx, ty);
|
||||
Refresh();
|
||||
*/
|
||||
}
|
||||
|
||||
void ModifyViewCheckBox::Refresh() {
|
||||
IntCoord x = 0;
|
||||
IntCoord y = ( ymax + 1 - m_height ) / 2;
|
||||
if( !hit && !chosen ) {
|
||||
output->Stencil( canvas, x, y, ViewCheckBox, MVCheckBoxMask );
|
||||
} else if( hit && !chosen ) {
|
||||
output->Stencil( canvas, x, y, ViewCheckBoxHit, MVCheckBoxMask );
|
||||
} else if( !hit && chosen ) {
|
||||
output->Stencil( canvas, x, y, ModifyCheckBox, MVCheckBoxMask );
|
||||
} else if( hit && chosen ) {
|
||||
output->Stencil( canvas, x, y, ModifyCheckBoxHit, MVCheckBoxMask );
|
||||
}
|
||||
if( !enabled ) {
|
||||
grayout->FillRect( canvas, 0, 0, xmax, ymax );
|
||||
}
|
||||
/*
|
||||
int h = output->GetFont()->Height();
|
||||
int t = HalfCheckBoxSize(h);
|
||||
Coord cx = t;
|
||||
Coord cy = (ymax + 1)/2;
|
||||
Coord left = cx - t;
|
||||
Coord right = cx + t;
|
||||
Coord bottom = cy - t;
|
||||
Coord top = cy + t;
|
||||
output->Rect(canvas, left, bottom, right, top);
|
||||
background->FillRect(canvas, left+1, bottom+1, right-1, top-1);
|
||||
if (chosen) {
|
||||
output->Line(canvas, left, bottom, right, top);
|
||||
output->Line(canvas, left, top, right, bottom);
|
||||
}
|
||||
if (hit) {
|
||||
output->Rect(canvas, left+1, bottom+1, right-1, top-1);
|
||||
}
|
||||
if (!enabled) {
|
||||
grayout->FillRect(canvas, 0, 0, xmax, ymax);
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* A button is a view of some value that is normally set when
|
||||
* the button is pressed.
|
||||
*/
|
||||
|
||||
#ifndef mybutton_h
|
||||
#define mybutton_h
|
||||
|
||||
#include <IV-2_6/InterViews/interactor.h>
|
||||
#include <IV-2_6/InterViews/subject.h>
|
||||
#include <IV-2_6/InterViews/button.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
class MyButton : public Button {
|
||||
public:
|
||||
virtual void Handle(Event&);
|
||||
protected:
|
||||
MyButton(ButtonState*, void*);
|
||||
MyButton(const char*, ButtonState*, void*);
|
||||
// MyButton(Painter*, ButtonState*, void*);
|
||||
virtual ~MyButton();
|
||||
|
||||
private:
|
||||
void Init();
|
||||
};
|
||||
|
||||
class MyTextButton : public MyButton {
|
||||
protected:
|
||||
char* text;
|
||||
Painter* background;
|
||||
Painter* grayout; /* for disabled buttons */
|
||||
|
||||
MyTextButton(const char*, const char*, ButtonState*, void*);
|
||||
MyTextButton(const char*, ButtonState*, void*);
|
||||
// MyTextButton(const char*, ButtonState*, void*, Painter*);
|
||||
virtual ~MyTextButton();
|
||||
|
||||
virtual void Reconfig();
|
||||
|
||||
void MakeBackground();
|
||||
void MakeShape();
|
||||
private:
|
||||
void Init(const char*);
|
||||
};
|
||||
|
||||
class MyPushButton : public MyTextButton {
|
||||
public:
|
||||
MyPushButton(const char*, ButtonState*, int);
|
||||
MyPushButton(const char*, ButtonState*, void*);
|
||||
MyPushButton(const char*, const char*, ButtonState*, int);
|
||||
MyPushButton(const char*, const char*, ButtonState*, void*);
|
||||
// MyPushButton(const char*, ButtonState*, int, Painter*);
|
||||
// MyPushButton(const char*, ButtonState*, void*, Painter*);
|
||||
virtual ~MyPushButton();
|
||||
|
||||
virtual void Refresh();
|
||||
protected:
|
||||
virtual void Reconfig();
|
||||
virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord);
|
||||
private:
|
||||
void Init();
|
||||
};
|
||||
|
||||
class MyRadioButton : public MyTextButton {
|
||||
public:
|
||||
MyRadioButton(const char*, ButtonState*, int);
|
||||
MyRadioButton(const char*, ButtonState*, void*);
|
||||
MyRadioButton(const char*, const char*, ButtonState*, int);
|
||||
MyRadioButton(const char*, const char*, ButtonState*, void*);
|
||||
// MyRadioButton(const char*, ButtonState*, int, Painter*);
|
||||
// MyRadioButton(const char*, ButtonState*, void*, Painter*);
|
||||
virtual ~MyRadioButton();
|
||||
|
||||
virtual void Refresh();
|
||||
protected:
|
||||
virtual void Reconfig();
|
||||
virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord);
|
||||
private:
|
||||
void Init();
|
||||
};
|
||||
|
||||
class MyCheckBox : public MyTextButton {
|
||||
public:
|
||||
MyCheckBox(const char*, ButtonState*, int, int);
|
||||
MyCheckBox(const char*, ButtonState*, void*, void*);
|
||||
MyCheckBox(const char*, const char*, ButtonState*, int, int);
|
||||
MyCheckBox(const char*, const char*, ButtonState*, void*, void*);
|
||||
// MyCheckBox(const char*, ButtonState*, int, int, Painter*);
|
||||
// MyCheckBox(const char*, ButtonState*, void*, void*, Painter*);
|
||||
virtual ~MyCheckBox();
|
||||
|
||||
virtual void Press();
|
||||
virtual void Refresh();
|
||||
virtual void Update();
|
||||
protected:
|
||||
virtual void Reconfig();
|
||||
virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord);
|
||||
private:
|
||||
void* offvalue;
|
||||
|
||||
void Init(void*);
|
||||
};
|
||||
|
||||
class PinCheckBox : public MyCheckBox {
|
||||
public:
|
||||
PinCheckBox(const char*, ButtonState*, int, int);
|
||||
PinCheckBox(const char*, ButtonState*, void*, void*);
|
||||
PinCheckBox(const char*, const char*, ButtonState*, int, int);
|
||||
PinCheckBox(const char*, const char*, ButtonState*, void*, void*);
|
||||
// PinCheckBox(const char*, ButtonState*, int, int, Painter*);
|
||||
// PinCheckBox(const char*, ButtonState*, void*, void*, Painter*);
|
||||
virtual ~PinCheckBox();
|
||||
|
||||
virtual void Refresh();
|
||||
protected:
|
||||
virtual void Reconfig();
|
||||
virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord);
|
||||
private:
|
||||
|
||||
void Init();
|
||||
};
|
||||
|
||||
class ModifyViewCheckBox : public MyCheckBox {
|
||||
public:
|
||||
ModifyViewCheckBox(const char*, ButtonState*, int, int);
|
||||
ModifyViewCheckBox(const char*, ButtonState*, void*, void*);
|
||||
ModifyViewCheckBox(const char*, const char*, ButtonState*, int, int);
|
||||
ModifyViewCheckBox(const char*, const char*, ButtonState*, void*, void*);
|
||||
// ModifyViewCheckBox(const char*, ButtonState*, int, int, Painter*);
|
||||
// ModifyViewCheckBox(const char*, ButtonState*, void*, void*, Painter*);
|
||||
virtual ~ModifyViewCheckBox();
|
||||
|
||||
virtual void Refresh();
|
||||
protected:
|
||||
virtual void Reconfig();
|
||||
virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord);
|
||||
private:
|
||||
|
||||
void Init();
|
||||
};
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,39 +0,0 @@
|
||||
#ifndef mybuttonstate_h
|
||||
#define mybuttonstate_h
|
||||
|
||||
#include <IV-2_6/InterViews/button.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
/*
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// This class was created to avoid all views being notified when the
|
||||
// ButtonState value is nulled.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
*/
|
||||
|
||||
class MyButtonState : public ButtonState {
|
||||
public:
|
||||
MyButtonState () {
|
||||
value = nil;
|
||||
Reference();
|
||||
}
|
||||
MyButtonState (int v) {
|
||||
value = (void*)v;
|
||||
Reference();
|
||||
}
|
||||
MyButtonState (void* v) {
|
||||
value = v;
|
||||
Reference();
|
||||
}
|
||||
virtual ~MyButtonState () { };
|
||||
|
||||
void SetNull(void *val = 0, int notify = 0) {
|
||||
value = val;
|
||||
if (notify) Notify();
|
||||
}
|
||||
};
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,309 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Implementation of control classes
|
||||
*/
|
||||
|
||||
#include <mycontrol.h>
|
||||
#include <InterViews/bitmap.h>
|
||||
#include <InterViews/cursor.h>
|
||||
#include <IV-2_6/InterViews/painter.h>
|
||||
#include <IV-2_6/InterViews/message.h>
|
||||
#include <IV-2_6/InterViews/sensor.h>
|
||||
|
||||
#include <fasdBitmaps/menu16.bm>
|
||||
#include <fasdBitmaps/menu16_mask.bm>
|
||||
#include <fasdBitmaps/menu12.bm>
|
||||
#include <fasdBitmaps/menu12_mask.bm>
|
||||
|
||||
static Cursor * menu16Cursor = 0;
|
||||
static Cursor * menu12Cursor = 0;
|
||||
static Cursor * origCursor = 0;
|
||||
|
||||
/** class MyControl **/
|
||||
|
||||
MyControl::MyControl( Interactor * i ) {
|
||||
Init( nil, i );
|
||||
}
|
||||
MyControl::MyControl( const char * name, Interactor * i ) {
|
||||
Init( name, i );
|
||||
}
|
||||
|
||||
void MyControl::Init( const char * name, Interactor * i ) {
|
||||
SetClassName( "MyControl" );
|
||||
if( name != nil ) {
|
||||
SetInstance( name );
|
||||
}
|
||||
enabled_ = true;
|
||||
parent_ = nil;
|
||||
state_ = new MyControlState;
|
||||
state_->Attach( this );
|
||||
input = new Sensor;
|
||||
input->Catch( EnterEvent );
|
||||
input->Catch( LeaveEvent );
|
||||
input->Catch( DownEvent );
|
||||
input->Catch( UpEvent );
|
||||
if( i != nil ) {
|
||||
Insert( i );
|
||||
}
|
||||
}
|
||||
|
||||
MyControl::~MyControl() {
|
||||
state_->Detach( this );
|
||||
}
|
||||
|
||||
void MyControl::Handle( Event & e ) {
|
||||
switch( e.eventType ) {
|
||||
case DownEvent:
|
||||
Down();
|
||||
break;
|
||||
case UpEvent:
|
||||
Up();
|
||||
break;
|
||||
case EnterEvent:
|
||||
Enter();
|
||||
break;
|
||||
case LeaveEvent:
|
||||
Leave();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MyControl::Enable( boolean b ) {
|
||||
if( b != enabled_ ) {
|
||||
enabled_ = b;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Hitting a control is equivalent to making the state active and
|
||||
* then selecting it.
|
||||
*/
|
||||
|
||||
void MyControl::Down() {
|
||||
if( Enabled() && !state_->Active() ) {
|
||||
state_->Activate();
|
||||
state_->NotifySelection( this );
|
||||
}
|
||||
}
|
||||
|
||||
void MyControl::Enter() {
|
||||
if( !origCursor ) {
|
||||
origCursor = GetCursor();
|
||||
}
|
||||
/* if (menu16Cursor == nil) {
|
||||
Bitmap menu16(menu16_bits, menu16_width, menu16_height, 8, 8);
|
||||
Bitmap menu16mask(menu16_mask_bits, menu16_mask_width,
|
||||
menu16_mask_height);
|
||||
menu16Cursor = new Cursor(
|
||||
&menu16, &menu16mask, output->GetFgColor(), output->GetBgColor()
|
||||
);
|
||||
}
|
||||
*/
|
||||
int handHotx = 6; // The Bitmap object seems to have changed how the
|
||||
int handHoty = 1; // coords for hot spot is calculated. DAS
|
||||
// Used to be x = 6, y = 10. i.e. 0,0 is bottom left.
|
||||
// now 0,0 seems to be top left. bm is 12x12
|
||||
if( menu12Cursor == nil ) {
|
||||
Bitmap * menu12 = new Bitmap( menu12_bits, menu12_width, menu12_height,
|
||||
handHotx, handHoty );
|
||||
Bitmap * menu12mask = new Bitmap( menu12_mask_bits, menu12_mask_width,
|
||||
menu12_mask_height );
|
||||
menu12Cursor = new Cursor(
|
||||
menu12, menu12mask, output->GetFgColor(), output->GetBgColor()
|
||||
);
|
||||
}
|
||||
|
||||
// SetCursor(menu16Cursor);
|
||||
SetCursor( menu12Cursor );
|
||||
if( Enabled() && state_->Active() ) {
|
||||
state_->NotifySelection( this );
|
||||
}
|
||||
}
|
||||
|
||||
void MyControl::Leave() {
|
||||
SetCursor( origCursor );
|
||||
if( Enabled() && state_->Active() ) {
|
||||
state_->NotifySelection( nil );
|
||||
}
|
||||
}
|
||||
|
||||
void MyControl::Select() {
|
||||
Highlight( true );
|
||||
Open();
|
||||
Grab();
|
||||
}
|
||||
|
||||
void MyControl::Unselect() {
|
||||
Close();
|
||||
Highlight( false );
|
||||
}
|
||||
|
||||
void MyControl::Grab() {
|
||||
Event e;
|
||||
do {
|
||||
Read( e );
|
||||
e.target->Handle( e );
|
||||
if( e.target == this && e.eventType == LeaveEvent ) {
|
||||
Skip();
|
||||
break;
|
||||
}
|
||||
} while( state_->Active() );
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip all input events until we see something for another open control.
|
||||
*/
|
||||
|
||||
void MyControl::Skip() {
|
||||
Event e;
|
||||
for( ;; ) {
|
||||
Read( e );
|
||||
if( e.eventType == EnterEvent && IsGrabbing( e.target ) ) {
|
||||
UnRead( e );
|
||||
break;
|
||||
} else if( e.eventType == UpEvent ) {
|
||||
Up();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check whether an interactor (usually an event target) is a grabbing
|
||||
* control. Trivially, the current control is grabbing. Any other controls
|
||||
* attached to the control's state are also grabbing. Similarly, any controls
|
||||
* attached to other control's state up the stack from the current one
|
||||
* are also considered to be grabbing.
|
||||
*/
|
||||
|
||||
boolean MyControl::IsGrabbing( Interactor * i ) {
|
||||
if( i == this ) {
|
||||
return true;
|
||||
}
|
||||
for( MyControlState * c = state_; c != nil; c = c->Next() ) {
|
||||
if( c->IsView( i ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for( c = state_->Prev(); c != nil; c = c->Prev() ) {
|
||||
if( c->IsView( i ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* On an up event, deactivate all the control states and then
|
||||
* call Do the current selection (if any).
|
||||
*/
|
||||
|
||||
void MyControl::Up() {
|
||||
if( state_->Active() ) {
|
||||
MyControl * target = state_->Selection();
|
||||
state_->Action( target );
|
||||
for( MyControlState * c = state_; c != nil; c = c->Prev() ) {
|
||||
c->Deactivate();
|
||||
}
|
||||
if( target != nil ) {
|
||||
Busy();
|
||||
target->Do();
|
||||
Done();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MyControl::Open() { }
|
||||
void MyControl::Close() { }
|
||||
void MyControl::Do() { }
|
||||
void MyControl::Busy() { }
|
||||
void MyControl::Done() { }
|
||||
|
||||
|
||||
MyControl * MyControl::RootControl() {
|
||||
MyControl * root = this;
|
||||
MyControl * Parent = ParentControl();
|
||||
|
||||
while( Parent != nil ) {
|
||||
root = Parent;
|
||||
Parent = Parent->ParentControl();
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
void MyControl::SetState( MyControlState * s ) {
|
||||
state_->Detach( this );
|
||||
state_ = s;
|
||||
s->Attach( this );
|
||||
}
|
||||
|
||||
void MyControl::Reparent( MyControl * ctrl, MyControl * Parent ) {
|
||||
ctrl->parent_ = Parent;
|
||||
}
|
||||
|
||||
/** class MyControlState **/
|
||||
|
||||
MyControlState::MyControlState( unsigned s ) {
|
||||
status = s;
|
||||
selection = nil;
|
||||
action = nil;
|
||||
next = nil;
|
||||
prev = nil;
|
||||
}
|
||||
|
||||
MyControlState::~MyControlState() { }
|
||||
|
||||
void MyControlState::NotifySelection( MyControl * c ) {
|
||||
if( selection != c ) {
|
||||
if( selection != nil ) {
|
||||
selection->Unselect();
|
||||
}
|
||||
selection = c;
|
||||
if( selection != nil ) {
|
||||
selection->Select();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MyControlState::Push( MyControlState * s ) {
|
||||
next = s;
|
||||
s->prev = this;
|
||||
}
|
||||
|
||||
void MyControlState::Pop() {
|
||||
if( prev != nil ) {
|
||||
prev->next = next;
|
||||
prev = nil;
|
||||
}
|
||||
Deactivate();
|
||||
}
|
||||
|
||||
void MyControlState::Deactivate() {
|
||||
Set( MyControlActive, false );
|
||||
if( selection != nil ) {
|
||||
selection->Unselect();
|
||||
selection = nil;
|
||||
}
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Controls provide an interface to selecting and executing some action.
|
||||
*/
|
||||
|
||||
#ifndef mycontrol_h
|
||||
#define mycontrol_h
|
||||
|
||||
#include <InterViews/resource.h>
|
||||
#include <IV-2_6/InterViews/scene.h>
|
||||
#include <IV-2_6/InterViews/subject.h>
|
||||
|
||||
#include <InterViews/_enter.h>
|
||||
|
||||
class MyControl;
|
||||
class MyControlState;
|
||||
|
||||
class MyControl : public MonoScene {
|
||||
public:
|
||||
MyControl(Interactor*);
|
||||
MyControl(const char* name, Interactor*);
|
||||
~MyControl();
|
||||
|
||||
MyControlState* State() { return state_; }
|
||||
void SetState(MyControlState*);
|
||||
|
||||
virtual void Handle(Event&);
|
||||
|
||||
virtual void Enable(boolean);
|
||||
boolean Enabled();
|
||||
|
||||
virtual void Select(); /* highlight, open, and grab */
|
||||
virtual void Unselect(); /* close, unhighlight */
|
||||
|
||||
virtual void Do(); /* action for selection */
|
||||
|
||||
MyControl* ParentControl();
|
||||
MyControl* RootControl();
|
||||
protected:
|
||||
virtual void Down(); /* activate control */
|
||||
virtual void Enter(); /* select a control if active */
|
||||
virtual void Open(); /* open subviews, if any */
|
||||
virtual void Grab(); /* read input events */
|
||||
virtual void Skip(); /* ignore input until enters active control */
|
||||
virtual void Leave(); /* unselect if active */
|
||||
virtual void Close(); /* close subviews, if any */
|
||||
virtual void Up(); /* deactivate control, exec selection */
|
||||
|
||||
virtual void Busy();
|
||||
virtual void Done();
|
||||
|
||||
virtual boolean IsGrabbing(Interactor*);
|
||||
|
||||
void Reparent(MyControl*, MyControl* parent);
|
||||
private:
|
||||
MyControlState* state_;
|
||||
boolean enabled_;
|
||||
MyControl* parent_;
|
||||
|
||||
private:
|
||||
void Init(const char*, Interactor*);
|
||||
};
|
||||
|
||||
inline boolean MyControl::Enabled() { return enabled_; }
|
||||
inline MyControl* MyControl::ParentControl() { return parent_; }
|
||||
|
||||
/*
|
||||
* MyControlState is a subject that several controls share to exchange
|
||||
* common information.
|
||||
*/
|
||||
|
||||
enum MyControlStatus { MyControlActive = 0x1 };
|
||||
|
||||
class MyControlState : virtual public Subject {
|
||||
public:
|
||||
MyControlState(unsigned status = 0);
|
||||
~MyControlState();
|
||||
|
||||
boolean Active() { return Set(MyControlActive); }
|
||||
void Activate() { Set(MyControlActive, true); }
|
||||
virtual void Deactivate();
|
||||
|
||||
MyControl* Selection() { return selection; }
|
||||
void Selection(MyControl* c) { selection = c; }
|
||||
virtual void NotifySelection(MyControl*);
|
||||
|
||||
MyControl* Action() { return action; }
|
||||
void Action(MyControl* c) { action = c; }
|
||||
|
||||
void Push(MyControlState*);
|
||||
void Pop();
|
||||
MyControlState* Next() { return next; }
|
||||
MyControlState* Prev() { return prev; }
|
||||
protected:
|
||||
unsigned status;
|
||||
MyControl* selection;
|
||||
MyControl* action;
|
||||
MyControlState* next;
|
||||
MyControlState* prev;
|
||||
|
||||
boolean Set(MyControlStatus s) { return (status & s) != 0; }
|
||||
void Set(MyControlStatus s, boolean b) {
|
||||
status = b ? (status | s) : (status & ~s);
|
||||
}
|
||||
};
|
||||
|
||||
#include <InterViews/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,561 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MyFileBrowser implementation.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
#include <stdlib.h> // for bcopy() function
|
||||
#include <stream.h>
|
||||
#include <myfilebrowser.h>
|
||||
|
||||
//#include "/proj/pdevel/autoc/arch.sunCC.iv/scl_cf.h"
|
||||
// This is an scl configuration file generated by the configure script
|
||||
// generated using gnu's autoconf
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <scl_config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYSENT_H
|
||||
#include <sysent.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
// needed at least for getuid()
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
// sys/stat.h is apparently needed for ObjectCenter?
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
// to help ObjectCenter
|
||||
#ifndef HAVE_MEMMOVE
|
||||
extern "C"
|
||||
{
|
||||
void * memmove( void * __s1, const void * __s2, size_t __n );
|
||||
}
|
||||
#endif
|
||||
|
||||
//#ifdef __GNUC__
|
||||
// needed at least for getuid()
|
||||
//#include <unistd.h>
|
||||
//#endif
|
||||
|
||||
//#ifdef __SUNCPLUSPLUS__
|
||||
// needed at least for getuid()
|
||||
//#include <sysent.h>
|
||||
//#include <unistd.h>
|
||||
//#endif
|
||||
|
||||
//#ifdef __OBJECTCENTER__
|
||||
// needed at least for getuid()
|
||||
//#include <sysent.h>
|
||||
//#include <sys/stat.h>
|
||||
|
||||
//extern "C"
|
||||
//{
|
||||
//void * memmove(void *__s1, const void *__s2, size_t __n);
|
||||
//}
|
||||
//#endif
|
||||
|
||||
#include <pwd.h>
|
||||
//#include <os/auth.h>
|
||||
//#include <os/fs.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <scldir.h>
|
||||
#include <stat.h>
|
||||
|
||||
//#include <sys/dir.h>
|
||||
//#include <sys/stat.h>
|
||||
//#include <InterViews/Std/sys/dir.h>
|
||||
//#include <InterViews/Std/sys/stat.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
class MyFBDirectory {
|
||||
public:
|
||||
MyFBDirectory( const char * name );
|
||||
virtual ~MyFBDirectory();
|
||||
|
||||
boolean LoadDirectory( const char * );
|
||||
const char * Normalize( const char * );
|
||||
const char * ValidDirectories( const char * );
|
||||
|
||||
int Index( const char * );
|
||||
const char * File( int index );
|
||||
int Count();
|
||||
|
||||
boolean IsADirectory( const char * );
|
||||
private:
|
||||
const char * Home( const char* = nil );
|
||||
const char * ElimDot( const char * );
|
||||
const char * ElimDotDot( const char * );
|
||||
const char * InterpSlashSlash( const char * );
|
||||
const char * InterpTilde( const char * );
|
||||
const char * ExpandTilde( const char *, int );
|
||||
const char * RealPath( const char * );
|
||||
|
||||
boolean Reset( const char * );
|
||||
void Clear();
|
||||
void Check( int index );
|
||||
void Insert( const char *, int index );
|
||||
void Append( const char * );
|
||||
void Remove( int index );
|
||||
virtual int Position( const char * );
|
||||
private:
|
||||
char ** strbuf;
|
||||
int strcount;
|
||||
int strbufsize;
|
||||
};
|
||||
|
||||
inline int MyFBDirectory::Count() {
|
||||
return strcount;
|
||||
}
|
||||
inline void MyFBDirectory::Append( const char * s ) {
|
||||
Insert( s, strcount );
|
||||
}
|
||||
inline const char * MyFBDirectory::File( int index ) {
|
||||
return ( 0 <= index && index < strcount ) ? strbuf[index] : nil;
|
||||
}
|
||||
|
||||
// evidently strdup is defined with sun but not with gnu, changed to not use it
|
||||
//#ifndef __SUNCPLUSPLUS__
|
||||
//char* strdup (const char* s) {
|
||||
//#endif
|
||||
char * mystrdup( const char * s ) {
|
||||
char * dup = new char[strlen( s ) + 1];
|
||||
strcpy( dup, s );
|
||||
return dup;
|
||||
}
|
||||
|
||||
MyFBDirectory::MyFBDirectory( const char * name ) {
|
||||
const int defaultSize = 256;
|
||||
|
||||
strbufsize = defaultSize;
|
||||
strbuf = new char*[strbufsize];
|
||||
strcount = 0;
|
||||
LoadDirectory( name );
|
||||
}
|
||||
|
||||
MyFBDirectory::~MyFBDirectory() {
|
||||
Clear();
|
||||
}
|
||||
|
||||
const char * MyFBDirectory::RealPath( const char * path ) {
|
||||
const char * realpath;
|
||||
|
||||
if( *path == '\0' ) {
|
||||
realpath = "./";
|
||||
} else {
|
||||
realpath = InterpTilde( InterpSlashSlash( path ) );
|
||||
}
|
||||
return realpath;
|
||||
}
|
||||
|
||||
boolean MyFBDirectory::LoadDirectory( const char * name ) {
|
||||
char buf[MAXPATHLEN + 2];
|
||||
const char * path = buf;
|
||||
|
||||
strcpy( buf, ValidDirectories( RealPath( name ) ) );
|
||||
return Reset( buf );
|
||||
}
|
||||
|
||||
int MyFBDirectory::Index( const char * name ) {
|
||||
for( int i = 0; i < strcount; ++i ) {
|
||||
if( strcmp( strbuf[i], name ) == 0 ) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
boolean MyFBDirectory::Reset( const char * path ) {
|
||||
boolean successful = IsADirectory( path );
|
||||
if( successful ) {
|
||||
DIR * dir = opendir( path );
|
||||
Clear();
|
||||
|
||||
for( struct dirent * d = readdir( dir ); d != NULL; d = readdir( dir ) ) {
|
||||
/*
|
||||
//#if defined(SYSV)
|
||||
// for (struct dirent* d = readdir(dir); d != NULL; d = readdir(dir)) {
|
||||
//#else
|
||||
// for (struct direct* d = readdir(dir); d != NULL; d = readdir(dir)) {
|
||||
//#endif
|
||||
*/
|
||||
Insert( d->d_name, Position( d->d_name ) );
|
||||
}
|
||||
closedir( dir );
|
||||
}
|
||||
return successful;
|
||||
}
|
||||
|
||||
boolean MyFBDirectory::IsADirectory( const char * path ) {
|
||||
struct stat st;
|
||||
return stat( path, &st ) == 0 && ( st.st_mode & S_IFMT ) == S_IFDIR;
|
||||
}
|
||||
|
||||
const char * MyFBDirectory::Home( const char * name ) {
|
||||
struct passwd * pw =
|
||||
( name == nil ) ? getpwuid( getuid() ) : getpwnam( ( char * )name );
|
||||
return ( pw == nil ) ? nil : pw->pw_dir;
|
||||
}
|
||||
|
||||
inline boolean DotSlash( const char * path ) {
|
||||
return
|
||||
path[0] != '\0' && path[0] == '.' &&
|
||||
( path[1] == '/' || path[1] == '\0' );
|
||||
}
|
||||
|
||||
inline boolean DotDotSlash( const char * path ) {
|
||||
return
|
||||
path[0] != '\0' && path[1] != '\0' &&
|
||||
path[0] == '.' && path[1] == '.' &&
|
||||
( path[2] == '/' || path[2] == '\0' );
|
||||
}
|
||||
|
||||
const char * MyFBDirectory::Normalize( const char * path ) {
|
||||
static char newpath[MAXPATHLEN + 1];
|
||||
const char * buf;
|
||||
|
||||
buf = InterpSlashSlash( path );
|
||||
buf = ElimDot( buf );
|
||||
buf = ElimDotDot( buf );
|
||||
buf = InterpTilde( buf );
|
||||
|
||||
if( *buf == '\0' ) {
|
||||
strcpy( newpath, "./" );
|
||||
|
||||
} else if( !DotSlash( buf ) && !DotDotSlash( buf ) && *buf != '/' ) {
|
||||
strcpy( newpath, "./" );
|
||||
strcat( newpath, buf );
|
||||
|
||||
} else if( IsADirectory( buf ) && buf[strlen( buf ) - 1] != '/' ) {
|
||||
strcpy( newpath, buf );
|
||||
strcat( newpath, "/" );
|
||||
|
||||
} else {
|
||||
strcpy( newpath, buf );
|
||||
}
|
||||
return newpath;
|
||||
}
|
||||
|
||||
const char * MyFBDirectory::ValidDirectories( const char * path ) {
|
||||
static char buf[MAXPATHLEN + 1];
|
||||
strcpy( buf, path );
|
||||
int i = strlen( path );
|
||||
|
||||
while( !IsADirectory( RealPath( buf ) ) && i >= 0 ) {
|
||||
for( --i; buf[i] != '/' && i >= 0; --i ) {
|
||||
;
|
||||
}
|
||||
buf[i + 1] = '\0';
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
const char * MyFBDirectory::InterpSlashSlash( const char * path ) {
|
||||
for( int i = strlen( path ) - 1; i > 0; --i ) {
|
||||
if( path[i] == '/' && path[i - 1] == '/' ) {
|
||||
return &path[i];
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
const char * MyFBDirectory::ElimDot( const char * path ) {
|
||||
static char newpath[MAXPATHLEN + 1];
|
||||
const char * src;
|
||||
char * dest = newpath;
|
||||
|
||||
for( src = path; src < &path[strlen( path )]; ++src ) {
|
||||
if( !DotSlash( src ) ) {
|
||||
*dest++ = *src;
|
||||
|
||||
} else if( *( dest - 1 ) == '/' ) {
|
||||
++src;
|
||||
|
||||
} else {
|
||||
*dest++ = *src;
|
||||
}
|
||||
}
|
||||
*dest = '\0';
|
||||
return newpath;
|
||||
}
|
||||
|
||||
static boolean CollapsedDotDotSlash( const char * path, const char*& start ) {
|
||||
if( path == start || *( start - 1 ) != '/' ) {
|
||||
return false;
|
||||
|
||||
} else if( path == start - 1 && *path == '/' ) {
|
||||
return true;
|
||||
|
||||
} else if( path == start - 2 ) { // NB: won't handle '//' right
|
||||
start = path;
|
||||
return *start != '.';
|
||||
|
||||
} else if( path < start - 2 && !DotDotSlash( start - 3 ) ) {
|
||||
for( start -= 2; path <= start; --start ) {
|
||||
if( *start == '/' ) {
|
||||
++start;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
start = path;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const char * MyFBDirectory::ElimDotDot( const char * path ) {
|
||||
static char newpath[MAXPATHLEN + 1];
|
||||
const char * src;
|
||||
char * dest = newpath;
|
||||
|
||||
for( src = path; src < &path[strlen( path )]; ++src ) {
|
||||
if( DotDotSlash( src ) && CollapsedDotDotSlash( newpath,
|
||||
( const char * & )dest ) ) {
|
||||
// DAS PORT gnu 2.6 (const char *)dest)) {
|
||||
src += 2;
|
||||
} else {
|
||||
*dest++ = *src;
|
||||
}
|
||||
}
|
||||
*dest = '\0';
|
||||
return newpath;
|
||||
}
|
||||
|
||||
const char * MyFBDirectory::InterpTilde( const char * path ) {
|
||||
static char realpath[MAXPATHLEN + 1];
|
||||
const char * beg = strrchr( path, '~' );
|
||||
boolean validTilde = beg != NULL && ( beg == path || *( beg - 1 ) == '/' );
|
||||
|
||||
if( validTilde ) {
|
||||
const char * end = strchr( beg, '/' );
|
||||
int length = ( end == nil ) ? strlen( beg ) : end - beg;
|
||||
const char * expandedTilde = ExpandTilde( beg, length );
|
||||
|
||||
if( expandedTilde == nil ) {
|
||||
validTilde = false;
|
||||
} else {
|
||||
strcpy( realpath, expandedTilde );
|
||||
if( end != nil ) {
|
||||
strcat( realpath, end );
|
||||
}
|
||||
}
|
||||
}
|
||||
return validTilde ? realpath : path;
|
||||
}
|
||||
|
||||
const char * MyFBDirectory::ExpandTilde( const char * tildeName, int length ) {
|
||||
const char * name = nil;
|
||||
|
||||
if( length > 1 ) {
|
||||
static char buf[MAXNAMLEN + 1];
|
||||
strncpy( buf, tildeName + 1, length - 1 );
|
||||
buf[length - 1] = '\0';
|
||||
name = buf;
|
||||
}
|
||||
return Home( name );
|
||||
}
|
||||
|
||||
void MyFBDirectory::Check( int index ) {
|
||||
char ** newstrbuf;
|
||||
|
||||
if( index >= strbufsize ) {
|
||||
strbufsize = ( index + 1 ) * 2;
|
||||
newstrbuf = new char*[strbufsize];
|
||||
// bcopy(strbuf, newstrbuf, strcount*sizeof(char*)); // non ANSI
|
||||
// the 1st two operands are reversed from bcopy. memcpy() is ANSI
|
||||
// memcpy is o.k. since memory areas do not overlap - DAS
|
||||
memcpy( newstrbuf, strbuf, strcount * sizeof( char * ) ); // ANSI
|
||||
delete strbuf;
|
||||
strbuf = newstrbuf;
|
||||
}
|
||||
}
|
||||
|
||||
// this makes a copy of 's' before it inserts it.
|
||||
void MyFBDirectory::Insert( const char * s, int index ) {
|
||||
char ** spot;
|
||||
index = ( index < 0 ) ? strcount : index;
|
||||
|
||||
if( index < strcount ) {
|
||||
Check( strcount + 1 );
|
||||
spot = &strbuf[index];
|
||||
// bcopy(spot, spot+1, (strcount - index)*sizeof(char*)); // non ANSI
|
||||
// the 1st two operands are reversed from bcopy. memcpy() is ANSI
|
||||
// memcpy is not always o.k. since memory areas overlap - DAS
|
||||
// memcpy(spot+1, spot, (strcount - index)*sizeof(char*)); // ANSI
|
||||
memmove( spot + 1, spot, ( strcount - index )*sizeof( char * ) ); // ANSI
|
||||
} else {
|
||||
Check( index );
|
||||
spot = &strbuf[index];
|
||||
}
|
||||
char * string = mystrdup( s );
|
||||
*spot = string;
|
||||
++strcount;
|
||||
}
|
||||
|
||||
void MyFBDirectory::Remove( int index ) {
|
||||
if( index < --strcount ) {
|
||||
char ** spot = &strbuf[index];
|
||||
delete *spot;
|
||||
// bcopy(spot+1, spot, (strcount - index)*sizeof(char*));
|
||||
// the 1st two operands are reversed from bcopy. memcpy() is ANSI
|
||||
// memcpy is not always o.k. since memory areas overlap - DAS
|
||||
// memcpy(spot, spot+1, (strcount - index)*sizeof(char*)); // ANSI
|
||||
memmove( spot, spot + 1, ( strcount - index )*sizeof( char * ) ); // ANSI
|
||||
}
|
||||
}
|
||||
|
||||
void MyFBDirectory::Clear() {
|
||||
for( int i = 0; i < strcount; ++i ) {
|
||||
delete strbuf[i];
|
||||
}
|
||||
strcount = 0;
|
||||
}
|
||||
|
||||
int MyFBDirectory::Position( const char * s ) {
|
||||
int i;
|
||||
|
||||
for( i = 0; i < strcount; ++i ) {
|
||||
if( strcmp( s, strbuf[i] ) < 0 ) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return strcount;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
MyFileBrowser::MyFileBrowser(
|
||||
ButtonState * bs, const char * dir_, int r, int c,
|
||||
boolean u, int h, const char * d, int restrictBool
|
||||
) : StringBrowser( bs, r, c, u, h, d ) {
|
||||
|
||||
// set restrict before Update() is called
|
||||
restrict = restrictBool;
|
||||
Init( dir_ );
|
||||
Update();
|
||||
}
|
||||
|
||||
MyFileBrowser::MyFileBrowser(
|
||||
const char * name, ButtonState * bs, const char * dir_, int r, int c,
|
||||
boolean u, int h, const char * d, int restrictBool
|
||||
) : StringBrowser( name, bs, r, c, u, h, d ) {
|
||||
|
||||
// set restrict before Update() is called
|
||||
restrict = restrictBool;
|
||||
Init( dir_ );
|
||||
Update();
|
||||
}
|
||||
|
||||
void MyFileBrowser::Init( const char * d ) {
|
||||
dir = new MyFBDirectory( d );
|
||||
lastpath = mystrdup( ValidDirectories( Normalize( d ) ) );
|
||||
}
|
||||
|
||||
MyFileBrowser::~MyFileBrowser() {
|
||||
delete dir;
|
||||
delete lastpath;
|
||||
}
|
||||
|
||||
static const char * Concat( const char * path, const char * file ) {
|
||||
static char buf[MAXPATHLEN + 1];
|
||||
|
||||
strcpy( buf, path );
|
||||
if( path[strlen( path ) - 1] != '/' ) {
|
||||
strcat( buf, "/" );
|
||||
}
|
||||
return strcat( buf, file );
|
||||
}
|
||||
|
||||
boolean MyFileBrowser::IsADirectory( const char * path ) {
|
||||
return dir->IsADirectory( Normalize( path ) );
|
||||
}
|
||||
|
||||
boolean MyFileBrowser::SetDirectory( const char * path ) {
|
||||
boolean successful = true;
|
||||
path = ValidDirectories( path );
|
||||
const char * normpath = Normalize( path );
|
||||
|
||||
if( strcmp( normpath, lastpath ) != 0 ) {
|
||||
char * newnormpath = mystrdup( normpath );
|
||||
successful = dir->LoadDirectory( newnormpath );
|
||||
|
||||
if( successful ) {
|
||||
delete lastpath;
|
||||
lastpath = newnormpath;
|
||||
Update();
|
||||
} else {
|
||||
delete newnormpath;
|
||||
}
|
||||
}
|
||||
return successful;
|
||||
}
|
||||
|
||||
const char * MyFileBrowser::ValidDirectories( const char * path ) {
|
||||
return dir->ValidDirectories( path );
|
||||
}
|
||||
|
||||
const char * MyFileBrowser::Normalize( const char * path ) {
|
||||
return dir->Normalize( path );
|
||||
}
|
||||
|
||||
const char * MyFileBrowser::Path( int index ) {
|
||||
const char * s = String( index );
|
||||
|
||||
return ( s == nil ) ? nil : Normalize( Concat( lastpath, s ) );
|
||||
}
|
||||
|
||||
void MyFileBrowser::UpdateDir() {
|
||||
boolean successful = dir->LoadDirectory( lastpath );
|
||||
if( successful ) {
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
void MyFileBrowser::Update() {
|
||||
Clear();
|
||||
|
||||
for( int i = 0; i < dir->Count(); ++i ) {
|
||||
const char * name = dir->File( i );
|
||||
|
||||
if( dir->IsADirectory( Concat( lastpath, name ) ) ) {
|
||||
char buf[MAXPATHLEN + 1];
|
||||
strcpy( buf, name );
|
||||
strcat( buf, "/" );
|
||||
// if(buf[0] != '.' || !restrict)
|
||||
if( !restrict ) {
|
||||
Append( buf );
|
||||
}
|
||||
} else {
|
||||
if( name[0] != '.' || !restrict ) {
|
||||
Append( name );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MyFileBrowser - a StringBrowser that displays file names.
|
||||
*/
|
||||
|
||||
#ifndef myfilebrowser_h
|
||||
#define myfilebrowser_h
|
||||
|
||||
#include <IV-2_6/InterViews/strbrowser.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
class MyFileBrowser : public StringBrowser {
|
||||
public:
|
||||
MyFileBrowser(
|
||||
ButtonState*, const char* dir_ = "~", int rows = 10, int cols = 24,
|
||||
boolean uniqueSel = true, int highlight = Reversed,
|
||||
const char* done = SBDone, int restrictBool = 0
|
||||
);
|
||||
MyFileBrowser(
|
||||
const char* name, ButtonState*, const char* = "~", int = 10, int = 24,
|
||||
boolean = true, int = Reversed, const char* = SBDone,
|
||||
int restrictBool = 0
|
||||
);
|
||||
virtual ~MyFileBrowser();
|
||||
|
||||
boolean IsADirectory(const char*);
|
||||
boolean SetDirectory(const char*);
|
||||
const char* GetDirectory();
|
||||
const char* ValidDirectories(const char*);
|
||||
const char* Normalize(const char*);
|
||||
const char* Path(int index);
|
||||
|
||||
virtual void Update();
|
||||
void UpdateDir();
|
||||
void Restrict(int boolvar) {
|
||||
restrict = boolvar;
|
||||
}
|
||||
int Restrict() {
|
||||
return restrict;
|
||||
}
|
||||
|
||||
private:
|
||||
void Init(const char*);
|
||||
private:
|
||||
class MyFBDirectory* dir;
|
||||
char* lastpath;
|
||||
int restrict;
|
||||
};
|
||||
|
||||
inline const char* MyFileBrowser::GetDirectory () { return lastpath; }
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,279 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MyFileChooser implementation.
|
||||
*/
|
||||
|
||||
#include <stream.h>
|
||||
|
||||
#include <InterViews/event.h>
|
||||
|
||||
#include <IV-2_6/InterViews/adjuster.h>
|
||||
#include <IV-2_6/InterViews/border.h>
|
||||
#include <IV-2_6/InterViews/box.h>
|
||||
#include <IV-2_6/InterViews/button.h>
|
||||
#include <IV-2_6/InterViews/frame.h>
|
||||
#include <IV-2_6/InterViews/glue.h>
|
||||
#include <IV-2_6/InterViews/message.h>
|
||||
#include <IV-2_6/InterViews/scroller.h>
|
||||
#include <IV-2_6/InterViews/scene.h>
|
||||
#include <IV-2_6/InterViews/sensor.h>
|
||||
#include <IV-2_6/InterViews/streditor.h>
|
||||
|
||||
#include <streditor2.h>
|
||||
#include <myfilebrowser.h>
|
||||
#include <myfilechooser.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
void MyFileChooser::Restrict( int boolvar ) {
|
||||
restrict = boolvar;
|
||||
( ( MyFileBrowser * )_browser )->Restrict( boolvar );
|
||||
_sedit->Message( "" );
|
||||
( ( MyFileBrowser * )_browser )->Update();
|
||||
}
|
||||
|
||||
MyFileChooser::MyFileChooser(
|
||||
const char * Title, const char * Subtitle, const char * dir,
|
||||
int rows, int cols, const char * acceptLabel, Alignment a, int restrictBool )
|
||||
: StringChooser( new ButtonState, a ) {
|
||||
|
||||
MyFileBrowser * fb = new MyFileBrowser( state, dir, rows, cols, true,
|
||||
Reversed, SBDone, restrictBool );
|
||||
|
||||
//DAS Initialize the StringChooser with the customized file brower
|
||||
if( restrictBool ) {
|
||||
StringChooser::Init( new StringEditor2( state, "", SEDone, 40 ), fb );
|
||||
} else {
|
||||
StringChooser::Init( new StringEditor2( state, fb->GetDirectory() ), fb );
|
||||
}
|
||||
Init( Title, Subtitle );
|
||||
|
||||
Insert( Interior( acceptLabel ) );
|
||||
}
|
||||
|
||||
MyFileChooser::MyFileChooser(
|
||||
const char * name, const char * Title, const char * Subtitle, const char * dir,
|
||||
int rows, int cols, const char * acceptLabel, Alignment a, int restrictBool )
|
||||
: StringChooser( new ButtonState, a ) {
|
||||
|
||||
SetInstance( name );
|
||||
|
||||
MyFileBrowser * fb = new MyFileBrowser( state, dir, rows, cols, true,
|
||||
Reversed, SBDone, restrictBool );
|
||||
//DAS Initialize the StringChooser with the customized file brower
|
||||
if( restrictBool ) {
|
||||
StringChooser::Init( new StringEditor2( state, "", SEDone, 40 ), fb );
|
||||
} else {
|
||||
StringChooser::Init( new StringEditor2( state, fb->GetDirectory() ), fb );
|
||||
}
|
||||
Init( Title, Subtitle );
|
||||
Insert( Interior( acceptLabel ) );
|
||||
}
|
||||
|
||||
MyFileChooser::MyFileChooser(
|
||||
ButtonState * bs, const char * dir, int rows, int cols, Alignment a ) :
|
||||
StringChooser( bs, a ) {
|
||||
MyFileBrowser * fb = new MyFileBrowser( state, dir, rows, cols );
|
||||
StringChooser::Init( new StringEditor2( state, fb->GetDirectory() ), fb );
|
||||
}
|
||||
|
||||
MyFileChooser::MyFileChooser( ButtonState * bs, Alignment a ) :
|
||||
StringChooser( bs, a )
|
||||
{ }
|
||||
|
||||
void MyFileChooser::Init( const char * t, const char * subt ) {
|
||||
if( *t == '\0' ) {
|
||||
title = new MarginFrame( new VGlue( 0, 0 ) );
|
||||
} else {
|
||||
// Interactor *i = new class Message(t, 4);
|
||||
// title = new MarginFrame(i);
|
||||
title = new MarginFrame( new class Message( t ) );
|
||||
}
|
||||
if( *subt == '\0' ) {
|
||||
subtitle = new MarginFrame( new VGlue( 0, 0 ) );
|
||||
} else {
|
||||
subtitle = new MarginFrame( new class Message( subt ) );
|
||||
}
|
||||
restrict = 0;
|
||||
// set parents _browser also to not be restricted
|
||||
( ( MyFileBrowser * )_browser )->Restrict( 0 );
|
||||
}
|
||||
|
||||
void MyFileChooser::SelectFile() {
|
||||
const char * path = _sedit->Text();
|
||||
int left = strlen( browser()->ValidDirectories( path ) );
|
||||
int right = strlen( path );
|
||||
|
||||
Select( left, right );
|
||||
}
|
||||
|
||||
void
|
||||
MyFileChooser::UpdateDir() {
|
||||
( ( MyFileBrowser * )_browser )->UpdateDir();
|
||||
}
|
||||
|
||||
void MyFileChooser::UpdateEditor() {
|
||||
int index = browser()->Selection();
|
||||
|
||||
if( !restrict ) {
|
||||
if( index >= 0 ) {
|
||||
_sedit->Message( browser()->Path( index ) );
|
||||
browser()->UnselectAll();
|
||||
} else {
|
||||
_sedit->Message( browser()->Normalize( _sedit->Text() ) );
|
||||
}
|
||||
} else {
|
||||
if( index >= 0 ) {
|
||||
_sedit->Message( browser()->String( index ) );
|
||||
browser()->UnselectAll();
|
||||
} else {
|
||||
const char * selection = _sedit->Text();
|
||||
int illegal = 0;
|
||||
char * foundDot = strchr( selection, '.' );
|
||||
if( ( foundDot == selection ||
|
||||
( foundDot > selection && *( foundDot - 1 ) == '/' ) ||
|
||||
( foundDot > selection && *( foundDot + 1 ) == '.' ) ||
|
||||
( selection[0] == '/' ) ||
|
||||
( selection[0] == '~' )
|
||||
) &&
|
||||
restrict
|
||||
) {
|
||||
illegal = 1;
|
||||
}
|
||||
if( !illegal ) {
|
||||
browser()->SetDirectory( selection );
|
||||
} else {
|
||||
cerr << "\007***ERROR*** Choice is restricted... "
|
||||
<< "Will not accept it.\n";
|
||||
_sedit->Message( "" );
|
||||
}
|
||||
}
|
||||
}
|
||||
SelectFile();
|
||||
}
|
||||
|
||||
void MyFileChooser::UpdateBrowser() {
|
||||
const char * selection = Choice();
|
||||
|
||||
int illegal = 0;
|
||||
char * foundDot = strchr( selection, '.' );
|
||||
if( ( foundDot == selection ||
|
||||
( foundDot > selection && *( foundDot - 1 ) == '/' ) ||
|
||||
( foundDot > selection && *( foundDot + 1 ) == '.' ) ||
|
||||
( selection[0] == '/' ) ||
|
||||
( selection[0] == '~' )
|
||||
) &&
|
||||
restrict
|
||||
) {
|
||||
illegal = 1;
|
||||
}
|
||||
if( !illegal ) {
|
||||
browser()->SetDirectory( selection );
|
||||
} else {
|
||||
_sedit->Message( "" );
|
||||
cerr << "\007***ERROR*** Choice is restricted... Will not accept it.\n";
|
||||
}
|
||||
|
||||
// browser()->SetDirectory(Choice());
|
||||
}
|
||||
|
||||
boolean MyFileChooser::Accept() {
|
||||
boolean accepted, dirSelected;
|
||||
|
||||
do {
|
||||
accepted = StringChooser::Accept();
|
||||
dirSelected = browser()->IsADirectory( Choice() );
|
||||
} while( accepted && dirSelected );
|
||||
|
||||
return accepted;
|
||||
}
|
||||
|
||||
static void ChangeMsg( const char * name, MarginFrame * frame ) {
|
||||
Interactor * msg;
|
||||
|
||||
if( *name == '\0' ) {
|
||||
msg = new VGlue( 0, 0 );
|
||||
} else {
|
||||
msg = new Message( name );
|
||||
}
|
||||
frame->Insert( msg );
|
||||
frame->Change( msg );
|
||||
}
|
||||
|
||||
void MyFileChooser::SetTitle( const char * name ) {
|
||||
ChangeMsg( name, title );
|
||||
}
|
||||
|
||||
void MyFileChooser::SetSubtitle( const char * name ) {
|
||||
ChangeMsg( name, subtitle );
|
||||
}
|
||||
|
||||
Interactor * MyFileChooser::AddScroller( Interactor * i ) {
|
||||
return new HBox(
|
||||
new MarginFrame( i, 2 ),
|
||||
new VBorder,
|
||||
new VBox(
|
||||
new UpMover( i, 1 ),
|
||||
new HBorder,
|
||||
new VScroller( i ),
|
||||
new HBorder,
|
||||
new DownMover( i, 1 )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Interactor * MyFileChooser::Interior( const char * acptLbl ) {
|
||||
const int space = round( .5 * cm );
|
||||
VBox * titleblock = new VBox(
|
||||
new HBox( title, new HGlue ),
|
||||
new HBox( subtitle, new HGlue )
|
||||
);
|
||||
|
||||
addButsArea = new MyMonoScene;
|
||||
// addButsArea = new Scene;
|
||||
VGlue * vg = new VGlue( space, 0 );
|
||||
addButsArea->Insert( vg );
|
||||
|
||||
return new MarginFrame(
|
||||
new VBox(
|
||||
titleblock,
|
||||
new VGlue( space, 0 ),
|
||||
new Frame( new MarginFrame( _sedit, 2 ) ),
|
||||
new VGlue( space, 0 ),
|
||||
new Frame( AddScroller( browser() ) ),
|
||||
new VGlue( space, 0 ),
|
||||
new HBox(
|
||||
addButsArea,
|
||||
new HGlue,
|
||||
new PushButton( "Cancel", state, '\007' ),
|
||||
new HGlue( space, 0 ),
|
||||
new PushButton( acptLbl, state, '\r' )
|
||||
)
|
||||
), space, space / 2, 0
|
||||
);
|
||||
}
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MyFileChooser - a StringChooser for choosing files from a directory.
|
||||
*/
|
||||
|
||||
#ifndef myfilechooser_h
|
||||
#define myfilechooser_h
|
||||
|
||||
#include <IV-2_6/InterViews/strchooser.h>
|
||||
#include <IV-2_6/InterViews/scene.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
class Button;
|
||||
class MyFileBrowser;
|
||||
class MarginFrame;
|
||||
|
||||
// I created this class so that I can create a Monoscene since the constructor
|
||||
// is protected for MonoScene.
|
||||
|
||||
class MyMonoScene : public MonoScene
|
||||
{
|
||||
public:
|
||||
MyMonoScene() { }
|
||||
};
|
||||
|
||||
|
||||
class MyFileChooser : public StringChooser {
|
||||
public:
|
||||
MyFileChooser(
|
||||
const char* Title = "Please select a file:",
|
||||
const char* Subtitle = "",
|
||||
const char* dir = "~",
|
||||
int rows = 10, int cols = 24,
|
||||
const char* acceptLabel = " Open ",
|
||||
Alignment a = Center,
|
||||
int restrictBool = 0
|
||||
);
|
||||
MyFileChooser(
|
||||
const char* name, const char* Title, const char* Subtitle,
|
||||
const char* dir, int rows, int cols, const char* acceptLabel,
|
||||
Alignment a, int restrictBool = 0
|
||||
);
|
||||
|
||||
void SetTitle(const char*);
|
||||
void SetSubtitle(const char*);
|
||||
void SelectFile();
|
||||
|
||||
virtual boolean Accept();
|
||||
void Restrict(int boolvar);
|
||||
int Restrict() {
|
||||
return restrict;
|
||||
}
|
||||
void UpdateDir();
|
||||
protected:
|
||||
MyFileChooser(ButtonState*, Alignment = Center);
|
||||
MyFileChooser(ButtonState*, const char* dir, int rows, int cols,Alignment);
|
||||
void Init(const char*, const char*);
|
||||
virtual Interactor* Interior(const char* acptlbl);
|
||||
Interactor* AddScroller(Interactor*);
|
||||
MyFileBrowser* browser();
|
||||
|
||||
virtual void UpdateEditor();
|
||||
virtual void UpdateBrowser();
|
||||
protected:
|
||||
MarginFrame* title, *subtitle;
|
||||
int restrict;
|
||||
// Scene *addButsArea;
|
||||
MyMonoScene *addButsArea;
|
||||
};
|
||||
|
||||
inline MyFileBrowser* MyFileChooser::browser () { return (MyFileBrowser*) _browser; }
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,383 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Implementation of common menus.
|
||||
*/
|
||||
|
||||
#include <InterViews/event.h>
|
||||
#include <InterViews/pattern.h>
|
||||
#include <InterViews/window.h>
|
||||
|
||||
#include <IV-2_6/InterViews/box.h>
|
||||
#include <IV-2_6/InterViews/frame.h>
|
||||
#include <IV-2_6/InterViews/glue.h>
|
||||
//#include <IV-2_6/InterViews/menu.h>
|
||||
#include <IV-2_6/InterViews/message.h>
|
||||
#include <IV-2_6/InterViews/painter.h>
|
||||
#include <IV-2_6/InterViews/shape.h>
|
||||
#include <IV-2_6/InterViews/world.h>
|
||||
#include <OS/math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <mymenu.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
/** class MyMenuItem **/
|
||||
|
||||
MyMenuItem::MyMenuItem( Interactor * i ) : MyControl( i ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyMenuItem::MyMenuItem( const char * name, Interactor * i ) : MyControl( name, i ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyMenuItem::MyMenuItem(
|
||||
const char * str, Alignment al )
|
||||
: MyControl( new Message( str, al, 2, hfil, 0 ) )
|
||||
// : MyControl(str, new Message(str, al, 2, hfil, 0))
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
MyMenuItem::MyMenuItem(
|
||||
const char * name,
|
||||
const char * str, Alignment al )
|
||||
: MyControl( name, new Message( str, al, 2, hfil, 0 ) ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyMenuItem::~MyMenuItem() { }
|
||||
|
||||
void MyMenuItem::Init() {
|
||||
SetClassName( "MyMenuItem" );
|
||||
}
|
||||
|
||||
void MyMenuItem::Busy() {
|
||||
RootControl()->Highlight( true );
|
||||
}
|
||||
|
||||
void MyMenuItem::Done() {
|
||||
RootControl()->Highlight( false );
|
||||
}
|
||||
|
||||
/** class MyMenuShadow **/
|
||||
|
||||
class MyMenuShadow : public MonoScene {
|
||||
public:
|
||||
static Pattern * halftone;
|
||||
int depth_;
|
||||
|
||||
MyMenuShadow( Interactor *, int depth = 4 );
|
||||
virtual ~MyMenuShadow();
|
||||
|
||||
virtual void Reconfig();
|
||||
virtual void Resize();
|
||||
virtual void Redraw( IntCoord, IntCoord, IntCoord, IntCoord );
|
||||
};
|
||||
|
||||
Pattern * MyMenuShadow::halftone;
|
||||
|
||||
MyMenuShadow::MyMenuShadow( Interactor * i, int d ) {
|
||||
SetClassName( "MyMenuShadow" );
|
||||
depth_ = d;
|
||||
if( halftone == nil ) {
|
||||
halftone = new Pattern( Pattern::gray );
|
||||
halftone->ref();
|
||||
}
|
||||
if( i != nil ) {
|
||||
Insert( new Frame( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
MyMenuShadow::~MyMenuShadow() { }
|
||||
|
||||
void MyMenuShadow::Reconfig() {
|
||||
MonoScene::Reconfig();
|
||||
const char * d = GetAttribute( "depth" );
|
||||
if( d != nil ) {
|
||||
depth_ = atoi( d );
|
||||
}
|
||||
shape->width += depth_;
|
||||
shape->height += depth_;
|
||||
}
|
||||
|
||||
void MyMenuShadow::Resize() {
|
||||
// if (component != nil) {
|
||||
if( interior() != nil ) {
|
||||
// Place(component, 0, depth_, xmax - depth_, ymax);
|
||||
Place( interior(), 0, depth_, xmax - depth_, ymax );
|
||||
}
|
||||
}
|
||||
|
||||
void MyMenuShadow::Redraw( IntCoord x1, IntCoord y1, IntCoord x2, IntCoord y2 ) {
|
||||
if( x2 >= depth_ && y1 <= ymax - depth_ ) {
|
||||
const Pattern * p = output->GetPattern();
|
||||
Resource::ref( p );
|
||||
boolean b = output->BgFilled();
|
||||
output->SetPattern( halftone );
|
||||
output->FillBg( false );
|
||||
IntCoord left = Math::max( x1, depth_ );
|
||||
IntCoord top = Math::min( y2, ymax - depth_ );
|
||||
output->FillRect( canvas, left, y1, x2, top );
|
||||
output->FillBg( b );
|
||||
output->SetPattern( p );
|
||||
Resource::unref( p );
|
||||
}
|
||||
}
|
||||
|
||||
/** class MyMenu **/
|
||||
|
||||
MyMenu::MyMenu( Interactor * i ) : MyControl( i ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyMenu::MyMenu( const char * name, Interactor * i ) : MyControl( name, i ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
void MyMenu::Init() {
|
||||
SetClassName( "MyMenu" );
|
||||
state_ = new MyControlState;
|
||||
state_->Reference();
|
||||
scene_ = new VBox;
|
||||
body_ = new MyMenuShadow( scene_ );
|
||||
depth_ = 3;
|
||||
align_ = BottomLeft;
|
||||
world_ = nil;
|
||||
rel_x_ = 0;
|
||||
rel_y_ = 0;
|
||||
ins_x_ = 0;
|
||||
ins_y_ = 0;
|
||||
}
|
||||
|
||||
MyMenu::~MyMenu() {
|
||||
delete body_;
|
||||
Unref( state_ );
|
||||
}
|
||||
|
||||
void MyMenu::SetBody( Interactor * i ) {
|
||||
body_ = i;
|
||||
}
|
||||
void MyMenu::SetAlign( Alignment a ) {
|
||||
align_ = a;
|
||||
}
|
||||
void MyMenu::SetDepth( int d ) {
|
||||
depth_ = d;
|
||||
}
|
||||
|
||||
void MyMenu::SetBodyState( MyControlState * s ) {
|
||||
Unref( state_ );
|
||||
state_ = s;
|
||||
s->Reference();
|
||||
}
|
||||
|
||||
void MyMenu::SetScene( Scene * s ) {
|
||||
delete body_;
|
||||
scene_ = s;
|
||||
body_ = nil;
|
||||
for( Scene * p = scene_; p != nil; p = p->Parent() ) {
|
||||
body_ = p;
|
||||
}
|
||||
/*
|
||||
if (scene_ != nil) {
|
||||
delete scene_;
|
||||
}
|
||||
scene_ = s;
|
||||
body_ = scene_->Root();
|
||||
*/
|
||||
}
|
||||
|
||||
void MyMenu::Include( MyControl * c ) {
|
||||
/*
|
||||
scene_->Insert(c);
|
||||
if (scene_ == nil) {
|
||||
scene_ = new VBox;
|
||||
body_ = new MyMenuShadow(scene_);
|
||||
}
|
||||
*/
|
||||
scene_->Insert( c );
|
||||
c->SetState( GetBodyState() );
|
||||
Reparent( c, this );
|
||||
}
|
||||
|
||||
void MyMenu::Reconfig() {
|
||||
MyControl::Reconfig();
|
||||
world_ = GetWorld();
|
||||
Setup();
|
||||
}
|
||||
|
||||
void MyMenu::Setup() {
|
||||
body_->Config( world_ );
|
||||
Shape * s = body_->GetShape();
|
||||
rel_x_ = s->width / 2;
|
||||
rel_y_ = s->height / 2;
|
||||
}
|
||||
|
||||
void MyMenu::Popup( Event & e ) {
|
||||
if( Enabled() ) {
|
||||
World * w;
|
||||
IntCoord wx, wy;
|
||||
e.GetAbsolute( w, wx, wy );
|
||||
if( w != world_ ) {
|
||||
world_ = w;
|
||||
Setup();
|
||||
}
|
||||
InsertBody( wx - rel_x_, wy - rel_y_ );
|
||||
State()->Selection( this );
|
||||
}
|
||||
}
|
||||
|
||||
void MyMenu::Leave() { }
|
||||
|
||||
void MyMenu::Open() {
|
||||
IntCoord x, y;
|
||||
Align( align_, 0, 0, x, y );
|
||||
GetRelative( x, y );
|
||||
InsertBody( x, y - body_->GetShape()->height );
|
||||
}
|
||||
|
||||
void MyMenu::InsertBody( IntCoord x, IntCoord y ) {
|
||||
ins_x_ = x;
|
||||
ins_y_ = y;
|
||||
world_->InsertPopup( body_, x, y );
|
||||
State()->Push( state_ );
|
||||
state_->Activate();
|
||||
world_->Flush();
|
||||
}
|
||||
|
||||
void MyMenu::Close() {
|
||||
if( body_->GetCanvas() != nil ) {
|
||||
MyControl * action = state_->Action();
|
||||
state_->Action( nil );
|
||||
if( action != nil ) {
|
||||
action->Align( Center, 0, 0, rel_x_, rel_y_ );
|
||||
action->GetRelative( rel_x_, rel_y_, body_ );
|
||||
}
|
||||
}
|
||||
state_->Pop();
|
||||
world_->Remove( body_ );
|
||||
world_->Flush();
|
||||
}
|
||||
|
||||
/** class MyMenuBar **/
|
||||
|
||||
MyMenuBar::MyMenuBar() {
|
||||
Init();
|
||||
}
|
||||
MyMenuBar::MyMenuBar( const char * name ) {
|
||||
SetInstance( name );
|
||||
Init();
|
||||
}
|
||||
|
||||
void MyMenuBar::Init() {
|
||||
SetClassName( "MyMenuBar" );
|
||||
state_ = new MyControlState;
|
||||
state_->Reference();
|
||||
}
|
||||
|
||||
MyMenuBar::~MyMenuBar() {
|
||||
Unref( state_ );
|
||||
}
|
||||
|
||||
void MyMenuBar::Include( MyControl * c ) {
|
||||
Insert( c );
|
||||
c->SetState( state_ );
|
||||
}
|
||||
|
||||
/** class MyPulldownMenu **/
|
||||
|
||||
MyPulldownMenu::MyPulldownMenu( Interactor * i ) : MyMenu( i ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyPulldownMenu::MyPulldownMenu(
|
||||
const char * name, Interactor * i ) : MyMenu( name, i ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyPulldownMenu::MyPulldownMenu(
|
||||
const char * str ) : MyMenu( str, new Message( str, Center, 2 ) ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyPulldownMenu::MyPulldownMenu(
|
||||
const char * name, const char * str )
|
||||
: MyMenu( name, new Message( str, Center, 2 ) ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyPulldownMenu::~MyPulldownMenu() { }
|
||||
|
||||
void MyPulldownMenu::Init() {
|
||||
SetClassName( "MyPulldownMenu" );
|
||||
SetAlign( BottomLeft );
|
||||
}
|
||||
|
||||
/** class MyPullrightMenu **/
|
||||
|
||||
MyPullrightMenu::MyPullrightMenu( Interactor * i ) : MyMenu( i ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyPullrightMenu::MyPullrightMenu(
|
||||
const char * name, Interactor * i ) : MyMenu( name, i ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyPullrightMenu::MyPullrightMenu(
|
||||
const char * str ) : MyMenu( str, new Message( str, Left, 2 ) ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyPullrightMenu::MyPullrightMenu(
|
||||
const char * name, const char * str )
|
||||
: MyMenu( name, new Message( str, Left, 2 ) ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyPullrightMenu::~MyPullrightMenu() { }
|
||||
|
||||
void MyPullrightMenu::Init() {
|
||||
SetClassName( "MyPullrightMenu" );
|
||||
SetAlign( TopRight );
|
||||
}
|
||||
|
||||
/** class PopupMenu **/
|
||||
|
||||
MyPopupMenu::MyPopupMenu() : MyMenu( ( Interactor * )nil ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyPopupMenu::MyPopupMenu( const char * name ) : MyMenu( name, ( Interactor * )nil ) {
|
||||
Init();
|
||||
}
|
||||
|
||||
MyPopupMenu::~MyPopupMenu() { }
|
||||
|
||||
void MyPopupMenu::Init() {
|
||||
SetClassName( "MyPopupMenu" );
|
||||
SetState( new MyControlState );
|
||||
SetAlign( Center );
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Common menus built on top of controls
|
||||
*/
|
||||
|
||||
#ifndef mymenu_h
|
||||
#define mymenu_h
|
||||
|
||||
#include <IV-2_6/InterViews/box.h>
|
||||
#include <mycontrol.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
class MyMenuItem : public MyControl {
|
||||
public:
|
||||
MyMenuItem(Interactor*);
|
||||
MyMenuItem(const char* name, Interactor*);
|
||||
MyMenuItem(const char* str, Alignment = Left);
|
||||
MyMenuItem(const char* name, const char* str, Alignment = Left);
|
||||
virtual ~MyMenuItem();
|
||||
|
||||
protected:
|
||||
virtual void Busy();
|
||||
virtual void Done();
|
||||
|
||||
private:
|
||||
void Init();
|
||||
};
|
||||
|
||||
class MyMenu : public MyControl {
|
||||
public:
|
||||
MyMenu(Interactor*);
|
||||
MyMenu(const char* name, Interactor* i);
|
||||
virtual ~MyMenu();
|
||||
|
||||
void SetBody(Interactor*);
|
||||
Interactor* GetBody() { return body_; }
|
||||
|
||||
void SetAlign(Alignment);
|
||||
Alignment GetAlign() { return align_; }
|
||||
|
||||
void SetDepth(int);
|
||||
int GetDepth() { return depth_; }
|
||||
|
||||
void SetBodyState(MyControlState*);
|
||||
MyControlState* GetBodyState() { return state_; }
|
||||
|
||||
void SetScene(Scene*);
|
||||
Scene* GetScene() { return scene_; }
|
||||
virtual void Include(MyControl*);
|
||||
|
||||
virtual void Popup(Event&);
|
||||
|
||||
IntCoord InsertX() { return ins_x_; }
|
||||
IntCoord InsertY() { return ins_y_; }
|
||||
protected:
|
||||
virtual void Leave();
|
||||
virtual void Open();
|
||||
virtual void Close();
|
||||
|
||||
virtual void Reconfig();
|
||||
virtual void Setup();
|
||||
virtual void InsertBody(IntCoord, IntCoord);
|
||||
private:
|
||||
Interactor* body_;
|
||||
Scene* scene_;
|
||||
MyControlState* state_;
|
||||
Interactor* shadow_;
|
||||
unsigned int depth_ : 16;
|
||||
unsigned int align_ : 16;
|
||||
class World* world_;
|
||||
IntCoord ins_x_, ins_y_;
|
||||
IntCoord rel_x_, rel_y_;
|
||||
private:
|
||||
void Init();
|
||||
};
|
||||
|
||||
class MyMenuBar : public HBox {
|
||||
public:
|
||||
MyMenuBar();
|
||||
MyMenuBar(const char* name);
|
||||
virtual ~MyMenuBar();
|
||||
|
||||
virtual void Include(MyControl*);
|
||||
protected:
|
||||
MyControlState* state_;
|
||||
private:
|
||||
void Init();
|
||||
};
|
||||
|
||||
class MyPulldownMenu : public MyMenu {
|
||||
public:
|
||||
MyPulldownMenu(Interactor* i);
|
||||
MyPulldownMenu(const char* name, Interactor* i);
|
||||
MyPulldownMenu(const char* str);
|
||||
MyPulldownMenu(const char* name, const char* str);
|
||||
virtual ~MyPulldownMenu();
|
||||
|
||||
private:
|
||||
void Init();
|
||||
};
|
||||
|
||||
class MyPullrightMenu : public MyMenu {
|
||||
public:
|
||||
MyPullrightMenu(Interactor* i);
|
||||
MyPullrightMenu(const char* name, Interactor* i);
|
||||
MyPullrightMenu(const char* str);
|
||||
MyPullrightMenu(const char* name, const char* str);
|
||||
virtual ~MyPullrightMenu();
|
||||
|
||||
private:
|
||||
void Init();
|
||||
};
|
||||
|
||||
class MyPopupMenu : public MyMenu {
|
||||
public:
|
||||
MyPopupMenu();
|
||||
MyPopupMenu(const char*);
|
||||
virtual ~MyPopupMenu();
|
||||
private:
|
||||
void Init();
|
||||
};
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,148 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MyMessage class implementation.
|
||||
*
|
||||
* adapted from Message by David Sauder
|
||||
*/
|
||||
|
||||
#include <mymessage.h>
|
||||
#include <InterViews/font.h>
|
||||
#include <IV-2_6/InterViews/painter.h>
|
||||
//#include <IV-2_6/InterViews/scene.h>
|
||||
#include <IV-2_6/InterViews/shape.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern "C" {
|
||||
#include <string.h>
|
||||
}
|
||||
|
||||
MyMessage::MyMessage( const char * msg, Alignment al, int Pad,
|
||||
int hstretch, int vstretch ) {
|
||||
Init( msg, al, Pad, hstretch, vstretch );
|
||||
}
|
||||
|
||||
MyMessage::MyMessage(
|
||||
const char * name,
|
||||
const char * msg, Alignment al, int Pad, int hstretch, int vstretch )
|
||||
: Interactor( name ) {
|
||||
Init( msg, al, Pad, hstretch, vstretch );
|
||||
}
|
||||
|
||||
void MyMessage::Init( const char * t, Alignment a, int p, int hstr, int vstr ) {
|
||||
SetClassName( "MyMessage" );
|
||||
textLen = strlen( t ) + 1;
|
||||
|
||||
text = new char[textLen];
|
||||
strcpy( text, t );
|
||||
|
||||
textReturned = new char[textLen];
|
||||
strcpy( textReturned, t );
|
||||
|
||||
alignment = a;
|
||||
pad = p;
|
||||
shape->hstretch = hstr;
|
||||
shape->vstretch = vstr;
|
||||
highlighted = false;
|
||||
}
|
||||
|
||||
MyMessage::~MyMessage() {
|
||||
delete text;
|
||||
}
|
||||
|
||||
void MyMessage::Reconfig() {
|
||||
const char * a = GetAttribute( "text" );
|
||||
if( a != nil ) {
|
||||
delete text;
|
||||
text = new char[strlen( a ) + 1];
|
||||
strcpy( text, a );
|
||||
}
|
||||
a = GetAttribute( "padding" );
|
||||
if( a != nil ) {
|
||||
pad = atoi( a );
|
||||
}
|
||||
const Font * f = output->GetFont();
|
||||
shape->width = pad + f->Width( text ) + pad;
|
||||
shape->height = pad + f->Height() + pad;
|
||||
shape->hshrink = pad + pad;
|
||||
shape->vshrink = pad + pad;
|
||||
}
|
||||
|
||||
void MyMessage::Realign( Alignment a ) {
|
||||
alignment = a;
|
||||
Draw();
|
||||
}
|
||||
|
||||
void MyMessage::Redraw( IntCoord l, IntCoord b, IntCoord r, IntCoord t ) {
|
||||
IntCoord x = 0, y = 0;
|
||||
Align( alignment, shape->width, shape->height, x, y );
|
||||
output->Clip( canvas, l, b, r, t );
|
||||
if( highlighted ) {
|
||||
output->SetColors( output->GetBgColor(), output->GetFgColor() );
|
||||
}
|
||||
output->ClearRect( canvas, l, b, r, t );
|
||||
output->Text( canvas, text, x + pad, y + pad );
|
||||
if( highlighted ) {
|
||||
output->SetColors( output->GetBgColor(), output->GetFgColor() );
|
||||
}
|
||||
output->NoClip();
|
||||
}
|
||||
|
||||
void MyMessage::Highlight( boolean b ) {
|
||||
if( highlighted != b ) {
|
||||
highlighted = b;
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
|
||||
void MyMessage::NewMessage( char * t ) {
|
||||
IntCoord x = 0, y = 0;
|
||||
|
||||
|
||||
/*
|
||||
int len_t = strlen(t);
|
||||
int len_text = strlen(text);
|
||||
|
||||
if(len_t > len_text){
|
||||
delete text;
|
||||
text = new char[len_t + 1];
|
||||
strcpy(text, t);
|
||||
} else {
|
||||
strcpy(text, t);
|
||||
for(i = len_t - 1; i < len_text; i++)
|
||||
text[i] = ' ';
|
||||
}
|
||||
*/
|
||||
strncpy( text, t, textLen );
|
||||
text[textLen - 1] = '\0';
|
||||
|
||||
strncpy( textReturned, t, textLen );
|
||||
textReturned[textLen - 1] = '\0';
|
||||
|
||||
output->Text( canvas, text, x + pad, y + pad );
|
||||
Draw();
|
||||
}
|
||||
|
||||
char * MyMessage::Text() {
|
||||
return textReturned;
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MyMessage - display a string of text (fixed size)
|
||||
*
|
||||
* adapted from Message by David Sauder
|
||||
*/
|
||||
|
||||
#ifndef MyMessage_h
|
||||
#define MyMessage_h
|
||||
|
||||
#define iv2_6_compatible
|
||||
|
||||
#include <IV-2_6/InterViews/interactor.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
class MyMessage : public Interactor {
|
||||
public:
|
||||
MyMessage(
|
||||
const char* msg, Alignment al = Center, int Pad = 0,
|
||||
int hstretch = 0, int vstretch = 0
|
||||
);
|
||||
MyMessage(
|
||||
const char* name,
|
||||
const char* msg, Alignment al = Center, int Pad = 0,
|
||||
int hstretch = 0, int vstretch = 0
|
||||
);
|
||||
virtual ~MyMessage();
|
||||
|
||||
virtual void Highlight(boolean);
|
||||
virtual void Realign(Alignment);
|
||||
void NewMessage (char* t);
|
||||
char* Text ();
|
||||
protected:
|
||||
char* text;
|
||||
char* textReturned;
|
||||
Alignment alignment : 16;
|
||||
unsigned pad : 15;
|
||||
boolean highlighted : 1;
|
||||
|
||||
virtual void Reconfig();
|
||||
virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord);
|
||||
int textLen;
|
||||
private:
|
||||
void Init(const char*, Alignment, int p, int hstretch, int vstretch);
|
||||
};
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,161 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MyMessage class implementation.
|
||||
*
|
||||
* adapted from Message by David Sauder
|
||||
*/
|
||||
|
||||
#include <mymessage2.h>
|
||||
#include <InterViews/font.h>
|
||||
#include <IV-2_6/InterViews/painter.h>
|
||||
#include <IV-2_6/InterViews/scene.h>
|
||||
#include <IV-2_6/InterViews/shape.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern "C" {
|
||||
#include <string.h>
|
||||
}
|
||||
|
||||
MyMessage2::MyMessage2( const char * msg, Alignment al, int pad_,
|
||||
int hstretch, int vstretch ) {
|
||||
Init( msg, al, pad_, hstretch, vstretch );
|
||||
}
|
||||
|
||||
MyMessage2::MyMessage2(
|
||||
const char * name,
|
||||
const char * msg, Alignment al, int Pad, int hstretch, int vstretch )
|
||||
: Interactor( name ) {
|
||||
Init( msg, al, Pad, hstretch, vstretch );
|
||||
}
|
||||
|
||||
void MyMessage2::Init( const char * t, Alignment a, int p, int hstr, int vstr ) {
|
||||
SetClassName( "MyMessage2" );
|
||||
textLen = strlen( t ) + 1;
|
||||
|
||||
text = new char[textLen];
|
||||
strcpy( text, t );
|
||||
|
||||
textReturned = new char[textLen];
|
||||
strcpy( textReturned, t );
|
||||
|
||||
alignment = a;
|
||||
pad = p;
|
||||
shape->hstretch = hstr;
|
||||
shape->vstretch = vstr;
|
||||
highlighted = false;
|
||||
}
|
||||
|
||||
MyMessage2::~MyMessage2() {
|
||||
delete text;
|
||||
}
|
||||
|
||||
void MyMessage2::Reconfig() {
|
||||
const char * a = GetAttribute( "text" );
|
||||
if( a != nil ) {
|
||||
delete text;
|
||||
text = new char[strlen( a ) + 1];
|
||||
strcpy( text, a );
|
||||
}
|
||||
a = GetAttribute( "padding" );
|
||||
if( a != nil ) {
|
||||
pad = atoi( a );
|
||||
}
|
||||
const Font * f = output->GetFont();
|
||||
shape->width = pad + f->Width( text ) + pad;
|
||||
shape->height = pad + f->Height() + pad;
|
||||
shape->hshrink = pad + pad;
|
||||
shape->vshrink = pad + pad;
|
||||
}
|
||||
|
||||
void MyMessage2::Realign( Alignment a ) {
|
||||
alignment = a;
|
||||
Draw();
|
||||
}
|
||||
|
||||
void MyMessage2::Redraw( IntCoord l, IntCoord b, IntCoord r, IntCoord t ) {
|
||||
IntCoord x = 0, y = 0;
|
||||
Align( alignment, shape->width, shape->height, x, y );
|
||||
output->Clip( canvas, l, b, r, t );
|
||||
if( highlighted ) {
|
||||
output->SetColors( output->GetBgColor(), output->GetFgColor() );
|
||||
}
|
||||
output->ClearRect( canvas, l, b, r, t );
|
||||
output->Text( canvas, text, x + pad, y + pad );
|
||||
if( highlighted ) {
|
||||
output->SetColors( output->GetBgColor(), output->GetFgColor() );
|
||||
}
|
||||
output->NoClip();
|
||||
}
|
||||
|
||||
void MyMessage2::Highlight( boolean b ) {
|
||||
if( highlighted != b ) {
|
||||
highlighted = b;
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
|
||||
void MyMessage2::NewMessage( char * t ) {
|
||||
IntCoord x = 0, y = 0;
|
||||
|
||||
|
||||
/*
|
||||
int len_t = strlen(t);
|
||||
int len_text = strlen(text);
|
||||
|
||||
if(len_t > len_text){
|
||||
delete text;
|
||||
text = new char[len_t + 1];
|
||||
strcpy(text, t);
|
||||
} else {
|
||||
strcpy(text, t);
|
||||
for(i = len_t - 1; i < len_text; i++)
|
||||
text[i] = ' ';
|
||||
}
|
||||
*/
|
||||
int bigger = 0;
|
||||
if( strlen( t ) > strlen( text ) ) {
|
||||
delete text;
|
||||
textLen = strlen( t ) + 1;
|
||||
text = new char[textLen];
|
||||
bigger = 1;
|
||||
}
|
||||
strncpy( text, t, textLen );
|
||||
text[textLen - 1] = '\0';
|
||||
|
||||
strncpy( textReturned, t, textLen );
|
||||
textReturned[textLen - 1] = '\0';
|
||||
|
||||
if( bigger ) {
|
||||
Reconfig();
|
||||
}
|
||||
output->Text( canvas, text, x + pad, y + pad );
|
||||
if( bigger ) {
|
||||
Draw();
|
||||
Parent()->Change();
|
||||
}
|
||||
}
|
||||
|
||||
char * MyMessage2::Text() {
|
||||
return textReturned;
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MyMessage2 - display a string of text (resizable)
|
||||
*
|
||||
* adapted from Message by David Sauder
|
||||
*/
|
||||
|
||||
#ifndef MyMessage2_h
|
||||
#define MyMessage2_h
|
||||
|
||||
#define iv2_6_compatible
|
||||
|
||||
#include <IV-2_6/InterViews/interactor.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
class MyMessage2 : public Interactor {
|
||||
public:
|
||||
MyMessage2(
|
||||
const char* msg, Alignment al = Center, int pad = 0,
|
||||
int hstretch = 0, int vstretch = 0
|
||||
);
|
||||
MyMessage2(
|
||||
const char* name,
|
||||
const char* msg, Alignment al = Center, int pad = 0,
|
||||
int hstretch = 0, int vstretch = 0
|
||||
);
|
||||
virtual ~MyMessage2();
|
||||
|
||||
|
||||
virtual void Highlight(boolean);
|
||||
virtual void Realign(Alignment);
|
||||
void NewMessage (char* t);
|
||||
char* Text ();
|
||||
protected:
|
||||
char* text;
|
||||
char* textReturned;
|
||||
Alignment alignment : 16;
|
||||
unsigned pad : 15;
|
||||
boolean highlighted : 1;
|
||||
|
||||
virtual void Reconfig();
|
||||
virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord);
|
||||
int textLen;
|
||||
private:
|
||||
void Init(const char*, Alignment, int pad, int hstretch, int vstretch);
|
||||
};
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,175 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MyStringBrowser - a Mac minifinder-like object for perusing and
|
||||
* choosing from list of strings. I rebound the key bindings. I also
|
||||
* wanted to add a function ReplaceText() so I could replace the text
|
||||
* on an existing line. However, in order to do this I needed to use
|
||||
* the private member variable 'display'; so I had to copy all of
|
||||
* StringBrowser since I couldn't use it's private variable 'display'.
|
||||
*/
|
||||
|
||||
#ifndef mystrbrowser_h
|
||||
#define mystrbrowser_h
|
||||
|
||||
#include <IV-2_6/InterViews/interactor.h>
|
||||
#include <IV-2_6/InterViews/button.h>
|
||||
#include <IV-2_6/InterViews/textdisplay.h>
|
||||
#include <IV-2_6/InterViews/textstyle.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
static const char* mySBDone = "\r\t\007\033";
|
||||
|
||||
/* these are new key bindings for MyStringBrowser */
|
||||
static const char mySBFirstString = '\001'; // <ctrl> a
|
||||
static const char mySBLastString = '\005'; // <ctrl> e
|
||||
//static const char mySBSelectAll = '\023'; // <ctrl> s
|
||||
static const char mySBSelectAll = '\027'; // <ctrl> w
|
||||
static const char mySBUnselectAll = '\177'; // <delete>
|
||||
static const char mySBUnselectAllAlt = '\010'; // <ctrl> h
|
||||
static const char mySBSelectPreviousString = '\020'; // <ctrl> p
|
||||
static const char mySBSelectNextString = '\016'; // <ctrl> n
|
||||
static const char mySBSelectTopString = '<';
|
||||
static const char mySBSelectBottomString = '>';
|
||||
static const char mySBScrollUpb = '\002'; // <ctrl> b
|
||||
static const char mySBScrollUpk = '\v'; // <ctrl> k
|
||||
static const char mySBScrollDownf = '\006'; // <ctrl> f
|
||||
static const char mySBScrollDownj = '\n'; // <ctrl> j
|
||||
static const char mySBPageDownSp = ' ';
|
||||
static const char mySBPageDown = '\026'; // <ctrl> v
|
||||
//static const char mySBPageUp = 'v';
|
||||
static const char mySBHalfPageDown = '\004'; // <ctrl> d
|
||||
static const char mySBHalfPageUp = '\025'; // <ctrl> u
|
||||
|
||||
class ButtonState;
|
||||
class TextDisplay;
|
||||
|
||||
class MyStringBrowser : public Interactor {
|
||||
public:
|
||||
MyStringBrowser(
|
||||
ButtonState*, int rows, int cols,
|
||||
boolean uniqueSel = true, int highlight = Reversed,
|
||||
const char* done = mySBDone
|
||||
);
|
||||
MyStringBrowser(
|
||||
const char* name, ButtonState*, int, int,
|
||||
boolean = true, int = Reversed, const char* = mySBDone
|
||||
);
|
||||
virtual ~MyStringBrowser();
|
||||
|
||||
void Browse();
|
||||
virtual void Insert(const char*, int index);
|
||||
virtual void Append(const char*);
|
||||
virtual void Remove(int index);
|
||||
virtual void ReplaceText(const char* s, int index);
|
||||
|
||||
int SearchForward(char *substr, int startIndex, int ignoreCase = 1);
|
||||
int SearchBackward(char *substr, int startIndex, int ignoreCase = 1);
|
||||
void Bold(int index);
|
||||
|
||||
int Index(const char*);
|
||||
char* String(int);
|
||||
int Count();
|
||||
void Clear();
|
||||
|
||||
void Select(int index);
|
||||
void SelectAll();
|
||||
void Unselect(int index);
|
||||
void UnselectAll();
|
||||
int Selection(int selindex = 0);
|
||||
int SelectionIndex(int index);
|
||||
int Selections();
|
||||
boolean Selected(int index);
|
||||
void ScrollTo(int index);
|
||||
|
||||
virtual void Handle(Event&);
|
||||
virtual void Adjust(Perspective&);
|
||||
protected:
|
||||
void Select(int dot, int mark);
|
||||
void Unselect(int dot, int mark);
|
||||
void ScrollBy(int, int);
|
||||
void ScrollBy(int lines);
|
||||
void ScrollTo(int, int);
|
||||
void ScrollToView(IntCoord, IntCoord);
|
||||
void GrabScroll(Event&);
|
||||
void RateScroll(Event&);
|
||||
|
||||
int Locate(IntCoord, IntCoord);
|
||||
boolean DoubleClicked(Event&);
|
||||
|
||||
virtual boolean HandleChar(char);
|
||||
// used to implement extra char bindings in subclasses
|
||||
virtual boolean HandleCharExtra(char c) { return false; }
|
||||
virtual boolean LeftButtonDown(Event&);
|
||||
|
||||
virtual void Reconfig();
|
||||
virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord);
|
||||
virtual void Resize();
|
||||
protected:
|
||||
int rows;
|
||||
int columns;
|
||||
boolean uniqueSel;
|
||||
boolean singleClick;
|
||||
int clickDelay;
|
||||
int highlight;
|
||||
ButtonState* subject;
|
||||
const char* done;
|
||||
|
||||
// used to be private when this was a StringBrowser
|
||||
char** strbuf;
|
||||
int strbufsize;
|
||||
int strcount;
|
||||
char** selbuf;
|
||||
int selbufsize;
|
||||
int selcount;
|
||||
|
||||
TextDisplay* display;
|
||||
int lineheight;
|
||||
unsigned long lasttime;
|
||||
IntCoord lastx, lasty;
|
||||
int lastdot, lastmark;
|
||||
boolean firstResize;
|
||||
private:
|
||||
void Init(ButtonState*, int, int, boolean, int, const char*);
|
||||
void InitTextDisplay();
|
||||
void InitPerspective(boolean scroll_to_top);
|
||||
|
||||
void UpdateSelection(int dot, int mark, int Style);
|
||||
void UpdateWidth();
|
||||
void Note(Event&);
|
||||
|
||||
boolean HandleDownEvent(Event&);
|
||||
boolean HandleKeyEvent(Event&);
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
inline int MyStringBrowser::Count () { return strcount; }
|
||||
inline int MyStringBrowser::Selections () { return selcount; }
|
||||
inline boolean MyStringBrowser::Selected (int i)
|
||||
{return SelectionIndex(i) >= 0;}
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,65 +0,0 @@
|
||||
|
||||
#include <sbutton.h> // ivfasd/sbutton.h
|
||||
|
||||
#include <InterViews/font.h>
|
||||
#include <InterViews/pattern.h>
|
||||
|
||||
#include <IV-2_6/InterViews/painter.h>
|
||||
#include <IV-2_6/InterViews/sensor.h>
|
||||
#include <IV-2_6/InterViews/shape.h>
|
||||
#include <IV-2_6/InterViews/subject.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
static const int pad = 3;
|
||||
|
||||
SButton::SButton( const char * c, ButtonState * b, int i ) : PushButton( c, b, i ) {
|
||||
SetClassName( "SButton" );
|
||||
Listen( noEvents );
|
||||
}
|
||||
|
||||
void SButton::Reconfig() {
|
||||
TextButton::Reconfig();
|
||||
MakeBackground();
|
||||
if( shape->Undefined() ) {
|
||||
MakeShape();
|
||||
shape->width += output->GetFont()->Width( " " );
|
||||
shape->height += 2 * pad;
|
||||
}
|
||||
}
|
||||
|
||||
void SButton::Redraw( IntCoord x1, IntCoord y1, IntCoord x2, IntCoord y2 ) {
|
||||
output->ClearRect( canvas, x1, y1, x2, y2 );
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void SButton::Refresh() {
|
||||
IntCoord x[4], y[4];
|
||||
IntCoord tx, ty;
|
||||
|
||||
x[0] = 0;
|
||||
y[0] = 0;
|
||||
x[1] = 0;
|
||||
y[1] = ymax;
|
||||
x[2] = xmax;
|
||||
y[2] = ymax;
|
||||
x[3] = xmax;
|
||||
y[3] = 0;
|
||||
tx = ( xmax - output->GetFont()->Width( text ) ) / 2;
|
||||
ty = pad;
|
||||
if( chosen || hit ) {
|
||||
/* (Redundant casts to work around a bug in cfront 1.2 .) */
|
||||
output->FillPolygon( canvas, ( Coord * )x, ( Coord * )y, 4 );
|
||||
background->Text( canvas, text, tx, ty );
|
||||
} else {
|
||||
background->FillRect( canvas, 0, 0, xmax, ymax );
|
||||
/* (Redundant casts to work around a bug in cfront 1.2 .) */
|
||||
output->Polygon( canvas, ( Coord * )x, ( Coord * )y, 4 );
|
||||
output->Text( canvas, text, tx, ty );
|
||||
}
|
||||
if( !enabled ) {
|
||||
grayout->FillRect( canvas, 0, 0, xmax, ymax );
|
||||
}
|
||||
}
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
#include <IV-2_6/InterViews/button.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
class SButton : public PushButton
|
||||
{
|
||||
public:
|
||||
SButton(const char*, ButtonState*, int);
|
||||
virtual void Refresh();
|
||||
protected:
|
||||
virtual void Reconfig();
|
||||
virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord);
|
||||
};
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
@@ -1,407 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* StringDisplay - interactive editor for character strings
|
||||
*/
|
||||
|
||||
#include <InterViews/bitmap.h>
|
||||
#include <InterViews/cursor.h>
|
||||
#include <InterViews/font.h>
|
||||
|
||||
#include <IV-2_6/InterViews/button.h>
|
||||
#include <IV-2_6/InterViews/painter.h>
|
||||
#include <IV-2_6/InterViews/sensor.h>
|
||||
#include <IV-2_6/InterViews/shape.h>
|
||||
#include <IV-2_6/InterViews/subject.h>
|
||||
|
||||
#include <strdisplay.h> // ivfasd/strdisplay.h
|
||||
#include <IV-2_6/InterViews/textbuffer.h>
|
||||
#include <IV-2_6/InterViews/textdisplay.h>
|
||||
#include <IV-2_6/InterViews/world.h>
|
||||
|
||||
#include <InterViews/Bitmaps/hand.bm>
|
||||
#include <InterViews/Bitmaps/handMask.bm>
|
||||
#include <InterViews/Bitmaps/lfast.bm>
|
||||
#include <InterViews/Bitmaps/lfastMask.bm>
|
||||
#include <InterViews/Bitmaps/rfast.bm>
|
||||
#include <InterViews/Bitmaps/rfastMask.bm>
|
||||
#include <OS/math.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static const int BUFFERSIZE = 1000;
|
||||
|
||||
StringDisplay::StringDisplay(
|
||||
ButtonState * s, const char * samp, const char * Done
|
||||
) {
|
||||
Init( s, samp, Done );
|
||||
}
|
||||
|
||||
StringDisplay::StringDisplay(
|
||||
const char * name, ButtonState * s, const char * samp, const char * Done
|
||||
) {
|
||||
SetInstance( name );
|
||||
Init( s, samp, Done );
|
||||
}
|
||||
|
||||
void StringDisplay::Init( ButtonState * s, const char * samp, const char * d ) {
|
||||
SetClassName( "StringDisplay" );
|
||||
sample = strcpy( new char[strlen( samp ) + 1], samp );
|
||||
size = BUFFERSIZE;
|
||||
buffer = new char[size];
|
||||
text = new TextBuffer( buffer, 0, size );
|
||||
left = 0;
|
||||
right = 0;
|
||||
subject = s;
|
||||
if( subject != nil ) {
|
||||
subject->Attach( this );
|
||||
}
|
||||
done = strcpy( new char[strlen( d ) + 1], d );
|
||||
display = new TextDisplay();
|
||||
display->CaretStyle( NoCaret );
|
||||
input = new Sensor();
|
||||
// input->Catch(KeyEvent);
|
||||
input->Catch( DownEvent );
|
||||
input->Catch( UpEvent );
|
||||
Message( sample );
|
||||
}
|
||||
|
||||
StringDisplay::~StringDisplay() {
|
||||
if( subject != nil ) {
|
||||
subject->Detach( this );
|
||||
}
|
||||
delete text;
|
||||
delete sample;
|
||||
delete done;
|
||||
delete buffer;
|
||||
delete display;
|
||||
}
|
||||
|
||||
static Cursor * handCursor;
|
||||
static Cursor * leftCursor;
|
||||
static Cursor * rightCursor;
|
||||
|
||||
void StringDisplay::Reconfig() {
|
||||
if( handCursor == nil ) {
|
||||
handCursor = new Cursor(
|
||||
new Bitmap(
|
||||
hand_bits, hand_width, hand_height, hand_x_hot, hand_y_hot
|
||||
),
|
||||
new Bitmap( hand_mask_bits, hand_mask_width, hand_mask_height ),
|
||||
output->GetFgColor(), output->GetBgColor()
|
||||
);
|
||||
|
||||
leftCursor = new Cursor(
|
||||
new Bitmap(
|
||||
lfast_bits, lfast_width, lfast_height, lfast_x_hot, lfast_y_hot
|
||||
),
|
||||
new Bitmap( lfast_mask_bits, lfast_mask_width, lfast_mask_height ),
|
||||
output->GetFgColor(), output->GetBgColor()
|
||||
);
|
||||
|
||||
rightCursor = new Cursor(
|
||||
new Bitmap(
|
||||
rfast_bits, rfast_width, rfast_height, rfast_x_hot, rfast_y_hot
|
||||
),
|
||||
new Bitmap( rfast_mask_bits, rfast_mask_width, rfast_mask_height ),
|
||||
output->GetFgColor(), output->GetBgColor()
|
||||
);
|
||||
}
|
||||
|
||||
const Font * f = output->GetFont();
|
||||
shape->Rect( f->Width( sample ), f->Height() );
|
||||
shape->Rigid( hfil, hfil, 0, 0 );
|
||||
display->LineHeight( f->Height() );
|
||||
}
|
||||
|
||||
void StringDisplay::Resize() {
|
||||
display->Draw( output, canvas );
|
||||
display->Resize( 0, 0, xmax, ymax );
|
||||
Select( left, right );
|
||||
}
|
||||
|
||||
void StringDisplay::Redraw( IntCoord l, IntCoord b, IntCoord r, IntCoord t ) {
|
||||
display->Draw( output, canvas );
|
||||
display->Redraw( l, b, r, t );
|
||||
}
|
||||
|
||||
void StringDisplay::Message( const char * t ) {
|
||||
text->Delete( text->BeginningOfText(), text->Length() );
|
||||
text->Insert( 0, t, strlen( t ) );
|
||||
int bol = text->BeginningOfLine( 0 );
|
||||
int eol = text->EndOfLine( 0 );
|
||||
display->Draw( output, canvas );
|
||||
display->ReplaceText( 0, text->Text( bol, eol ), eol - bol );
|
||||
Select( eol );
|
||||
}
|
||||
|
||||
void StringDisplay::Select( int l ) {
|
||||
Select( l, l );
|
||||
}
|
||||
|
||||
void StringDisplay::Select( int l, int r ) {
|
||||
display->Draw( output, canvas );
|
||||
int origin = display->Left( 0, 0 );
|
||||
if( display->Left( 0, r - 1 ) < 0 ) {
|
||||
origin += xmax / 2 - display->Left( 0, r - 1 );
|
||||
} else if( display->Right( 0, r + 1 ) > xmax ) {
|
||||
origin += xmax / 2 - display->Right( 0, r + 1 );
|
||||
}
|
||||
origin = Math::min(
|
||||
0, Math::max( Math::min( 0, xmax - display->Width() ), origin )
|
||||
);
|
||||
display->Scroll( 0, origin, ymax );
|
||||
DoSelect( l, r );
|
||||
}
|
||||
|
||||
void StringDisplay::DoSelect( int l, int r ) {
|
||||
display->Draw( output, canvas );
|
||||
if( l > r ) {
|
||||
int tmp = r;
|
||||
r = l;
|
||||
l = tmp;
|
||||
}
|
||||
l = Math::max( l, text->BeginningOfLine( left ) );
|
||||
r = Math::min( r, text->EndOfLine( right ) );
|
||||
if( r < left || l > right ) {
|
||||
if( right > left ) {
|
||||
display->Style( 0, left, 0, right - 1, Plain );
|
||||
}
|
||||
if( r > l ) {
|
||||
display->Style( 0, l, 0, r - 1, Reversed );
|
||||
}
|
||||
} else {
|
||||
if( l < left ) {
|
||||
display->Style( 0, l, 0, left - 1, Reversed );
|
||||
} else if( l > left ) {
|
||||
display->Style( 0, left, 0, l - 1, Plain );
|
||||
}
|
||||
if( r > right ) {
|
||||
display->Style( 0, right, 0, r - 1, Reversed );
|
||||
} else if( r < right ) {
|
||||
display->Style( 0, r, 0, right - 1, Plain );
|
||||
}
|
||||
}
|
||||
left = l;
|
||||
right = r;
|
||||
if( left == right ) {
|
||||
display->Caret( 0, left );
|
||||
} else {
|
||||
display->Caret( -1, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void StringDisplay::Edit() {
|
||||
Event e;
|
||||
e.target = nil;
|
||||
e.eventType = EnterEvent;
|
||||
Handle( e );
|
||||
}
|
||||
|
||||
void StringDisplay::Edit( const char * t, int l, int r ) {
|
||||
Message( t );
|
||||
Select( l, r );
|
||||
Edit();
|
||||
}
|
||||
|
||||
const char * StringDisplay::Text() {
|
||||
return text->Text();
|
||||
}
|
||||
|
||||
/*
|
||||
void* StringDisplay::HighlightText (int boolVal) {
|
||||
|
||||
static Font *origFont = output->GetFont();
|
||||
static Font *highlightFont = new Font("*helvetica-bold-r-normal--12*");
|
||||
|
||||
if (boolVal && !highlighted){
|
||||
output->SetFont(highlightFont);
|
||||
Draw();
|
||||
highlighted = 1;
|
||||
}
|
||||
else if (highlighted){
|
||||
output->SetFont(origFont);
|
||||
Draw();
|
||||
highlighted = 0;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
boolean StringDisplay::HandleChar( char c ) {
|
||||
if( strchr( done, c ) != nil ) {
|
||||
if( subject != nil ) {
|
||||
subject->SetValue( c );
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
switch( c ) {
|
||||
case SEBeginningOfLine:
|
||||
Select( text->BeginningOfLine( left ) );
|
||||
break;
|
||||
case SEEndOfLine:
|
||||
Select( text->EndOfLine( right ) );
|
||||
break;
|
||||
case SESelectAll:
|
||||
Select( text->BeginningOfText(), text->EndOfText() );
|
||||
break;
|
||||
case SESelectWord:
|
||||
Select(
|
||||
text->BeginningOfWord( text->PreviousCharacter( left ) ), right
|
||||
);
|
||||
break;
|
||||
case SEPreviousCharacter:
|
||||
Select( text->PreviousCharacter( left ) );
|
||||
break;
|
||||
case SENextCharacter:
|
||||
Select( text->NextCharacter( right ) );
|
||||
break;
|
||||
case SEDeleteNextCharacter:
|
||||
if( left == right ) {
|
||||
right = text->NextCharacter( right );
|
||||
}
|
||||
InsertText( "", 0 );
|
||||
break;
|
||||
case SEDeletePreviousCharacter:
|
||||
case SEDeletePreviousCharacterAlt:
|
||||
if( left == right ) {
|
||||
left = text->PreviousCharacter( left );
|
||||
}
|
||||
InsertText( "", 0 );
|
||||
break;
|
||||
default:
|
||||
if( !iscntrl( c ) ) {
|
||||
InsertText( &c, 1 );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void StringDisplay::InsertText( const char * t, int len ) {
|
||||
display->Draw( output, canvas );
|
||||
if( left != right ) {
|
||||
text->Delete( left, right - left );
|
||||
display->DeleteText( 0, left, right - left );
|
||||
}
|
||||
text->Insert( left, t, len );
|
||||
display->InsertText( 0, left, t, len );
|
||||
int l = left;
|
||||
while( len > 0 ) {
|
||||
l = text->NextCharacter( l );
|
||||
--len;
|
||||
}
|
||||
Select( l );
|
||||
}
|
||||
|
||||
void StringDisplay::Handle( Event & e ) {
|
||||
boolean Done = false;
|
||||
World * World = GetWorld();
|
||||
display->Draw( output, canvas );
|
||||
display->CaretStyle( BarCaret );
|
||||
do {
|
||||
switch( e.eventType ) {
|
||||
/*
|
||||
case KeyEvent:
|
||||
if (e.len != 0) {
|
||||
Done = HandleChar(e.keystring[0]);
|
||||
}
|
||||
break;
|
||||
*/
|
||||
case DownEvent:
|
||||
if( e.target == this ) {
|
||||
/*
|
||||
if (!highlighted)
|
||||
HighlightText(1);
|
||||
*/
|
||||
int origin = display->Left( 0, 0 );
|
||||
int width = display->Width();
|
||||
if( e.button == LEFTMOUSE ) {
|
||||
/*
|
||||
int start = display->LineIndex(0, e.x);
|
||||
do {
|
||||
if (e.x < 0) {
|
||||
origin = Math::min(0, origin - e.x);
|
||||
} else if (e.x > xmax) {
|
||||
origin = Math::max(
|
||||
xmax - width, origin - (e.x - xmax)
|
||||
);
|
||||
}
|
||||
display->Scroll(0, origin, ymax);
|
||||
DoSelect(start, display->LineIndex(0, e.x));
|
||||
Poll(e);
|
||||
} while (e.leftmouse);
|
||||
*/
|
||||
} else if( e.button == MIDDLEMOUSE ) {
|
||||
Cursor * origCursor = GetCursor();
|
||||
SetCursor( handCursor );
|
||||
int x = e.x;
|
||||
do {
|
||||
origin += e.x - x;
|
||||
origin = Math::min(
|
||||
0, Math::max( Math::min( 0, xmax - width ), origin )
|
||||
);
|
||||
display->Scroll( 0, origin, ymax );
|
||||
x = e.x;
|
||||
Poll( e );
|
||||
} while( e.middlemouse );
|
||||
SetCursor( origCursor );
|
||||
} else if( e.button == RIGHTMOUSE ) {
|
||||
Cursor * origCursor = GetCursor();
|
||||
int x = e.x;
|
||||
do {
|
||||
origin += x - e.x;
|
||||
origin = Math::min(
|
||||
0, Math::max( Math::min( 0, xmax - width ), origin )
|
||||
);
|
||||
display->Scroll( 0, origin, ymax );
|
||||
if( e.x - x < 0 ) {
|
||||
SetCursor( leftCursor );
|
||||
} else {
|
||||
SetCursor( rightCursor );
|
||||
}
|
||||
Poll( e );
|
||||
} while( e.rightmouse );
|
||||
SetCursor( origCursor );
|
||||
}
|
||||
} else {
|
||||
UnRead( e );
|
||||
Done = true;
|
||||
}
|
||||
break;
|
||||
case UpEvent:
|
||||
Done = true;
|
||||
/*
|
||||
if (highlighted)
|
||||
HighlightText(0);
|
||||
*/
|
||||
break;
|
||||
}
|
||||
if( !Done ) {
|
||||
Read( e );
|
||||
}
|
||||
} while( !Done && !World->done() );
|
||||
display->CaretStyle( NoCaret );
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1988, 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* StringDisplay - scrollable display for character strings
|
||||
* This object started out as InterView's StringEditor
|
||||
*/
|
||||
|
||||
#ifndef strdisplay_h
|
||||
#define strdisplay_h
|
||||
|
||||
#include <IV-2_6/InterViews/interactor.h>
|
||||
#include <IV-2_6/InterViews/streditor.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
class ButtonState;
|
||||
class TextDisplay;
|
||||
class TextBuffer;
|
||||
|
||||
class StringDisplay : public Interactor {
|
||||
public:
|
||||
StringDisplay(ButtonState*, const char* sample, const char* done = SEDone);
|
||||
StringDisplay(
|
||||
const char* name, ButtonState*, const char*, const char* = SEDone
|
||||
);
|
||||
virtual ~StringDisplay();
|
||||
|
||||
void Message(const char* text);
|
||||
void Select(int);
|
||||
void Select(int left, int right);
|
||||
void Edit();
|
||||
void Edit(const char* text, int left, int right);
|
||||
|
||||
const char* Text();
|
||||
|
||||
virtual void Handle(Event&);
|
||||
virtual void Reconfig();
|
||||
protected:
|
||||
virtual boolean HandleChar(char);
|
||||
void InsertText(const char*, int);
|
||||
void DoSelect(int left, int right);
|
||||
|
||||
virtual void Redraw(IntCoord, IntCoord, IntCoord, IntCoord);
|
||||
virtual void Resize();
|
||||
|
||||
TextBuffer* text;
|
||||
int left, right;
|
||||
ButtonState* subject;
|
||||
char* done;
|
||||
char* sample;
|
||||
char* buffer;
|
||||
int size;
|
||||
TextDisplay* display;
|
||||
private:
|
||||
void Init(ButtonState*, const char*, const char*);
|
||||
/*
|
||||
void *HighlightText(int boolVal);
|
||||
int highlighted;
|
||||
*/
|
||||
};
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,345 +0,0 @@
|
||||
|
||||
/*
|
||||
* StringEditor2 - interactive editor for character strings
|
||||
* this adds <contrl> K and fixes <cntrl> W
|
||||
*/
|
||||
|
||||
#include <InterViews/bitmap.h>
|
||||
#include <InterViews/canvas.h>
|
||||
#include <InterViews/cursor.h>
|
||||
#include <InterViews/font.h>
|
||||
|
||||
// in order to include xcanvas.h you will need to have a -I option
|
||||
// for /usr/local/include because <X11/Xlib.h> from /usr/local/include/
|
||||
// gets included from InterViews/include/IV-X11/Xlib.h
|
||||
#include <IV-X11/xcanvas.h>
|
||||
#include <InterViews/window.h>
|
||||
// xcanvas.h and window.h were included so I could write the
|
||||
// function IsMapped()
|
||||
|
||||
#include <InterViews/Bitmaps/hand.bm>
|
||||
#include <InterViews/Bitmaps/handMask.bm>
|
||||
#include <InterViews/Bitmaps/lfast.bm>
|
||||
#include <InterViews/Bitmaps/lfastMask.bm>
|
||||
#include <InterViews/Bitmaps/rfast.bm>
|
||||
#include <InterViews/Bitmaps/rfastMask.bm>
|
||||
|
||||
#include <IV-2_6/InterViews/button.h>
|
||||
#include <IV-2_6/InterViews/painter.h>
|
||||
#include <IV-2_6/InterViews/sensor.h>
|
||||
#include <IV-2_6/InterViews/shape.h>
|
||||
#include <IV-2_6/InterViews/streditor.h>
|
||||
#include <IV-2_6/InterViews/textbuffer.h>
|
||||
#include <IV-2_6/InterViews/textdisplay.h>
|
||||
#include <IV-2_6/InterViews/world.h>
|
||||
#include <OS/math.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <streditor2.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
static const int BUFFERSIZE = 1000;
|
||||
|
||||
const char RingBell = '\007'; // <CNTRL> G
|
||||
|
||||
void
|
||||
StringEditor2::Init( const char * samp, int width ) {
|
||||
SetClassName( "StringEditor2" );
|
||||
/* // I think this is commented because there is no painter (output) yet
|
||||
Font* f = output->GetFont();
|
||||
shape->hunits = f->Width("n");
|
||||
shape->vunits = f->Height();
|
||||
shape->Rect(shape->hunits*strlen(samp), shape->vunits);
|
||||
|
||||
shape->Rigid();
|
||||
*/
|
||||
lastChar = 0;
|
||||
boxWidth = width;
|
||||
if( boxWidth ) {
|
||||
initStrLen = boxWidth;
|
||||
} else {
|
||||
initStrLen = strlen( samp );
|
||||
}
|
||||
if( !initStrLen ) {
|
||||
initStrLen = DEFAULT_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
StringEditor2::StringEditor2(
|
||||
ButtonState * s, const char * samp, const char * done_, int width
|
||||
) : StringEditor( s, samp, done_ ) {
|
||||
Init( samp, width );
|
||||
}
|
||||
|
||||
StringEditor2::StringEditor2(
|
||||
const char * name, ButtonState * s, const char * samp, const char * done_,
|
||||
int width
|
||||
) : StringEditor( s, samp, done_ ) {
|
||||
SetInstance( name );
|
||||
Init( samp, width );
|
||||
}
|
||||
|
||||
boolean StringEditor2::HandleChar( char c ) {
|
||||
int rc;
|
||||
if( rc = TermChar( c ) ) {
|
||||
if( TypeCheck() ) {
|
||||
SetSubject( rc );
|
||||
lastChar = rc;
|
||||
return true;
|
||||
} else {
|
||||
fprintf( stderr, "%c" , RingBell );
|
||||
fflush( stderr );
|
||||
lastChar = c;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
switch( c ) {
|
||||
case SEBeginningOfLine:
|
||||
Select( text->BeginningOfLine( left ) );
|
||||
break;
|
||||
case SEEndOfLine:
|
||||
Select( text->EndOfLine( right ) );
|
||||
break;
|
||||
case SESelectAll:
|
||||
Select( text->BeginningOfText(), text->EndOfText() );
|
||||
break;
|
||||
// case SESelectWord:
|
||||
// Select(
|
||||
// text->BeginningOfWord(text->PreviousCharacter(left)), right
|
||||
// );
|
||||
// break;
|
||||
case SESelectWord:
|
||||
if( text->IsEndOfWord( right ) )
|
||||
Select(
|
||||
left, text->EndOfWord( text->BeginningOfNextWord( right ) )
|
||||
);
|
||||
else
|
||||
Select(
|
||||
left, text->EndOfWord( right )
|
||||
);
|
||||
break;
|
||||
case SEDeleteToEndOfLine:
|
||||
Select( left, text->EndOfLine( right ) );
|
||||
break;
|
||||
case SEPreviousCharacter:
|
||||
Select( text->PreviousCharacter( left ) );
|
||||
break;
|
||||
case SENextCharacter:
|
||||
Select( text->NextCharacter( right ) );
|
||||
break;
|
||||
case SEDeleteNextCharacter:
|
||||
if( left == right ) {
|
||||
right = text->NextCharacter( right );
|
||||
}
|
||||
InsertText( "", 0 );
|
||||
break;
|
||||
case SEDeletePreviousCharacter:
|
||||
case SEDeletePreviousCharacterAlt:
|
||||
if( left == right ) {
|
||||
left = text->PreviousCharacter( left );
|
||||
}
|
||||
InsertText( "", 0 );
|
||||
break;
|
||||
case ESCAPE_KEY:
|
||||
lastChar = ESCAPE_KEY;
|
||||
|
||||
break;
|
||||
default:
|
||||
if( lastChar == ESCAPE_KEY ) {
|
||||
// if last char was <esc> next char is ignored unless it's:
|
||||
switch( c ) {
|
||||
case 'f': // jump cursor to beginning of next word
|
||||
Select( text->BeginningOfNextWord( right ) );
|
||||
break;
|
||||
case 'b': // jump cursor to beginning of previous word
|
||||
if( text->IsBeginningOfWord( left ) )
|
||||
Select( text->BeginningOfWord(
|
||||
text->PreviousCharacter( left ) ) );
|
||||
else {
|
||||
Select( text->BeginningOfWord( left ) );
|
||||
}
|
||||
break;
|
||||
}
|
||||
// printf("char: '%0x', '%d'\n", c, c);
|
||||
// fflush(stdout);
|
||||
} else if( CheckForCmdChars( c ) ) {
|
||||
;
|
||||
} else if( !InsertValidChar( c ) ) {
|
||||
fprintf( stdout, "%c" , RingBell );
|
||||
fflush( stdout );
|
||||
}
|
||||
break;
|
||||
}
|
||||
lastChar = c;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static Cursor * handCursor;
|
||||
static Cursor * leftCursor;
|
||||
static Cursor * rightCursor;
|
||||
|
||||
void StringEditor2::Reconfig() {
|
||||
if( handCursor == nil ) {
|
||||
handCursor = new Cursor(
|
||||
new Bitmap(
|
||||
hand_bits, hand_width, hand_height, hand_x_hot, hand_y_hot
|
||||
),
|
||||
new Bitmap( hand_mask_bits, hand_mask_width, hand_mask_height ),
|
||||
output->GetFgColor(), output->GetBgColor()
|
||||
);
|
||||
|
||||
leftCursor = new Cursor(
|
||||
new Bitmap(
|
||||
lfast_bits, lfast_width, lfast_height, lfast_x_hot, lfast_y_hot
|
||||
),
|
||||
new Bitmap( lfast_mask_bits, lfast_mask_width, lfast_mask_height ),
|
||||
output->GetFgColor(), output->GetBgColor()
|
||||
);
|
||||
|
||||
rightCursor = new Cursor(
|
||||
new Bitmap(
|
||||
rfast_bits, rfast_width, rfast_height, rfast_x_hot, rfast_y_hot
|
||||
),
|
||||
new Bitmap( rfast_mask_bits, rfast_mask_width, rfast_mask_height ),
|
||||
output->GetFgColor(), output->GetBgColor()
|
||||
);
|
||||
}
|
||||
|
||||
const Font * f = output->GetFont();
|
||||
|
||||
shape->hunits = f->Width( "n" );
|
||||
shape->vunits = f->Height();
|
||||
if( boxWidth > 0 ) { // resize to setting of boxwidth
|
||||
shape->Rect( f->Width( "n" )*boxWidth, f->Height() );
|
||||
} else { // or width of original size
|
||||
shape->Rect( f->Width( "n" )*initStrLen, f->Height() );
|
||||
}
|
||||
shape->Rigid();
|
||||
display->LineHeight( f->Height() );
|
||||
}
|
||||
|
||||
void StringEditor2::Handle( Event & e ) {
|
||||
boolean Done = false;
|
||||
World * World = GetWorld();
|
||||
display->Draw( output, canvas );
|
||||
display->CaretStyle( BarCaret );
|
||||
do {
|
||||
if( e.meta ) {
|
||||
lastChar = ESCAPE_KEY;
|
||||
}
|
||||
switch( e.eventType ) {
|
||||
case KeyEvent:
|
||||
if( e.len != 0 ) {
|
||||
Done = HandleChar( e.keystring[0] );
|
||||
}
|
||||
break;
|
||||
case DownEvent:
|
||||
if( e.target == this ) {
|
||||
int origin = display->Left( 0, 0 );
|
||||
int width = display->Width();
|
||||
if( e.button == LEFTMOUSE ) {
|
||||
int start = display->LineIndex( 0, e.x );
|
||||
do {
|
||||
if( e.x < 0 ) {
|
||||
origin = Math::min( 0, origin - e.x );
|
||||
} else if( e.x > xmax ) {
|
||||
origin = Math::max(
|
||||
xmax - width, origin - ( e.x - xmax )
|
||||
);
|
||||
}
|
||||
display->Scroll( 0, origin, ymax );
|
||||
DoSelect( start, display->LineIndex( 0, e.x ) );
|
||||
Poll( e );
|
||||
} while( e.leftmouse );
|
||||
} else if( e.button == MIDDLEMOUSE ) {
|
||||
Cursor * origCursor = GetCursor();
|
||||
SetCursor( handCursor );
|
||||
int x = e.x;
|
||||
do {
|
||||
origin += e.x - x;
|
||||
origin = Math::min(
|
||||
0, max( min( 0, xmax - width ), origin )
|
||||
);
|
||||
display->Scroll( 0, origin, ymax );
|
||||
x = e.x;
|
||||
Poll( e );
|
||||
} while( e.middlemouse );
|
||||
SetCursor( origCursor );
|
||||
} else if( e.button == RIGHTMOUSE ) {
|
||||
Cursor * origCursor = GetCursor();
|
||||
int x = e.x;
|
||||
do {
|
||||
origin += x - e.x;
|
||||
origin = Math::min(
|
||||
0, Math::max( Math::min( 0, xmax - width ), origin )
|
||||
);
|
||||
display->Scroll( 0, origin, ymax );
|
||||
if( e.x - x < 0 ) {
|
||||
SetCursor( leftCursor );
|
||||
} else {
|
||||
SetCursor( rightCursor );
|
||||
}
|
||||
Poll( e );
|
||||
} while( e.rightmouse );
|
||||
SetCursor( origCursor );
|
||||
}
|
||||
} else {
|
||||
UnRead( e );
|
||||
Done = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if( !Done ) {
|
||||
Read( e );
|
||||
}
|
||||
} while( !Done );
|
||||
int ismapped = 0;
|
||||
ismapped = IsMapped();
|
||||
if( ismapped ) {
|
||||
display->CaretStyle( NoCaret );
|
||||
}
|
||||
}
|
||||
|
||||
// boolean i.e. true = 1 and false = 0
|
||||
boolean StringEditor2::IsMapped() {
|
||||
return ( canvas != nil && canvas->status() == Canvas::mapped );
|
||||
/*
|
||||
if(GetTopLevelWindow())
|
||||
{
|
||||
// this doesn't work... seems to always return false DAS
|
||||
int bool = GetTopLevelWindow()->is_mapped();
|
||||
// int bool canvas->rep()->window_->is_mapped();
|
||||
return bool;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
*/
|
||||
/* // this doesn't work
|
||||
if(canvas)
|
||||
{
|
||||
int bool = canvas->window()->is_mapped();
|
||||
// int bool canvas->rep()->window_->is_mapped();
|
||||
return bool;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
*/
|
||||
}
|
||||
|
||||
// this used to be inline but CenterLine CC won't expand it as inline because
|
||||
// a statement follows the first return statment.
|
||||
// accept all non <cntrl>
|
||||
boolean StringEditor2::InsertValidChar( char c ) {
|
||||
if( !iscntrl( c ) ) {
|
||||
InsertText( &c, 1 );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
@@ -1,120 +0,0 @@
|
||||
|
||||
// ~sauderd/src/iv/hfiles/streditor2.h
|
||||
|
||||
/*
|
||||
* StringEditor2 - interactive editor for character strings
|
||||
* this adds:
|
||||
* <contrl> K -- select rest of line
|
||||
* <meta/esc> f -- jump to beginning of next word
|
||||
* <meta/esc> b -- jump to beginning of previous word
|
||||
* and fixes <cntrl> W -- select rest of word.
|
||||
* I
|
||||
* It also creates a generic HandleChar() that
|
||||
* calls the following three virtual functions:
|
||||
* int TypeCheck() -- Does type checking on the
|
||||
* StringEditor2's text and returns a
|
||||
* constant representing the type or zero
|
||||
* (error). It is done after a terminating
|
||||
* char is typed.
|
||||
* void SetSubject(int c) -- Sets the member
|
||||
* variable 'subject' (a ButtonState)
|
||||
* when a terminating char is typed
|
||||
* if TypeCheck() is successful.
|
||||
* boolean CheckForCmdChar(char) -- Allows you to
|
||||
* check for valid keystrokes as part of
|
||||
* multi-character commands. This is a separate
|
||||
* function for inheritance reasons (i.e. this
|
||||
* function can be defined for a subtype without
|
||||
* redefining InsertValidChar() which can be used
|
||||
* to do limited type checking.)
|
||||
* boolean InsertValidChar(char c) -- Defines and writes
|
||||
* all the characters accepted by the
|
||||
* object that are not defined as <cntrl>
|
||||
* char commands. This is part of the default
|
||||
* action of HandleChar().
|
||||
*/
|
||||
|
||||
#ifndef streditor2_h
|
||||
#define streditor2_h
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
#include <string.h> // put here for inline function that uses strchr()
|
||||
#include <ctype.h>
|
||||
//#include <std.h>
|
||||
#include <IV-2_6/InterViews/button.h>
|
||||
#include <IV-2_6/InterViews/textdisplay.h> // needed to define NoCaret
|
||||
#include <IV-2_6/InterViews/streditor.h>
|
||||
|
||||
// <cntrl> K
|
||||
#define SEDeleteToEndOfLine '\v'
|
||||
#define ESCAPE_KEY '\033'
|
||||
#define DEFAULT_WIDTH 15
|
||||
|
||||
// return values for TypeCheck()
|
||||
#define SETYPE_STRING 1
|
||||
#define SETYPE_UNSIGNED_INTEGER 2
|
||||
#define SETYPE_SIGNED_INTEGER 3
|
||||
#define SETYPE_REAL 4
|
||||
#define SETYPE_ENUM 5
|
||||
#define SETYPE_OTHER 6
|
||||
// make your own!! // #define SETYPE_GEEK 1001
|
||||
|
||||
class StringEditor2 : public StringEditor {
|
||||
public:
|
||||
StringEditor2(ButtonState*, const char* sample, const char* done_ = SEDone,
|
||||
int width = 0);
|
||||
StringEditor2(
|
||||
const char* name, ButtonState*, const char*, const char* = SEDone,
|
||||
int width = 0
|
||||
);
|
||||
virtual ~StringEditor2() {};
|
||||
|
||||
// this needed to be a virtual function
|
||||
virtual void NewEdit() { StringEditor::Edit(); }
|
||||
void GetMark(int& l, int& r) { l = left; r = right; };
|
||||
virtual void Handle(Event&);
|
||||
virtual void Reconfig (); // needed to redefine the way size is determined
|
||||
|
||||
// object will become this width (* FontWidth("n")) at next Reconfig()
|
||||
void SetBoxWidth(int width);
|
||||
// returns type number if success otherwise returns zero.
|
||||
virtual int TypeCheck() { return SETYPE_STRING; };
|
||||
void RemoveCursor() { display->CaretStyle(NoCaret); };
|
||||
virtual void SetSubject(int c)
|
||||
{ if (subject != nil) { subject->SetValue(c); } };
|
||||
char LastChar() { return lastChar; }
|
||||
|
||||
boolean IsMapped();
|
||||
|
||||
protected:
|
||||
virtual int TermChar(char c) { return ((strchr(done, c) != nil) ? c : 0); }
|
||||
virtual boolean HandleChar(char);
|
||||
virtual boolean CheckForCmdChars(char c) { return false; }
|
||||
virtual boolean InsertValidChar(char c); // accept all non <cntrl> chars
|
||||
|
||||
private:
|
||||
void Init(const char* samp, int width);
|
||||
|
||||
protected:
|
||||
char lastChar; // last char typed... used to implment 2 keystroke cmds
|
||||
int boxWidth; // Used to limit the size of the box when Reconfig()ing
|
||||
// boxWidth != zero => size is based on
|
||||
// boxWidth * fontWidth("n")
|
||||
// boxWidth == zero => size is based on
|
||||
// initStrLen * fontWidth("n")
|
||||
int initStrLen; // original size of object ... set to
|
||||
// boxWidth if boxWidth > 0 else
|
||||
// strlen(constructor param 'sample') > 0 =>
|
||||
// initStrLen = strlen(sample)
|
||||
// strlen(constructor param 'sample') == 0 =>
|
||||
// initStrLen = DEFAULT_WIDTH
|
||||
};
|
||||
|
||||
inline void StringEditor2::SetBoxWidth(int width) {
|
||||
boxWidth = width;
|
||||
}
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,150 +0,0 @@
|
||||
|
||||
// ~sauderd/src/iv/cfiles/streditor2sub.c
|
||||
|
||||
/*
|
||||
* StringEditor2Sub - Interactive editor for character strings based
|
||||
* on IntStringEditor. This one is sociable with
|
||||
* a supervisor. In addition to supplying the
|
||||
* supervisor with the terminating char it also
|
||||
* returns a pointer to itself.
|
||||
* It does this by redefining SetSubject() to
|
||||
* communicate with the supervisor supplying the
|
||||
* fields contained in class SubordinateInfo.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <IV-2_6/InterViews/button.h>
|
||||
#include <IV-2_6/InterViews/textbuffer.h>
|
||||
|
||||
#include <streditor2sub.h> // "~sauderd/src/iv/hfiles/streditor2sub.h"
|
||||
|
||||
static const int BUFFERSIZE = 1000;
|
||||
|
||||
|
||||
void StringEditor2Sub::SetSubject( int c ) {
|
||||
if( subject != nil ) {
|
||||
subInfo->SetValue( c );
|
||||
subject->SetValue( subInfo ); // don't cast this to (void*)
|
||||
// it makes it not work.
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
define this if you want the supervisor to be notified before this
|
||||
StringEditor2Sub handles it's own event. If you do define this you will
|
||||
probably want to call StringEditor2::Handle() for this object when the
|
||||
supervisor has done what it wanted to do before this object handled it's
|
||||
event. You will need to read the event if you don't call handle for this
|
||||
object otherwise this function will cause an infinite loop (i.e. read the
|
||||
event, unread the event, read the event, unread the event, etc)
|
||||
*/
|
||||
/*
|
||||
void StringEditor2Sub::Handle(Event& e)
|
||||
{
|
||||
// if(e.eventType == 2 || e.eventType == 4)
|
||||
if(e.eventType == DownEvent || e.eventType == KeyEvent)
|
||||
{
|
||||
UnRead(e);
|
||||
subInfo->SetValue(' ');
|
||||
subject->SetValue(subInfo); // don't cast this to (void*)
|
||||
// call notify for subject (which calls see update)
|
||||
}
|
||||
else
|
||||
StringEditor2::Handle(e);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
boolean StringEditor2Sub::HandleChar (char c) {
|
||||
if (strchr(done, c) != nil) {
|
||||
if (subject != nil) {
|
||||
subInfo->SetValue(c);
|
||||
// subject->SetValue((void*)subInfo);
|
||||
subject->SetValue(subInfo);
|
||||
printf("se value: %d, this: %d\n", (int)subInfo->GetValue(),
|
||||
subInfo->GetSubordinate());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
switch (c) {
|
||||
case SEBeginningOfLine:
|
||||
Select(text->BeginningOfLine(left));
|
||||
break;
|
||||
case SEEndOfLine:
|
||||
Select(text->EndOfLine(right));
|
||||
break;
|
||||
case SESelectAll:
|
||||
Select(text->BeginningOfText(), text->EndOfText());
|
||||
break;
|
||||
// case SESelectWord:
|
||||
// Select(
|
||||
// text->BeginningOfWord(text->PreviousCharacter(left)), right
|
||||
// );
|
||||
// break;
|
||||
case SESelectWord:
|
||||
if(text->IsEndOfWord(right))
|
||||
Select(
|
||||
left, text->EndOfWord(text->BeginningOfNextWord(right))
|
||||
);
|
||||
else
|
||||
Select(
|
||||
left, text->EndOfWord(right)
|
||||
);
|
||||
break;
|
||||
case SEDeleteToEndOfLine:
|
||||
Select(left, text->EndOfLine(right));
|
||||
break;
|
||||
case SEPreviousCharacter:
|
||||
Select(text->PreviousCharacter(left));
|
||||
break;
|
||||
case SENextCharacter:
|
||||
Select(text->NextCharacter(right));
|
||||
break;
|
||||
case SEDeleteNextCharacter:
|
||||
if (left == right) {
|
||||
right = text->NextCharacter(right);
|
||||
}
|
||||
InsertText("", 0);
|
||||
break;
|
||||
case SEDeletePreviousCharacter:
|
||||
case SEDeletePreviousCharacterAlt:
|
||||
if (left == right) {
|
||||
left = text->PreviousCharacter(left);
|
||||
}
|
||||
InsertText("", 0);
|
||||
break;
|
||||
case ESCAPE_KEY:
|
||||
meta = true;
|
||||
break;
|
||||
default:
|
||||
if(meta){
|
||||
switch(c){
|
||||
case 'f':
|
||||
Select(text->BeginningOfNextWord(right));
|
||||
break;
|
||||
case 'b':
|
||||
if(text->IsBeginningOfWord(left))
|
||||
Select(text->BeginningOfWord(
|
||||
text->PreviousCharacter(left)));
|
||||
else
|
||||
Select(text->BeginningOfWord(left));
|
||||
break;
|
||||
}
|
||||
// printf("char: '%0x', '%d'\n", c, c);
|
||||
// fflush(stdout);
|
||||
// meta = false;
|
||||
}
|
||||
else if (!iscntrl(c)) {
|
||||
InsertText(&c, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(meta)
|
||||
if(c != ESCAPE_KEY)
|
||||
meta = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,65 +0,0 @@
|
||||
|
||||
// ~sauderd/src/iv/hfiles/streditor2sub.h
|
||||
|
||||
/*
|
||||
* StringEditor2Sub - Interactive editor for character strings based
|
||||
* on StringEditor2. This one is sociable with
|
||||
* a supervisor. In addition to supplying the
|
||||
* supervisor with the terminating char it also
|
||||
* returns a pointer to itself.
|
||||
* It does this by redefining SetSubject() to
|
||||
* communicate with the supervisor supplying the
|
||||
* fields contained in class SubordinateInfo.
|
||||
*/
|
||||
|
||||
#ifndef streditor2sub_h
|
||||
#define streditor2sub_h
|
||||
|
||||
#include <InterViews/event.h>
|
||||
#include <streditor2.h>
|
||||
#include <subinfo.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
class StringEditor2Sub : public StringEditor2 {
|
||||
public:
|
||||
StringEditor2Sub(ButtonState*, const char* sample,
|
||||
const char* Done, int width = 0);
|
||||
StringEditor2Sub(
|
||||
const char* name, ButtonState*, const char*, const char*, int width = 0
|
||||
);
|
||||
~StringEditor2Sub() { delete subInfo; };
|
||||
|
||||
virtual void SetSubject(int c);
|
||||
|
||||
protected:
|
||||
SubordinateInfo *subInfo;
|
||||
|
||||
private:
|
||||
void Init();
|
||||
};
|
||||
|
||||
inline void StringEditor2Sub::Init()
|
||||
{
|
||||
subInfo = new SubordinateInfo(0, this);
|
||||
}
|
||||
|
||||
inline StringEditor2Sub::StringEditor2Sub (
|
||||
ButtonState* s, const char* samp, const char* Done, int width
|
||||
) : StringEditor2(s, samp, Done, width)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
inline StringEditor2Sub::StringEditor2Sub (
|
||||
const char* name, ButtonState* s, const char* samp, const char* Done,
|
||||
int width
|
||||
) : StringEditor2(s, samp, Done, width)
|
||||
{
|
||||
SetInstance(name);
|
||||
Init();
|
||||
}
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,62 +0,0 @@
|
||||
|
||||
/*
|
||||
* SubordinateInfo - used for supervisor/subordinate communication.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef subinfo_h
|
||||
#define subinfo_h
|
||||
|
||||
#include <IV-2_6/InterViews/interactor.h>
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
class SubordinateInfo {
|
||||
public:
|
||||
SubordinateInfo(int val, Interactor* sub);
|
||||
SubordinateInfo(void* val, Interactor* sub);
|
||||
|
||||
void operator=(SubordinateInfo& s);
|
||||
void SetValue(int val);
|
||||
void SetValue(void* val);
|
||||
void GetValue(int& v);
|
||||
void GetValue(void*& v);
|
||||
// int GetValue();
|
||||
void* GetValue();
|
||||
void GetSubordinate(Interactor*& s);
|
||||
Interactor* GetSubordinate();
|
||||
private:
|
||||
Interactor *subordinate;
|
||||
void* value;
|
||||
};
|
||||
|
||||
inline SubordinateInfo::SubordinateInfo(int val, Interactor* sub)
|
||||
{ subordinate = sub; value = (void*)val; };
|
||||
|
||||
inline SubordinateInfo::SubordinateInfo(void* val, Interactor* sub)
|
||||
{ subordinate = sub; value = val; };
|
||||
|
||||
inline void SubordinateInfo::SetValue(int val) { value = (void*)val; };
|
||||
|
||||
inline void SubordinateInfo::SetValue(void* val){ value = val; };
|
||||
|
||||
inline void SubordinateInfo::GetValue (int& v) { v = (int)value; };
|
||||
|
||||
inline void SubordinateInfo::GetValue (void*& v){ v = value; };
|
||||
|
||||
//inline int SubordinateInfo::GetValue () { return (int)value; };
|
||||
|
||||
inline void* SubordinateInfo::GetValue () { return value; };
|
||||
|
||||
inline void SubordinateInfo::GetSubordinate (Interactor*& s)
|
||||
{ s = subordinate; };
|
||||
|
||||
inline Interactor* SubordinateInfo::GetSubordinate ()
|
||||
{ return subordinate; };
|
||||
|
||||
inline void SubordinateInfo::operator=(SubordinateInfo& s)
|
||||
{ s.GetValue(value); subordinate = s.GetSubordinate(); };
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -1,129 +0,0 @@
|
||||
/* varmessage.h - several variations on messages */
|
||||
|
||||
#ifndef varmessage
|
||||
#define varmessage
|
||||
|
||||
#include <IV-2_6/InterViews/message.h>
|
||||
#include <mymessage.h> // ivfasd/mymessage.h
|
||||
|
||||
#include <IV-2_6/_enter.h>
|
||||
|
||||
/*
|
||||
In order to make these do anything you need to include the
|
||||
following (or make your own) entries in properties[] ...
|
||||
|
||||
static PropertyData properties[] = {
|
||||
{ "*GenTitleMessage*font", "*times-bold-r-normal--24*" },
|
||||
{ "*GenTitleItalMessage*font", "*times-medium-i-normal--24*" },
|
||||
{ "*GenTitleItalMenu*font", "*times-medium-i-normal--14*" },
|
||||
{ "*BoldMessage*font", "*helvetica-bold-r-normal--12*" },
|
||||
{ "*BoldMyMessage*font", "*helvetica-bold-r-normal--12*" },
|
||||
{ "*BigBoldMessage*font", "*helvetica-bold-r-normal--18*" },
|
||||
{ "*BigBoldMyMessage*font", "*helvetica-bold-r-normal--18*" },
|
||||
}
|
||||
*/
|
||||
|
||||
class GenTitleMessage;
|
||||
class GenTitleItalMessage;
|
||||
class GenTitleItalMenu;
|
||||
|
||||
class BoldMessage;
|
||||
class BoldMyMessage;
|
||||
|
||||
class BigBoldMessage;
|
||||
class BigBoldMyMessage;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
class GenTitleMessage : public Message {
|
||||
public:
|
||||
GenTitleMessage(const char*, Alignment = Left);
|
||||
};
|
||||
|
||||
inline GenTitleMessage::GenTitleMessage(const char * c, Alignment a)
|
||||
: Message(c, a)
|
||||
{
|
||||
SetClassName("GenTitleMessage");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
class GenTitleItalMessage : public Message {
|
||||
public:
|
||||
GenTitleItalMessage(const char*, Alignment = Left);
|
||||
};
|
||||
|
||||
inline GenTitleItalMessage::GenTitleItalMessage(const char * c, Alignment a)
|
||||
: Message(c, a)
|
||||
{
|
||||
SetClassName("GenTitleItalMessage");
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
class GenTitleItalMenu : public Message {
|
||||
public:
|
||||
GenTitleItalMenu(const char*, Alignment = Left);
|
||||
};
|
||||
|
||||
inline GenTitleItalMenu::GenTitleItalMenu(const char * c, Alignment a)
|
||||
: Message(c, a)
|
||||
{
|
||||
SetClassName("GenTitleItalMenu");
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
class BoldMessage : public Message {
|
||||
public:
|
||||
BoldMessage(const char*, Alignment = Left);
|
||||
};
|
||||
|
||||
inline BoldMessage::BoldMessage(const char * c, Alignment a)
|
||||
: Message(c, a)
|
||||
{
|
||||
SetClassName("BoldMessage");
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
class BoldMyMessage : public MyMessage {
|
||||
public:
|
||||
BoldMyMessage(char*, Alignment = Center);
|
||||
};
|
||||
|
||||
inline BoldMyMessage::BoldMyMessage(char * c, Alignment a)
|
||||
: MyMessage(c, a)
|
||||
{
|
||||
SetClassName("BoldMyMessage");
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
class BigBoldMessage : public Message {
|
||||
public:
|
||||
BigBoldMessage(const char*, Alignment = Left);
|
||||
};
|
||||
|
||||
inline BigBoldMessage::BigBoldMessage(const char * c, Alignment a)
|
||||
: Message(c, a)
|
||||
{
|
||||
SetClassName("BigBoldMessage");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
class BigBoldMyMessage : public MyMessage {
|
||||
public:
|
||||
BigBoldMyMessage(char*, Alignment = Center);
|
||||
};
|
||||
|
||||
inline BigBoldMyMessage::BigBoldMyMessage(char * c, Alignment a)
|
||||
: MyMessage(c, a)
|
||||
{
|
||||
SetClassName("BigBoldMyMessage");
|
||||
}
|
||||
|
||||
#include <IV-2_6/_leave.h>
|
||||
|
||||
#endif
|
||||
@@ -49,7 +49,6 @@ SET(LIBSTEPCORE_PRIVATE_HDRS
|
||||
ExpDict.h
|
||||
read_func.h
|
||||
Registry.h
|
||||
scl_osschema.h
|
||||
sdaiApplication_instance.h
|
||||
sdaiBinary.h
|
||||
sdaiEnum.h
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
#ifndef SCL_OSSCHEMA_H
|
||||
#define SCL_OSSCHEMA_H
|
||||
|
||||
//#define _ODI_OSSG_
|
||||
|
||||
/*
|
||||
*/
|
||||
#include <string>
|
||||
#include <sdai.h>
|
||||
|
||||
#include <errordesc.h>
|
||||
|
||||
//#include <ExpDict.h>
|
||||
#include <SingleLinkList.h>
|
||||
#include <STEPattribute.h>
|
||||
#include <STEPattributeList.h>
|
||||
//#include <STEPentity.h>
|
||||
#include <STEPaggregate.h>
|
||||
|
||||
#include <gennode.h>
|
||||
#include <gennodearray.h>
|
||||
#include <mgrnode.h>
|
||||
#include <mgrnodearray.h>
|
||||
#include <instmgr.h>
|
||||
|
||||
void scl_dummy ()
|
||||
{
|
||||
|
||||
OS_MARK_SCHEMA_TYPE(ErrorDescriptor)
|
||||
|
||||
OS_MARK_SCHEMA_TYPE(std::string)
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(String))
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(Binary))
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(Enum))
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(BOOLEAN))
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(LOGICAL))
|
||||
|
||||
OS_MARK_SCHEMA_TYPE(STEPattribute)
|
||||
OS_MARK_SCHEMA_TYPE(SingleLinkNode)
|
||||
OS_MARK_SCHEMA_TYPE(SingleLinkList)
|
||||
OS_MARK_SCHEMA_TYPE(AttrListNode)
|
||||
OS_MARK_SCHEMA_TYPE(STEPattributeList)
|
||||
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(sdaiObject))
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(PID))
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(PID_SDAI))
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(PID_DA))
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(DAObject))
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(DAObject_SDAI))
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(Application_instance))
|
||||
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(Select))
|
||||
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(DAObject__set))
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(Session_instance))
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(Model_contents_instances))
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(Model_contents))
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(Model_contents__list))
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(Entity_extent))
|
||||
OS_MARK_SCHEMA_TYPE(SCLP23(Entity_extent__set))
|
||||
|
||||
OS_MARK_SCHEMA_TYPE(STEPaggregate)
|
||||
OS_MARK_SCHEMA_TYPE(GenericAggregate)
|
||||
OS_MARK_SCHEMA_TYPE(EntityAggregate)
|
||||
OS_MARK_SCHEMA_TYPE(SelectAggregate)
|
||||
OS_MARK_SCHEMA_TYPE(StringAggregate)
|
||||
OS_MARK_SCHEMA_TYPE(BinaryAggregate)
|
||||
OS_MARK_SCHEMA_TYPE(EnumAggregate)
|
||||
OS_MARK_SCHEMA_TYPE(LOGICALS)
|
||||
OS_MARK_SCHEMA_TYPE(BOOLEANS)
|
||||
OS_MARK_SCHEMA_TYPE(RealAggregate)
|
||||
OS_MARK_SCHEMA_TYPE(IntAggregate)
|
||||
OS_MARK_SCHEMA_TYPE(STEPnode)
|
||||
OS_MARK_SCHEMA_TYPE(GenericAggrNode)
|
||||
OS_MARK_SCHEMA_TYPE(EntityNode)
|
||||
OS_MARK_SCHEMA_TYPE(SelectNode)
|
||||
OS_MARK_SCHEMA_TYPE(StringNode)
|
||||
OS_MARK_SCHEMA_TYPE(BinaryNode)
|
||||
OS_MARK_SCHEMA_TYPE(EnumNode)
|
||||
OS_MARK_SCHEMA_TYPE(RealNode)
|
||||
OS_MARK_SCHEMA_TYPE(IntNode)
|
||||
|
||||
/*
|
||||
//O S_MARK_SCHEMA_TYPE(GenericNode)
|
||||
//O S_MARK_SCHEMA_TYPE(GenNodeArray)
|
||||
//O S_MARK_SCHEMA_TYPE(MgrNode)
|
||||
//O S_MARK_SCHEMA_TYPE(MgrNodeArray)
|
||||
//O S_MARK_SCHEMA_TYPE(MgrNodeArraySorted)
|
||||
//O S_MARK_SCHEMA_TYPE(InstMgr)
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -11,9 +11,6 @@ Various functions for manipulating characters and strings. Also
|
||||
contains the function CheckRemainingInput which checks an input stream
|
||||
for errors following a read.
|
||||
|
||||
dir.h
|
||||
C++ interface to the Unix file system dir structure.
|
||||
|
||||
dirobj.cc, dirobj.h
|
||||
Defines dirobj, a class for managing directories and interpreting path
|
||||
expressions.
|
||||
@@ -38,8 +35,3 @@ scl_hash.cc, scl_hash.h
|
||||
Defines a hash table facility with Hash_Table and Element structs and
|
||||
a collection of functions implementing hash table operations.
|
||||
|
||||
scl_string.cc, scl_string.h
|
||||
Defines SCLstring, a string class similar to the string class proposed
|
||||
as part of the C++ language standard.
|
||||
|
||||
stat.h
|
||||
@@ -1,79 +0,0 @@
|
||||
|
||||
#ifdef __O3DB__
|
||||
#include <OpenOODB.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* C++ interface to Unix file system dir structure
|
||||
*/
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* unistd.h defines _POSIX_VERSION on POSIX.1 systems. */
|
||||
#if defined(DIRENT) || defined(_POSIX_VERSION)
|
||||
#include <dirent.h>
|
||||
#define NLENGTH(dirent) (strlen((dirent)->d_name))
|
||||
#else /* not (DIRENT or _POSIX_VERSION) */
|
||||
#define dirent direct
|
||||
#define NLENGTH(dirent) ((dirent)->d_namlen)
|
||||
|
||||
#ifdef HAVE_SYS_DIR_H
|
||||
#include <sys/dir.h>
|
||||
//#elif HAVE_SYS_NDIR_H
|
||||
//#include <sys/ndir.h>
|
||||
//#elif HAVE_NDIR_H
|
||||
//#include <ndir.h>
|
||||
#endif
|
||||
|
||||
#endif /* not (DIRENT or _POSIX_VERSION) */
|
||||
|
||||
#if 0
|
||||
#ifndef sys_dir_h
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(opendir)
|
||||
#define opendir sys_dir_h_opendir
|
||||
#define readdir sys_dir_h_readdir
|
||||
#define telldir sys_dir_h_telldir
|
||||
#define seekdir sys_dir_h_seekdir
|
||||
#define closedir sys_dir_h_closedir
|
||||
#endif
|
||||
|
||||
#if defined(SYSV)
|
||||
#include "//usr/include/sys/types.h"
|
||||
#include "//usr/include/dirent.h"
|
||||
#else
|
||||
#include "//usr/include/sys/dir.h"
|
||||
#endif
|
||||
|
||||
#undef opendir
|
||||
#undef readdir
|
||||
#undef telldir
|
||||
#undef seekdir
|
||||
#undef closedir
|
||||
|
||||
#ifndef sys_dir_h
|
||||
#define sys_dir_h
|
||||
#endif
|
||||
|
||||
extern DIR* opendir(const char*);
|
||||
#if defined(SYSV)
|
||||
extern struct dirent* readdir(DIR*);
|
||||
#else
|
||||
extern struct direct* readdir(DIR*);
|
||||
#endif
|
||||
extern long telldir(DIR*);
|
||||
extern void seekdir(DIR*);
|
||||
extern int closedir(DIR*);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif /* if 0 */
|
||||
|
||||
#endif
|
||||
@@ -1,55 +0,0 @@
|
||||
|
||||
#ifdef __O3DB__
|
||||
#include <OpenOODB.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989 Stanford University
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Stanford not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. Stanford makes no representations about
|
||||
* the suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* C++ interface to Unix file system stat structure
|
||||
*/
|
||||
|
||||
#ifndef sys_stat_h
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define KERNEL
|
||||
#include "//usr/include/sys/stat.h"
|
||||
#undef KERNEL
|
||||
|
||||
/* just in case standard header didn't */
|
||||
#ifndef sys_stat_h
|
||||
#define sys_stat_h
|
||||
#endif
|
||||
|
||||
extern int stat(const char* path, struct stat*);
|
||||
extern int fstat(int fd, struct stat*);
|
||||
extern int lstat(const char* path, struct stat*);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
|
||||
typedef char * scl_char_str;
|
||||
typedef scl_char_str * scl_char_str_ptr;
|
||||
|
||||
class scl_char_str__list {
|
||||
public:
|
||||
scl_char_str__list(int = 16);
|
||||
~scl_char_str__list();
|
||||
|
||||
scl_char_str_ptr& operator[](int index);
|
||||
void Insert(scl_char_str_ptr, int index);
|
||||
void Append(scl_char_str_ptr);
|
||||
void Remove(int index);
|
||||
int Index(scl_char_str_ptr);
|
||||
|
||||
int Count();
|
||||
void Clear();
|
||||
private:
|
||||
void Check(int index);
|
||||
private:
|
||||
scl_char_str_ptr* _buf;
|
||||
int _bufsize;
|
||||
int _count;
|
||||
};
|
||||
Reference in new issue
Block a user