This is display_def.c in view mode; [Download] [Up]
/* -*-C-*- ******************************************************************************** * * File: display_def.c * RCS: $Header: /home/everest1/cattelan/work/xwebster.motif/RCS/display_def.c,v 1.1 1992/03/21 22:39:43 cattelan Exp $ * Description: Module for clearing, appending to and displaying a definition. * Author: Niels Mayer, HPLabs * Created: Wed Aug 31 19:17:42 1988 * Modified: Mon Mar 6 17:16:58 1989 (Niels Mayer) mayer@hplnpm * Language: C * Package: N/A * Status: G-Job * * xwebster - dictionary browser * * Copyright 1988 Hewlett-Packard Company * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of HP not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. HP makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * Please send any improvements, bug fixes, useful modifications, and comments * to mayer@hplabs.hp.com. ******************************************************************************** */ static char rcs_identity[] = "@(#)$Header: /home/everest1/cattelan/work/xwebster.motif/RCS/display_def.c,v 1.1 1992/03/21 22:39:43 cattelan Exp $"; #include "xwebster.h" #include "user_prefs.h" #include <Xm/ScrolledW.h> #include <Xm/Text.h> static Widget display_Wgt = NULL; static char text[16384]; /* hopefully no def will be longer than this! */ static int end_idx = 0; /****************************************************************************** * KLUDGE_O_RAMA: on select, invert the text in the StaticText widget to show * that something's being done and store the definition in the cut buffer. ******************************************************************************/ static XtCallbackProc Display_Select_Callback(widget, client_data, call_data) Widget widget; caddr_t client_data; caddr_t call_data; { Pixel foreground; Pixel background; char* displ_text; XtVaGetValues(widget, XmNforeground, &foreground, XmNbackground, &background, NULL); XtVaSetValues(widget, XmNforeground, background, XmNbackground, foreground, NULL); XtVaGetValues(display_Wgt, XmNstring, &displ_text, NULL); XStoreBuffer(XtDisplay(widget), displ_text, strlen(displ_text), 0); } /****************************************************************************** * KLUDGE_O_RAMA: on release, uninvert the text in the StaticText widget. ******************************************************************************/ static XtCallbackProc Display_Release_Callback(widget, client_data, call_data) Widget widget; caddr_t client_data; caddr_t call_data; { Pixel foreground; Pixel background; /* * Uninvert the display that was inverted in Display_Select_Callback */ XtVaGetValues(widget, XmNforeground, &foreground, XmNbackground, &background, NULL); XtVaSetValues(widget, XmNforeground, background, XmNbackground, foreground, NULL); } /****************************************************************************** * ******************************************************************************/ void Display_Def_Init(w) Widget w; { Widget display_scroller_Wgt = XtVaCreateManagedWidget("display_scroller", xmScrolledWindowWidgetClass, w, XmNscrollingPolicy, XmAPPLICATION_DEFINED, XmNscrollHorizontal, False, XmNwordWrap, True, NULL); display_Wgt = XtVaCreateManagedWidget("display", xmTextWidgetClass, display_scroller_Wgt, XmNeditMode, XmMULTI_LINE_EDIT, XmNeditable, FALSE, NULL); XtAddCallback(display_Wgt, XmNactivateCallback, (XtCallbackProc) Display_Select_Callback, NULL); /* XtAddCallback(display_Wgt, XmNrelease, Display_Release_Callback, NULL); */ /* XtAddCallback(display_Wgt, XmNactivateCallback, Display_Release_Callback, NULL);*/ } /****************************************************************************** * ******************************************************************************/ Display_Def_Text_Reset() { /* Set it to null to clear the current text */ XmTextSetString(display_Wgt,NULL); } /****************************************************************************** * ******************************************************************************/ Display_Def_Text_Append(intext) char* intext; { /* Insert seems to work better for mutiple lines, there may be a better way although */ XmTextInsert(display_Wgt, XmTextGetLastPosition(display_Wgt),intext); } /****************************************************************************** * ******************************************************************************/ Display_Def_Refresh() { /* *This function could probably be removed but I don't want to *Bother with it right now, not that important */ XmTextSetInsertionPosition(display_Wgt, 0); } /****************************************************************************** * ******************************************************************************/ Display_Def_Show_Help() { Display_Def_Text_Reset(); Display_Def_Text_Append(user_prefs.help_text); Display_Def_Refresh(); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.