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 "togglelistdialog.h"
28
ToggleListDialog::ToggleListDialog(Widget w, bool b): PromptDialog(w) {
36
ToggleListDialog::~ToggleListDialog() {
41
void ToggleListDialog::CreateWidget() {
42
Arg args[9]; int i = 0;
43
XtSetArg(args[i], XmNautoUnmanage, GetAutoUnmanage()); i++;
44
SetWidget(XmCreatePromptDialog(GetParent(), (char *)GetClassName(), args, i));
47
void ToggleListDialog::Configure() {
48
PromptDialog::Configure();
49
ManageHelpButton(False);
51
ManageSelectionLabel(False);
52
ManageTextString(False);
56
void ToggleListDialog::SetToggleChangedCallback(XtCallbackProc fun,
60
for (unsigned i=0; i<numToggles; i++)
61
XtAddCallback(toggleList[i], XmNvalueChangedCallback,
62
toggleFun, clientData);
65
void ToggleListDialog::CreateToggles(const string *label,
66
List<string *> *items) {
67
char wname[12] = "toggle_box";
68
Widget toggleBox = XmCreateRadioBox(GetWidget(), wname, 0, 0);
71
toggleList = new Widget[items->count()];
73
Widget frame = XtVaCreateManagedWidget("frame",
74
xmFrameWidgetClass, toggleBox, 0);
75
XtVaCreateManagedWidget(label->getstr(),
76
xmLabelWidgetClass, frame,
77
XmNchildType, XmFRAME_TITLE_CHILD, 0);
79
for (items->first(); !items->done(); items->next()) {
80
const char *s = items->cur()->getstr();
81
XmString btn = CreateXmString(s);
82
Widget w = XtVaCreateManagedWidget(s,
83
xmToggleButtonWidgetClass, toggleBox,
85
XmNhighlightThickness, 0,
87
toggleList[numToggles] = w;
91
XtAddCallback(w, XmNvalueChangedCallback, toggleFun,
95
XtManageChild(toggleBox);
98
void ToggleListDialog::CreateToggles(List<string *> *items) {
100
CreateToggles(&empty, items);
103
void ToggleListDialog::SetToggleBitmap(unsigned i, Bitmap *bitmap) {
104
if (check(i < numToggles)) {
105
Widget tb = toggleList[i];
106
Pixmap pixmap = bitmap->CreatePixmap(tb, GetDisplay());
108
XmNlabelType, XmPIXMAP,
109
XmNlabelPixmap, pixmap, 0);
113
void ToggleListDialog::SetToggleText(unsigned i, const string *txt) {
114
if (check(i < numToggles)) {
115
XmString s = CreateXmString(txt->getstr());
116
XtVaSetValues(toggleList[i], XmNlabelString, s, 0);
121
void ToggleListDialog::GetToggleText(unsigned i, string *txt) {
122
if (check(i < numToggles)) {
123
XmString s = CreateXmString("");
124
XtVaGetValues(toggleList[i], XmNlabelString, &s, 0);
126
if (XmStringGetLtoR(s, XmFONTLIST_DEFAULT_TAG, &str)) {
134
unsigned ToggleListDialog::NumToggles() {
138
void ToggleListDialog::SetValue(unsigned n) {
139
if (check(n < numToggles))
140
XmToggleButtonSetState(toggleList[n], True, True);
143
int ToggleListDialog::GetValue() {
144
for (unsigned i=0; i<numToggles; i++) {
145
if (XmToggleButtonGetState(toggleList[i]))