Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtmail / dtmail / AntiCheckBoxUiItem.C
1 /* $TOG: AntiCheckBoxUiItem.C /main/4 1997/04/29 15:57:39 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/AntiCheckBoxUiItem.hh>
23
24 // AntiCheckBoxUiItem::AntiCheckBoxUiItem
25 // AntiCheckBoxUiItem ctor
26 ////////////////////////////////////////////////////////////////////
27
28 AntiCheckBoxUiItem::AntiCheckBoxUiItem(
29                                        Widget w, 
30                                        int source, 
31                                        char *search_key
32                                        ):CheckBoxUiItem(w, source, search_key)
33 {
34   ;
35 }
36
37 // AntiCheckBoxUiItem::writeFromUiToSource()
38 // Takes values in the UI and puts them into the source DB
39 ///////////////////////////////////////////////////////////////////
40 void AntiCheckBoxUiItem::writeFromUiToSource()
41 {
42   Boolean       checkbox_value;
43   Widget w = this->getWidget();
44   PropSource    *p_s = this->getPropSource();
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       p_s->setValue("f");
51     }   
52   else
53     {
54       p_s->setValue("");
55     }
56 }
57
58 // AntiCheckBoxUiItem::writeFromSourceToUi()
59 // Takes values in the UI and puts them into the source DB
60 ///////////////////////////////////////////////////////////////////
61 void AntiCheckBoxUiItem::writeFromSourceToUi()
62 {
63   char *value = NULL;
64   Widget w = this->getWidget();
65
66   PropSource    *p_s = this->getPropSource();
67
68   value = (char *)p_s->getValue();
69
70   // 
71   // this will have to be made more robust... 
72   //
73   // This assumes that a non-null value means that the 
74   // value is set and that a non-null means turn on the CB
75   if (strcmp(value, "f") == 0)
76     options_checkbox_set_value(w, TRUE, this->dirty_bit);
77   else if (value == NULL || strcmp(value, "") == 0)
78     options_checkbox_set_value(w, FALSE, this->dirty_bit);
79   
80   if (NULL != NULL)
81     free((void*) value);
82 }
83
84
85