build git 2.17.1
[AROS-Contrib.git] / bgui / examples / List.c
blobcce364aec8bdca6ef65d979b4a71d240bad625ba
1 /*
2 * @(#) $Header$
4 * List.c
6 * (C) Copyright 1998 Manuel Lemos.
7 * (C) Copyright 1995-1996 Jaba Development.
8 * (C) Copyright 1995-1996 Jan van den Baard.
9 * All Rights Reserved.
11 * This example will show the most simple form of
12 * a DragNDrop Listview. It opens a window with a
13 * single-select Listview object.
15 * The entries in the Listview can be moved in the
16 * list.
18 * $Log$
19 * Revision 42.1 2000/08/10 11:50:54 chodorowski
20 * Cleaned up and prettyfied the GUIs a bit.
22 * Revision 42.0 2000/05/09 22:19:53 mlemos
23 * Bumped to revision 42.0 before handing BGUI to AROS team
25 * Revision 41.11 2000/05/09 20:33:43 mlemos
26 * Bumped to revision 41.11
28 * Revision 1.2 2000/05/09 19:59:00 mlemos
29 * Merged with the branch Manuel_Lemos_fixes.
31 * Revision 1.1.2.1 1998/02/28 17:45:26 mlemos
32 * Ian sources
37 /* Execute me to compile with DICE V3.0
38 dcc List.c -proto -mi -ms -mRR -lbgui
39 quit
43 #include "DemoCode.h"
46 * Just a bunch of entries...
48 STATIC UBYTE *entries[] = {
49 "Entry 1",
50 "Entry 2",
51 "Entry 3",
52 "Entry 4",
53 "Entry 5",
54 "Entry 6",
55 "Entry 7",
56 "Entry 8",
57 "Entry 9",
58 "Entry 10",
59 "Entry 11",
60 "Entry 12",
61 "Entry 13",
62 "Entry 14",
63 "Entry 15",
64 "Entry 16",
65 "Entry 17",
66 "Entry 18",
67 "Entry 19",
68 "Entry 20",
69 NULL
73 * Object ID's
75 #define ID_QUIT 1
77 static char *TabLabels[] =
79 "Single-Select",
80 "Multi-Select",
81 NULL
84 ** Cycle to Page map-list.
85 **/
86 static struct TagItem Cyc2Page[] = { { MX_Active, PAGE_Active, }, { TAG_END } };
89 * Here we go...
91 VOID StartDemo( void )
93 struct Window *window;
94 Object *WO_Window, *tabs, *page;
95 IPTR signal;
96 ULONG rc;
97 BOOL running = TRUE;
100 * Build the window object tree.
102 WO_Window = WindowObject,
103 WINDOW_Title, "Listview DragNDrop",
104 WINDOW_ScaleWidth, 25,
105 WINDOW_ScaleHeight, 20,
106 WINDOW_RMBTrap, TRUE,
107 WINDOW_AutoAspect, TRUE,
108 WINDOW_AutoKeyLabel, TRUE,
109 WINDOW_CloseOnEsc, TRUE,
110 WINDOW_MasterGroup,
111 VGroupObject, NormalOffset, Spacing( 0 ),
112 StartMember,
113 tabs = Tabs(NULL, TabLabels, 0, 0),
114 EndMember,
115 StartMember,
116 page = PageObject, FRM_Type, FRTYPE_TAB_ABOVE,
117 PageMember,
118 VGroupObject, WideVOffset, WideHOffset, NormalSpacing,
119 StartMember,
120 InfoFixed(NULL, ISEQ_C "Single-Select Drag-n-Drop\nListview object.", NULL, 2 ), FixMinHeight,
121 EndMember,
122 StartMember,
124 * Create a draggable and droppable listview
125 * and make it show the drop-spot.
127 ListviewObject,
128 LISTV_EntryArray, entries,
129 LISTV_ShowDropSpot, TRUE,
130 BT_DragObject, TRUE,
131 BT_DropObject, TRUE,
132 EndObject,
133 EndMember,
134 EndObject,
135 PageMember,
136 VGroupObject, WideVOffset, WideHOffset, NormalSpacing,
137 StartMember,
138 InfoFixed( NULL, ISEQ_C "Multi-Select Drag-n-Drop\nListview object.", NULL, 2 ), FixMinHeight,
139 EndMember,
140 StartMember,
142 * Create a multi-select, draggable and
143 * droppable listview and make it show
144 * the drop-spot.
146 ListviewObject,
147 LISTV_MultiSelect, TRUE,
148 LISTV_EntryArray, entries,
149 LISTV_ShowDropSpot, TRUE,
150 BT_DragObject, TRUE,
151 BT_DropObject, TRUE,
152 EndObject,
153 EndMember,
154 EndObject,
155 EndObject,
156 EndMember,
157 StartMember,
158 HGroupObject, NormalOffset, NormalSpacing,
159 VarSpace( DEFAULT_WEIGHT ),
160 StartMember, PrefButton( "_Quit", ID_QUIT ), EndMember,
161 VarSpace( DEFAULT_WEIGHT ),
162 EndObject, FixMinHeight,
163 EndMember,
164 EndObject,
165 EndObject;
168 * Window object tree OK?
170 if ( WO_Window ) {
172 ** Connect the cycle to the page.
174 AddMap(tabs, page, Cyc2Page );
176 * Open the window.
178 if (( window = WindowOpen( WO_Window ))) {
180 * Get signal wait mask.
182 GetAttr( WINDOW_SigMask, WO_Window, &signal );
184 do {
185 Wait( signal );
187 * Handle messages.
189 while (( rc = HandleEvent( WO_Window )) != WMHI_NOMORE ) {
190 switch ( rc ) {
191 case WMHI_CLOSEWINDOW:
192 case ID_QUIT:
193 running = FALSE;
194 break;
197 } while ( running );
198 } else
199 Tell( "Unable to open the window.\n" );
200 DisposeObject( WO_Window );
201 } else
202 Tell( "Unable to create the window object.\n" );