1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
/*
* RCS: @(#) $Id: trans.c,v 1.4 2004/09/13 12:47:39 mantam Exp $
*/
#include <tk.h>
#include <string.h>
/* following line should be uncommented for compilation on the Mac */
/* #include "trans.h" */
/*
* This part taken from SNACK
* Copyright (C) 1997-98 Kare Sjolander <[email protected]>
*
*/
#if defined(__WIN32__)
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# define EXTERN __declspec(dllexport)
# undef WIN32_LEAN_AND_MEAN
# define EXPORT(a,b) __declspec(dllexport) a b
BOOL APIENTRY
DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved)
{
return TRUE;
}
#else
# define EXPORT(a,b) a b
#endif
EXTERN int AxisCmd( ClientData clientData, Tcl_Interp *interp,
int argc, const char *argv[]);
EXTERN int SegmtCmd( ClientData clientData, Tcl_Interp *interp,
int argc, const char *argv[]);
EXTERN int WavfmCmd( ClientData clientData, Tcl_Interp *interp,
int argc, const char *argv[]);
/*
extern Tk_ItemType axisType;
extern Tk_CustomOption axisTagsOption;
*/
int useOldObjAPI = 0;
int littleEndian = 0;
/* Called by "load trans" */
EXPORT(int,Trans_Init) _ANSI_ARGS_(( Tcl_Interp *interp))
{
Tcl_CmdInfo infoPtr;
const char *version;
int res;
union {
char c[sizeof(short)];
short s;
} order;
#ifdef USE_TCL_STUBS
if (Tcl_InitStubs(interp, "8", 0) == NULL) {
return TCL_ERROR;
}
if (Tk_InitStubs(interp, "8", 0) == NULL) {
return TCL_ERROR;
}
#endif
version = Tcl_GetVar(interp, "tcl_version",
(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
if (strcmp(version, "8.0") == 0) {
useOldObjAPI = 1;
}
res = Tcl_PkgProvide( interp, "trans", "1.5");
if (res != TCL_OK) return res;
if (Tcl_GetCommandInfo(interp, "button", &infoPtr) != 0) {
/* Tk canvas items */
/*
Tk_CreateItemType(&axisType);
axisTagsOption.parseProc = Tk_CanvasTagsParseProc;
axisTagsOption.printProc = Tk_CanvasTagsPrintProc;
*/
/* Tk widgets for waveform and segmentation display */
Tcl_CreateCommand( interp, "axis", AxisCmd,
(ClientData)Tk_MainWindow(interp),
(Tcl_CmdDeleteProc *)NULL);
Tcl_CreateCommand( interp, "segmt", SegmtCmd,
(ClientData)Tk_MainWindow(interp),
(Tcl_CmdDeleteProc *)NULL);
Tcl_CreateCommand( interp, "wavfm", WavfmCmd,
(ClientData)Tk_MainWindow(interp),
(Tcl_CmdDeleteProc *)NULL);
}
/* Determine computer byte order */
order.s = 1;
if (order.c[0] == 1) {
littleEndian = 1;
}
return TCL_OK;
}
EXPORT(int,Trans_SafeInit)(Tcl_Interp *interp)
{
return Trans_Init(interp);
}
|