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 "selectiondialog.h"
26
SelectionDialog::SelectionDialog(Widget w): Dialog(w) {
28
text = list = selectionLabel = 0;
31
void SelectionDialog::CreateWidget() {
32
Arg args[9]; int i = 0;
33
XtSetArg(args[i], XmNautoUnmanage, GetAutoUnmanage()); i++;
34
SetWidget(XmCreateSelectionDialog(GetParent(), (char *)GetClassName(), args, i));
37
void SelectionDialog::Configure() {
38
text = XmSelectionBoxGetChild(GetWidget(), XmDIALOG_TEXT);
39
list = XmSelectionBoxGetChild(GetWidget(), XmDIALOG_LIST);
40
selectionLabel = XmSelectionBoxGetChild(GetWidget(),
41
XmDIALOG_SELECTION_LABEL);
44
void SelectionDialog::SetTextString(const char *v) {
47
XmTextSetString(text, (char *)v);
50
void SelectionDialog::SetTextString(const string *v) {
51
SetTextString(v->getstr());
54
void SelectionDialog::GetTextString(char *n) {
57
char *s = XmTextGetString(text);
62
void SelectionDialog::GetTextString(string *n) {
68
void SelectionDialog::ManageTextString(bool b) {
72
XtUnmanageChild(text);
75
void SelectionDialog::SetSelectionLabel(const char *v) {
76
if (!check(GetWidget()))
78
XmString t = CreateXmString(v);
79
XtVaSetValues(GetWidget(), XmNselectionLabelString, t, 0);
83
void SelectionDialog::ManageSelectionLabel(bool b) {
85
XtManageChild(selectionLabel);
87
XtUnmanageChild(selectionLabel);
90
void SelectionDialog::SetDefaultValue(const char *s) {
94
void SelectionDialog::SetDefaultValue(const string *s) {
95
SetDefaultValue(s->getstr());
98
void SelectionDialog::SetApplyCallback(XtCallbackProc fun,
99
XtPointer clientData) {
100
if (!check(GetWidget()))
102
XtAddCallback(GetWidget(), XmNapplyCallback, fun, clientData);
105
void SelectionDialog::SetApplyButtonLabel(const char *txt) {
106
if (!check(GetWidget()))
108
XmString t = CreateXmString(txt);
109
XtVaSetValues(GetWidget(), XmNapplyLabelString, t, 0);
113
void SelectionDialog::ManageApplyButton(bool b) {
114
Widget button = XmSelectionBoxGetChild(GetWidget(),
115
XmDIALOG_APPLY_BUTTON);
116
ManageWidget(button, b);
119
void SelectionDialog::ClearCB(Widget, XtPointer cd, XtPointer) {
120
SelectionDialog *s = (SelectionDialog *)cd;
121
s->SetTextString("");
124
void SelectionDialog::SetDefaultCB(Widget, XtPointer cd, XtPointer) {
125
SelectionDialog *s = (SelectionDialog *)cd;
126
s->SetTextString(s->GetDefaultValue());
129
void SelectionDialog::DeselectAllItems() {
130
XmListDeselectAllItems(list);
133
void SelectionDialog::DeleteAllItems() {
134
XmListDeleteAllItems(list);
137
void SelectionDialog::SelectItem(const string *s) {
138
XmString xs = CreateXmString(s->getstr());
139
XmListSelectItem(GetList(), xs, False);
143
void SelectionDialog::AddItem(const char *s, int pos) {
144
XmString xs = CreateXmString(s);
145
XmListAddItem(GetList(), xs, pos);
149
void SelectionDialog::AddItem(const string *s, int pos) {
150
AddItem(s->getstr(), pos);
153
void SelectionDialog::SetEditable(bool b) {
154
XmTextFieldSetEditable(GetText(), b);