~ubuntu-branches/ubuntu/breezy/ncbi-tools6/breezy

« back to all changes in this revision

Viewing changes to desktop/smtools.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2002-04-04 22:13:09 UTC
  • Revision ID: james.westby@ubuntu.com-20020404221309-vfze028rfnlrldct
Tags: upstream-6.1.20011220a
ImportĀ upstreamĀ versionĀ 6.1.20011220a

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*   smtools.c
 
2
* ===========================================================================
 
3
*
 
4
*                            PUBLIC DOMAIN NOTICE
 
5
*            National Center for Biotechnology Information (NCBI)
 
6
*
 
7
*  This software/database is a "United States Government Work" under the
 
8
*  terms of the United States Copyright Act.  It was written as part of
 
9
*  the author's official duties as a United States Government employee and
 
10
*  thus cannot be copyrighted.  This software/database is freely available
 
11
*  to the public for use. The National Library of Medicine and the U.S.
 
12
*  Government do not place any restriction on its use or reproduction.
 
13
*  We would, however, appreciate having the NCBI and the author cited in
 
14
*  any work or product based on this material
 
15
*
 
16
*  Although all reasonable efforts have been taken to ensure the accuracy
 
17
*  and reliability of the software and data, the NLM and the U.S.
 
18
*  Government do not and cannot warrant the performance or results that
 
19
*  may be obtained by using this software or data. The NLM and the U.S.
 
20
*  Government disclaim all warranties, express or implied, including
 
21
*  warranties of performance, merchantability or fitness for any particular
 
22
*  purpose.
 
23
*
 
24
* ===========================================================================
 
25
*
 
26
* File Name:  smtools.c
 
27
*
 
28
* Author:  Alex Smirnov
 
29
*
 
30
* Version Creation Date:   8/10/95
 
31
*
 
32
* $Revision: 6.0 $
 
33
*
 
34
* File Description: 
 
35
*
 
36
* Modifications:  
 
37
* --------------------------------------------------------------------------
 
38
* Date     Name        Description of modification
 
39
* -------  ----------  -----------------------------------------------------
 
40
*
 
41
*
 
42
* ==========================================================================
 
43
*/
 
44
 
 
45
/**************************************************************************/
 
46
/* INCLUDE */
 
47
/**************************************************************************/
 
48
#include <vibrant.h>
 
49
#include <picture.h> 
 
50
#include <fstyle.h> 
 
51
#include <fstylep.h> 
 
52
 
 
53
/**************************************************************************/
 
54
/* DEFINES */
 
55
/**************************************************************************/
 
56
#define INPANEL_COLOR    0
 
57
#define INPANEL_SHADDING 1
 
58
#define INPANEL_LTYPE    2
 
59
#define INIT_FONTSET     6
 
60
 
 
61
/**************************************************************************/
 
62
/* TYPEDEFS */
 
63
/**************************************************************************/
 
64
typedef struct {
 
65
  BigScalar val;
 
66
  GrouP     g;
 
67
  Boolean   vis;
 
68
} Nlm_ToolNode;
 
69
 
 
70
typedef void (*Nlm_InPanelDraw)   (Int2 x, Int2 y, Int2 w, Int2 h, 
 
71
                                   Int2 i, Int2 j);
 
72
typedef void (*Nlm_InPanelChange) (void);
 
73
 
 
74
typedef struct {
 
75
  PaneL   p;
 
76
  Int2    width;
 
77
  Int2    height;
 
78
  Int2    x, y;
 
79
  Int2    curx, cury;
 
80
  Nlm_InPanelDraw   draw;
 
81
  Nlm_InPanelChange change;
 
82
} Nlm_InterPanel, PNTR Nlm_InterPanelPtr;
 
83
 
 
84
typedef struct {
 
85
  Nlm_Uint1  red;
 
86
  Nlm_Uint1  green;
 
87
  Nlm_Uint1  blue;
 
88
} NLMINTERNALCOLOR;
 
89
 
 
90
typedef struct s_AddFontList {
 
91
  struct s_AddFontList PNTR next;
 
92
  Nlm_FontSpec              fsp;
 
93
} Nlm_AddFontList, PNTR Nlm_AddFontListPtr;
 
94
 
 
95
static void colorDraw    (Int2 x,Int2 y,Int2 w,Int2 h,Int2 i,Int2 j);
 
96
static void shaddingDraw (Int2 x,Int2 y,Int2 w,Int2 h,Int2 i,Int2 j);
 
97
static void lTypeDraw    (Int2 x,Int2 y,Int2 w,Int2 h,Int2 i,Int2 j);
 
98
static void colorChg     (void);
 
99
static void shaddingChg  (void);
 
100
static void lTypeChg     (void);
 
101
 
 
102
/**************************************************************************/
 
103
/* STATIC VARIABLE */
 
104
/**************************************************************************/
 
105
static Nlm_ToolNode      tools[SM_TOOLS_TOTAL];
 
106
static Nlm_SmToolsProc   curProc = NULL;
 
107
static LisT              fontList = NULL;
 
108
 
 
109
#ifdef WIN_MAC
 
110
static Nlm_FontSpec       fontNames[INIT_FONTSET] = {
 
111
{"Geneva", 9, STYLE_REGULAR, CHARSET_ANSI, PITCH_VARIABLE, FAMILY_SWISS},
 
112
{"Times", 9, STYLE_REGULAR, CHARSET_ANSI, PITCH_VARIABLE, FAMILY_ROMAN},
 
113
{"Monaco", 9, STYLE_REGULAR, CHARSET_ANSI, PITCH_FIXED, FAMILY_MODERN},
 
114
{"Geneva", 12, STYLE_REGULAR, CHARSET_ANSI, PITCH_VARIABLE, FAMILY_SWISS},
 
115
{"Times", 12, STYLE_REGULAR, CHARSET_ANSI, PITCH_VARIABLE, FAMILY_ROMAN},
 
116
{"Monaco", 12, STYLE_REGULAR, CHARSET_ANSI, PITCH_FIXED, FAMILY_MODERN} };
 
117
#endif
 
118
#ifdef WIN_MSWIN
 
119
static Nlm_FontSpec       fontNames[INIT_FONTSET] = {
 
120
{"Arial", 9, STYLE_REGULAR, CHARSET_ANSI, PITCH_VARIABLE, FAMILY_SWISS},
 
121
{"Times", 9, STYLE_REGULAR, CHARSET_ANSI, PITCH_VARIABLE, FAMILY_ROMAN},
 
122
{"Courier New", 9, STYLE_REGULAR, CHARSET_ANSI, PITCH_FIXED, FAMILY_MODERN},
 
123
{"Arial", 12, STYLE_REGULAR, CHARSET_ANSI, PITCH_VARIABLE, FAMILY_SWISS},
 
124
{"Times", 12, STYLE_REGULAR, CHARSET_ANSI, PITCH_VARIABLE, FAMILY_ROMAN},
 
125
{"Courier New", 12, STYLE_REGULAR, CHARSET_ANSI, PITCH_FIXED, FAMILY_MODERN}};
 
126
#endif
 
127
#ifdef WIN_MOTIF
 
128
static Nlm_FontSpec       fontNames[INIT_FONTSET] = {
 
129
{"helvetica", 12, STYLE_REGULAR, CHARSET_ANSI, PITCH_VARIABLE, FAMILY_SWISS},
 
130
{"times", 12, STYLE_REGULAR, CHARSET_ANSI, PITCH_VARIABLE, FAMILY_ROMAN},
 
131
{"courier", 12, STYLE_REGULAR, CHARSET_ANSI, PITCH_FIXED, FAMILY_MODERN},
 
132
{"helvetica", 14, STYLE_REGULAR, CHARSET_ANSI, PITCH_VARIABLE, FAMILY_SWISS},
 
133
{"times", 14, STYLE_REGULAR, CHARSET_ANSI, PITCH_VARIABLE, FAMILY_ROMAN},
 
134
{"courier", 14, STYLE_REGULAR, CHARSET_ANSI, PITCH_FIXED, FAMILY_MODERN}};
 
135
#endif
 
136
 
 
137
static Nlm_AddFontListPtr addFontList = NULL;
 
138
 
 
139
/* Basic colors */
 
140
static NLMINTERNALCOLOR theBasicColors[16] = {
 
141
{128,128,128},{255,255,255},{255,0  ,0  },{0  ,255,0  },
 
142
{0  ,0  ,255},{255,255,0  },{255,0  ,255},{0  ,255,255},
 
143
{0  ,0  ,0  },{192,192,192},{128,0  ,0  },{0  ,128,0  },
 
144
{0  ,0  ,128},{128,128,0  },{128,0  ,128},{0  ,128,128} };
 
145
 
 
146
static Nlm_InterPanel interPanels [] = {
 
147
 {(PaneL)0, 16, 12, 8, 2, 0, 0, colorDraw, colorChg },
 
148
 {(PaneL)0, 20, 24, 2, 2, 0, 0, shaddingDraw, shaddingChg },
 
149
 {(PaneL)0, 40, 15, 2, 3, 0, 0, lTypeDraw, lTypeChg }
 
150
};
 
151
 
 
152
/**************************************************************************/
 
153
/* STATIC FUNCTION */
 
154
/**************************************************************************/
 
155
static void
 
156
/*FCN*/colorDraw (
 
157
  Int2 x, 
 
158
  Int2 y, 
 
159
  Int2 w, 
 
160
  Int2 h, 
 
161
  Int2 i, 
 
162
  Int2 j
 
163
){
 
164
  RecT  rdraw;
 
165
 
 
166
  LoadRect ( &rdraw, x, y, x+w, y+h );
 
167
  SelectColor ( theBasicColors[j*8+i].red,
 
168
                theBasicColors[j*8+i].green,
 
169
                theBasicColors[j*8+i].blue );
 
170
  PaintRect ( &rdraw );
 
171
  Black();
 
172
  FrameRect ( &rdraw );
 
173
}
 
174
 
 
175
static void 
 
176
/*FCN*/colorChg (
 
177
  void
 
178
){
 
179
  Int2 i;
 
180
 
 
181
  i = interPanels[INPANEL_COLOR].cury * 8 + 
 
182
      interPanels[INPANEL_COLOR].curx;
 
183
  tools[SM_TOOLS_COLOR].val = 
 
184
      ((BigScalar)theBasicColors[i].red << 16) |
 
185
      ((BigScalar)theBasicColors[i].green << 8) |
 
186
      ((BigScalar)theBasicColors[i].blue);
 
187
  if ( curProc != NULL ) curProc (SM_TOOLS_COLOR); 
 
188
}
 
189
 
 
190
static void
 
191
/*FCN*/shaddingDraw (
 
192
  Int2 x, 
 
193
  Int2 y, 
 
194
  Int2 w, 
 
195
  Int2 h, 
 
196
  Int2 i, 
 
197
  Int2 j
 
198
){
 
199
  RecT  rdraw;
 
200
 
 
201
  LoadRect ( &rdraw, x, y, x+w, y+h );
 
202
  Black();
 
203
  switch (j*2 + i){
 
204
    case 0:
 
205
      Solid(); break;
 
206
    case 1:
 
207
      Dark(); break;
 
208
    case 2:
 
209
      Medium(); break;
 
210
    default:
 
211
      Light();
 
212
  }
 
213
  PaintRect ( &rdraw );
 
214
  FrameRect ( &rdraw );
 
215
}
 
216
 
 
217
static void 
 
218
/*FCN*/shaddingChg (
 
219
  void
 
220
){
 
221
  Int2 i;
 
222
 
 
223
  i = interPanels[INPANEL_SHADDING].cury * 2 + 
 
224
      interPanels[INPANEL_SHADDING].curx;
 
225
  switch (i){
 
226
    case 0:
 
227
      i = SOLID_SHADING; break;
 
228
    case 1:
 
229
      i = DARK_SHADING; break;
 
230
    case 2:
 
231
      i = MEDIUM_SHADING; break;
 
232
    default:
 
233
      i = LIGHT_SHADING;
 
234
  }
 
235
  tools[SM_TOOLS_SHADDING].val =  (BigScalar)i;
 
236
  if ( curProc != NULL ) curProc (SM_TOOLS_SHADDING); 
 
237
}
 
238
 
 
239
static void
 
240
/*FCN*/lTypeDraw (
 
241
  Int2 x, 
 
242
  Int2 y, 
 
243
  Int2 w, 
 
244
  Int2 h, 
 
245
  Int2 i, 
 
246
  Int2 j
 
247
){
 
248
  PoinT pt1, pt2;
 
249
 
 
250
  pt1.x = x+1 ; pt2.x = x+w-2;
 
251
  pt1.y = pt2.y = y + h/2;
 
252
  Black();
 
253
  switch ( i*3 + j ){
 
254
    case 0:
 
255
      WidePen ( 1 );
 
256
      Solid(); break;
 
257
    case 1:
 
258
      WidePen ( 1 );
 
259
      Dotted(); break;
 
260
    case 2:
 
261
      WidePen ( 1 );
 
262
      Dashed(); break;
 
263
    case 3:
 
264
      Solid(); 
 
265
      WidePen ( 2 ); break;
 
266
    case 4:
 
267
      Solid(); 
 
268
      WidePen ( 3 ); break;
 
269
    default:
 
270
      Solid(); 
 
271
      WidePen ( 4 ); break;
 
272
  }
 
273
  DrawLine ( pt1, pt2 );
 
274
}
 
275
 
 
276
static void 
 
277
/*FCN*/lTypeChg (
 
278
  void
 
279
){
 
280
  Int2 i;
 
281
 
 
282
  i = interPanels[INPANEL_LTYPE].curx * 3 + 
 
283
      interPanels[INPANEL_LTYPE].cury;
 
284
  switch(i){
 
285
    case 0:
 
286
      i = 0x100 | SOLID_LINE; break;
 
287
    case 1:
 
288
      i = 0x100 | DOTTED_LINE; break;
 
289
    case 2:
 
290
      i = 0x100 | DASHED_LINE; break;
 
291
    case 3:
 
292
      i = 0x200 | SOLID_LINE; break;
 
293
    case 4:
 
294
      i = 0x300 | SOLID_LINE; break;
 
295
    default:
 
296
      i = 0x400 | SOLID_LINE; break;
 
297
  }
 
298
  tools[SM_TOOLS_LTYPE].val =  (BigScalar)i;
 
299
  if ( curProc != NULL ) curProc (SM_TOOLS_LTYPE); 
 
300
}
 
301
 
 
302
static void 
 
303
/*FCN*/InPanelCursor (
 
304
  Nlm_InterPanelPtr pInfo,
 
305
  RecT         PNTR rpPtr
 
306
){
 
307
  RecT rdraw;
 
308
  Int2 x,y;
 
309
 
 
310
  if ( pInfo->curx >= 0 ){
 
311
    WidePen (1);
 
312
    Black();
 
313
    Solid();
 
314
    InvertMode();
 
315
    x = rpPtr->left + pInfo->curx*(pInfo->width+4);
 
316
    y = rpPtr->top +  pInfo->cury*(pInfo->height+4),
 
317
    LoadRect ( &rdraw, x, y, 
 
318
               x+pInfo->width+4, y+pInfo->height+4 );
 
319
    FrameRect ( &rdraw );
 
320
    CopyMode();
 
321
  }
 
322
}
 
323
 
 
324
static void 
 
325
/*FCN*/InPanelClick ( 
 
326
  PaneL p, 
 
327
  Nlm_PoinT pt
 
328
){
 
329
  Nlm_RecT          rp;
 
330
  Nlm_InterPanelPtr pInfo;
 
331
  Int2              x, y;
 
332
 
 
333
  ObjectRect (p, &rp);
 
334
  pInfo = &(interPanels[0]);
 
335
  while ( pInfo->p != p ) pInfo++;
 
336
  Nlm_ObjectRect (p, &rp);
 
337
  x = pt.x - rp.left;
 
338
  y = pt.y - rp.top;
 
339
  x /= pInfo->width + 4;
 
340
  y /= pInfo->height + 4;
 
341
  if ( (x < 0) || (y < 0) ||
 
342
       (x >= pInfo->x) || (y >= pInfo->y) ||
 
343
       ((pInfo->curx == x) && (pInfo->cury == y)) ) return;
 
344
  InPanelCursor ( pInfo, &rp );
 
345
  pInfo->curx = x;
 
346
  pInfo->cury = y;
 
347
  InPanelCursor ( pInfo, &rp );
 
348
  pInfo->change();
 
349
} /* End of InPanelClick() */
 
350
 
 
351
static void
 
352
/*FCN*/InPanelDraw (
 
353
  PaneL p
 
354
){
 
355
  Nlm_InterPanelPtr pInfo;
 
356
  RecT              rp;
 
357
  Int2              i, j;
 
358
 
 
359
  ObjectRect (p, &rp);
 
360
  pInfo = &(interPanels[0]);
 
361
  while ( pInfo->p != p ) pInfo++;
 
362
  for ( i=0; i<pInfo->x; i++ ){
 
363
    for ( j=0; j<pInfo->y; j++ ){
 
364
      pInfo->draw ( rp.left + 2 + i*(pInfo->width+4),
 
365
                    rp.top + 2 + j*(pInfo->height+4),
 
366
                    pInfo->width, pInfo->height,
 
367
                    i, j );
 
368
    }
 
369
  }
 
370
  InPanelCursor( pInfo, &rp );
 
371
}
 
372
 
 
373
static void
 
374
/*FCN*/InPanelSet (
 
375
  Nlm_InterPanelPtr pInfo,
 
376
  Int2 curx, 
 
377
  Int2 cury
 
378
){
 
379
  Nlm_WindoW tmpPort;
 
380
  RecT       rp;
 
381
 
 
382
  if ( (curx != pInfo->curx) || (cury != pInfo->cury) ){
 
383
    ResetClip();
 
384
    tmpPort = SavePort (pInfo->p);
 
385
    Select ( pInfo->p );
 
386
    ObjectRect ( pInfo->p, &rp);
 
387
    InPanelCursor ( pInfo, &rp );
 
388
    pInfo->curx = curx;
 
389
    pInfo->cury = cury;
 
390
    InPanelCursor ( pInfo, &rp );
 
391
    RestorePort (tmpPort);
 
392
  }
 
393
}
 
394
 
 
395
static void
 
396
/*FCN*/InPanel ( 
 
397
  GrouP             g, 
 
398
  Nlm_InterPanelPtr pInfo
 
399
){
 
400
  SetGroupMargins (g, 10, 10 );
 
401
  pInfo->p = SimplePanel ( g, pInfo->x * (pInfo->width + 4), 
 
402
             pInfo->y * (pInfo->height + 4), 
 
403
             InPanelDraw );
 
404
  SetPanelClick ( pInfo->p, InPanelClick, NULL, NULL, NULL );
 
405
} /* End of InPanel () */
 
406
 
 
407
static void 
 
408
/*FCN*/Nlm_FontList ( 
 
409
  LisT lst
 
410
){
 
411
  Nlm_AddFontListPtr addFontPtr;
 
412
  Nlm_FontSpec       fsp;
 
413
  Nlm_Int2           val;
 
414
  Nlm_Int2           i;
 
415
  Nlm_Boolean        upd = FALSE;
 
416
  Nlm_Char           fullFontName[64];
 
417
 
 
418
  val = Nlm_GetValue (lst) - 1;
 
419
  if ( (val >= 0) && (tools[SM_TOOLS_FONT].val != (BigScalar)NULL) ){
 
420
    if ( val == 0 ){
 
421
      fsp = *((Nlm_FontSpecPtr)tools[SM_TOOLS_FONT].val);
 
422
      Nlm_DisableSM();
 
423
      if ( Nlm_ChooseFont ( &fsp, CFF_READ_FSP, NULL) ) {
 
424
        Nlm_EnableSM();
 
425
        fsp.name[FONT_NAME_SIZE-1] = 0;
 
426
        *((Nlm_FontSpecPtr)tools[SM_TOOLS_FONT].val) = fsp;
 
427
        for ( i=0; i<INIT_FONTSET; i++ ){
 
428
          if ( Nlm_EqualFontSpec ( &fsp, &(fontNames[i]) ) ) break;
 
429
        }
 
430
        if ( i == INIT_FONTSET ){
 
431
          addFontPtr = addFontList;
 
432
          while ( addFontPtr != NULL ) {
 
433
            if ( Nlm_EqualFontSpec ( &fsp, &(addFontPtr->fsp) ) ) break;
 
434
            addFontPtr = addFontPtr->next;
 
435
          }
 
436
          if ( addFontPtr == NULL ){
 
437
            sprintf ( fullFontName, "%s %d ", fsp.name, fsp.size );
 
438
            if ( fsp.style & STYLE_BOLD ) StringCat ( fullFontName, "b" );
 
439
            if ( fsp.style & STYLE_ITALIC ) StringCat ( fullFontName, "i" );
 
440
            if ( fsp.style & STYLE_UNDERLINE ) StringCat ( fullFontName, "u" );
 
441
            ListItem ( lst, fullFontName );
 
442
            addFontPtr = addFontList;
 
443
            if ( addFontPtr == NULL ) {
 
444
              addFontList = addFontPtr = MemNew ( sizeof(Nlm_AddFontList) );
 
445
            } else {
 
446
              while ( addFontPtr->next != NULL ) addFontPtr = addFontPtr->next;
 
447
              addFontPtr->next = MemNew ( sizeof(Nlm_AddFontList) );
 
448
              addFontPtr = addFontPtr->next;
 
449
            }
 
450
            addFontPtr->next = NULL;
 
451
            addFontPtr->fsp = fsp;
 
452
          }
 
453
        }
 
454
        upd = TRUE;
 
455
      } else {
 
456
        Nlm_EnableSM();
 
457
      }
 
458
    } else if ( val <= INIT_FONTSET ) {
 
459
      *((Nlm_FontSpecPtr)tools[SM_TOOLS_FONT].val) = fontNames[val-1];
 
460
      upd = TRUE;
 
461
    } else {
 
462
      val -= 7;
 
463
      addFontPtr = addFontList;
 
464
      while ( val ){
 
465
        addFontPtr = addFontPtr->next;
 
466
        val--;
 
467
      }
 
468
      *((Nlm_FontSpecPtr)tools[SM_TOOLS_FONT].val) = addFontPtr->fsp;
 
469
      upd = TRUE;
 
470
    }
 
471
    if ( upd && (curProc != NULL) ) curProc ( SM_TOOLS_FONT );
 
472
  }
 
473
}
 
474
 
 
475
static void
 
476
/*FCN*/OnCustomColor (
 
477
  ButtoN bn
 
478
){
 
479
  Uint4  color;
 
480
  Uint1  r,g,b;
 
481
 
 
482
  color = (Uint4)tools[SM_TOOLS_COLOR].val;
 
483
  r = (Uint1)(color >> 16 ) & 0xFF;
 
484
  g = (Uint1)(color >> 8 ) & 0xFF;;
 
485
  b = (Uint1)color & 0xFF;
 
486
  Nlm_DisableSM();
 
487
  if ( Nlm_ChooseColorDialog ( &r,&g,&b, TRUE ) ){
 
488
    Nlm_EnableSM();
 
489
    tools[SM_TOOLS_COLOR].val = (BigScalar)
 
490
      (((Uint4)r << 16) | ((Uint4)g << 8) | (Uint4)b);
 
491
    InPanelSet ( &(interPanels[INPANEL_COLOR]), -1, 0 );
 
492
    if ( curProc != NULL ) curProc (SM_TOOLS_COLOR); 
 
493
  } else {
 
494
    Nlm_EnableSM();
 
495
  }
 
496
}
 
497
 
 
498
/**************************************************************************/
 
499
/* GLOBAL FUNCTIONS */
 
500
/**************************************************************************/
 
501
GrouP 
 
502
/*FCN*/Nlm_CtreateToolsSM ( 
 
503
  WindoW w
 
504
){
 
505
  GrouP     g1;
 
506
  Int2      i;
 
507
  Nlm_Char  fullFontName[32];
 
508
 
 
509
  g1 = HiddenGroup ( w, 4, 1, NULL );
 
510
  SetGroupSpacing (g1, 10, 0);
 
511
  tools[SM_TOOLS_COLOR].g = NormalGroup ( g1 ,-1, 2,"Color", systemFont, NULL);
 
512
  InPanel ( tools[SM_TOOLS_COLOR].g, &(interPanels[INPANEL_COLOR]) );
 
513
  AlignObjects ( ALIGN_CENTER, 
 
514
    (HANDLE)PushButton ( tools[SM_TOOLS_COLOR].g, "Other...", OnCustomColor ),
 
515
    (HANDLE)interPanels[INPANEL_COLOR].p, NULL);
 
516
 
 
517
  tools[SM_TOOLS_SHADDING].g = 
 
518
      NormalGroup ( g1 ,1, 1,"Shading", systemFont, NULL);
 
519
  InPanel ( tools[SM_TOOLS_SHADDING].g, &(interPanels[INPANEL_SHADDING]));
 
520
 
 
521
  tools[SM_TOOLS_LTYPE].g = 
 
522
      NormalGroup ( g1 ,1, 1,"Line Type", systemFont, NULL);
 
523
  InPanel ( tools[SM_TOOLS_LTYPE].g, &(interPanels[INPANEL_LTYPE]) );
 
524
 
 
525
  tools[SM_TOOLS_FONT].g = 
 
526
      NormalGroup ( g1 ,1, 1,"Font", systemFont, NULL);
 
527
#ifdef MOTIF
 
528
  fontList = SingleList ( tools[SM_TOOLS_FONT].g, 12, 4, Nlm_FontList );
 
529
#else
 
530
  fontList = SingleList ( tools[SM_TOOLS_FONT].g, 8, 4, Nlm_FontList );
 
531
#endif
 
532
  ListItem ( fontList, "Other..." );
 
533
  for ( i=0; i<INIT_FONTSET; i++ ) {
 
534
    sprintf ( fullFontName, "%s %d", fontNames[i].name, fontNames[i].size );
 
535
    ListItem ( fontList, fullFontName );
 
536
  }
 
537
  Nlm_ShowToolsSM ( 0 );
 
538
  return g1;
 
539
}
 
540
 
 
541
void 
 
542
/*FCN*/Nlm_SetToolsCallbackSM ( 
 
543
  Nlm_SmToolsProc proc
 
544
){
 
545
  curProc = proc;
 
546
}
 
547
 
 
548
void 
 
549
/*FCN*/Nlm_SetToolDefaultSM  ( 
 
550
  Int2      tool, 
 
551
  BigScalar val
 
552
){
 
553
  tools[tool].val = val;
 
554
}
 
555
 
 
556
BigScalar
 
557
/*FCN*/Nlm_GetToolValueSM  ( 
 
558
  Int2 tool
 
559
){
 
560
  return tools[tool].val;
 
561
}
 
562
 
 
563
void
 
564
/*FCN*/Nlm_ShowToolsSM ( 
 
565
Int2 show_tools
 
566
){
 
567
  Nlm_FontSpecPtr    valfsp;
 
568
  Nlm_AddFontListPtr addFontPtr;
 
569
  Int4               val;
 
570
  Int2               curx, cury, i;
 
571
  NLMINTERNALCOLOR   color;
 
572
 
 
573
  if ( show_tools & SM_SHTOOLS_COLOR ){
 
574
    Enable (tools[SM_TOOLS_COLOR].g);
 
575
    val = (Int4)tools[SM_TOOLS_COLOR].val;
 
576
    color.red = (Uint1)((val>>16)&0xFF);
 
577
    color.green = (Uint1)((val>>8)&0xFF);
 
578
    color.blue = (Uint1)(val&0xFF);
 
579
    for ( cury=0; cury<2; cury++ ){
 
580
      for ( curx=0; curx<8; curx++ ){
 
581
        i = curx + cury*8;
 
582
        if ( (color.red == theBasicColors[i].red) &&
 
583
             (color.green == theBasicColors[i].green) &&
 
584
             (color.blue == theBasicColors[i].blue)) break;
 
585
      }
 
586
      if ( curx != 8 ) break;
 
587
    }
 
588
    if ( cury == 2 ) curx = -1;
 
589
    InPanelSet ( &(interPanels[INPANEL_COLOR]), curx, cury );
 
590
  } else Disable (tools[SM_TOOLS_COLOR].g);
 
591
  if ( show_tools & SM_SHTOOLS_SHADDING ){
 
592
    Enable (tools[SM_TOOLS_SHADDING].g);
 
593
    val = (Int4)tools[SM_TOOLS_SHADDING].val;
 
594
    switch ( val ){
 
595
      case DARK_SHADING:
 
596
        curx = 1; cury = 0; break;
 
597
      case MEDIUM_SHADING:
 
598
        curx = 0; cury = 1; break;
 
599
      case LIGHT_SHADING:
 
600
        curx = 1; cury = 1; break;
 
601
      default:
 
602
        curx = cury = 0;
 
603
    }
 
604
    InPanelSet ( &(interPanels[INPANEL_SHADDING]), curx, cury );
 
605
  } else Disable (tools[SM_TOOLS_SHADDING].g);
 
606
  if ( show_tools & SM_SHTOOLS_LTYPE ){
 
607
    Enable (tools[SM_TOOLS_LTYPE].g);
 
608
    val = (Int4)tools[SM_TOOLS_LTYPE].val;
 
609
    switch (val) {
 
610
      case (0x100 | DOTTED_LINE):
 
611
        curx = 0; cury = 1; break;
 
612
      case (0x100 | DASHED_LINE):
 
613
        curx = 0; cury = 2; break;
 
614
      case (0x200 | SOLID_LINE):
 
615
        curx = 1; cury = 0; break;
 
616
      case (0x300 | SOLID_LINE):
 
617
        curx = 1; cury = 1; break;
 
618
      case (0x400 | SOLID_LINE):
 
619
        curx = 1; cury = 2; break;
 
620
      default:
 
621
        curx = cury = 0;
 
622
    }
 
623
    InPanelSet ( &(interPanels[INPANEL_LTYPE]), curx, cury );
 
624
  } else Disable (tools[SM_TOOLS_LTYPE].g);
 
625
  if ( show_tools & SM_SHTOOLS_FONT ){
 
626
    Hide(tools[SM_TOOLS_FONT].g);
 
627
    Enable (tools[SM_TOOLS_FONT].g);
 
628
    valfsp = (Nlm_FontSpecPtr)tools[SM_TOOLS_FONT].val;
 
629
    i = -1;
 
630
    if ( valfsp != NULL ) {
 
631
      for ( i=0; i<INIT_FONTSET; i++ ){
 
632
        if ( EqualFontSpec ( valfsp, &(fontNames[i])) ){
 
633
          break;
 
634
        }
 
635
      }
 
636
      if ( i == INIT_FONTSET ){
 
637
        addFontPtr = addFontList;
 
638
        while ( addFontPtr != NULL ) {
 
639
          if ( Nlm_EqualFontSpec ( valfsp, &(addFontPtr->fsp) ) ) break;
 
640
          addFontPtr = addFontPtr->next;
 
641
          i++;
 
642
        }
 
643
        if ( addFontPtr == NULL ) i = -1;
 
644
      }
 
645
    }
 
646
    i += 2;
 
647
    SetValue(fontList, i);
 
648
    Show(tools[SM_TOOLS_FONT].g);
 
649
  } else Disable (tools[SM_TOOLS_FONT].g);
 
650
}
 
651
 
 
652
/* END */