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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
|
/* File: graphselect.c
* Author: Jean Thierry-Mieg (mieg@mrc-lmb.cam.ac.uk)
* Copyright (C) J Thierry-Mieg and R Durbin, 1992
* -------------------------------------------------------------------
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* -------------------------------------------------------------------
* This file is part of the ACEDB genome database package, written by
* Richard Durbin (MRC LMB, UK) rd@mrc-lmb.cam.ac.uk, and
* Jean Thierry-Mieg (CRBM du CNRS, France) mieg@kaa.cnrs-mop.fr
*
* Description:
** New version of graphSelect written using the graphAce toolBox.
* Exported functions:
BOOL graphSelect
* HISTORY:
* Last edited: May 6 10:16 2003 (edgrif)
* * May 12 14:20 1999 (edgrif): Add calls to make menus blocking & no busy cursor.
* * Dec 17 09:36 1998 (edgrif): change var. called 'main' to mainGraph (!)
* * Sep 29 14:21 1998 (edgrif): Removed #ifdef ACEDB, instead the
* caller can now select two different display modes for
* graphSelect (one is the old '#ifdef ACEDB' stuff).
* Created: Mon Jul 20 22:25:49 1992 (mieg)
*-------------------------------------------------------------------
* gha 04/30/93 change spacing, bold
* gha 05/03/93 change title, layout
*/
/* $Id: graphselect.c,v 1.18 2003/05/06 13:13:31 edgrif Exp $ */
#include "regular.h"
#include <w2/graph_.h>
static void popPick(int box, double x_unused, double y_unused, int modifier_unused) ;
static void popCancel(void) ;
static void popPlainDraw(FREEOPT *f) ;
static void popScrolledDraw(FREEOPT *f) ;
static GraphSelectDisplayMode display_mode = GRAPH_SELECT_SCROLLED ;
static Array box2key = 0 ;
static KEY popChoice ;
static int minBox ;
static Graph mainGraph = 0 ;
static MENUOPT popMenu[] = {{popCancel, "Cancel"}, {0, 0}} ;
/*---------------------------------------------------------------------------*/
/* External routines */
/* */
/* Set mode to be either scrolled or non-scrolled selections. */
/* */
void graphSetSelectDisplayMode(GraphSelectDisplayMode mode)
{
display_mode = mode ;
return ;
}
BOOL graphSelect (KEY *kpt, FREEOPT *f)
{
Graph oldGraph = graphActive() ;
BOOL result = FALSE ;
messStatus ("Please answer Selector") ;
/* Select style of display. */
#ifdef ACEDB_GTK
popPlainDraw(f) ;
#else
if (display_mode == GRAPH_SELECT_SCROLLED)
popScrolledDraw(f) ;
else
popPlainDraw(f) ;
#endif
graphActivate(mainGraph);
result = graphBlock() ;
if (graphActivate(mainGraph)) graphDestroy();
mainGraph = 0 ;
graphActivate(oldGraph) ;
if (result) *kpt = popChoice ;
return result ;
}
/*---------------------------------------------------------------------------*/
/* Internal routines. */
/* */
static void popPick(int box, double x_unused, double y_unused, int modifier_unused)
{
if (box <= minBox)
return ;
popChoice = array(box2key, box, int);
graphActivate(mainGraph);
graphUnBlock((int) popChoice ) ;
return;
}
static void popCancel(void)
{
popChoice = 0 ;
graphActivate(mainGraph);
graphUnBlock(0) ;
}
#ifndef ACEDB_GTK
/* Display the selections in their own scrolled subwindow. */
/* */
static void popScrolledDraw(FREEOPT *f)
{
int i, max = f->key, maxLen = 30, px, py ;
KEY key ;
box2key = arrayReCreate(box2key, 32, int) ;
mainGraph = graphCreate(TEXT_FIT,
messprintf("Selector : %s", f->text), .3, .3, .25, .3) ;
graphSetBlockMode(GRAPH_BLOCKING) ;
graphButton("CANCEL", (GraphFunc) popCancel, 1, 0.5) ;
graphTextFormat(BOLD); /* gha debug 4/30/93 */
graphText("Single-click to select", 1, 2.2) ;
graphFitBounds(&px, &py);
graphMenu (popMenu) ;
graphSubCreate(TEXT_SCROLL, 1, 4, px - 2, py - 4 );
graphRegister (PICK, popPick) ;
graphMenu (popMenu) ;
graphTextFormat(PLAIN_FORMAT);
minBox = graphBoxStart() ;
for (i = 0, f++ ; i < max ; f++, i++)
{
array(box2key, graphBoxStart(), int) = key = f->key ;
graphText(f->text, 1, i) ;
if (strlen(f->text) > maxLen)
maxLen = strlen(f->text) ;
graphBoxEnd() ;
}
graphBoxEnd() ;
graphBoxMenu (minBox, popMenu);
graphTextBounds(maxLen + 3, max + 4) ;
graphRedraw() ;
graphActivate(mainGraph);
graphRedraw();
}
#endif
/* Display the selections in a single plain window the whole of which can */
/* be scrolled. */
/* */
static void popPlainDraw(FREEOPT *f)
{
int i, max = f->key, maxLen = 30 ;
KEY key ;
box2key = arrayReCreate(box2key, 32, int) ;
mainGraph = graphCreate(TEXT_SCROLL,
messprintf("Selector : %s", f->text), .3, .3, .25, .3) ;
graphSetBlockMode(GRAPH_BLOCKING) ;
graphRegister (PICK, popPick) ;
graphMenu (popMenu) ;
graphTextFormat(BOLD); /* gha debug 4/30/93 */
graphText("Select or ", 1, 0.1) ;
graphTextFormat(PLAIN_FORMAT);
graphButton("CANCEL", (GraphFunc) popCancel, 12, 0.1) ;
minBox = graphBoxStart() ;
for (i = 0, f++ ; i < max ; f++, i++)
{
array(box2key, graphBoxStart(), int) = key = f->key ;
graphText(f->text, 1, i+3) ;
if (strlen(f->text) > maxLen)
maxLen = strlen(f->text) ;
graphBoxEnd() ;
}
graphBoxEnd() ;
graphBoxMenu(minBox, popMenu);
graphTextBounds (maxLen + 3, max + 3) ;
graphRedraw() ;
}
/****************************************************/
/****************************************************/
|