~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina5/tina-tools/tinatool/wdgts/xm/wdgtsXm_tw_textsw.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**********
  2  * 
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  * 
 35  * Program :    TINA
 36  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/wdgts/xm/wdgtsXm_tw_textsw.c,v $
 37  * Date    :  $Date: 2007/02/15 01:55:50 $
 38  * Version :  $Revision: 1.3 $
 39  * CVS Id  :  $Id: wdgtsXm_tw_textsw.c,v 1.3 2007/02/15 01:55:50 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes : Tina windows text subwindow:
 44  *         Only one - belongs to parent tool (a bit like highlander!).
 45  *
 46  *********
 47 */
 48 
 49 #include "wdgtsXm_tw_textsw.h"
 50 
 51 #if HAVE_CONFIG_H
 52 #   include <config.h>
 53 #endif
 54 
 55 #include <stdio.h>
 56 #include <math.h>
 57 #include <string.h>
 58 
 59 #include <Xm/RowColumn.h>
 60 #include <Xm/Text.h>
 61 #include <tina/sys/sysDef.h>
 62 #include <tina/sys/sysPro.h>
 63 #include <tinatool/wdgts/xm/wdgts_XmDef.h>
 64 #include <tinatool/wdgts/xm/wdgtsXm_tw_tool.h>
 65 
 66 static Widget text;
 67 
 68 void    tw_text_add(Widget text, char *string)
 69 {
 70     XmTextPosition end;
 71 
 72     end = XmTextGetLastPosition(text);
 73     XmTextReplace(text, end, end, string);
 74 }
 75 
 76 void    tw_text_set(Widget text, char *string)
 77 {
 78     XmTextPosition end;
 79 
 80     XmTextSetString(text, string);
 81 }
 82 void tw_textsw_clear(void* text_subwin)
 83 {
 84   tw_text_set(text_subwin,"");
 85 }
 86 
 87 void    textsw_print(char *string)
 88 {
 89     tw_text_add(text, string);
 90 }
 91 
 92 void    textsw_print_sw(void* text_subwin, char *string)
 93 {
 94     tw_text_add(text_subwin, string);
 95 }
 96 void    tw_textsw_print(void* text_subwin, char *string)
 97 {
 98     tw_text_add(text_subwin, string);
 99 }
100 
101 /* Create Text subwindow (but don't redirect format's (etc) output to it) */
102 Widget  tw_textsubwin(int rows, int cols)
103 {
104     Widget  textsw;
105     Widget  textsubwin;
106     Widget  form, tw_get_form(void);
107     Widget  panel, tw_get_panel(void);
108     int     nargs;
109     Arg     wargs[12];
110 
111     panel = (Widget) tw_get_panel();
112     form = (Widget) tw_get_form();
113 
114     if(!form) errorf(non_fatal,"Aaaaargh NO FORM in tw_textsubwin\n");
115     nargs = 0;
116     XtSetArg(wargs[nargs], XmNscrollVertical, TRUE);
117     nargs++;
118     XtSetArg(wargs[nargs], XmNscrollLeftSide, FALSE);
119     nargs++;
120     XtSetArg(wargs[nargs], XmNscrollHorizontal, FALSE);
121     nargs++;
122     XtSetArg(wargs[nargs], XmNwordWrap, TRUE);
123     nargs++;
124     XtSetArg(wargs[nargs], XmNcolumns, cols);
125     nargs++;
126     XtSetArg(wargs[nargs], XmNrows, rows);
127     nargs++;
128     XtSetArg(wargs[nargs], XmNeditMode, XmMULTI_LINE_EDIT);
129     nargs++;
130     XtSetArg(wargs[nargs], XmNscrollingPolicy, XmAUTOMATIC);
131     nargs++;
132 
133     textsubwin = XmCreateScrolledText(form, "twtextsw", wargs, nargs);
134     XtManageChild(textsubwin);
135     textsw = XtParent(textsubwin);
136 
137     nargs = 0;
138     XtSetArg(wargs[nargs], XmNtopAttachment, XmATTACH_WIDGET);
139     nargs++;
140     XtSetArg(wargs[nargs], XmNtopWidget, panel);
141     nargs++;
142     XtSetArg(wargs[nargs], XmNleftAttachment, XmATTACH_FORM);
143     nargs++;
144     XtSetArg(wargs[nargs], XmNrightAttachment, XmATTACH_FORM);
145     nargs++;
146     XtSetValues(textsw, wargs, nargs);
147 
148     tw_inc_totwidth(tw_charwidth((double) cols));
149     tw_inc_totheight(tw_charheight((double) rows));
150 
151     tw_set_panel(textsw);
152     return (textsubwin);
153 }
154 
155 /* Create Text subwindow AND redirect format's (etc) output to it */
156 Widget  tw_textsw(int rows, int cols)
157 {
158     text =  tw_textsubwin(rows, cols);
159 
160     message_set_print(textsw_print);
161     error_set_print(textsw_print);
162     format_set_print(textsw_print);
163 
164     return (text);
165 }
166 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.