diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2005-02-18 12:25:26 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2005-02-18 12:25:26 +0000 |
commit | 3ac7f63f4ccc7c6dcd6c1b29b4da958c0ef863a6 (patch) | |
tree | 98c2722b295ad2be732d66d622962682e28e76ff /src/gui/window.cpp | |
parent | 8f28717190dd36f64c8c9d3a155ebdd3af93ea25 (diff) | |
download | mana-3ac7f63f4ccc7c6dcd6c1b29b4da958c0ef863a6.tar.gz mana-3ac7f63f4ccc7c6dcd6c1b29b4da958c0ef863a6.tar.bz2 mana-3ac7f63f4ccc7c6dcd6c1b29b4da958c0ef863a6.tar.xz mana-3ac7f63f4ccc7c6dcd6c1b29b4da958c0ef863a6.zip |
Gui v3 with Images*
Diffstat (limited to 'src/gui/window.cpp')
-rw-r--r-- | src/gui/window.cpp | 93 |
1 files changed, 29 insertions, 64 deletions
diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 8f9d819e..f06866d5 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -49,19 +49,18 @@ Window::Window(const std::string& text, bool modal, Window *parent): ResourceManager *resman = ResourceManager::getInstance(); dBorders = resman->getImage("core/graphics/gui/vscroll_grey.png"); dBackground = resman->getImage("core/graphics/gui/bg_quad_dis.png"); - dWindowSurface = 0; + + dUpperBorder = dBorders->getSubImage(4,0,1,3); + dLeftBorder = dBorders->getSubImage(0,4,3,1); + dRightBorder = dBorders->getSubImage(8,4,3,1); + dLowerBorder = dBorders->getSubImage(8,15,1,3); - dWindowSurface = SDL_AllocSurface(SDL_SWSURFACE, 20, 20, (screen->format->BytesPerPixel*8), 0, 0, 0, 0); - Uint32 boxColor = SDL_MapRGB(screen->format, 255, 0, 255); - SDL_Rect sourceRect; - sourceRect.x = sourceRect.y = 0; - sourceRect.w = 20; - sourceRect.h = 20; - if ( dWindowSurface ) - { - SDL_FillRect(dWindowSurface, &sourceRect, boxColor); - //SDL_SetAlpha(chatBoxBackground, SDL_SRCALPHA, 120); - } + dBackground->setAlpha(0.7f); + dBorders->setAlpha(0.7f); + dUpperBorder->setAlpha(0.7f); + dLeftBorder->setAlpha(0.7f); + dRightBorder->setAlpha(0.7f); + dLowerBorder->setAlpha(0.7f); // Register mouse listener addMouseListener(this); @@ -86,7 +85,6 @@ Window::~Window() log("Window::~Window(\"%s\")", caption.c_str()); // Free dialog bitmaps - SDL_FreeSurface(dWindowSurface); //release_bitmap(dLeft); //release_bitmap(dMid); //release_bitmap(dRight); @@ -102,58 +100,25 @@ void Window::setWindowContainer(WindowContainer *wc) void Window::draw(gcn::Graphics* graphics) { - // Resize the Window Image if it's has to be done - if ( (dWindowSurface->w != getWidth()) || (dWindowSurface->h != getHeight()) ) - { - SDL_FreeSurface(dWindowSurface); - dWindowSurface = SDL_AllocSurface(SDL_SWSURFACE | SDL_SRCCOLORKEY | SDL_SRCALPHA, getWidth(), getHeight(), - (screen->format->BytesPerPixel*8), 0, 0, 0, 0); - SDL_Rect sourceRect; - sourceRect.x = sourceRect.y = 0; - sourceRect.w = getWidth(); - sourceRect.h = getHeight(); - if ( dWindowSurface ) - { - // Draw the background - dBackground->drawPattern(dWindowSurface, 0, 0, getWidth(), getHeight()); - // Draw the borders - dBorders->draw(dWindowSurface, 0, 0, 0, 0, 4, 4); // Top-Left - dBorders->draw(dWindowSurface, 7, 0, getWidth()-3, 0, 4, 4); // Top-Right - dBorders->draw(dWindowSurface, 7, 15, getWidth()-3, getHeight()-3, 4, 4); // Bottom-Right - dBorders->draw(dWindowSurface, 0, 15, 0, getHeight()-3, 4, 4); // Bottom-Left - - // Upper Border - Image *dTemp = dBorders->getSubImage(4,0,1,3); - dTemp->drawPattern(dWindowSurface, 4, 0, getWidth()-4-3, 3); - delete dTemp; - // Left Border - dTemp = dBorders->getSubImage(0,4,3,1); - dTemp->drawPattern(dWindowSurface, 0, 4, 3, getHeight()-4-3); - delete dTemp; - // Right Border - dTemp = dBorders->getSubImage(8,4,3,1); - dTemp->drawPattern(dWindowSurface, getWidth()-2, 4, 3, getHeight()-4-3); - delete dTemp; - // Bottom Border - dTemp = dBorders->getSubImage(8,15,1,3); - dTemp->drawPattern(dWindowSurface, 4, getHeight()-2, getWidth()-4-3, 3); - delete dTemp; - - SDL_SetAlpha(dWindowSurface, SDL_SRCALPHA, 160); - } - - } - int x, y; - getAbsolutePosition(x, y); - - // Draw the window image - SDL_Rect screenRect; - screenRect.w = getWidth(); - screenRect.h = getHeight(); - screenRect.x = x; - screenRect.y = y; - if ( dWindowSurface ) SDL_BlitSurface(dWindowSurface, NULL, screen, &screenRect); + getAbsolutePosition(x, y); + + // Draw the background + dBackground->drawPattern(screen, x, y, getWidth(), getHeight()); + // Draw the borders + dBorders->draw(screen, 0, 0, x-1, y-1, 4, 4); // Top-Left + dBorders->draw(screen, 7, 0, x+getWidth()-3, y-1, 4, 4); // Top-Right + dBorders->draw(screen, 7, 15, x+getWidth()-3, y+getHeight()-3, 4, 4); // Bottom-Right + dBorders->draw(screen, 0, 15, x-1, y+getHeight()-3, 4, 4); // Bottom-Left + + // Upper Border + dUpperBorder->drawPattern(screen, x+3, y-1, getWidth()-4-2, 3); + // Left Border + dLeftBorder->drawPattern(screen, x-1, y+3, 3, getHeight()-4-2); + // Right Border + dRightBorder->drawPattern(screen, x+getWidth()-2, y+3, 3, getHeight()-4-2); + // Lower Border + dLowerBorder->drawPattern(screen, x+3, y+getHeight()-2, getWidth()-4-2, 3); // Draw title graphics->setFont(getFont()); |