File: vttogdlg.cpp

package info (click to toggle)
v1 1.20-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 6,240 kB
  • ctags: 9,439
  • sloc: cpp: 48,033; ansic: 8,939; makefile: 1,369; sh: 30
file content (304 lines) | stat: -rw-r--r-- 9,593 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
//=======================================================================
// vttogdlg.cxx - Source file for toggleDialog class
//  Copyright (C) 1995,1996  Bruce E. Wampler
//
//  This program is part of the V C++ GUI Framework example programs.
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  (see COPYING) along with this program; if not, write to the Free
//  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=======================================================================

#include "vttogdlg.h"
#include <v/v_defs.h>
#include <v/vapp.h>
#include <v/vnotice.h>

    static CommandObject DefaultCmds[] =
      {
	// A label, then 3 toggle buttons to select toggle frames
	{C_Label,490,0,"Tab Frame Demo",NoList,CA_None,isSens,NoFrame,0,0},

	// This borderless frame makes the toggle buttons tightly spaced
	{C_Frame,400,0,"",NoList,CA_NoSpace | CA_NoBorder,isSens,NoFrame,0,490},
	{C_ToggleButton,401,1,"Tab 1",NoList, CA_None, isSens, 400, 0, 0},
	{C_ToggleButton,402,0,"Tab 2",NoList, CA_None, isSens, 400, 401, 0},
	{C_ToggleButton,403,0,"Tab 3",NoList, CA_None, isSens, 400, 402, 0},

	// A Master frame to give uniform border to toggle frames
	{C_Frame,409,0, "", NoList,CA_None,isSens,400,0,401},

	// Toggle Frame 1 - default off
	{C_ToggleFrame, 410,1,"",NoList, CA_NoBorder,isSens,409,0,0},
	{C_Button, 411, 0, "Button A   ",NoList, CA_None, isSens, 410,0,0},
	{C_Button, 412, 0, "Button B(1)",NoList, CA_None, isSens, 410,0,411},

	// Toggle Frame 2 - default on
	{C_ToggleFrame, 420,0,"",NoList, CA_NoBorder | CA_Hidden,isSens,409,0,0},
	{C_Button, 421, 0, "Button A(2)",NoList, CA_Hidden, isSens, 420,0,0},
	{C_Button, 422, 0, "Button B(2)",NoList, CA_Hidden, isSens, 420,421,0},

	// Toggle Frame 3 - default off
	{C_ToggleFrame, 430,0,"",NoList, CA_NoBorder | CA_Hidden,isSens,409,0,0},
	{C_Button, 431, 0, "Button A(3)",NoList, CA_Hidden, isSens, 430,0,0},
	{C_Button, 432, 0, "Button B(3)",NoList, CA_Hidden, isSens, 430,431,431},

        {C_Button, 500, 500," ModalModal Test ",NoList,CA_None,isSens,NoFrame,0,400},
        {C_Button, M_Cancel, M_Cancel," Cancel ",NoList,CA_None,isSens,NoFrame,0,500},
        {C_Button, M_OK, M_OK, " OK ", NoList, CA_DefaultButton,
                isSens, NoFrame, M_Cancel, 500},

        {C_EndOfList,0,0,0,0,CA_None,0,0,0}
      };


//-------------------- list dialog
    char* comboList[] =
      {
        "Bruce",
        "Katrina",
        "Risa",
        "Van",
        "Chaco and Sushi",
        0
      };

    char* testList[] =
      {
        "First 0", "Item 1", "Item 2", "Item 3", "Item 4", "Item 5",
        "Item 6",  "Item 7", "Item 8", "Item 9", "Item 10", "Item 11",
        "Item 12", "Item 13", "Item 14", "Item 15", "Item 16",
        "Item 17", "Item 18", "Item 19", "Item 20", "Item 21",
        "Item 22", "Item 23", "Item 24", "Item 25", "Item 26",
        "Item 27", "Item 28", "Item 29", "Item 30", "Item 31",
        "Item 32", "Item 33", "Item 34", "Item 35", "Item 36",
        "Item 37", "Item 38", "Item 39", "Item 40", "Item 41 (last)",
        0
      };

    char* testList2[] =
      {
        "First A",
        "Item B",
        "Item C",
        "Item D",
        "Item E",
        "Item F",
        "Item G",
        0
      };

    char* wideList[] =
      {
	"This Tests",
	"CA_ListWidth",
	"A", "B", "C", "D", "E", "F", "G", 0
      };

    static char* valList[] = {"Value A", "Value B", "A Long Value", "Last Value", 0};

    static int minMaxStep[3] = {-10, 110, 2};

    CommandObject ListList[] =
      {
        {C_Label, 210, 210, "List Test",
                 NoList, CA_MainMsg, isSens, 0,0},

//V:1.14	{C_TextEdit,222,0,"Initial data.",NoList,
//V:1.14                 CA_None,isSens,NoFrame,0,210},

        {C_List, 200, 0, "A List", (void*)testList,
                 CA_Size,isSens,NoFrame,0,210,32},
        {C_ComboBox,201,2,"ComboBox",(void*)comboList,
                 CA_Simple,isSens,NoFrame,200,210},

        {C_Spinner, 50,0,"Spinner", (void*)valList,CA_Text,isSens,NoFrame,
	    200,201},

        {C_Spinner, 51,32, "Spinner", NoList,CA_None,isSens,NoFrame, 200,50},
        {C_Spinner, 52,-2, "Spinner", (void*)minMaxStep,CA_None,isSens,NoFrame, 
		51,50},

        {C_List, 220, 80, "Wide List", (void*)wideList,
                 CA_Size|CA_ListWidth,isSens,NoFrame,200,52,4,"List Test"},

        {C_Button, M_OK, M_OK, " OK ", NoList,
                CA_DefaultButton, isSens, NoFrame, 0, 200},
	{C_Button, 53,0,"Change Combo",NoList,CA_None,isSens,NoFrame,M_OK,200},
	{C_Button, 54,0,"Change List",NoList,CA_None,isSens,NoFrame,53,200},
        {C_EndOfList,0,0,0,0,CA_None,0,0,0}
      };

static int whichList = 0;

//=========================>>> toggleDialog::toggleDialog <<<====================
  toggleDialog::toggleDialog(vBaseWindow* bw) :
    vModalDialog(bw,"V Toggle Dialog")
  {
    UserDebug(Constructor,"toggleDialog::toggleDialog()\n")

    AddDialogCmds(DefaultCmds);         // add the predefined commands
  }

//========================>>> toggleDialog::~toggleDialog <<<====================
  toggleDialog::~toggleDialog()
  {
    UserDebug(Destructor,"toggleDialog::~toggleDialog() destructor\n")
  }

//========================>>> toggleDialog::ShowModalDialog <<<====================
 ItemVal toggleDialog::ShowModalDialog(char* msg, ItemVal& rv)
 {
  
   return vModalDialog::ShowModalDialog(msg,rv);
 }

//====================>>> toggleDialog::DialogCommand <<<=======================
  void toggleDialog::DialogDisplayed()
  {
    SetString(411,"Button A(1)");
  }

//====================>>> toggleDialog::DialogCommand <<<=======================
  void toggleDialog::DialogCommand(ItemVal id, ItemVal retval, CmdType ctype)
  {
    // After the user has selected a command from the dialog,
    // this routine is called with the value.  This code would be generated
    // by Vigr.

    ItemVal curval;

    UserDebug2(CmdEvents,"toggleDialog::DialogCommand(id:%d, val:%d)\n",id, retval)

    switch (id)         // We will do some things depending on value
      {
	case 4:
	  {
	    SetString(2,"This is new");
	    break;
	  }

	case 401:	// Always assume toggle to ON
	  {
	    SetValue(id,1,Value);	// turn on toggle button
	    SetValue(402,0,Value);
	    SetValue(403,0,Value);	// others off

	    SetValue(420,0,Value);	// Toggle others off
	    SetValue(430,0,Value);	// Toggle others off
	    SetValue(410,1,Value);	// and ours on
	    break;
	  }

	case 402:	// Toggle 2
	  {
	    SetValue(id,1,Value);	// turn on toggle button
	    SetValue(401,0,Value);
	    SetValue(403,0,Value);	// others off

	    SetValue(410,0,Value);	// Toggle others off
	    SetValue(430,0,Value);	// Toggle others off
	    SetValue(420,1,Value);	// and ours on
	    break;
	  }

	case 403:	// toggle 3
	  {
	    SetValue(id,1,Value);	// turn on toggle button
	    SetValue(402,0,Value);
	    SetValue(401,0,Value);	// others off

	    SetValue(420,0,Value);	// Toggle others off
	    SetValue(410,0,Value);	// Toggle others off
	    SetValue(430,1,Value);	// and ours on
	    break;
	  }

        case 411: case 412: case 421: case 422: case 431: case 432:
          {
            vNoticeDialog note(this);
            note.Notice("Button pressed.");
            break;
          }

	case 500:	// modal modal test
	  {
	    vNoticeDialog note(this);
	    note.Notice("This is a modal from a modal");
	    break;
	  }

      }
    // All commands should also route through the parent handler
    vDialog::DialogCommand(id,retval,ctype);
  }

//=========================>>> listDialog::listDialog <<<====================
  listDialog::listDialog(vBaseWindow* bw) :
    vDialog(bw,0,"V List Dialog")
  {
    UserDebug(Constructor,"listDialog::listDialog()\n")

    AddDialogCmds(ListList);         // add the predefined commands
  }

//========================>>> listDialog::~listDialog <<<====================
  listDialog::~listDialog()
  {
    UserDebug(Destructor,"listDialog::~listDialog() destructor\n")
  }

//====================>>> listDialog::DialogCommand <<<=======================
  void listDialog::DialogCommand(ItemVal id, ItemVal retval, CmdType ctype)
  {
    // After the user has selected a command from the dialog,
    // this routine is called with the value.  This code would be generated
    // by Vigr.

    ItemVal curval;

    UserDebug2(CmdEvents,"listDialog::DialogCommand(id:%d, val:%d)\n",id, retval)

    switch (id)         // We will do some things depending on value
      {
	case 53:
	  {
	    if (*comboList[0] == 'b')
		comboList[0] = "Bruce";
	    else
		comboList[0] = "bruce";
	    SetValue(201,0,ChangeList);

	    break;
	  }

	case 54:
	  {
	    if (whichList == 0)
	      {
		whichList = 1;
		ListList[1].itemList = (void*)testList2;
	      }
	    else
	      {
		whichList = 0;
		ListList[1].itemList = (void*)testList;
	      }
	    SetValue(200,3,ChangeListPtr);	// change the whole list!
	    break;
	  }

      }
    // All commands should also route through the parent handler
    vDialog::DialogCommand(id,retval,ctype);
  }