11 Window::Window(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*/,
12 void (* f)(Element *)/*= NULL*/): Element(x, y, w, h),
13 // /*clicked(false), inside(false),*/ fgColor(0x4FF0), bgColor(0x1E10),
14 //4FF0 -> 010011 11111 10000 -> 0100 1101 1111 1111 1000 0100 -> 4D FF 84
15 //1E10 -> 000111 10000 10000 -> 0001 1111 1000 0100 1000 0100 -> 1F 84 84
16 /*clicked(false), inside(false),*/ fgColor(0xFF84FF4D), bgColor(0xFF84841F),
19 close = new Button(w - (CLOSEBOX_WIDTH + 1), 1, closeBox, closeBoxHover, closeBoxDown);
20 list.push_back(close);
21 close->SetNotificationElement(this);
26 for(uint32 i=0; i<list.size(); i++)
31 void Window::HandleKey(SDLKey key)
33 if (key == SDLK_ESCAPE)
36 event.type = SDL_USEREVENT, event.user.code = WINDOW_CLOSE;
37 SDL_PushEvent(&event);
40 // Handle the items this window contains...
41 for(uint32 i=0; i<list.size(); i++)
42 // Make coords relative to upper right corner of this window...
43 list[i]->HandleKey(key);
46 void Window::HandleMouseMove(uint32 x, uint32 y)
48 // Handle the items this window contains...
49 for(uint32 i=0; i<list.size(); i++)
50 // Make coords relative to upper right corner of this window...
51 list[i]->HandleMouseMove(x - extents.x, y - extents.y);
54 void Window::HandleMouseButton(uint32 x, uint32 y, bool mouseDown)
56 // Handle the items this window contains...
57 for(uint32 i=0; i<list.size(); i++)
58 // Make coords relative to upper right corner of this window...
59 list[i]->HandleMouseButton(x - extents.x, y - extents.y, mouseDown);
62 void Window::Draw(uint32 offsetX/*= 0*/, uint32 offsetY/*= 0*/)
64 uint32 addr = (extents.x + offsetX) + ((extents.y + offsetY) * pitch);
66 for(uint32 y=0; y<extents.h; y++)
68 for(uint32 x=0; x<extents.w; x++)
70 // Doesn't clip in y axis! !!! FIX !!!
71 if (extents.x + x < pitch)
72 screenBuffer[addr + x + (y * pitch)] = bgColor;
76 // Handle the items this window contains...
77 for(uint32 i=0; i<list.size(); i++)
78 list[i]->Draw(extents.x, extents.y);
81 void Window::AddElement(Element * e)
86 void Window::Notify(Element * e)
91 event.type = SDL_USEREVENT, event.user.code = WINDOW_CLOSE;
92 SDL_PushEvent(&event);