Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtmail / dtmail / CheckBoxUiItem.C
1 /* $TOG: CheckBoxUiItem.C /main/5 1997/04/29 15:58:33 mgreess $ */
2 /*
3  *+SNOTICE
4  *
5  *      RESTRICTED CONFIDENTIAL INFORMATION:
6  *      
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
13  *      Sun's request.
14  *
15  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
16  *
17  *+ENOTICE
18  */
19
20 #include <DtMail/options_util.h>
21 #include <DtMail/PropUi.hh>
22 #include <DtMail/CheckBoxUiItem.hh>
23
24 // CheckBoxUiItem::CheckBoxUiItem
25 // CheckBoxUiItem ctor
26 ////////////////////////////////////////////////////////////////////
27
28 CheckBoxUiItem::CheckBoxUiItem(Widget w, int source, char *search_key):PropUiItem(w, source, search_key)
29 {
30 #ifdef DEAD_WOOD
31   data_source = source;
32 #endif /* DEAD_WOOD */
33
34   options_checkbox_init(w, &(this->dirty_bit));
35
36 }
37
38 // CheckBoxUiItem::writeFromUiToSource()
39 // Takes values in the UI and puts them into the source DB
40 ///////////////////////////////////////////////////////////////////
41 void CheckBoxUiItem::writeFromUiToSource()
42 {
43   Boolean       checkbox_value;
44   Widget w = this->getWidget();
45
46   checkbox_value = options_checkbox_get_value(w);
47    
48   if(checkbox_value == TRUE) // make sure the value is in the table
49     {
50       prop_source->setValue("");
51     }   
52   else
53     {
54       prop_source->setValue("f");
55     }
56 }
57
58 // CheckBoxUiItem::writeFromSourceToUi()
59 // Takes values in the UI and puts them into the source DB
60 ///////////////////////////////////////////////////////////////////
61 void CheckBoxUiItem::writeFromSourceToUi()
62 {
63   char *value = NULL;
64   Widget w = this->getWidget();
65
66   value = (char *)prop_source->getValue();
67
68   // 
69   // this will have to be made more robust... 
70   //
71   // This assumes that a non-null value means that the 
72   // value is set and that a non-null means turn on the CB
73   if (strcmp(value, "") == 0)
74     options_checkbox_set_value(w, TRUE, this->dirty_bit);
75   else if (NULL == value || strcmp(value, "f") == 0)
76     options_checkbox_set_value(w, FALSE, this->dirty_bit);
77   
78   if (NULL != NULL)
79     free((void*) value);
80 }
81
82
83