6 * (C) Copyright 1998 Manuel Lemos.
7 * (C) Copyright 1995 Jaba Development.
8 * (C) Copyright 1995 Jan van den Baard.
12 * Revision 42.0 2000/05/09 22:20:02 mlemos
13 * Bumped to revision 42.0 before handing BGUI to AROS team
15 * Revision 41.11 2000/05/09 20:33:52 mlemos
16 * Bumped to revision 41.11
18 * Revision 1.2 2000/05/09 19:59:08 mlemos
19 * Merged with the branch Manuel_Lemos_fixes.
21 * Revision 1.1.2.3 1998/12/07 00:14:09 mlemos
22 * Made the listview be activated by the key indicated in the added label.
24 * Revision 1.1.2.2 1998/03/01 19:45:41 mlemos
25 * Fixed the display of empty lines.
27 * Revision 1.1.2.1 1998/02/28 17:45:38 mlemos
33 /* Execute me to compile with DICE V3.0
34 dcc MultiSelect.c -proto -mi -ms -mRR -lbgui
41 ** The entries shown in the list.
43 UBYTE
*ListEntries
[] = {
44 ISEQ_C
"This listview object has multi-",
45 ISEQ_C
"selection turned on. You can",
46 ISEQ_C
"multi-select the items by holding",
47 ISEQ_C
"down the SHIFT-key while clicking",
48 ISEQ_C
"on the different items or by clicking",
49 ISEQ_C
"on an entry and dragging the mouse",
52 ISEQ_C
"If you check the \"No SHIFT\" checbox",
53 ISEQ_C
"you can multi-select the items without",
54 ISEQ_C
"using the SHIFT key",
61 struct TagItem CheckToList
[] = {
62 { GA_Selected
, LISTV_MultiSelectNoShift
},
74 VOID
StartDemo( void )
76 struct Window
*window
;
77 Object
*WO_Window
, *GO_Quit
, *GO_Show
, *GO_List
, *GO_Shift
, *GO_All
, *GO_None
;
83 * Create the window object.
85 WO_Window
= WindowObject
,
86 WINDOW_Title
, "Multi-Selection Demo",
87 WINDOW_AutoAspect
, TRUE
,
88 WINDOW_SmartRefresh
, TRUE
,
90 WINDOW_ScaleWidth
, 30,
91 WINDOW_ScaleHeight
, 30,
93 VGroupObject
, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ), GROUP_BackFill
, SHINE_RASTER
,
95 VGroupObject
, HOffset( 4 ), VOffset( 4 ),
96 FRM_Type
, FRTYPE_BUTTON
,
99 GO_List
= ListviewObject
,
100 LISTV_EntryArray
, ListEntries
,
101 LISTV_MultiSelect
, TRUE
,
102 Label("Se_lect next entry"),
108 StartMember
, GO_All
= KeyButton( "_All", ID_ALL
), EndMember
,
109 StartMember
, GO_None
= KeyButton( "N_one", ID_NONE
), EndMember
,
110 EndObject
, FixMinHeight
,
115 HGroupObject
, HOffset( 4 ), VOffset( 4 ),
116 FRM_Type
, FRTYPE_BUTTON
,
118 VarSpace( DEFAULT_WEIGHT
),
119 StartMember
, GO_Shift
= KeyCheckBox( "_No SHIFT:", FALSE
, 0 ), EndMember
,
120 VarSpace( DEFAULT_WEIGHT
),
121 EndObject
, FixMinHeight
,
124 HGroupObject
, Spacing( 4 ),
125 StartMember
, GO_Show
= KeyButton( "_Show", ID_SHOW
), EndMember
,
126 VarSpace( DEFAULT_WEIGHT
),
127 StartMember
, GO_Quit
= KeyButton( "_Quit", ID_QUIT
), EndMember
,
128 EndObject
, FixMinHeight
,
134 ** Object created OK?
138 ** Assign the keys to the buttons.
140 tmp
+= GadgetKey( WO_Window
, GO_Quit
, "q" );
141 tmp
+= GadgetKey( WO_Window
, GO_Show
, "s" );
142 tmp
+= GadgetKey( WO_Window
, GO_Shift
, "n" );
143 tmp
+= GadgetKey( WO_Window
, GO_All
, "a" );
144 tmp
+= GadgetKey( WO_Window
, GO_None
, "o" );
145 tmp
+= GadgetKey( WO_Window
, GO_List
, "l" );
153 if ( AddMap( GO_Shift
, GO_List
, CheckToList
)) {
155 ** try to open the window.
157 if (( window
= WindowOpen( WO_Window
))) {
159 ** Obtain it's wait mask.
161 GetAttr( WINDOW_SigMask
, WO_Window
, &signal
);
170 while (( rc
= HandleEvent( WO_Window
)) != WMHI_NOMORE
) {
172 ** Evaluate return code.
176 case WMHI_CLOSEWINDOW
:
182 SetGadgetAttrs(( struct Gadget
* )GO_List
, window
, NULL
, LISTV_SelectMulti
, LISTV_Select_All
, TAG_END
);
186 SetGadgetAttrs(( struct Gadget
* )GO_List
, window
, NULL
, LISTV_DeSelect
, ~0, TAG_END
);
194 ** Simply dump all selected entries
197 if (( str
= ( UBYTE
* )FirstSelected( GO_List
))) {
206 str
= ( UBYTE
* )NextSelected( GO_List
, str
);
210 ** Oops. There are no selected
213 Tell( "No selections made!\n" );
220 Tell( "Could not open the window\n" );
222 Tell( "Unable to add notification\n" );
224 Tell( "Could not assign gadget keys\n" );
226 ** Disposing of the window object will
227 ** also close the window if it is
228 ** already opened and it will dispose of
229 ** all objects attached to it.
231 DisposeObject( WO_Window
);
233 Tell( "Could not create the window object\n" );