Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / libs / muimaster / classes / scrollbar.c
blobcb5d9ba374da91ba5470afe646bfa11326880129
1 /*
2 Copyright 2002-2006, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <exec/memory.h>
7 #include <intuition/icclass.h>
8 #include <intuition/gadgetclass.h>
9 #include <clib/alib_protos.h>
10 #include <proto/exec.h>
11 #include <proto/intuition.h>
12 #include <proto/utility.h>
13 #include <proto/muimaster.h>
15 #include "../datatypescache.h"
16 #include "../imspec_intern.h"
18 #include "mui.h"
19 #include "muimaster_intern.h"
20 #include "support.h"
21 #include "prefs.h"
23 #define MYDEBUG 1
24 #include "debug.h"
26 extern struct Library *MUIMasterBase;
28 struct Scrollbar_DATA
30 Object *prop;
31 Object *up_arrow;
32 Object *down_arrow;
33 int sb_pos;
37 IPTR Scrollbar__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg)
39 struct Scrollbar_DATA *data;
40 //struct TagItem *tags,*tag;
41 int horiz = GetTagData(MUIA_Group_Horiz, 0, msg->ops_AttrList);
42 int usewinborder = GetTagData(MUIA_Prop_UseWinBorder, 0, msg->ops_AttrList);
43 int sb_pos = GetTagData(MUIA_Scrollbar_Type, 0, msg->ops_AttrList);
45 Object *prop = MUI_NewObject(MUIC_Prop, PropFrame, MUIA_Prop_Horiz, horiz,
46 TAG_MORE, msg->ops_AttrList);
48 obj = (Object *)DoSuperNewTags(cl, obj, NULL,
49 MUIA_Group_Spacing, 0,
50 MUIA_Background, MUII_GroupBack,
52 TAG_MORE, (IPTR) msg->ops_AttrList);
53 if (!obj)
54 return FALSE;
56 data = INST_DATA(cl, obj);
57 data->prop = prop;
58 data->sb_pos = sb_pos;
60 if (!usewinborder)
62 data->up_arrow = ImageObject,
63 MUIA_Background, MUII_ButtonBack,
64 MUIA_Weight, 0,
65 ImageButtonFrame,
66 MUIA_InputMode, MUIV_InputMode_RelVerify,
67 MUIA_Image_Spec, horiz ? MUII_ArrowLeft : MUII_ArrowUp,
68 MUIA_Image_Prop, prop,
69 End;
70 if (data->up_arrow)
72 DoMethod(data->up_arrow, MUIM_Notify, MUIA_Timer, MUIV_EveryTime,
73 (IPTR)prop, 2, MUIM_Prop_Decrease, 1);
76 data->down_arrow = ImageObject,
77 MUIA_Background, MUII_ButtonBack,
78 MUIA_Weight, 0,
79 ImageButtonFrame,
80 MUIA_InputMode, MUIV_InputMode_RelVerify,
81 MUIA_Image_Spec, horiz ? MUII_ArrowRight : MUII_ArrowDown,
82 MUIA_Image_Prop, prop,
83 End;
84 if (data->down_arrow)
86 DoMethod(data->down_arrow, MUIM_Notify, MUIA_Timer, MUIV_EveryTime,
87 (IPTR)prop, 2, MUIM_Prop_Increase, 1);
90 switch (sb_pos)
92 case MUIV_Scrollbar_Type_Default:
93 case MUIV_Scrollbar_Type_Top:
94 DoMethod(obj, OM_ADDMEMBER, (IPTR)data->prop);
95 DoMethod(obj, OM_ADDMEMBER, (IPTR)data->up_arrow);
96 DoMethod(obj, OM_ADDMEMBER, (IPTR)data->down_arrow);
97 break;
98 case MUIV_Scrollbar_Type_Bottom:
99 DoMethod(obj, OM_ADDMEMBER, (IPTR)data->up_arrow);
100 DoMethod(obj, OM_ADDMEMBER, (IPTR)data->down_arrow);
101 DoMethod(obj, OM_ADDMEMBER, (IPTR)data->prop);
102 break;
103 case MUIV_Scrollbar_Type_Sym:
104 DoMethod(obj, OM_ADDMEMBER, (IPTR)data->up_arrow);
105 DoMethod(obj, OM_ADDMEMBER, (IPTR)data->prop);
106 DoMethod(obj, OM_ADDMEMBER, (IPTR)data->down_arrow);
107 break;
110 else
112 _flags(obj) |= MADF_BORDERGADGET;
113 DoMethod(obj, OM_ADDMEMBER, (IPTR)data->prop);
116 return (IPTR)obj;
120 IPTR Scrollbar__MUIM_Setup(struct IClass *cl, Object *obj, Msg msg)
122 struct Scrollbar_DATA *data = INST_DATA(cl, obj);
124 if (!DoSuperMethodA(cl, obj, msg))
125 return FALSE;
127 if (!(_flags(obj) & MADF_BORDERGADGET) && !data->sb_pos)
129 switch (muiGlobalInfo(obj)->mgi_Prefs->scrollbar_arrangement)
131 case SCROLLBAR_ARRANGEMENT_TOP:
132 DoMethod(obj, MUIM_Group_Sort, (IPTR)data->prop,
133 (IPTR)data->up_arrow, (IPTR)data->down_arrow, (IPTR)NULL);
134 break;
135 case SCROLLBAR_ARRANGEMENT_MIDDLE:
136 DoMethod(obj, MUIM_Group_Sort, (IPTR)data->up_arrow,
137 (IPTR)data->prop, (IPTR)data->down_arrow, (IPTR)NULL);
138 break;
139 case SCROLLBAR_ARRANGEMENT_BOTTOM:
140 DoMethod(obj, MUIM_Group_Sort, (IPTR)data->up_arrow,
141 (IPTR)data->down_arrow, (IPTR)data->prop, (IPTR)NULL);
142 break;
145 switch (muiGlobalInfo(obj)->mgi_Prefs->scrollbar_type)
147 case SCROLLBAR_TYPE_STANDARD:
148 break;
149 case SCROLLBAR_TYPE_NEWLOOK:
150 break;
151 case SCROLLBAR_TYPE_CUSTOM:
152 break;
156 return TRUE;
160 BOOPSI_DISPATCHER(IPTR, Scrollbar_Dispatcher, cl, obj, msg)
162 switch (msg->MethodID)
164 case OM_NEW: return Scrollbar__OM_NEW(cl, obj, (struct opSet *) msg);
165 case MUIM_Setup: return Scrollbar__MUIM_Setup(cl, obj, msg);
166 default: return DoSuperMethodA(cl, obj, msg);
169 BOOPSI_DISPATCHER_END
171 const struct __MUIBuiltinClass _MUI_Scrollbar_desc =
173 MUIC_Scrollbar,
174 MUIC_Group,
175 sizeof(struct Scrollbar_DATA),
176 (void*)Scrollbar_Dispatcher