3 static define borderSize = (radius * 8 / 20);
7 DisplaySystem displaySystem;
11 static Map<RoundMatch, RoundedBMPs> roundedBMPs { };
13 static byte borderData[] =
15 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x4B, 0x8D, 0xC9, 0xCC, 0xFC, 0xFF, 0xFF,
16 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0xAE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
17 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0xCC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
18 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x78, 0x36, 0x33, 0x03, 0x00, 0x00,
19 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xB3, 0xFF, 0xFF, 0xFF, 0xF6, 0x8D, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20 0x00, 0x00, 0x00, 0x00, 0x03, 0xD4, 0xFF, 0xFF, 0xFF, 0xB1, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21 0x00, 0x00, 0x00, 0x00, 0xB0, 0xFF, 0xFF, 0xFF, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22 0x00, 0x00, 0x00, 0x7D, 0xFF, 0xFF, 0xFF, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0x7B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24 0x00, 0x00, 0xC9, 0xFF, 0xFF, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25 0x00, 0x45, 0xFF, 0xFF, 0xF9, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26 0x00, 0xC6, 0xFF, 0xFF, 0x8A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27 0x0F, 0xFF, 0xFF, 0xFC, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 0x57, 0xFF, 0xFF, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29 0x93, 0xFF, 0xFF, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30 0xC6, 0xFF, 0xFF, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31 0xEA, 0xFF, 0xFF, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32 0xF9, 0xFF, 0xFF, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
37 static byte insideData[] =
39 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x87, 0xC9, 0xCC, 0xFC, 0xFF, 0xFF,
43 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x72, 0xEA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
44 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4E, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
45 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
46 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x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, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
56 0x00, 0x00, 0x00, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
57 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
58 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
64 DisplaySystem displaySystem;
67 Bitmap tl { alphaBlend = true };
68 Bitmap bl { alphaBlend = true };
69 Bitmap tr { alphaBlend = true };
70 Bitmap br { alphaBlend = true };
71 Bitmap vert { alphaBlend = true };
72 Bitmap horz { alphaBlend = true };
73 Bitmap eVert { alphaBlend = true };
74 Bitmap eHorz { alphaBlend = true };
75 Bitmap itl { alphaBlend = true };
76 Bitmap ibl { alphaBlend = true };
77 Bitmap itr { alphaBlend = true };
78 Bitmap ibr { alphaBlend = true };
79 Bitmap ivert { alphaBlend = true };
80 Bitmap ihorz { alphaBlend = true };
81 Bitmap ieVert { alphaBlend = true };
82 Bitmap ieHorz { alphaBlend = true };
86 /*tl.Load(":roundedTL.png", null, null);
87 itl.Load(":insideTL.png", null, null);
89 tl.Convert(null, pixelFormatAlpha, null);
90 itl.Convert(null, pixelFormatAlpha, null);*/
92 tl.Allocate(null, radius, radius, 0, pixelFormatAlpha, false);
93 itl.Allocate(null, radius, radius, 0, pixelFormatAlpha, false);
97 memcpy(tl.picture, borderData, sizeof(borderData));
98 memcpy(itl.picture, insideData, sizeof(insideData));
102 Bitmap temp { alphaBlend = true };
105 temp.Allocate(null, 20, 20, 0, pixelFormatAlpha, false);
107 memcpy(temp.picture, borderData, sizeof(borderData));
108 surface = tl.GetSurface(0,0, null);
109 surface.blend = false;
110 surface.Filter(temp, 0,0,0,0, radius, radius, 20,20);
113 memcpy(temp.picture, insideData, sizeof(insideData));
114 surface = itl.GetSurface(0,0, null);
115 surface.blend = false;
116 surface.Filter(temp, 0,0,0,0, radius, radius, 20,20);
122 bl.Allocate(null, tl.width, tl.height, 0, pixelFormatAlpha, false);
123 tr.Allocate(null, tl.width, tl.height, 0, pixelFormatAlpha, false);
124 br.Allocate(null, tl.width, tl.height, 0, pixelFormatAlpha, false);
125 ibl.Allocate(null, itl.width, itl.height, 0, pixelFormatAlpha, false);
126 itr.Allocate(null, itl.width, itl.height, 0, pixelFormatAlpha, false);
127 ibr.Allocate(null, itl.width, itl.height, 0, pixelFormatAlpha, false);
128 vert.Allocate(null, tl.width, 1, 0, pixelFormatAlpha, false);
129 horz.Allocate(null, 1, tl.height, 0, pixelFormatAlpha, false);
130 eVert.Allocate(null, borderSize /*tl.width*/, 1, 0, pixelFormatAlpha, false);
131 eHorz.Allocate(null, 1, borderSize /*tl.height*/, 0, pixelFormatAlpha, false);
132 ivert.Allocate(null, tl.width, 1, 0, pixelFormatAlpha, false);
133 ihorz.Allocate(null, 1, tl.height, 0, pixelFormatAlpha, false);
134 ieVert.Allocate(null, borderSize /*tl.width*/, 1, 0, pixelFormatAlpha, false);
135 ieHorz.Allocate(null, 1, borderSize /*tl.height*/, 0, pixelFormatAlpha, false);
139 int w = tl.width, h = tl.height, s = tl.stride;
140 byte * picture = tl.picture, * ipicture = itl.picture;
141 for(y = 0; y < tl.height; y++)
143 for(x = 0; x < tl.width; x++)
145 byte b = picture[y * s + x];
146 byte ib = ipicture[y * s + x];
148 ((byte *)bl.picture)[(h-1-y) * s + x] = b;
149 ((byte *)br.picture)[(h-1-y) * s + (w-1-x)] = b;
150 ((byte *)tr.picture)[y * s + (w-1-x)] = b;
152 ((byte *)ibl.picture)[(h-1-y) * s + x] = ib;
153 ((byte *)ibr.picture)[(h-1-y) * s + (w-1-x)] = ib;
154 ((byte *)itr.picture)[y * s + (w-1-x)] = ib;
157 printf("0x%02X", b);*/
159 /*if(y < tl.height-1) Print(",");
164 for(y = 0; y < tl.height; y++)
166 for(x = 0; x < tl.width; x++)
168 byte ib = ipicture[y * s + x];
171 printf("0x%02X", ib);
173 if(y < tl.height-1) Print(",");
177 vert.Grab(tl, 0, tl.height - vert.height);
178 horz.Grab(tl, tl.width - horz.width, 0);
179 eVert.Grab(br, tl.width - borderSize, 0);
180 eHorz.Grab(br, 0, tl.height - borderSize);
182 ivert.Grab(itl, 0, tl.height - vert.height);
183 ihorz.Grab(itl, tl.width - horz.width, 0);
184 ieVert.Grab(ibr, tl.width - borderSize, 0);
185 ieHorz.Grab(ibr, 0, tl.height - borderSize);
187 tl.MakeDD(displaySystem);
188 bl.MakeDD(displaySystem);
189 tr.MakeDD(displaySystem);
190 br.MakeDD(displaySystem);
191 vert.MakeDD(displaySystem);
192 horz.MakeDD(displaySystem);
193 eVert.MakeDD(displaySystem);
194 eHorz.MakeDD(displaySystem);
195 itl.MakeDD(displaySystem);
196 ibl.MakeDD(displaySystem);
197 itr.MakeDD(displaySystem);
198 ibr.MakeDD(displaySystem);
199 ivert.MakeDD(displaySystem);
200 ihorz.MakeDD(displaySystem);
201 ieVert.MakeDD(displaySystem);
202 ieHorz.MakeDD(displaySystem);
206 void RenderBack(Surface surface, Size size, ColorAlpha background)
210 surface.blitTint = background;
212 surface.Tile(ihorz, tl.width,0, size.w - 2*tl.width, borderSize);
213 surface.Tile(ivert, 0, tl.height, borderSize, size.h - 2*tl.height);
214 surface.Tile(ieHorz, br.width, size.h - ieHorz.height, size.w - 2*br.width, ieHorz.height);
215 surface.Tile(ieVert, size.w - ieVert.width, br.height, ieVert.width, size.h - 2*br.height);
217 surface.Blit(itl, 0,0,0,0, borderSize, tl.height);
218 surface.Blit(itl, 0,0,0,0, tl.width, borderSize);
220 surface.Blit(itr, size.w - borderSize, 0, itr.width - borderSize, 0, borderSize, tr.height);
221 surface.Blit(itr, size.w - tr.width, 0, 0, 0, tr.width, borderSize);
223 surface.Blit(ibl, 0,size.h - borderSize, 0,bl.height - borderSize, bl.width, bl.height - borderSize);
224 surface.Blit(ibl, 0,size.h - bl.height,0,0, borderSize, bl.height);
226 surface.Blit(ibr, size.w - borderSize, size.h - tr.height, bl.width - borderSize, 0, borderSize, br.height);
227 surface.Blit(ibr, size.w - br.width, size.h - borderSize, 0, bl.height - borderSize, br.width, borderSize);
231 void RenderBorder(Surface surface, Size size, ColorAlpha borderColor)
235 surface.blitTint = borderColor;
237 surface.Tile(horz, tl.width,0, size.w - 2*tl.width, horz.height);
238 surface.Tile(vert, 0, tl.height, vert.width, size.h - 2*tl.height);
239 surface.Tile(eHorz, br.width, size.h - eHorz.height, size.w - 2*br.width, eHorz.height);
240 surface.Tile(eVert, size.w - eVert.width, br.height, eVert.width, size.h - 2*br.height);
242 surface.Blit(tl, 0,0,0,0, tl.width, tl.height);
243 surface.Blit(tr, size.w - tr.width,0,0,0, tr.width, tr.height);
244 surface.Blit(bl, 0,size.h - bl.height,0,0, bl.width, bl.height);
245 surface.Blit(br, size.w - br.width, size.h - tr.height,0,0, br.width, br.height);*/
247 surface.Tile(horz, tl.width,0, size.w - 2*tl.width, borderSize);
248 surface.Tile(vert, 0, tl.height, borderSize, size.h - 2*tl.height);
249 surface.Tile(eHorz, br.width, size.h - ieHorz.height, size.w - 2*br.width, ieHorz.height);
250 surface.Tile(eVert, size.w - ieVert.width, br.height, ieVert.width, size.h - 2*br.height);
252 surface.Blit(tl, 0,0,0,0, borderSize, tl.height);
253 surface.Blit(tl, 0,0,0,0, tl.width, borderSize);
255 surface.Blit(tr, size.w - borderSize, 0, itr.width - borderSize, 0, borderSize, tr.height);
256 surface.Blit(tr, size.w - tr.width, 0, 0, 0, tr.width, borderSize);
258 surface.Blit(bl, 0,size.h - borderSize, 0,bl.height - borderSize, bl.width, bl.height - borderSize);
259 surface.Blit(bl, 0,size.h - bl.height,0,0, borderSize, bl.height);
261 surface.Blit(br, size.w - borderSize, size.h - tr.height, bl.width - borderSize, 0, borderSize, br.height);
262 surface.Blit(br, size.w - br.width, size.h - borderSize, 0, bl.height - borderSize, br.width, borderSize);
267 class RoundedSquare : Window
269 ColorAlpha borderColor;
280 bool OnLoadGraphics()
282 bmps = roundedBMPs[RoundMatch { displaySystem, radius }];
285 bmps = RoundedBMPs { displaySystem = displaySystem, radius = radius };
286 roundedBMPs[RoundMatch { displaySystem, radius }] = bmps;
287 bmps.OnLoadGraphics();
293 void OnUnloadGraphics()
295 RoundedBMPs bmps = roundedBMPs[RoundMatch { displaySystem, radius }];
299 //Iterator<RoundedBMPs> it { }; it.Find(bmps); it.Remove();
300 roundedBMPs[RoundMatch { displaySystem, radius }] = null;
305 void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h)
311 void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
315 *cw = *w - borderSize * 2;
316 *ch = *h - borderSize * 2;
322 void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving)
324 bmps.RenderBack(surface, size, { (byte)(opacity * 255), background });
327 void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving)
329 //if(borderStyle == contour)
330 bmps.RenderBorder(surface, size, borderColor);
335 return false;//(!style.drawBehind && opacity == 1.0);
339 class MyRoundedSquare : RoundedSquare
341 background = lightBlue;
347 Label test { this, position = { 0, 0 }, size = { 100, 20 }, text = "Bubble Window" };
350 /*MyRoundedSquare testRounded