|
NCBI Home IEB Home C Toolkit docs C++ Toolkit source browser C Toolkit source browser (2) |
NCBI C Toolkit Cross ReferenceC/ddv/ddvgraph.c |
source navigation diff markup identifier search freetext search file search |
1 /* $Id: ddvgraph.c,v 1.41 2003/04/21 15:30:21 kans Exp $
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: ddvgraph.c
27 *
28 * Author: Patrick Durand
29 *
30 * Version Creation Date: 06/19/99
31 *
32 * $Revision: 1.41 $
33 *
34 * File Description: graphic engine of DeuxD-Viewer (DDV)
35 *
36 * Modifications:
37 * --------------------------------------------------------------------------
38 * $Log: ddvgraph.c,v $
39 * Revision 1.41 2003/04/21 15:30:21 kans
40 * use consistent newline character
41 *
42 * Revision 1.40 2001/04/27 20:12:46 juran
43 * Heed warnings: Make functions static.
44 Block out 'dead code' (functions that aren't called anywhere in ncbi).
45 *
46 * Revision 1.39 2000/07/24 22:00:08 hurwitz
47 * fixed bug that 1/2 characters were displayed sometimes
48 *
49 * Revision 1.38 2000/07/19 19:04:01 hurwitz
50 * fixed bug that was causing overwrite of numbering over tick marks in DDE
51 *
52 * Revision 1.37 2000/07/07 22:43:55 lewisg
53 * interface tweaks
54 *
55 * Revision 1.36 2000/07/07 22:31:14 lewisg
56 * interface tweaks
57 *
58 * Revision 1.35 2000/05/16 19:43:00 hurwitz
59 * grey out create block, delete block, undo, and redo as needed
60 *
61 * Revision 1.34 2000/05/09 22:24:06 hurwitz
62 * extend ruler to cover tails even when there's only 1 aligned block in the alignment
63 *
64 * Revision 1.33 2000/05/09 19:53:17 hurwitz
65 * extended ruler to cover tails
66 *
67 * Revision 1.32 2000/04/26 21:54:27 hurwitz
68 * added save function to tell AlnMgr about edits made in DDE
69 *
70 * Revision 1.31 2000/04/05 20:52:35 hurwitz
71 * added GUI control for shifting left and right alignment boundaries
72 *
73 * Revision 1.30 2000/03/29 23:57:04 hurwitz
74 * temporary fix for DDE use before it's initialized
75 *
76 * Revision 1.29 2000/03/29 20:02:48 hurwitz
77 * keep track of master during move row operations
78 *
79 * Revision 1.28 2000/03/24 20:34:59 lewisg
80 * add blast from file, bug fixes, get rid of ant code, etc.
81 *
82 * Revision 1.27 2000/02/23 19:49:33 durand
83 * use row number instead of SeqId for coloring
84 *
85 * Revision 1.26 2000/02/15 15:31:46 lewisg
86 * move DDVRulerDescr to pgppop
87 *
88 * Revision 1.25 2000/02/08 17:18:40 hurwitz
89 * don't use char* szEditSeq
90 *
91 * Revision 1.24 2000/02/07 14:03:35 durand
92 * replace BioseqUnlockById by BioseqUnlock
93 *
94 * Revision 1.23 2000/02/04 16:05:40 durand
95 * add click action to select a row
96 *
97 * Revision 1.22 2000/02/03 15:56:47 hurwitz
98 * added constructor and destructor for DDVRulerDescrPtr
99 *
100 * Revision 1.21 2000/02/02 14:44:31 durand
101 * added function to create data structure for block editor, fixed some bugs
102 *
103 * Revision 1.20 2000/01/26 13:38:54 durand
104 * update the GUI for the editor. Add functions to create the data to be used by the editor
105 *
106 * Revision 1.19 2000/01/24 16:11:13 lewisg
107 * speed up seqid comparison in color manager, make fast windows version of SetColor()
108 *
109 * Revision 1.18 2000/01/10 15:09:46 durand
110 * Use Entrez instead of ID1
111 *
112 * Revision 1.17 2000/01/05 21:11:14 durand
113 * update mouse click actions and DrawSequence function for a better use from ddv and cn3d
114 *
115 * Revision 1.16 1999/12/29 22:55:03 lewisg
116 * get rid of seqalign id
117 *
118 * Revision 1.15 1999/12/07 21:40:14 durand
119 * add mouse modes menu and caret facility for the editor
120 *
121 * Revision 1.14 1999/11/29 15:26:25 durand
122 * designed a new GUI to fix problems under MacOS, Linux and SGI
123 *
124 * Revision 1.13 1999/11/23 17:34:33 lewisg
125 * SavePort added to redraw
126 *
127 * Revision 1.12 1999/11/18 14:37:14 durand
128 * avoid flashing sequence during selection
129 *
130 * Revision 1.11 1999/11/09 17:09:00 durand
131 * transfer some functions from ddvgraph to ddvcreate, so that ddvcreate remains Vibrant free and can be compiled with BLAST
132 *
133 * Revision 1.10 1999/11/03 21:29:49 durand
134 * add CTRL and SHFT keys for mouse selection. redesign the loader functions of DDV to properly register the message callbacks
135 *
136 * Revision 1.9 1999/10/29 14:15:38 durand
137 * add simple mouse selection functions
138 *
139 * Revision 1.8 1999/10/21 13:12:12 durand
140 * fix a problem in panel draw callback
141 *
142 * Revision 1.7 1999/10/20 13:17:18 durand
143 * add display for disc. SeqAlign tails
144 *
145 * Revision 1.5 1999/10/18 17:20:56 durand
146 * fix a bug in the bsp coord mapping for minus strand
147 *
148 * Revision 1.4 1999/10/15 21:57:36 durand
149 * add a UI for display options
150 *
151 * Revision 1.3 1999/10/12 15:01:29 lewisg
152 * resolve confict with internal/ddv
153 *
154 * Revision 1.2 1999/10/02 15:11:21 durand
155 * update the code to reuse more functions from UDV
156 *
157 * Revision 1.1 1999/09/30 14:10:26 durand
158 * add ddv to toolkit
159 *
160 * Revision 1.16 1999/09/22 20:40:20 durand
161 * update the drawing procedure to deal with discontinuous seqalign
162 *
163 * Revision 1.15 1999/09/22 13:17:15 wheelan
164 * Changed DDV_InitColour_When_Start to use new AlnMgrGetNextNthSeqRange function (better for discontinuous)
165 *
166 * Revision 1.14 1999/09/20 13:39:04 durand
167 * replace totsaps by alnsaps (new AlignMgr stuff)
168 *
169 * Revision 1.13 1999/09/16 13:07:07 durand
170 * DDV is able to display bioseq coords along with seqalign coords
171 *
172 * Revision 1.11 1999/09/09 21:54:23 durand
173 * create a display for disconitnuous SeqAlign
174 *
175 * Revision 1.10 1999/09/01 23:02:59 lewisg
176 * binary search in color functions
177 *
178 * Revision 1.9 1999/08/06 14:32:18 wheelan
179 * changes to support new alignmgr function names
180 *
181 * Revision 1.8 1999/08/04 18:01:47 wheelan
182 * changes to support new seqalign indexing
183 *
184 * Revision 1.7 1999/07/22 15:25:27 durand
185 * improve DDV_DrawSequence function
186 *
187 * Revision 1.6 1999/07/20 14:58:00 durand
188 * use the Color Manager to display colored MSA
189 *
190 * Revision 1.5 1999/07/06 19:02:21 durand
191 * update DDV_GetSequenceFromParaG
192 *
193 * Revision 1.4 1999/06/30 14:57:23 durand
194 * update DDV loader functions
195 *
196 * Revision 1.3 1999/06/28 22:07:18 durand
197 * add loader functions and clean the code with Lint and Purify
198 *
199 * Revision 1.2 1999/06/19 18:36:44 durand
200 * update display procedure
201 *
202 * Revision 1.1 1999/06/19 17:21:05 durand
203 * add Vibrant DDV code
204 *
205 *
206 *
207 * ==========================================================================
208 */
209
210 #include <ncbi.h>
211 #include <vibrant.h>
212 #include <udviewer.h>
213 #include <udvseq.h>
214 #include <ddvcolor.h>
215 #include <ddvmain.h>
216 #include <ddvgraph.h>
217 #include <ddvclick.h>
218 #include <pgppop.h>
219 #include <alignmgr.h>
220 #include <ddvcreate.h>
221
222 #undef WANTDEADCODE
223
224 static void DDV_DrawAlignmentBoundaries(PaneL p, DdvMainPtr dmp);
225
226 /*******************************************************************************
227
228 Function : DDV_ReorderParaG()
229
230 Purpose : reorder ParaG positions after style change(s)
231
232 Return value : -
233
234 *******************************************************************************/
235 #ifdef WANTDEADCODE
236 static void DDV_ReorderParaG(ValNodePtr PNTR TableHead, Int4 nRow)
237 {
238 Int4 Startline=0,i,nLines;
239 ParaGPtr pgp;
240 ValNodePtr vnp;
241
242 for(i=0;i<nRow;i++){
243 vnp=TableHead[i];
244 pgp=(ParaGPtr)vnp->data.ptrvalue;
245 if (pgp->ScaleStyle==SCALE_POS_TOP)
246 nLines++;
247 nLines=1;
248 while(vnp){
249 pgp=(ParaGPtr)vnp->data.ptrvalue;
250 pgp->StartLine=Startline;
251 pgp->nLines=nLines;
252 vnp=vnp->next;
253 }
254 Startline+=nLines;
255 }
256 }
257 #endif
258
259 /*******************************************************************************
260
261 Function : DDV_ChangeRulerStyleForSeq()
262
263 Purpose : change the ruler style for a row in the alignment; ie for a Seq.
264
265 Return value : -
266
267 *******************************************************************************/
268 #ifdef WANTDEADCODE
269 static void DDV_ChangeRulerStyleForSeq(ValNodePtr PNTR TableHead,Int4 nRow,
270 Uint1 RulerStyle)
271 {
272 ParaGPtr pgp;
273 ValNodePtr vnp;
274
275 vnp=TableHead[nRow];
276 while(vnp){
277 pgp=(ParaGPtr)vnp->data.ptrvalue;
278 pgp->ScaleStyle=RulerStyle;
279 vnp=vnp->next;
280 }
281 }
282 #endif
283
284 /*******************************************************************************
285
286 Function : DDV_InvalRegion()
287
288 Purpose : invalidate a specific region of DDV panel
289
290 Note : disp_from,disp_to,disp_row are display coordinates.
291 disp_from,disp_to are zero-based.
292 disp_row is one-based
293
294 Return value : the sequence
295
296 *******************************************************************************/
297 extern void DDV_InvalRegion(PaneL hWndDDV,UnDViewerGraphDataPtr GrData,
298 Int4 disp_from,Int4 disp_to,Int4 disp_row,Boolean IsSelect)
299 {
300 DdvMainPtr dmp;
301 RecT rcP,rc;
302 Int2 from_x,to_x,from_y,to_y;
303 WindoW temport;
304
305 dmp = (DdvMainPtr) GetObjectExtra(hWndDDV);
306 if (dmp==NULL) return;
307
308 /*convert disp coord to pixel positions*/
309 /*left of the first letter in the range*/
310 from_x=(Int2)((disp_from-GrData->udv_hscrl.ScrollPos)*GrData->udv_font.ColWidth);
311 /*right of the last letter in the range*/
312 to_x=(Int2)((disp_to-GrData->udv_hscrl.ScrollPos+1)*GrData->udv_font.ColWidth);
313 /*just above the row*/
314 from_y=(Int2)((disp_row-GrData->udv_vscrl.ScrollPos-1)*GrData->udv_font.LineHeight);
315 /*just below the row*/
316 to_y=(Int2)(from_y+2*GrData->udv_font.LineHeight);
317
318 /*adjust the values according to the PaneL RecT position*/
319 /*panel size*/
320 temport=SavePort(ParentWindow(hWndDDV));
321 Select(hWndDDV);
322 ObjectRect(hWndDDV,&rcP);
323 InsetRect(&rcP,4,4);
324 /*drawing region:*/
325 DDV_AdjustDrawingRect(&rcP,&(GrData->udv_font),dmp);
326
327 rcP.left+=GrData->udv_panel.cxName+GrData->udv_scale.cxLeftScale;
328 rcP.top+=3*GrData->udv_panel.cyScale/2;
329 from_x+=rcP.left-1;
330 to_x+=rcP.left;
331 from_y+=rcP.top+1;
332 to_y+=rcP.top;
333
334 rc.left=from_x-2;
335 rc.top=from_y-2;
336 rc.right=to_x+2;
337 rc.bottom=to_y+2;
338
339 /*InvalRect(&rc);*/
340 /*DDV_DrawPanelContent_H (hWndDDV,dmp,&rc,IsSelect);*/
341
342 if (!IsSelect){
343 /*printf("invalRect\n");*/
344 InvalRect(&rc);
345 }
346 else{
347 DDV_DrawPanelContent_H (hWndDDV,dmp,&rc,IsSelect);
348 }
349 /* Update();*/
350 RestorePort(temport);
351 }
352
353 /*******************************************************************************
354
355 Function : DDV_GetBspRangeInSeg()
356
357 Purpose : scan a segment and get the region of a Bsp in the SeqAlign
358
359 Return value : the sequence
360
361 *******************************************************************************/
362
363 #ifdef WANTDEADCODE
364 static void DDV_GetBspRangeInSeg(SegmentPtr segp,Int4Ptr start,Int4Ptr stop)
365 {
366 SegmentPtr segp2;
367 Int4 from,to;
368
369 if (!segp) return;
370 from=INT4_MAX;
371 to=INT4_MIN;
372 segp2=segp;
373 while(segp2){
374 if (segp2->gap==0) {
375 from=MIN(from,segp2->from);
376 to=MAX(to,segp2->to);
377 }
378 segp2=segp2->bsp_next;
379 }
380 *start=from;
381 *stop=to;
382 }
383 #endif
384
385
386 /*******************************************************************************
387
388 Function : DDV_GetCurrentDispRange()
389
390 Purpose : compute the size (row/col) of the DDV panel
391
392 Return value : see arguments (zero-based values)
393
394 *******************************************************************************/
395 extern void DDV_GetCurrentDispRange(PaneL hWndDDV,UnDViewerGraphDataPtr GrData,
396 Int4 LengthAli,Int4Ptr from_col,Int4Ptr to_col,Int4Ptr from_row,
397 Int4Ptr to_row)
398 {
399
400 RecT rcP;
401 DdvMainPtr dmp;
402
403 dmp = (DdvMainPtr) GetObjectExtra(hWndDDV);
404 if (dmp==NULL) return;
405
406 /*panel size*/
407 ObjectRect(hWndDDV,&rcP);
408 InsetRect(&rcP,4,4);
409
410 /*drawing region:*/
411 DDV_AdjustDrawingRect(&rcP,&(GrData->udv_font),dmp);
412
413 rcP.left+=GrData->udv_panel.cxName+GrData->udv_scale.cxLeftScale;
414 rcP.top+=GrData->udv_panel.cyScale;
415
416 *from_col=0;
417 *to_col=(rcP.right-rcP.left)/GrData->udv_font.ColWidth-1;
418 *from_col+=GrData->udv_hscrl.ScrollPos;
419 *to_col+=GrData->udv_hscrl.ScrollPos;
420 if (*to_col>LengthAli) *to_col=LengthAli-1;
421 if (*from_col>LengthAli) *from_col=LengthAli-1;
422 *from_row=0;
423 *to_row=(rcP.bottom-rcP.top)/GrData->udv_font.LineHeight-1;
424 *from_row+=GrData->udv_vscrl.ScrollPos;
425 *to_row+=GrData->udv_vscrl.ScrollPos;
426 if (*from_row>(GrData->udv_panel.nTotLines-1)) *from_row=GrData->udv_panel.nTotLines-1;
427 if (*to_row>(GrData->udv_panel.nTotLines-1)) *to_row=GrData->udv_panel.nTotLines-1;
428
429 }
430
431 /*******************************************************************************
432
433 Function : DDV_GetRulerForEditor()
434
435 Purpose : create the ruler for the editor. This new descriptor is created
436 using the descriptor of the viewer.
437
438 Return value : an allocated data block ready for use by the editor. Null if
439 failure
440
441 *******************************************************************************/
442 NLM_EXTERN ValNodePtr DDV_GetRulerForEditor(ValNodePtr descr_head,Int4 from_disp,
443 Int4 to_disp)
444 {
445 DDVRulerDescrPtr drdp,prev_drdp,new_drdp;
446 ValNodePtr vnp2,vnp3,vnpDesc;
447 Int4 cumulDecr,drdp_size,beginCopy,endCopy,drdp_start_ali;
448 Boolean bPop;
449
450 cumulDecr=0;
451 vnpDesc=NULL;
452 prev_drdp=NULL;
453
454 for(vnp2=descr_head;vnp2!=NULL;vnp2=vnp2->next){
455 drdp=(DDVRulerDescrPtr)vnp2->data.ptrvalue;
456 drdp_size=drdp->disp_stop-drdp->disp_start+1;
457
458 /*not yet in the region of interest ?*/
459 if (drdp->disp_stop<from_disp) {
460 cumulDecr+=drdp_size;
461 continue;
462 }
463
464 beginCopy=_max_(from_disp,drdp->disp_start);
465 endCopy=_min_(drdp->disp_stop,to_disp);
466
467 if (drdp->bUnAligned==FALSE)
468 drdp_start_ali=drdp->align_start+(beginCopy-drdp->disp_start);
469 else
470 drdp_start_ali=(Int4)-1;
471 /*in order to merge nodes of same type, i keep track of
472 the previous populated drdp node. Same style==yes, then
473 just extend to the right the previous node*/
474 if (prev_drdp){
475 if (prev_drdp->bUnAligned==drdp->bUnAligned){
476 prev_drdp->disp_stop=endCopy;
477 bPop=TRUE;
478 }
479 else{
480 bPop=FALSE;
481 }
482 }
483 else{
484 bPop=FALSE;
485 }
486 if (!bPop){
487 new_drdp=(DDVRulerDescrPtr)MemNew(sizeof(DDVRulerDescr));
488 if (!new_drdp) goto erreur;
489
490 new_drdp->disp_start=beginCopy;
491 new_drdp->disp_stop=endCopy;
492 new_drdp->align_start=drdp_start_ali;
493 new_drdp->bUnAligned=drdp->bUnAligned;
494 if (!vnpDesc){
495 vnp3=ValNodeAddPointer(&vnpDesc,0,(Pointer)new_drdp);
496 }
497 else{
498 vnp3=ValNodeAddPointer(&vnp3,0,(Pointer)new_drdp);
499 }
500 prev_drdp=new_drdp;
501 }
502 if (drdp->disp_stop>=to_disp) break;
503 cumulDecr+=drdp_size;
504 }
505
506 return(vnpDesc);
507 erreur:
508 if (vnpDesc)
509 ValNodeFreeData(vnpDesc);
510 return(NULL);
511 }
512
513
514 /*******************************************************************************
515
516 Function : DDV_ComputeRuler()
517
518 Purpose : compute the Ruler descriptor (usefull for discontinuous align)
519
520 Parameters :
521
522 Return value : a list of RUler descriptor
523
524 *******************************************************************************/
525 extern ValNodePtr DDV_ComputeRuler(SeqAlignPtr sap,DDV_Disp_OptPtr ddop)
526 {
527
528 DDVRulerDescrPtr drdp;
529 ValNodePtr vnp=NULL,vnp_head=NULL;
530 Int4 disp_start=0,length,TotAliLength=0,r=0;
531 Boolean bUnAligned;
532
533 /* make ruler for LEFT_TAIL */
534 if ((ddop->DispDiscStyle == MSA_TXT_STYLE_2) && (ddop->ShowLeftTail)) {
535 length = AlnMgrGetMaxTailLength(sap, LEFT_TAIL);
536 if (length) {
537 drdp=(DDVRulerDescrPtr)MemNew(sizeof(DDVRulerDescr));
538 drdp->disp_start=disp_start;
539 drdp->disp_stop=disp_start+length-1;
540 drdp->bUnAligned=TRUE;
541 drdp->align_start = -1;
542 disp_start += length;
543 vnp_head=ValNodeAddPointer(NULL,0,(Pointer)drdp);
544 vnp=vnp_head;
545 }
546 }
547
548 if (AlnMgrIsSAPDiscAli(sap)){
549 /* make ruler for multiple blocks */
550 while(AlnMgrGetNextLengthBit(sap,&length,&r)){
551 if (length<0){
552 bUnAligned=TRUE;
553 switch(ddop->DispDiscStyle){/*user's display choice*/
554 case MSA_TXT_STYLE_1:
555 length=ddop->SpacerSize;
556 break;
557 case MSA_TXT_STYLE_2:
558 length=ABS(length);
559 break;
560 }
561 }
562 else{
563 bUnAligned=FALSE;
564 }
565
566 drdp=(DDVRulerDescrPtr)MemNew(sizeof(DDVRulerDescr));
567 drdp->disp_start=disp_start;
568 drdp->disp_stop=disp_start+length-1;
569 drdp->bUnAligned=bUnAligned;
570
571 if (bUnAligned==FALSE)
572 drdp->align_start=TotAliLength;/*SeqAlign Coord*/
573 else
574 drdp->align_start=-1;/*drdp->disp_start;*//*Disp Coord*/
575
576 if (!vnp_head){
577 vnp_head=ValNodeAddPointer(NULL,0,(Pointer)drdp);
578 vnp=vnp_head;
579 }
580 else{
581 vnp=ValNodeAddPointer(&vnp,0,(Pointer)drdp);
582 }
583 disp_start+=length;
584 if (bUnAligned==FALSE)
585 TotAliLength+=length;
586 }
587 }
588
589 else if (sap->type == SAT_MASTERSLAVE){
590 /* make ruler for a single block */
591 drdp=(DDVRulerDescrPtr)MemNew(sizeof(DDVRulerDescr));
592 drdp->disp_start=disp_start;
593 length=AlnMgrGetAlnLength(sap,FALSE);
594 drdp->disp_stop=disp_start+length-1;
595 drdp->bUnAligned = FALSE;
596 drdp->align_start=0;
597 if (!vnp_head){
598 vnp_head=ValNodeAddPointer(NULL,0,(Pointer)drdp);
599 vnp=vnp_head;
600 }
601 else{
602 vnp=ValNodeAddPointer(&vnp,0,(Pointer)drdp);
603 }
604 }
605
606 /* make ruler for RIGHT_TAIL */
607 if ((ddop->DispDiscStyle == MSA_TXT_STYLE_2) && (ddop->ShowRightTail)) {
608 length = AlnMgrGetMaxTailLength(sap, RIGHT_TAIL);
609 if (length) {
610 drdp=(DDVRulerDescrPtr)MemNew(sizeof(DDVRulerDescr));
611 drdp->disp_start=disp_start;
612 drdp->disp_stop=disp_start+length-1;
613 drdp->bUnAligned=TRUE;
614 drdp->align_start = -1;
615 disp_start += length;
616 vnp = ValNodeAddPointer(&vnp,0,(Pointer)drdp);
617 }
618 }
619
620 return(vnp_head);
621 }
622
623 /*******************************************************************************
624
625 Function : DDV_DrawSequenceName()
626
627 Purpose : draw the name of the sequence (left column of the DDV panel)
628
629 Parameters : GrData; graphical data (font size, etc)
630 ScaleStyle;style of the ParaG scale
631 top, left; coord to start the draw
632
633 Return value : none
634
635 *******************************************************************************/
636 static void DDV_DrawSequenceName(UnDViewerGraphDataPtr GrData,ParaGPtr pgp,
637 Int2 top,Int2 left,Int4 cur_row,Int4 CurEditRow,Int4 CurMasterRow)
638 {
639 SeqIdPtr sip = NULL;
640 RecT rc;
641 Int2 x,y,decal=1,size;/*text position/size*/
642 Char szAccess[21];
643 BioseqPtr bsp;
644
645 /*get a name*/
646 bsp = BioseqLockById(pgp->sip);
647 if(bsp) {
648 sip = SeqIdFindBestAccession(bsp->id);
649 BioseqUnlock(bsp);
650 }
651 if (!sip)
652 sip = SeqIdFindBest(pgp->sip, 0);
653 SeqIdWrite(sip, szAccess,PRINTID_TEXTID_ACCESSION, 20);
654
655 /*compute position*/
656 if (pgp->ScaleStyle==SCALE_POS_TOP) decal++;
657
658 /*draw name*/
659 size=StringWidth(szAccess);
660 x=left/*-GrData->udv_scale.cxLeftScale*/-size;
661 y=top+decal*GrData->udv_font.LineHeight;
662 MoveTo(x,y);
663 if (cur_row==CurEditRow){
664 Magenta();
665 }
666 PaintString (szAccess);
667 if (cur_row==CurMasterRow){
668 Blue();
669 MoveTo(x,y);
670 LineTo(x+size,y);
671 }
672 /*draw a little box (for selection a full sequence)*/
673 left+=GrData->udv_font.cxChar;
674 top+=GrData->udv_font.cxChar/2;
675 LoadRect(&rc,left,top,left+GrData->udv_font.cxChar,
676 top+GrData->udv_font.cxChar);
677 Blue();
678 PaintOval(&rc);
679 Black();
680 }
681
682
683 /*****************************************************************************
684
685 Function: DDV_DrawSequence()
686
687 Purpose: draw a sequence within a ParaG
688
689 Return value: -
690
691 *****************************************************************************/
692 static void DDV_DrawSequence(UnDViewerGraphDataPtr GrData,ParaGPtr pgp,
693 DDV_ColorGlobal *pColorGlobal,SeqIdPtr sip,RectPtr rc_pgp,
694 CharPtr szSeq,Int4 from,Int4 to,Uint1 ScaleStyle,
695 Int2 leftDecal,Uint1 strand,Boolean bUseColors,ValNodePtr vnp_bsp,
696 Int4 row,Boolean bSelect)
697 {
698 DDV_ColorCell *dclrp,*highlighClr;
699 Int4 dp;
700 Uint4 old_colour,new_colour,hlClr;
701 Int2 decal=1,i,x,y,pos=0;
702 Boolean isAlpha,bSelected,bGoTo;
703 RecT rcSel;
704
705 if (!szSeq) return;
706
707 /*scale or not... to be or not to be ?*/
708 if (ScaleStyle==SCALE_POS_TOP) decal++;
709
710 /*compute the first letter's coordinate*/
711 x=rc_pgp->left+leftDecal-GrData->udv_font.cxChar/2;
712 y=rc_pgp->top+decal*GrData->udv_font.LineHeight;
713
714 i=from;/*if from!=0, means we don't draw the entire ParaG*/
715 to++;
716
717 /*get the selection(s)*/
718
719 if (pColorGlobal){/*use color*/
720 old_colour=new_colour=GetColorRGB(0,0,0);
721 highlighClr =
722 DDV_SearchColorCellbyName(pColorGlobal->pvnSpecialColors, "Highlight");
723 if (highlighClr)
724 hlClr = GetColorRGB (highlighClr->rgb[0], highlighClr->rgb[1],highlighClr->rgb[2]);
725 else
726 hlClr = GetColorRGB (255,255,0);
727 while(szSeq[i] && i<to){
728 /*if a letter, get the color*/
729 if (szSeq[i]!=' '){
730 if (isalpha(szSeq[i])){
731 isAlpha=TRUE;
732 dp=DDV_GetBspCoordGivenDispCoord(pgp,pgp->StartLetter+i);
733 bSelected=DDV_IsLetterSelected(vnp_bsp,dp);
734 if (dp==(Int4)-1)
735 dclrp=NULL;
736 else
737 dclrp=DDV_GetColor(pColorGlobal,NULL, row+1, dp);
738
739 if(bUseColors){
740 if (dclrp)
741 new_colour=GetColorRGB(dclrp->rgb[0],dclrp->rgb[1],dclrp->rgb[2]);
742 else
743 new_colour=GetColorRGB(0,0,0);
744 }
745 }
746 else {
747 bSelected=FALSE;
748 isAlpha=FALSE;
749 new_colour=GetColorRGB(0,0,0);
750 }
751 if (GrData->GotoLetter==pgp->StartLetter+i){
752 bGoTo=TRUE;bSelected=TRUE;
753 }
754 else{
755 bGoTo=FALSE;
756 }
757 if (bSelected){
758 if (bGoTo==FALSE){
759 if (bSelect)
760 #ifdef WIN_MSWIN
761 Nlm_SetColorEx(hlClr);
762 #else
763 Nlm_SetColor(hlClr);
764 #endif
765 else White();
766 }
767 else{
768 Red();
769 }
770 rcSel.left=x-2;
771 rcSel.top=y-GrData->udv_font.LineHeight;
772 rcSel.bottom=y;
773 rcSel.right=rcSel.left+GrData->udv_font.ColWidth;
774 PaintRect(&rcSel);
775 /*FrameRect(&rcSel);*/
776 }
777 if ((bUseColors && new_colour!=old_colour) || bSelected) {
778 #ifdef WIN_MSWIN
779 Nlm_SetColorEx(new_colour);
780 #else
781 Nlm_SetColor(new_colour);
782 #endif
783 old_colour=new_colour;
784 }
785 MoveTo(x,y);
786 if (isAlpha && dclrp)
787 PaintChar((dclrp->LowerCase ? TO_LOWER(szSeq[i]) : szSeq[i]));
788 else
789 PaintChar(szSeq[i]);
790 }
791 i++;
792 x+=GrData->udv_font.ColWidth;
793 }
794 }
795 else{/*B&W display mode*/
796 Black();
797 while(szSeq[i] && i<to){
798 /*if a letter, get the color*/
799 if (szSeq[i]!=' '){
800 MoveTo(x,y);
801 PaintChar(szSeq[i]);
802 }
803 i++;
804 x+=GrData->udv_font.ColWidth;
805 }
806 }
807
808 Black();
809 }
810
811 /*****************************************************************************
812
813 Function: DDV_DrawParaG()
814
815 Purpose: draw a ParaG given from, to (seqalign coord) and a position (rc_pgp)
816
817 Return value: -
818
819 *****************************************************************************/
820 static void DDV_DrawParaG(RectPtr rc_pgp,ParaGPtr pgp,Int4 from,Int4 to,
821 UnDViewerGraphDataPtr GrData,DDV_ColorGlobal *pColorGlobal,
822 DDV_Disp_OptPtr ddop,ValNodePtr vnp_bsp,Int4 row,Boolean bSelect)
823 {
824 CharPtr szSeq;
825 BioseqPtr bsp;
826 SeqIdPtr sip;
827 Int4 bspLength,bsp_start,bsp_stop,from_pgp,to_pgp;
828 Int2 decal,diff;
829 Boolean IsAA;
830 Uint1 strand;
831 MsaTxtDispPtr mtdp;
832 ValNodePtr vnp;
833
834 /*get some bsp info*/
835 /*sip=SeqIdFindBest(pgp->sip,0);
836 if (sip==NULL)*/
837 sip=pgp->sip;
838 bsp=BioseqLockById(sip);
839 if (!bsp) return;
840 bspLength=BioseqGetLen(bsp);
841 IsAA=ISA_aa(bsp->mol);
842 BioseqUnlock(bsp);
843
844 szSeq=(CharPtr)MemNew((pgp->StopLetter-pgp->StartLetter+2)*sizeof(Char));
845 /*get a sequence to draw*/
846 DDV_GetSequenceFromParaG(pgp,&szSeq,bspLength,IsAA,&strand,&bsp_start,&bsp_stop);
847
848 if (pgp->ScaleStyle==SCALE_POS_TOP){
849 vnp=pgp->ptxtList;
850 decal=0;
851 while(vnp){
852 mtdp=(MsaTxtDispPtr)vnp->data.ptrvalue;
853 diff=(Int2)(mtdp->to-mtdp->from+1);
854 if (mtdp->TextStyle == MSA_TXT_STYLE_SEQ){
855 UDV_Draw_scale(
856 GrData,
857 FALSE,
858 FALSE,
859 pgp->ScaleStyle,
860 (Int4)decal,
861 (Int4)decal+diff,
862 rc_pgp,
863 (Int2)(GrData->udv_font.ColWidth/2)+
864 (Int2)(decal*GrData->udv_font.ColWidth),
865 bspLength,
866 mtdp->from,
867 FALSE,
868 GrData->udv_font.ColWidth,(Uint4)DDV_DISP_HORZ);
869 }
870 decal+=diff;
871 vnp=vnp->next;
872 }
873 }
874
875 if (szSeq){/*draw the sequence*/
876 from_pgp=_max_(pgp->StartLetter,from);
877 to_pgp=_min_(pgp->StopLetter,to);
878 DDV_DrawSequence(GrData,
879 pgp,
880 pColorGlobal,
881 sip,
882 rc_pgp,
883 szSeq,
884 from_pgp-pgp->StartLetter,
885 to_pgp-pgp->StartLetter,
886 pgp->ScaleStyle,
887 (Int2)(GrData->udv_font.ColWidth/2+
888 (Int2)(from_pgp-pgp->StartLetter)*GrData->udv_font.ColWidth),
889 strand,
890 ddop->bUseColors,
891 vnp_bsp,
892 row,
893 bSelect);
894 if (pgp->szEditSeq==NULL)/*viewer deletes allocated char array*/
895 MemFree(szSeq);
896 }
897 }
898
899 /*****************************************************************************
900
901 Function: DDV_ComputeColWidth()
902
903 Purpose: compute the width of a single column
904
905 Return value: the height
906
907 *****************************************************************************/
908 extern Int2 DDV_ComputeColWidth(Int2 cxChar)
909 {
910 return(cxChar+2);
911 }
912
913 /*******************************************************************************
914
915 Function : DDV_AdjustDrawingRect()
916
917 Purpose : adjust the Panel Rect using the size of a letter ; in that way,
918 I get a RecT where it's possible to avoid the display of half letters
919 (on the borders of the RecT).
920
921 Parameters : rcP;panel RecT
922 udv_font; font information
923
924 Return value : none
925
926 *******************************************************************************/
927 extern void DDV_AdjustDrawingRect(RecT * rcP, UDVFontDataPtr udv_font, DdvMainPtr dmp)
928 {
929 Int4 temp;
930
931 rcP->left=(rcP->left/udv_font->ColWidth)*udv_font->ColWidth + udv_font->ColWidth;
932
933 /* rcP->right=(rcP->right/udv_font->ColWidth)*udv_font->ColWidth-2; */
934 /* bug fix, DIH, 7/24/00 */
935 temp = rcP->right - (dmp->GrData.udv_panel.cxName + dmp->GrData.udv_scale.cxLeftScale);
936 temp = (temp/udv_font->ColWidth)*udv_font->ColWidth - 2;
937 rcP->right = temp + (dmp->GrData.udv_panel.cxName + dmp->GrData.udv_scale.cxLeftScale);
938
939 rcP->top=(rcP->top/udv_font->LineHeight)*udv_font->LineHeight + udv_font->LineHeight;
940 rcP->bottom=(rcP->bottom/udv_font->LineHeight)*udv_font->LineHeight;
941 }
942
943
944 /*******************************************************************************
945
946 Function : DDV_DrawPanelContent_H()
947
948 Purpose : draw the panel of DDV viewer (case 1: full horz display)
949
950 Parameters : p;handle of the panel
951 dmp; main data block
952
953 Return value : none
954
955 *******************************************************************************/
956 extern void DDV_DrawPanelContent_H (PaneL p,DdvMainPtr dmp,RecT PNTR MyUpdateRect,
957 Boolean bSelect)
958 {
959 ParaGPtr pgp,/*ParaG data*/
960 first_pgp;/*used to get info from the first pgp of a row*/
961 ValNodePtr vnp,/*used to scan ParaGand Ruler Descriptor*/
962 vnp_pgp,/*used to get info from the first pgp of a row*/
963 vnp_bsp=NULL;/*selected region(s) of one bioseq*/
964 SelStructPtr ssp;/*used to get the selected region(s)*/
965 BioseqPtr bsp;
966 Int4 i,/*just for a loop*/
967 from_row,/*first row to draw*/
968 to_row,/*the last row to draw*/
969 top_offset=0,/*offset from top (pixel)*/
970 left_offset,/*offset from right (pixel)*/
971 from_col,/*draw column from_col...*/
972 to_col,/*...to column to_col*/
973 from_pgp,/*within a ParaG, draw 'from'... */
974 to_pgp,/*... 'to'*/
975 nLinesDraw,/*number of lines drawn*/
976 nColsDraw,/*number of col. drawn*/
977 nTotRow,/*total number of row to draw*/
978 start_i=0,/*first ParaG to draw*/
979 start_ruler,/*beginning of the display ruler*/
980 curMasterRow;
981 RecT rcP;/*size of the DDV panel*/
982 RecT rcD;/*size of the drawing panel*/
983 RecT rcI;/*size of the invalidated rect*/
984 RecT rc_pgp;/*location of a ParaG on the Panel*/
985 Int2 length_pgp,/* i.e. 'length' letters to draw*/
986 x,y;/*caret position (edit mode only)*/
987 Uint2 bsp_eID,/*...*/
988 bsp_iID;/*... identifiers of a bioseq in the SeqAlign*/
989 Boolean bNotDrawCol;
990 DdvMainWinPtr mWin_d;
991 DDVRulerDescrPtr drdp;
992
993 if (dmp->hParent){
994 mWin_d=(DdvMainWinPtr)GetObjectExtra(dmp->hParent);
995 if (mWin_d->Show_logo){
996 UDV_Logo_onDraw(p);
997 return;
998 }
999 }
1000
1001 /*some checks before a core dump...*/
1002 if (!dmp->MSA_d.pgp_l.TableHead) return;
1003
1004 /*restrict panel drawing area: 'add' little margins*/
1005 ObjectRect((Handle) p, &rcP);
1006 InsetRect(&rcP,4,4);
1007
1008 /*3D border to resize the cxName field*/
1009 LtGray();
1010
1011 MoveTo((Int2)(dmp->GrData.udv_panel.cxName-1),rcP.top);
1012 LineTo((Int2)(dmp->GrData.udv_panel.cxName-1),rcP.bottom);
1013
1014 LtGray();
1015 MoveTo((Int2)(dmp->GrData.udv_panel.cxName+1),rcP.top);
1016 LineTo((Int2)(dmp->GrData.udv_panel.cxName+1),rcP.bottom);
1017 LtGray();
1018 MoveTo((Int2)(dmp->GrData.udv_panel.cxName+2),rcP.top);
1019 LineTo((Int2)(dmp->GrData.udv_panel.cxName+2),rcP.bottom);
1020
1021 Black();
1022 MoveTo((Int2)(dmp->GrData.udv_panel.cxName+3),rcP.top);
1023 LineTo((Int2)(dmp->GrData.udv_panel.cxName+3),rcP.bottom);
1024
1025 /*drawing region:*/
1026 DDV_AdjustDrawingRect(&rcP,&(dmp->GrData.udv_font),dmp);
1027
1028 /* debugging */
1029 /* UDV_draw_rectangle(rcP, TRUE); */
1030
1031 rcD=rcI=rcP;
1032 rcP.left+=dmp->GrData.udv_panel.cxName+dmp->GrData.udv_scale.cxLeftScale;
1033 top_offset=dmp->GrData.udv_vscrl.ScrollPos*dmp->GrData.udv_font.LineHeight;
1034 left_offset=dmp->GrData.udv_hscrl.ScrollPos*dmp->GrData.udv_font.ColWidth;
1035
1036 /*set the font*/
1037 SelectFont(dmp->GrData.udv_font.hFnt);
1038
1039 rcD=rcP;
1040 ClipRect(&rcD);
1041 /*display the master numerical ruler*/
1042 from_col=dmp->GrData.udv_hscrl.ScrollPos;
1043 to_col=dmp->GrData.udv_hscrl.ScrollPos+dmp->GrData.udv_hscrl.ScrollPage;
1044 if (to_col==0) to_col=dmp->MSA_d.pgp_l.LengthAli;
1045 if (to_col>dmp->MSA_d.pgp_l.LengthAli) to_col=dmp->MSA_d.pgp_l.LengthAli;
1046 rcD.top+=dmp->GrData.udv_panel.cyScale/2;
1047
1048 /*get the first node of the Ruler descriptor, then get the start value*/
1049 drdp=(DDVRulerDescrPtr)dmp->MSA_d.pgp_l.RulerDescr->data.ptrvalue;
1050 start_ruler=drdp->disp_start;
1051 UDV_Draw_scale(
1052 &dmp->GrData,
1053 dmp->GrData.udv_scale.ShowMajorTick,
1054 dmp->GrData.udv_scale.ShowMMinorTick,
1055 (Uint1)dmp->GrData.udv_scale.ScalePosition,
1056 from_col+start_ruler,
1057 to_col+start_ruler,
1058 &rcD,
1059 (Int2)(dmp->GrData.udv_font.ColWidth/2)+
1060 (Int2)((from_col-dmp->GrData.udv_hscrl.ScrollPos)*
1061 dmp->GrData.udv_font.ColWidth),
1062 dmp->MSA_d.pgp_l.LengthAli+start_ruler-1,
1063 from_col+start_ruler,
1064 FALSE,
1065 dmp->GrData.udv_font.ColWidth,(Uint4)DDV_DISP_HORZ);
1066
1067 /*go at the bottom of the scale*/
1068 ResetClip();
1069
1070 rcP.top+=3*dmp->GrData.udv_panel.cyScale/2;
1071 rcD=rcP;
1072 rcD.left=rcI.left;
1073
1074 /*compute the region to draw (invalidate rect only)*/
1075 from_col=(MyUpdateRect->left-rcP.left)/dmp->GrData.udv_font.ColWidth-2;
1076 to_col=(MyUpdateRect->right-rcP.left)/dmp->GrData.udv_font.ColWidth+2;
1077 if (from_col<0 && to_col<0) bNotDrawCol=TRUE;
1078 else bNotDrawCol=FALSE;
1079 if (from_col<0) from_col=0;
1080 if (to_col<0) to_col=0;
1081 from_col+=dmp->GrData.udv_hscrl.ScrollPos;
1082 to_col+=dmp->GrData.udv_hscrl.ScrollPos;
1083 if (to_col>dmp->MSA_d.pgp_l.LengthAli) to_col=dmp->MSA_d.pgp_l.LengthAli;
1084 if (from_col>dmp->MSA_d.pgp_l.LengthAli) from_col=dmp->MSA_d.pgp_l.LengthAli;
1085 from_row=(MyUpdateRect->top-rcP.top)/dmp->GrData.udv_font.LineHeight-1;
1086 to_row=(MyUpdateRect->bottom-rcP.top)/dmp->GrData.udv_font.LineHeight+1;
1087 if (from_row<0 && to_row<0) return;
1088 if (from_row<0) from_row=0;
1089 if (to_row<0) to_row=0;
1090 from_row+=dmp->GrData.udv_vscrl.ScrollPos;
1091 to_row+=dmp->GrData.udv_vscrl.ScrollPos;
1092 if (from_row>dmp->GrData.udv_panel.nTotLines) from_row=dmp->GrData.udv_panel.nTotLines;
1093 if (to_row>dmp->GrData.udv_panel.nTotLines) to_row=dmp->GrData.udv_panel.nTotLines;
1094 nTotRow=to_row-from_row;
1095
1096 /*find the first ParaG to draw*/
1097 for(i=0;i<dmp->MSA_d.pgp_l.nBsp;i++){
1098 if (!(pgp=(ParaGPtr)(dmp->MSA_d.pgp_l.TableHead[i]->data.ptrvalue))) continue;
1099 if ((pgp->StartLine<=to_row)&&((pgp->StartLine+pgp->nLines)>=from_row)){
1100 start_i=i;break;
1101 }
1102 }
1103
1104 ClipRect(&rcD);
1105
1106 /* get the row of the master */
1107 if (dmp->dsp == NULL) {
1108 curMasterRow = 0;
1109 }
1110 else {
1111 curMasterRow = DDE_GetIndexOfMaster(dmp->dsp);
1112 }
1113
1114 /*draw the names*/
1115 nLinesDraw=0;
1116 for(i=start_i;i<dmp->MSA_d.pgp_l.nBsp;i++){
1117 if (!(pgp=(ParaGPtr)(dmp->MSA_d.pgp_l.TableHead[i]->data.ptrvalue))) continue;
1118 if ((pgp->StartLine<=to_row)&&(pgp->StartLine>=from_row)){
1119 nLinesDraw+=pgp->nLines;
1120 DDV_DrawSequenceName(&dmp->GrData,pgp,
1121 (Int2)(pgp->StartLine*dmp->GrData.udv_font.LineHeight-
1122 top_offset+rcP.top),
1123 (Int2)(dmp->GrData.udv_panel.cxName-3),
1124 i, dmp->deri.curEditRow, curMasterRow);
1125 }
1126 else nLinesDraw+=pgp->nLines;
1127 if (nLinesDraw>to_row) break;
1128 }
1129 ResetClip();
1130
1131 if (bNotDrawCol) return;
1132
1133 ClipRect(&rcP);
1134 nLinesDraw=0;
1135 /*get the selection(s)*/
1136
1137 ssp=ObjMgrGetSelected();
1138
1139 /*draw ParaG*/
1140 for(i=start_i;i<dmp->MSA_d.pgp_l.nBsp;i++){/*draw line by line...*/
1141 if (!(pgp=(ParaGPtr)(dmp->MSA_d.pgp_l.TableHead[i]->data.ptrvalue))) continue;
1142 nColsDraw=0;
1143 if (vnp_bsp){
1144 vnp_bsp=ValNodeFree(vnp_bsp);
1145 }
1146 /*for each line, get the selected region(s)*/
1147 if (ssp!=NULL){
1148 vnp_pgp=dmp->MSA_d.pgp_l.TableHead[i];
1149 first_pgp=(ParaGPtr)(vnp_pgp->data.ptrvalue);
1150 if (first_pgp){
1151 bsp=BioseqLockById(first_pgp->sip);
1152 if (bsp){
1153 bsp_eID=ObjMgrGetEntityIDForPointer((Pointer)bsp);
1154 bsp_iID = GetItemIDGivenPointer (bsp_eID,
1155 OBJ_BIOSEQ, (Pointer) bsp);
1156 if (bsp_eID!=0 && bsp_iID!=0){
1157 vnp_bsp=DDV_GetSelectedRegions(ssp,bsp_eID,bsp_iID);
1158 }
1159 BioseqUnlock(bsp);
1160 }
1161 }
1162 }
1163 /*...col. by col.*/
1164 for(vnp=dmp->MSA_d.pgp_l.TableHead[i];vnp!=NULL;vnp=vnp->next){
1165 if (!(pgp=(ParaGPtr)(vnp->data.ptrvalue))) continue;
1166 if ((pgp->StartLetter>=from_col && pgp->StartLetter<=to_col)||
1167 (pgp->StopLetter>=from_col && pgp->StopLetter<=to_col)||
1168 (pgp->StartLetter<=from_col && pgp->StopLetter>=to_col)){
1169
1170 from_pgp=pgp->StartLetter;
1171 to_pgp=pgp->StopLetter;
1172
1173 length_pgp=to_pgp-from_pgp+1;/*+1 to surround the last letter*/
1174 rc_pgp.top=(Int2)(pgp->StartLine*dmp->GrData.udv_font.LineHeight-
1175 top_offset+rcP.top);
1176 rc_pgp.bottom=(Int2)(rc_pgp.top+pgp->nLines*
1177 dmp->GrData.udv_font.LineHeight);
1178 rc_pgp.left=(Int2)(from_pgp*dmp->GrData.udv_font.ColWidth-
1179 left_offset+rcP.left);
1180 rc_pgp.right=(Int2)(rc_pgp.left+length_pgp*
1181 dmp->GrData.udv_font.ColWidth);
1182 /*highlight a goto position ?*/
1183 if (dmp->dtd.row==i+1 && dmp->dtd.col!=0){
1184 dmp->GrData.GotoLetter=dmp->dtd.col-1;
1185 }
1186 else{
1187 dmp->GrData.GotoLetter=(Int4)-1;
1188 }
1189 DDV_DrawParaG(&rc_pgp,pgp,from_col,to_col,&dmp->GrData,
1190 dmp->Globals.colorp,&(dmp->ddo),vnp_bsp,i,bSelect);
1191 }
1192 else{
1193 nColsDraw+=(pgp->StopLetter-pgp->StartLetter);
1194 }
1195 if(nColsDraw>to_col)break;
1196 }
1197 nLinesDraw+=pgp->nLines;
1198 if (nLinesDraw>nTotRow) break;
1199 }
1200 /*display the caret; edit mode only*/
1201 if (dmp->MouseMode==DDV_MOUSEMODE_EDIT){
1202 x=(Int2)(dmp->dci.new_col*dmp->GrData.udv_font.ColWidth-
1203 left_offset+rcP.left);
1204 y=(Int2)(dmp->dci.new_row*dmp->GrData.udv_font.LineHeight-
1205 top_offset+rcP.top)-1;
1206 Red();
1207 MoveTo(x+dmp->GrData.udv_font.ColWidth,y);
1208 LineTo(x+dmp->GrData.udv_font.ColWidth,
1209 y-dmp->GrData.udv_font.LineHeight/2);
1210 MoveTo(x+dmp->GrData.udv_font.ColWidth-1,y);
1211 LineTo(x+dmp->GrData.udv_font.ColWidth-1,
1212 y-dmp->GrData.udv_font.LineHeight/2);
1213 MoveTo(x+dmp->GrData.udv_font.ColWidth/2,y+1);
1214 LineTo(x+3*dmp->GrData.udv_font.ColWidth/2,y+1);
1215 MoveTo(x+dmp->GrData.udv_font.ColWidth/2,y+2);
1216 LineTo(x+3*dmp->GrData.udv_font.ColWidth/2,y+2);
1217 Black();
1218 }
1219 ResetClip();
1220
1221 if (dmp->bEditor) {
1222 /* this is for allowing edits of the alignment boundaries */
1223 DDV_DrawAlignmentBoundaries(p, dmp);
1224 }
1225
1226 return;
1227 }
1228
1229 static void DDV_DrawAlignmentBoundaries(PaneL p, DdvMainPtr dmp) {
1230 /*******************************************************************************
1231 draw vertical bars at the top of the panel showing the alignment
1232 boundaries, and horizontal lines connecting them.
1233 *******************************************************************************/
1234 Int4 LeftHPos, RightHPos;
1235 Int4 TopVPos, BotVPos;
1236 Int4 i, NumBlocks;
1237 RecT rcP, rcBanner;
1238 DdvMainWinPtr mWin_d;
1239
1240 ObjectRect(p, &rcP);
1241 DDV_GetVPixelPosOfEmptySpace(dmp, rcP, &TopVPos, &BotVPos);
1242 rcBanner = rcP;
1243 rcBanner.left += dmp->GrData.udv_panel.cxName + dmp->GrData.udv_scale.cxLeftScale;
1244 rcBanner.top = TopVPos;
1245 rcBanner.bottom = BotVPos;
1246 rcBanner.left -= 4;
1247 ClipRect(&rcBanner);
1248 EraseRect(&rcBanner);
1249
1250 /* for each aligned block, draw a semi-rectangle on top of it */
1251 NumBlocks = DDE_GetNumBlocks(dmp->dsp->pEdit);
1252 for (i=0; i<NumBlocks; i++) {
1253 LeftHPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, DDE_GetAlignStart(dmp->dsp->pEdit, i));
1254 LeftHPos -= dmp->GrData.udv_font.ColWidth;
1255 RightHPos = DDV_GetHPixelPosGivenColNumber(dmp, rcP, DDE_GetAlignStop(dmp->dsp->pEdit, i));
1256 UDV_draw_vertical_bar(rcBanner, LeftHPos, FALSE);
1257 UDV_draw_vertical_bar(rcBanner, RightHPos, FALSE);
1258 UDV_draw_horizontal_bar(TopVPos, LeftHPos, RightHPos);
1259 }
1260
1261 ResetClip();
1262
1263 /* grey out either "create block" or "delete block" option */
1264 if (dmp->hParent){
1265 mWin_d = (DdvMainWinPtr) GetObjectExtra(dmp->hParent);
1266 if (NumBlocks == 0) {
1267 Disable(mWin_d->MainMenu.DeleteBlock);
1268 Enable(mWin_d->MainMenu.CreateBlock);
1269 }
1270 else {
1271 Enable(mWin_d->MainMenu.DeleteBlock);
1272 Disable(mWin_d->MainMenu.CreateBlock);
1273 }
1274 }
1275
1276 }
1277
1278
1279 extern void DDV_GreyOut(DdvMainWinPtr mWin_d, Boolean Start, Boolean End) {
1280 /*******************************************************************************
1281 grey out "undo" if Start is TRUE.
1282 grey out "redo" if End is TRUE.
1283 *******************************************************************************/
1284 if (Start) { Disable(mWin_d->MainMenu.Prev); }
1285 else { Enable(mWin_d->MainMenu.Prev); }
1286 if (End) { Disable(mWin_d->MainMenu.Next); }
1287 else { Enable(mWin_d->MainMenu.Next); }
1288 }
1289
1290
1291 /*******************************************************************************
1292
1293 Function : DDV_DrawPanelContent_V()
1294
1295 Purpose : draw the panel of DDV viewer (case 2: full vert display)
1296
1297 Parameters : p;handle of the panel
1298 dmp; main data block
1299
1300 Return value : none
1301
1302 *******************************************************************************/
1303 static void DDV_DrawPanelContent_V (PaneL p,DdvMainPtr dmp)
1304 {/*not yet implemented*/
1305 return;
1306 }
1307
1308 /*******************************************************************************
1309
1310 Function : DDV_DrawPanelContent()
1311
1312 Purpose : draw the panel of DDV viewer
1313
1314 Parameters : p;handle of the panel
1315 dmp; main data block
1316
1317 Return value : none
1318
1319 *******************************************************************************/
1320 extern void DDV_DrawPanelContent (PaneL p,DdvMainPtr dmp)
1321 {
1322 if (dmp->MSA_d.pgp_l.DisplayType==DDV_DISP_HORZ)
1323 DDV_DrawPanelContent_H (p,dmp,&updateRect,TRUE);
1324 else
1325 DDV_DrawPanelContent_V (p,dmp);
1326 return;
1327 }
1328
1329 /*******************************************************************************
1330
1331 Function : DDV_DrawViewer()
1332
1333 Purpose : callback for the viewer panel
1334
1335 Parameters : handle of the panel
1336
1337 Return value : none
1338
1339 *******************************************************************************/
1340 extern void DDV_DrawViewer (PaneL p)
1341 {
1342
1343 DdvMainPtr dmp;
1344
1345 /*get the application data*/
1346 dmp = (DdvMainPtr) GetObjectExtra(p);
1347 if (dmp==NULL) return;
1348
1349 if (dmp->MSA_d.pgp_l.DisplayType==DDV_DISP_HORZ)
1350 DDV_DrawPanelContent_H (p,dmp,&updateRect,TRUE);
1351 else
1352 DDV_DrawPanelContent_V (p,dmp);
1353 }
1354 |
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |