~ubuntu-branches/ubuntu/breezy/garlic/breezy

« back to all changes in this revision

Viewing changes to foreground.c

  • Committer: Bazaar Package Importer
  • Author(s): zhaoway
  • Date: 2001-04-24 07:09:13 UTC
  • Revision ID: james.westby@ubuntu.com-20010424070913-uzpupnwdfhmliebz
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000 Damir Zucic */
 
2
 
 
3
/*=============================================================================
 
4
 
 
5
                                foreground.c
 
6
 
 
7
Purpose:
 
8
        Execute  foreground command:  change the main window foreground
 
9
        color. 
 
10
 
 
11
Input:
 
12
        (1) Pointer to MolComplexS structure, with macromol. complexes.
 
13
        (2) The number of macromolecular complexes.
 
14
        (3) Pointer to RuntimeS structure, with some runtime data.
 
15
        (4) Pointer to ConfigS structure, with configuration data.
 
16
        (5) Pointer to GUIS structure, with GUI data.
 
17
        (6) Pointer to NearestAtomS structure.
 
18
        (7) The number of pixels in the main window free area.
 
19
        (8) Pointer to refreshI.
 
20
 
 
21
Output:
 
22
        (1) Log file created.
 
23
        (2) Return value.
 
24
 
 
25
Return value:
 
26
        (1) Positive (command) code on success.
 
27
        (2) Negative (error) code on failure.
 
28
 
 
29
========includes:============================================================*/
 
30
 
 
31
#include <stdio.h>
 
32
 
 
33
#include <string.h>
 
34
 
 
35
#include <X11/Xlib.h>
 
36
#include <X11/Xutil.h>
 
37
#include <X11/Xos.h>
 
38
#include <X11/Xatom.h>
 
39
 
 
40
#include "defines.h"
 
41
#include "commands.h"
 
42
#include "typedefs.h"
 
43
 
 
44
/*======function prototypes:=================================================*/
 
45
 
 
46
char            *ExtractToken_ (char *, int, char *, char *);
 
47
int             ParseColor_ (RGBS *, unsigned long *, GUIS *, char *, char *);
 
48
size_t          MainRefresh_ (MolComplexS *, int,
 
49
                              RuntimeS *, ConfigS *, GUIS *,
 
50
                              NearestAtomS *, size_t, unsigned int);
 
51
 
 
52
/*======execute fg command:==================================================*/
 
53
 
 
54
int Foreground_ (MolComplexS *mol_complexSP, int mol_complexesN,
 
55
                 RuntimeS *runtimeSP, ConfigS *configSP, GUIS *guiSP,
 
56
                 NearestAtomS *nearest_atomSP, size_t pixelsN,
 
57
                 unsigned int *refreshIP)
 
58
{
 
59
char            *remainderP;
 
60
char            tokenA[STRINGSIZE];
 
61
 
 
62
/* Skip the first token: */
 
63
remainderP = ExtractToken_ (tokenA, STRINGSIZE,
 
64
                            runtimeSP->curr_commandA, " \t\n");
 
65
if (!remainderP) return ERROR_FOREGROUND;
 
66
 
 
67
/* The second token should contain the color: */
 
68
remainderP = ExtractToken_ (tokenA, STRINGSIZE, remainderP, " \t\n");
 
69
if (!remainderP)
 
70
        {
 
71
        strcpy (runtimeSP->messageA, "Main window foreground color missing!");
 
72
        runtimeSP->message_length = strlen (runtimeSP->messageA);
 
73
        return ERROR_NO_COLOR;
 
74
        }
 
75
 
 
76
/* Prepare the main window foreground color: */
 
77
strncpy (configSP->fg_colorA, tokenA, SHORTSTRINGSIZE - 1);
 
78
configSP->fg_colorA[SHORTSTRINGSIZE - 1] = '\0';
 
79
ParseColor_ (&guiSP->main_winS.fg_rgbS, &guiSP->main_winS.fg_colorID,
 
80
             guiSP, configSP->fg_colorA, "white");
 
81
 
 
82
/* Refresh the main window: */
 
83
(*refreshIP)++;
 
84
MainRefresh_ (mol_complexSP, mol_complexesN, runtimeSP, configSP, guiSP,
 
85
              nearest_atomSP, pixelsN, *refreshIP);
 
86
 
 
87
/* Return positive value on success: */
 
88
return COMMAND_FOREGROUND;
 
89
}
 
90
 
 
91
/*===========================================================================*/
 
92
 
 
93