📄 dna.h
字号:
//-----------------------------------------------------------------------//// dna.h //// Copyright (C) 2000 by Thomas J. Nelson //// All Rights Reserved. ////-----------------------------------------------------------------------//#include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>#include <stdarg.h>#include <ctype.h>#include <errno.h>#ifdef LINUX#include <Xlocale.h>#else#include <locale.h>#endif#include <time.h>#include <sys/stat.h>#include <sys/time.h> #include <sys/times.h>#include <Xm/XmAll.h>#include <X11/Xlib.h>#include <X11/Xutil.h>#include <X11/Xatom.h> // For definition of XA_WINDOW #include <X11/Xresource.h>#include <X11/cursorfont.h>#include <X11/keysym.h>#include <X11/keysymdef.h>#include <fcntl.h>#include <unistd.h>#include <dirent.h>//---------------#define's-------------------------//#define min(a,b) (((a)<(b)) ? (a) : (b))#define max(a,b) (((a)>(b)) ? (a) : (b))#define swap(a,b) { g.swap_temp=(a); (a)=(b); (b)=g.swap_temp; } #define fswap(a,b) { g.fswap_temp=(a); (a)=(b); (b)=g.fswap_temp; } #define dswap(a,b) { g.dswap_temp=(a); (a)=(b); (b)=g.dswap_temp; } #define sgn(a) ( (a)>0 ? (1) : ( (a)<0 ? (-1) : (0) ) )#define uchar unsigned char#define uint unsigned int#define ulong unsigned long#define ushort unsigned short int#define MAXWINDOWS 10#ifndef MAXINT #define MAXINT 2147483647#endif#define XmACB XmAnyCallbackStruct#define XmSBCB XmSelectionBoxCallbackStruct#define XmFSBCB XmFileSelectionBoxCallbackStruct#define XtEH XtEventHandler#define XtP XtPointer#define XtCBP XtCallbackProc//--------------constants-------------------------//const int FILENAMELENGTH=1024; // max. length of a filenameconst int MAXSEQUENCES=256; // Maximum possible no. of sequences const int MAXCOMMENTS=50; // Maximum possible no. of commentsconst int SAME=0;//// Error codesconst int OK=0;const int NOMEM=1;const int ABORT=2;const int NOTFOUND=3;const int ERROR=4;const int NOIMAGES=5;const int GOTNEW=6;const int UNKNOWN=7;const int CANTCREATEFILE=8;const int CRITERR=9;const int ZEROLENGTH=10;const int QUIT=11;const int BADPARAMETERS=12;const int YES=13;const int NO=14;const int CANCEL=15;//// Movement & positioning modesconst int OFF=0;const int ON=1;const int UP=1;const int DOWN=2;const int LEFT=3;const int RIGHT=4;const int START=5;const int CONTINUE=6;const int END=7;const int CENTER=8;//// Number typesconst int INTEGER=0;const int FLOAT=1;const int INTARRAY=2;const int DOUBLE=3;const int CHARACTER=4;const int WORD=5;const int HEXADECIMAL=6;const int RGBVALUE=7;const int RGBHEX=8;//// Global statesconst int RESET=-2;const int NORMAL=0;const int REDRAW=8;const int BUSY=9;const int CALCULATING=13;const int ALTKEY=30;const int MESSAGE=40;const int EXPOSE=44;//// Text directionconst int HORIZONTAL=0;const int VERTICAL=1;const int NOBACKGROUND=0;const int BACKGROUND=1;const int LEFTBORDER=100; // border at left for buttonsconst int TOPBORDER=30; // border at top for titleconst int LINESPACING=2; // No. of pixels between lines of text//// List types in dialog boxesconst int RADIO=0;const int RADIOTEXT=1;const int RADIOVALUE=2;const int RADIOVALUEWIDE=3;const int RADIOPUSHBUTTON=4;//// Box types in dialog boxesconst int TOGGLE=0;const int INTCLICKBOX=1;const int FILENAME=2;const int MULTICLICKBOX=3;const int NON_EDIT_LIST=4;const int STRING=5;const int LIST=6;const int LABEL=7;const int NO_LABEL_LIST=8;const int DOUBLECLICKBOX=9;const int MULTIFILENAME=10;const int TOGGLESTRING=11; // Toggle and get a stringconst int TOGGLEMULTICLICKBOX=12; // Toggle and get RGB valueconst int SCROLLEDSTRING=13; // Get string using scrolled text widget//// Message typesconst int NONE=0;const int INFO=1;const int PROMPT=2;const int QUESTION=3;// ERROR=4const int WARNING=5;const int WORKING=6;const int DONE=7;const int YESNOQUESTION=8;//// List add item modeconst int BOTTOM=0;const int TOP=1;//// Filename modeconst int SINGLE=1;const int MULTIPLE=2;//// Sequence typesconst int PROTEIN=0;const int DNA=1;//// Save formatsconst int SCREEN=1;const int HIGHLIGHT=2; // Compat. with highlight program//// For copyimageconst int GET=0;const int PUT=1;//-----------Typedef's------------------------------//typedef struct clickboxinfo { char *title; char *filename; char *dirmask; char *path; char *buttonlabel; // For BUTTONVALSLIDER button label int answer; // Generic answer for single clickbox double fanswer; // Generic answer for single clickbox int *answers; // Generic array of answers for multiclickbox. Must // be a ptr so all individual clickboxes can see // each other's data. int k; // Index of which slider in multiclickbox int button; // Generic button no. int startval; double fstartval; int minval; int maxval; double fminval; double fmaxval; int decimalpoints; // No. of decimal points to display ints as floats int type; // Data type desired (INTEGER or FLOAT) int wantpreview; int allowedit; // 0=cant change 1=ok to change 2=each line is command int ask; // 0=dont ask user (eg for filename) 1=ask user int editrow; int editcol; int position; int maxstringsize; // Maximum length of a string to edit Widget form; // The parent form widget that called clickbox Widget listwidget; // The child list widget of the clickbox if any int count; // No. of items in list if any Widget widget[20]; // Generic list of Widgets to be changed by callback Widget *w; // List of Widgets created by callback, to be destroyed int wc; // No. of Widgets in list w to destroy char **list; // List of strings int listsize; // No. of elements in list int helptopic; // Help topic number void *ptr; // Generic pointer int done; // Flag indicating done int wantdragcb; // 1=f1,f2,f3 called while dragging mouse 0=called only // when value changes. Set to 0 if f1-f3 are slow. // (used for multiclickbox only) void(*f1)(int answer); // Function to call with integer arg void(*f2)(double answer); // Function to call with double arg void(*f3)(int answers[10]); // Function to call with integer array arg // Function to call with integer and clickboxinfo* void(*f4)(int answer, clickboxinfo *c); };typedef struct Listinfo{ char* title; // Title of list box char** info; // Contents of list (strings) int size; // No. of items int itemstoshow; // No. of items to show at a time int firstitem; // 1st item to show int wantsort; // 1=sort items before showing list int wantsave; // 1=prompt to save list before closing int helptopic; // Help topic int *selection; // Return for answer selected by user. This must // point to an actual variable, even if no selection // is wanted. (e.g., list.selection = &crud; ) int allowedit; // 1=allow user to change items in list // The following items don't need to be specified if // allowedit is 0. char* edittitle; // Title of menu box if user edits a line * int editcol; // Left most column user is allowed to edit int editrow; // 1st row that can be edited int width; // Minimum width in pixels of dialog widget to create // (If 0, width is calculated from 'info'). Widget form; // Form widget containing list Widget widget; // Generic widget Widget browser; // Browser widget int transient; // 1=list pops up 0=user must position the list int maxstringsize; // Maximum allowable size for an 'info[]' item int wantfunction; // 1=call function f1 void (*f1)(int answer); // Function to call when click on list item void (*f2)(int listno); // Function to call to update list (only used if // autoupdate is 1) int autoupdate; // 1=automatically update list after every command int clearbutton; // 1=add button to erase contents int highest_erased; // No. of items erased by clearbutton} listinfo;const int DCOUNT=30; // No. of box or menu itemstypedef struct dialoginfo{ /* Select only 1 from each set */ char title[50]; /* Title across top */ char radio[10][DCOUNT][100]; /* 10 sets of up to DCOUNT options length 100 */ int radiono[10]; /* no.of actual radio groups (max=10) */ int radiotype[10][DCOUNT]; /* Input method for obtaining answer in a */ /* radio box (0=no answer, 1=message(), */ /* 2, clickbox(). */ /* Answers returnable from a radio box */ /* radioanswer[radioboxno][item_no] */ /* Maximum 100 characters */ char radioanswer[10][DCOUNT][100]; int radiomin[10][DCOUNT]; /* Minimum int value returnable in radio */ int radiomax[10][DCOUNT]; /* Maximum int value returnable in radio */ int radiocomeback[10]; /* 1=need to return if radio item changes */ int radioset[DCOUNT]; /* Radio box selection number */ int boxtype[DCOUNT]; /* Character type to be returned in answer */ /* box (0=string, 1=integer). If integer it*/ /* uses clickbox to select the integer. */ int boxmin[DCOUNT]; /* Minimum value returnable in box */ int boxmax[DCOUNT]; /* Maximum value returnable in box */ int wantfunc[DCOUNT]; /* Flag if clickbox in answer box calls */ /* a callback */ /* For selecting parameters in dialog box */ /* 1 set of up to DCOUNT multiple choices */ char boxes[DCOUNT][100]; /* or up to DCOUNT strings in boxes */ int boxset[DCOUNT]; /* Toggle box setting (0 or 1) */ int boxcount[DCOUNT]; /* Returns number of items in boxlist */ int noofradios; /* no. of radio groups */ int noofboxes; /* no. of string boxes + check boxes */ /* Prior value of most recently-changed */ /* string if non-zero */ char lastanswer[DCOUNT][100]; /* Corresponding strings returned from box */ /* This has to be >= 2 chars longer than */ /* the maxlength used in 'message'. */ char answer[DCOUNT][FILENAMELENGTH]; char path[FILENAMELENGTH]; /* Path to start looking for filename */ int helptopic; /* ID # of associated help topic */ char **boxmenu[DCOUNT]; /* Menu items for box (dynamically alloc'd)*/ /* max of DCOUNT menu items/listbox */ char *boxmenutitle[DCOUNT]; /* Menu title */ char **boxlist[DCOUNT]; /* Multi-filename list for box */ int boxmenuselection[DCOUNT];/* Number of menu item selected. */ /* boxmax[k] is the total no. of items. */ int boxcomeback[DCOUNT]; /* 1=Need to return if box item changes */ int startcol[DCOUNT]; /* Leftmost allowable editing position */ /* (in strings, not lists) */ int needrepeat; /* 1=Comeback was hit, need to call dialog */ /* again */ char *message1; /* Error message to display first */ char *message2; /* Error message to display first */ int messagemode; /* Message mode of error message */ double clickboxstep[DCOUNT]; /* Step distance for slider in clickbox */ Widget radiowidget[10][DCOUNT]; /* Radio button Widget (needed in callback)*/ Widget radioslider[10][DCOUNT]; /* Radio button Widget (needed in callback)*/ /* Answer box Widget (needed in callback) */ Widget boxwidget[DCOUNT][4]; /* Max of 4 widgets per line (eg, r,g,b or */ /* a toggle button + string). */ int transient; /* Whether to make window transient */ int bpp; /* Bits/pixel to use in multiclickbox */ int want_changecicb; /* 1=call dialogchangecicb when changing ci*/ int keep; /* ON = dialog stays on screen */ /* OFF = dialog automatically unmanaged */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -