/********************************************************************
This file is part of the abs 0.907 distribution. abs is a spreadsheet
with graphical user interface.
Copyright (C) 1998-2001 André Bertin (Andre.Bertin@ping.be)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version if in the same spirit as version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Concact: abs@pi.be
http://home.pi.be/bertin/abs.shtml
*********************************************************************/
#include <stdio.h>
#include "param.h"
#include "workbook.h"
#include "pastedialog.h"
#include "gr_interf.h"
#include "memory.h"
#include "button.h"
#include "callback.h"
static Widget pastepromptShell = NULL;
static Widget pastepromptDialog;
static Widget all, formulaw, value, format;
static Widget none, add, substract, divide, multiply;
static Widget transpose;
static void (*pastepromptfunction) ();
extern Widget gettop ();
void
PasteCancelAction (Widget widget, XtPointer closure, XtPointer call_data)
{
if (pastepromptShell)
{
XtPopdown (pastepromptShell);
}
reactivate_zoom ();
}
void
PasteAcceptAction (Widget widget, XtPointer closure, XtPointer call_data)
{
PasteCancelAction (widget, closure, call_data);
m_paste_special (getradio (all), getradio (formulaw), getradio (value), getradio (format),
getradio (none), getradio (add), getradio (substract), getradio (divide), getradio (multiply),
getcheck (transpose));
}
void
PasteMakePrompt (Widget centerw, char *prompt, void (*func) (), char *def)
{
Arg centerArgs[2];
Arg args[20];
int n;
Position source_x, source_y;
Position dest_x, dest_y;
Dimension center_width, center_height;
Dimension prompt_width, prompt_height;
Widget cancel, ok, box;
desactivate_zoom ();
if (pastepromptShell == NULL)
{
n = 0;
XtSetArg (args[n], XtNinput, True);
n++;
XtSetArg (args[n], XtNwidth, 350);
n++;
XtSetArg (args[n], XtNheight, 200);
n++;
pastepromptShell = XtCreatePopupShell
("pastepromptShell", transientShellWidgetClass, gettop (), args, 3);
n = 0;
XtSetArg (args[n], XtNwidth, 350);
n++;
XtSetArg (args[n], XtNheight, 200);
n++;
pastepromptDialog = XtCreateManagedWidget ("pastepromptDialog", formWidgetClass,
pastepromptShell, args, n);
n = 0;
XtSetArg (args[n], XtNwidth, 350);
n++;
XtSetArg (args[n], XtNheight, 1);
n++;
XtSetArg (args[n], XtNborderWidth, 0);
n++;
box = XtCreateManagedWidget ("pastepromptDialog", formWidgetClass,
pastepromptDialog, args, n);
n = 0;
XtSetArg (args[n], XtNwidth, 1);
n++;
XtSetArg (args[n], XtNheight, 200);
n++;
XtSetArg (args[n], XtNborderWidth, 0);
n++;
box = XtCreateManagedWidget ("pastepromptDialog", formWidgetClass,
pastepromptDialog, args, n);
w_n = 0;
w_dim (85, 20);
w_rel (NULL, 30, 170);
ok = XtCreateManagedWidget
("Paste", commandWidgetClass, pastepromptDialog, w_args, w_n);
XtAddCallback (ok, XtNcallback, PasteAcceptAction, NULL);
w_n = 0;
w_dim (85, 20);
w_rel (NULL, 130, 170);
cancel = XtCreateManagedWidget
("Cancel", commandWidgetClass, pastepromptDialog, w_args, w_n);
XtAddCallback (cancel, XtNcallback, PasteCancelAction, NULL);
CreateLabel (pastepromptDialog, "Paste:", 10, 10, 80, 20);
CreateLabel (pastepromptDialog, "All", 40, 40, 80, 20);
all = (Widget) make_radio (pastepromptDialog, "all", NULL, NULL, NULL);
w_n = 0;
w_rel (NULL, 20, 40);
XtSetValues (all, w_args, w_n);
CreateLabel (pastepromptDialog, "Formula", 40, 65, 80, 20);
formulaw = (Widget) make_radio (pastepromptDialog, "formulaw", all, NULL, NULL);
w_n = 0;
w_rel (NULL, 20, 65);
XtSetValues (formulaw, w_args, w_n);
CreateLabel (pastepromptDialog, "Value", 40, 90, 80, 20);
value = (Widget) make_radio (pastepromptDialog, "value", all, NULL, NULL);
w_n = 0;
w_rel (NULL, 20, 90);
XtSetValues (value, w_args, w_n);
CreateLabel (pastepromptDialog, "Format", 40, 115, 80, 20);
format = (Widget) make_radio (pastepromptDialog, "format", all, NULL, NULL);
w_n = 0;
w_rel (NULL, 20, 115);
XtSetValues (format, w_args, w_n);
CreateLabel (pastepromptDialog, "Operation:", 110, 10, 80, 20);
CreateLabel (pastepromptDialog, "None", 140, 40, 80, 20);
none = (Widget) make_radio (pastepromptDialog, "none", NULL, NULL, NULL);
w_n = 0;
w_rel (NULL, 120, 40);
XtSetValues (none, w_args, w_n);
CreateLabel (pastepromptDialog, "Add", 140, 65, 80, 20);
add = (Widget) make_radio (pastepromptDialog, "add", none, NULL, NULL);
w_n = 0;
w_rel (NULL, 120, 65);
XtSetValues (add, w_args, w_n);
CreateLabel (pastepromptDialog, "Substract", 140, 90, 80, 20);
substract = (Widget) make_radio (pastepromptDialog, "substract", none, NULL, NULL);
w_n = 0;
w_rel (NULL, 120, 90);
XtSetValues (substract, w_args, w_n);
CreateLabel (pastepromptDialog, "Multiply", 140, 115, 80, 20);
multiply = (Widget) make_radio (pastepromptDialog, "multiply", none, NULL, NULL);
w_n = 0;
w_rel (NULL, 120, 115);
XtSetValues (multiply, w_args, w_n);
CreateLabel (pastepromptDialog, "Divide", 140, 140, 80, 20);
divide = (Widget) make_radio (pastepromptDialog, "divide", none, NULL, NULL);
w_n = 0;
w_rel (NULL, 120, 140);
XtSetValues (divide, w_args, w_n);
CreateLabel (pastepromptDialog, "Transpose", 240, 50, 80, 20);
w_n = 0;
w_rel (NULL, 220, 50);
transpose = (Widget) make_check (pastepromptDialog, "transpose", NULL, NULL);
w_set (transpose);
setcheck (transpose, 0);
XtRealizeWidget (pastepromptShell);
}
XtSetArg (centerArgs[0], XtNwidth, ¢er_width);
XtSetArg (centerArgs[1], XtNheight, ¢er_height);
XtGetValues (centerw, centerArgs, 2);
XtSetArg (centerArgs[0], XtNwidth, &prompt_width);
XtSetArg (centerArgs[1], XtNheight, &prompt_height);
XtGetValues (pastepromptShell, centerArgs, 2);
source_x = (int) (center_width - prompt_width) / 2;
source_y = (int) (center_height - prompt_height) / 3;
XtTranslateCoords (centerw, source_x, source_y, &dest_x, &dest_y);
XtSetArg (centerArgs[0], XtNx, dest_x);
XtSetArg (centerArgs[1], XtNy, dest_y);
XtSetValues (pastepromptShell, centerArgs, 2);
XtPopup (pastepromptShell, XtGrabNone);
pastepromptfunction = func;
}
syntax highlighted by Code2HTML, v. 0.9.1