1
////////////////////////////////////////////////////////////////////////////////
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
4
// (c) copyright 1997, Vrije Universiteit Amsterdam.
5
// Author: Frank Dehne (frank@cs.vu.nl).
7
// TCM is free software; you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License as published by
9
// the Free Software Foundation; either version 2 of the License, or
10
// (at your option) any later version.
12
// TCM is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
17
// You should have received a copy of the GNU General Public License
18
// along with TCM; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21
////////////////////////////////////////////////////////////////////////////////
22
#include "replacedialog.h"
26
ReplaceDialog::ReplaceDialog(Widget w): FindDialog(w) {
29
void ReplaceDialog::CreateWidget() {
30
Arg args[9]; int i = 0;
31
XtSetArg(args[i], XmNautoUnmanage, GetAutoUnmanage()); i++;
32
SetWidget(XmCreatePromptDialog(GetParent(), (char *)GetClassName(), args, i));
35
void ReplaceDialog::Configure() {
36
FindDialog::Configure();
37
SetOKButtonLabel("Find\nNext");
38
SetApplyButtonLabel("Replace\nAll");
39
replaceButton = XtVaCreateManagedWidget("Replace",
40
xmPushButtonWidgetClass, GetWidget(), 0);
41
XmString t = CreateXmString("Replace\nNext");
42
XtVaSetValues(replaceButton, XmNlabelString, t, 0);
43
SetHelpCallback(ReplaceClearCB, this);
44
replaceLabel = XtVaCreateManagedWidget("Replace with",
45
xmLabelWidgetClass, GetForm(),
46
XmNleftAttachment, XmATTACH_FORM,
47
XmNtopAttachment, XmATTACH_WIDGET,
48
XmNtopWidget, GetText(), 0);
49
replaceText = XtVaCreateManagedWidget("replace_text",
50
xmTextFieldWidgetClass, GetForm(),
51
XmNleftAttachment, XmATTACH_FORM,
52
XmNrightAttachment, XmATTACH_FORM,
53
XmNtopAttachment, XmATTACH_WIDGET,
54
XmNtopWidget, replaceLabel, 0);
55
XtVaSetValues(GetToggleRC(),
56
XmNtopAttachment, XmATTACH_WIDGET,
57
XmNtopWidget, replaceText, 0);
61
void ReplaceDialog::AttachToggles() {}
63
void ReplaceDialog::SetReplaceText(const string *v) {
64
SetReplaceText(v->getstr());
67
void ReplaceDialog::SetReplaceText(const char *v) {
68
if (!check(replaceText))
70
XmTextSetString(replaceText, (char *)v);
73
void ReplaceDialog::GetReplaceText(char *n) {
74
if (!check(replaceText))
76
char *s = XmTextGetString(replaceText);
81
void ReplaceDialog::GetReplaceText(string *n) {
87
void ReplaceDialog::SetReplaceCallback(XtCallbackProc fun,
88
XtPointer clientData) {
89
if (!check(replaceButton))
91
XtAddCallback(replaceButton, XmNactivateCallback, fun, clientData);
94
void ReplaceDialog::ReplaceClearCB(Widget, XtPointer clientData, XtPointer) {
95
ReplaceDialog *d = (ReplaceDialog *)clientData;
97
d->SetReplaceText("");