#include "xsm.h"
#include "save.h"
#include "popup.h"
#include "log.h"
#include <X11/Shell.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/AsciiText.h>
Widget logPopup;
Widget logForm;
Widget logText;
Widget logOkButton;
void
DisplayLogXtProc(Widget w, XtPointer client_data, XtPointer callData)
{
static int first_time = 1;
if (client_log_visible)
{
XMapRaised (XtDisplay (topLevel), XtWindow (logPopup));
}
else
{
PopupPopup (mainWindow, logPopup,
False, first_time, 50, 50, "DelLogWinAction()");
client_log_visible = 1;
if (first_time)
first_time = 0;
}
}
static void
logOkXtProc(Widget w, XtPointer client_data, XtPointer callData)
{
XtPopdown (logPopup);
client_log_visible = 0;
}
void
add_log_text(char *str)
{
XawTextPosition pos = XawTextGetInsertionPoint (logText);
XawTextBlock text;
text.firstPos = 0;
text.length = strlen (str);
text.ptr = str;
text.format = XawFmt8Bit;
XawTextReplace (logText, pos, pos, &text);
}
static void
DelLogWinAction(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
XtCallCallbacks (logOkButton, XtNcallback, NULL);
}
void
create_log_popup(void)
{
static XtActionsRec actions[] = {
{"DelLogWinAction", DelLogWinAction}
};
XtAppAddActions (appContext, actions, XtNumber (actions));
logPopup = XtVaCreatePopupShell ("logPopup",
topLevelShellWidgetClass, topLevel,
XtNallowShellResize, True,
NULL);
logForm = XtVaCreateManagedWidget (
"logForm", formWidgetClass, logPopup,
NULL);
logText = XtVaCreateManagedWidget (
"logText", asciiTextWidgetClass, logForm,
XtNfromHoriz, NULL,
XtNfromVert, NULL,
XtNeditType, XawtextAppend,
XtNdisplayCaret, False,
XtNscrollVertical, XawtextScrollAlways,
XtNscrollHorizontal, XawtextScrollWhenNeeded,
XtNresizable, True,
XtNtop, XawChainTop,
XtNbottom, XawChainBottom,
NULL);
logOkButton = XtVaCreateManagedWidget (
"logOkButton", commandWidgetClass, logForm,
XtNfromHoriz, NULL,
XtNfromVert, logText,
XtNtop, XawChainBottom,
XtNbottom, XawChainBottom,
XtNleft, XawChainLeft,
XtNright, XawChainLeft,
NULL);
XtAddCallback (logOkButton, XtNcallback, logOkXtProc, 0);
}