Repository navigation
Expand file tree
/
Copy pathbgrenderclass.c
More file actions
197 lines (155 loc) · 4.36 KB
/
Copy pathbgrenderclass.c
File metadata and controls
197 lines (155 loc) · 4.36 KB
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
/*
* Ambient - the ultimate desktop
* ------------------------------
* Copyright 2001-2005 by David Gerber <zapek@morphos.net>
* Copyright 2005-2006 Ambient Open Source Team
* All Rights Reserved
*
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
* $Id: bgrenderclass.c,v 1.13 2017/08/21 06:17:44 cyfm Exp $
*/
#include "ambient.h"
/* public */
/* private */
#include "ambient_cat.h"
#include "mui_func.h"
#include "background.h"
#include "prefswin.h"
struct Data {
APTR cyc_bgrender;
APTR grp_bgrender;
APTR pp_color;
ULONG needsbg;
};
struct MUI_PenSpec defcol = {
"m2"
};
DEFNEW
{
struct Data *data;
APTR cyc_bgrender;
APTR grp_bgrender;
APTR pp_color;
ULONG isroot;
static STRPTR cycleopts_root[7];
static STRPTR cycleopts_window[3];
cycleopts_window[0] = cycleopts_root[0] = GSI(MSG_PREFSWIN_BACKGROUND_MODE_COLOR);
cycleopts_window[1] = cycleopts_root[1] = GSI(MSG_PREFSWIN_BACKGROUND_MODE_TILED);
cycleopts_root[2] = GSI(MSG_PREFSWIN_BACKGROUND_MODE_CENTERED);
cycleopts_root[3] = GSI(MSG_PREFSWIN_BACKGROUND_MODE_SCALED);
cycleopts_root[4] = GSI(MSG_PREFSWIN_BACKGROUND_MODE_STRETCHED);
cycleopts_root[5] = GSI(MSG_PREFSWIN_BACKGROUND_MODE_ZOOMED);
isroot = GetTagData(MA_BGRender_Root, FALSE, INITTAGS);
obj = DoSuperNew(cl, obj,
Child, HGroup,
Child, cyc_bgrender = MUI_MakeObject(MUIO_Cycle, GetTagData(MA_BGRender_Label, (ULONG)NULL, INITTAGS), isroot ? cycleopts_root : cycleopts_window),
Child, grp_bgrender = PageGroup,
MUIA_HorizWeight, 25,
Child, HGroup,
Child, NSLabel2(MSG_PREFSWIN_BACKGROUND_MODE_COLOR),
Child, pp_color = PoppenObject,
MUIA_CycleChain, 1,
MUIA_Window_Title, GSI(MSG_PREFSWIN_BACKGROUND_MODE_COLOR_SELECT),
End,
End,
Child, HVSpace,
End,
End,
TAG_MORE, INITTAGS
);
if (!obj)
{
return ((ULONG)NULL);
}
data = INST_DATA(cl, obj);
data->cyc_bgrender = cyc_bgrender;
data->grp_bgrender = grp_bgrender;
data->pp_color = pp_color;
set(cyc_bgrender, MUIA_CycleChain, 1);
setupprefs(cyc_bgrender, MUIA_Cycle_Active,
GetTagData(MA_BGRender_Mode, BGRENDER_Color, INITTAGS)
);
setupprefs(pp_color, MUIA_Pendisplay_Spec,
GetTagData(MA_BGRender_Color, (ULONG)&defcol, INITTAGS)
);
DoMethod(obj, MM_BGRender_Change, getv(data->cyc_bgrender, MUIA_Cycle_Active));
DoMethod(data->cyc_bgrender, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime,
obj, 2, MM_BGRender_Change, MUIV_TriggerValue
);
return ((ULONG)obj);
}
DEFSMETHOD(BGRender_Change)
{
GETDATA;
switch (msg->mode)
{
case BGRENDER_Color:
set(obj, MA_BGRender_NeedsBackground, FALSE);
set(data->grp_bgrender, MUIA_Group_ActivePage, 0);
break;
case BGRENDER_Centered:
case BGRENDER_Scaled:
set(obj, MA_BGRender_NeedsBackground, TRUE);
set(data->grp_bgrender, MUIA_Group_ActivePage, 0);
break;
case BGRENDER_Stretched:
case BGRENDER_Tiled:
case BGRENDER_Zoomed:
set(obj, MA_BGRender_NeedsBackground, TRUE);
set(data->grp_bgrender, MUIA_Group_ActivePage, 1);
break;
#ifdef DEBUG
default:
PDB(("erk, value exceeded\n"));
break;
#endif
}
return (0);
}
DEFGET
{
GETDATA;
switch (msg->opg_AttrID)
{
case MA_BGRender_Mode:
*msg->opg_Storage = getv(data->cyc_bgrender, MUIA_Cycle_Active);
return (TRUE);
case MA_BGRender_Color:
*msg->opg_Storage = getv(data->pp_color, MUIA_Pendisplay_Spec);
return (TRUE);
case MA_BGRender_NeedsBackground:
*msg->opg_Storage = data->needsbg;
return (TRUE);
}
return (DOSUPER);
}
DEFSET
{
struct TagItem *ti;
if ((ti = FindTagItem(MA_BGRender_NeedsBackground, INITTAGS)))
{
GETDATA;
data->needsbg = ti->ti_Data;
}
return (DOSUPER);
}
BEGINMTABLE
DECNEW
DECGET
DECSET
DECSMETHOD(BGRender_Change)
ENDMTABLE
DECSUBCLASS_NC(MUIC_Group, bgrenderclass)