1 /* $TOG: CheckForMailUiItem.C /main/1 1998/02/17 15:19:56 mgreess $ */
5 * RESTRICTED CONFIDENTIAL INFORMATION:
7 * The information in this document is subject to special
8 * restrictions in a confidential disclosure agreement bertween
9 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
10 * document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
11 * Sun's specific written approval. This documment and all copies
12 * and derivative works thereof must be returned or destroyed at
15 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
20 #include <X11/Intrinsic.h>
22 #include <DtMail/options_util.h>
23 #include <DtMail/PropUi.hh>
24 #include <DtMail/CheckForMailUiItem.hh>
25 #include <DtMail/SpinBoxUiItem.hh>
27 int CheckForMailUiItem::_initialized = 0;
28 DtVirtArray<CheckForMailUiItem*> *CheckForMailUiItem::_checkformail_ui = NULL;
30 CheckForMailUiItem::CheckForMailUiItem(Widget w, int source, char *search_key):
31 SpinBoxUiItem(w, source, search_key)
38 _checkformail_ui = new DtVirtArray<CheckForMailUiItem*> (3);
41 options_spinbox_init(w, &(this->dirty_bit));
42 XtVaGetValues(w, XmNtextField, &textfield, NULL);
45 XmNvalueChangedCallback,
46 CheckForMailUiItem::valueChangedCB,
49 _checkformail_ui->append(this);
53 // Takes values in the UI and puts them into the source DB
54 ///////////////////////////////////////////////////////////////////
55 void CheckForMailUiItem::valueChangedCB(Widget w, XtPointer client, XtPointer)
57 CheckForMailUiItem *cui = (CheckForMailUiItem*) client;
58 cui->_valueChanged = TRUE;
62 // Takes values in the UI and puts them into the source DB
63 ///////////////////////////////////////////////////////////////////
64 void CheckForMailUiItem::writeFromUiToSource()
67 Widget w = this->getWidget();
70 if (!_valueChanged) return;
72 spinbox_value = options_spinbox_get_value(w);
73 sprintf(val_str, "%d", spinbox_value);
74 prop_source->setValue(val_str);
76 for (int i = 0; i < _checkformail_ui->length(); i++)
78 CheckForMailUiItem *cui = (*_checkformail_ui)[i];
79 if (cui != this) cui->writeFromSourceToUi();
81 _valueChanged = FALSE;
85 // Takes values in the UI and puts them into the source DB
86 ///////////////////////////////////////////////////////////////////
87 void CheckForMailUiItem::writeFromSourceToUi()
90 Widget w = this->getWidget();
92 value = prop_source->getValue();
93 options_spinbox_set_value(w, atoi(value), this->dirty_bit);
94 _valueChanged = FALSE;
96 if (NULL != value) free((void*) value);