~ubuntu-branches/ubuntu/intrepid/tcm/intrepid

« back to all changes in this revision

Viewing changes to src/ui/replacedialog.c

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2003-07-03 20:08:21 UTC
  • Revision ID: james.westby@ubuntu.com-20030703200821-se4xtqx25e5miczi
Tags: upstream-2.20
ImportĀ upstreamĀ versionĀ 2.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
////////////////////////////////////////////////////////////////////////////////
 
2
//
 
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).
 
6
//
 
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.
 
11
//
 
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.
 
16
//
 
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
 
20
// 02111-1307, USA.
 
21
////////////////////////////////////////////////////////////////////////////////
 
22
#include "replacedialog.h"
 
23
#include "mstring.h"
 
24
#include <Xm/XmAll.h>
 
25
 
 
26
ReplaceDialog::ReplaceDialog(Widget w): FindDialog(w) { 
 
27
}
 
28
 
 
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));
 
33
}
 
34
 
 
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);
 
58
        XmStringFree(t);
 
59
}
 
60
 
 
61
void ReplaceDialog::AttachToggles() {}
 
62
 
 
63
void ReplaceDialog::SetReplaceText(const string *v) {
 
64
        SetReplaceText(v->getstr());
 
65
}
 
66
 
 
67
void ReplaceDialog::SetReplaceText(const char *v) {
 
68
        if (!check(replaceText))
 
69
                return;
 
70
        XmTextSetString(replaceText, (char *)v);
 
71
}
 
72
 
 
73
void ReplaceDialog::GetReplaceText(char *n) {
 
74
        if (!check(replaceText))
 
75
                return;
 
76
        char *s = XmTextGetString(replaceText);
 
77
        strcpy(n, s);
 
78
        XtFree(s);
 
79
}
 
80
 
 
81
void ReplaceDialog::GetReplaceText(string *n) {
 
82
        char tmp[MAXNAME];
 
83
        GetReplaceText(tmp);
 
84
        *n = tmp;
 
85
}
 
86
 
 
87
void ReplaceDialog::SetReplaceCallback(XtCallbackProc fun, 
 
88
                XtPointer clientData) {
 
89
        if (!check(replaceButton))
 
90
                    return;
 
91
        XtAddCallback(replaceButton, XmNactivateCallback, fun, clientData);
 
92
}
 
93
 
 
94
void ReplaceDialog::ReplaceClearCB(Widget, XtPointer clientData, XtPointer) {
 
95
        ReplaceDialog *d = (ReplaceDialog *)clientData;
 
96
        d->SetTextString("");
 
97
        d->SetReplaceText("");
 
98
}