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

Linux Cross Reference
Tina5/tina-tools/tinatool/wdgts/gtk/wdgtsGtk_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/gtk/wdgtsGtk_tw_textsw.c,v $
 37  * Date    :  $Date: 2007/02/15 01:55:50 $
 38  * Version :  $Revision: 1.3 $
 39  * CVS Id  :  $Id: wdgtsGtk_tw_textsw.c,v 1.3 2007/02/15 01:55:50 paul Exp $
 40  *
 41  * Author  :  a.lacey@man.ac.uk, giob@man.ac.uk
 42  *
 43  *********
 44 */
 45 /** 
 46  *  @file  wdgtsGtk_tw_textsw.c
 47  *  @brief Define and create GTK text window and its writing functions.
 48  *
 49  *  Height adjustment is not provided if the window is resized.
 50  *  (Will do this only if there is time - GAB 13 Nov 2003).
 51  *
 52  *  Note that the functions in this file are duplicated for each widget set 
 53  *  (xv, GTK, xm, etc ...).
 54  */
 55 
 56 #include "wdgtsGtk_tw_textsw.h"
 57 
 58 #if HAVE_CONFIG_H
 59 #   include <config.h>
 60 #endif
 61 
 62 #include <stdio.h>
 63 #include <gtk/gtk.h>
 64 #include <tinatool/wdgts/gtk/wdgts_GtkDef.h>
 65 #include <tinatool/wdgts/gtk2/wdgtsGtk_tw_tool.h>
 66 
 67 static  GtkWidget  *textsw;
 68 
 69 
 70 /**
 71  * @brief  Write string to main text window.  
 72  * @param  string   String to display.
 73  * 
 74  * Text is black on current background and all chars inserted. 
 75  */
 76 void textsw_print(char *string)
 77 {
 78   gtk_text_insert(GTK_TEXT(textsw), 
 79                   NULL,
 80                   &textsw->style->black, NULL,
 81                   string, -1);
 82 }
 83 
 84 /**
 85  * @brief  Print to the specified text subwindow.  
 86  * @param  text_subwin  Void pointer to text subwindow.
 87  * @param  string       String to print.
 88  */
 89 void textsw_print_sw(void *text_subwin, char *string)
 90 {
 91   gtk_text_insert(GTK_TEXT(text_subwin), 
 92                   NULL,
 93                   &textsw->style->black, NULL,
 94                   string, -1);
 95 }
 96 
 97 /**
 98  * @brief  Print to the specified text subwindow.  
 99  * @param  text_subwin  Void pointer to text subwindow.
100  * @param  string       String to print.
101  *
102  * Only a wrapper for textsw_print_sw().
103  */
104 void tw_textsw_print(void *text_subwin, char *string)
105 {
106   textsw_print_sw(text_subwin, string);
107 }
108 
109 /**
110  * @brief  Create main text window.  
111  * @param  rows  Integer number of rows in window.
112  * @param  cols  Integer number of cols in window.
113  *
114  * Note that the text subwindow is packed in the main window vbox, not
115  * the current panel (hbox) as this would prevent vertical resizing.
116  * Moreover, the subwin is packed at the end of the vbox as it is more
117  * aesthetic to have the resizeable subwindow at the bottom.
118  */
119 GtkWidget *tw_textsubwin(int rows, int cols)
120 {
121   GtkWidget  *panel = tw_get_vbox();
122   GtkWidget  *text;
123   GtkWidget  *box2, *table;
124   GtkWidget  *vscrollbar;
125 
126   box2 = gtk_vbox_new (FALSE, 0);
127   gtk_box_pack_start (GTK_BOX (panel), box2, TRUE, TRUE, 0);
128   gtk_widget_show (box2);
129   
130   table = gtk_table_new (2, 2, FALSE);
131   gtk_table_set_row_spacing (GTK_TABLE (table), 0, 0);
132   gtk_table_set_col_spacing (GTK_TABLE (table), 0, 0);
133   gtk_box_pack_end (GTK_BOX (box2), table, TRUE, TRUE, 0);
134   gtk_widget_show (table);
135   
136   /* Create the GtkText widget */
137   text = gtk_text_new (NULL, NULL);
138   gtk_widget_set_usize(text, (cols * 4), (rows * 20));
139   gtk_text_set_editable (GTK_TEXT (text), FALSE);
140   gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1,
141                     GTK_EXPAND | GTK_SHRINK | GTK_FILL,
142                     GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
143   gtk_widget_show (text);
144 
145   /* Add a vertical scrollbar to the GtkText widget */
146   vscrollbar = gtk_vscrollbar_new (GTK_TEXT (text)->vadj);
147   gtk_table_attach (GTK_TABLE (table), vscrollbar, 1, 2, 0, 1,
148                     GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
149   gtk_widget_show (vscrollbar);
150 
151   gtk_widget_realize(text);
152         
153   return (text);
154 }
155 
156 
157 /**
158  * @brief  Create main text window AND redirect all Tina output to it.  
159  * @param  rows  Integer number of rows in window.
160  * @param  cols  Integer number of cols in window.
161  */
162 GtkWidget *tw_textsw(int rows, int cols)
163 {
164   textsw = tw_textsubwin(rows, cols);
165 
166   message_set_print(textsw_print); 
167   error_set_print(textsw_print);
168   format_set_print(textsw_print); 
169 
170   return(textsw);
171 }
172 
173 /**
174  * @brief  Clear the main text window.  
175  * @param  sw   Void pointer to a text window.
176  *
177  * Not used - consider removing - GAB 13 Nov 2003.
178  * Not tested either ...
179  */
180 void tw_textsw_clear(void *sw)
181 {
182   gtk_editable_delete_text (GTK_TEXT(sw), 0, -1);
183 }
184 

~ [ 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.