From b3f70d8d46199524edc590269a73c262899763c7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 8 Sep 2011 00:07:56 +0300 Subject: Replace most iterator to const_iterator. Some other minor changes. --- src/gui/widgets/window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui/widgets/window.cpp') diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 4435496a7..9709f4c8a 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -373,7 +373,7 @@ void Window::widgetHidden(const gcn::Event &event A_UNUSED) if (!mFocusHandler) return; - for (it = mWidgets.begin(); it != mWidgets.end(); it++) + for (it = mWidgets.begin(); it != mWidgets.end(); ++ it) { if (mFocusHandler->isFocused(*it)) mFocusHandler->focusNone(); -- cgit v1.2.3-60-g2f50 From 4484b433abc8f07bcf7d4d22fd946e00b66b078d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 9 Sep 2011 19:43:40 +0300 Subject: Fix first part of shadow variables/methods errors. --- src/client.cpp | 30 +++++----- src/game.cpp | 12 ++-- src/graphics.h | 2 +- src/gui/changeemaildialog.cpp | 18 +++--- src/gui/changeemaildialog.h | 2 +- src/gui/changepassworddialog.cpp | 20 +++---- src/gui/changepassworddialog.h | 2 +- src/gui/charselectdialog.cpp | 10 ++-- src/gui/charselectdialog.h | 2 +- src/gui/chatwindow.cpp | 4 +- src/gui/palette.h | 13 +++-- src/gui/popupmenu.cpp | 8 +-- src/gui/setup_video.cpp | 30 +++++----- src/gui/spellpopup.cpp | 8 +-- src/gui/statuspopup.cpp | 6 +- src/gui/textpopup.cpp | 6 +- src/gui/widgets/avatarlistbox.cpp | 3 +- src/gui/widgets/browserbox.cpp | 14 ++--- src/gui/widgets/popup.cpp | 10 ++-- src/gui/widgets/progressbar.h | 4 +- src/gui/widgets/window.cpp | 84 +++++++++++++-------------- src/gui/windowmenu.cpp | 8 +-- src/guichan/cliprectangle.cpp | 16 ++--- src/guichan/include/guichan/cliprectangle.hpp | 32 +++++----- src/guichan/include/guichan/inputevent.hpp | 8 +-- src/guichan/include/guichan/keyevent.hpp | 20 +++---- src/guichan/include/guichan/mouseevent.hpp | 16 ++--- src/guichan/inputevent.cpp | 16 ++--- src/guichan/keyevent.cpp | 20 +++---- src/guichan/mouseevent.cpp | 16 ++--- src/map.h | 6 +- src/position.h | 4 +- src/resources/ambientlayer.cpp | 8 +-- src/resources/colordb.h | 8 +-- src/resources/itemdb.h | 8 +-- src/resources/spritedef.h | 6 +- src/vector.h | 8 +-- 37 files changed, 242 insertions(+), 246 deletions(-) (limited to 'src/gui/widgets/window.cpp') diff --git a/src/client.cpp b/src/client.cpp index 472c862e6..b9e9735c9 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -140,11 +140,11 @@ Configuration config; /**< XML file configuration reader */ Configuration serverConfig; /**< XML file server configuration reader */ Configuration branding; /**< XML branding information reader */ Configuration paths; /**< XML default paths information reader */ -Logger *logger; /**< Log object */ -ChatLogger *chatLogger; /**< Chat log object */ +Logger *logger = 0; /**< Log object */ +ChatLogger *chatLogger = 0; /**< Chat log object */ KeyboardConfig keyboard; -UserPalette *userPalette; -Graphics *graphics; +UserPalette *userPalette = 0; +Graphics *mainGraphics = 0; Sound sound; @@ -440,20 +440,20 @@ Client::Client(const Options &options): switch(useOpenGL) { case 0: - graphics = new Graphics; + mainGraphics = new Graphics; break; case 1: default: - graphics = new OpenGLGraphics; + mainGraphics = new OpenGLGraphics; break; case 2: - graphics = new OpenGL1Graphics; + mainGraphics = new OpenGL1Graphics; break; }; #else // Create the graphics context - graphics = new Graphics; + mainGraphics = new Graphics; #endif runCounters = config.getBoolValue("packetcounters"); @@ -465,7 +465,7 @@ Client::Client(const Options &options): const bool hwaccel = config.getBoolValue("hwaccel"); // Try to set the desired video mode - if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel)) + if (!mainGraphics->setVideoMode(width, height, bpp, fullscreen, hwaccel)) { logger->log(strprintf("Couldn't set %dx%dx%d video mode: %s", width, height, bpp, SDL_GetError())); @@ -482,7 +482,7 @@ Client::Client(const Options &options): config.setValueInt("screenwidth", oldWidth); config.setValueInt("screenheight", oldHeight); config.setValue("screen", oldFullscreen); - if (!graphics->setVideoMode(oldWidth, oldHeight, bpp, + if (!mainGraphics->setVideoMode(oldWidth, oldHeight, bpp, oldFullscreen, hwaccel)) { logger->error(strprintf("Couldn't restore %dx%dx%d " @@ -493,7 +493,7 @@ Client::Client(const Options &options): } // Initialize for drawing - graphics->_beginDraw(); + mainGraphics->_beginDraw(); Theme::selectSkin(); // Theme::prepareThemePath(); @@ -507,7 +507,7 @@ Client::Client(const Options &options): // Initialize the drop shortcuts. dropShortcut = new DropShortcut; - gui = new Gui(graphics); + gui = new Gui(mainGraphics); // Initialize sound engine try @@ -645,8 +645,8 @@ Client::~Client() logger->log1("Quitting3"); - delete graphics; - graphics = 0; + delete mainGraphics; + mainGraphics = 0; logger->log1("Quitting4"); @@ -760,7 +760,7 @@ int Client::exec() frame_count++; if (gui) gui->draw(); - graphics->updateScreen(); + mainGraphics->updateScreen(); // logger->log("active"); } else diff --git a/src/game.cpp b/src/game.cpp index aaa9694bf..a0635f42f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -371,8 +371,8 @@ Game::Game(): // Create the viewport viewport = new Viewport; - viewport->setDimension(gcn::Rectangle(0, 0, graphics->mWidth, - graphics->mHeight)); + viewport->setDimension(gcn::Rectangle(0, 0, mainGraphics->mWidth, + mainGraphics->mHeight)); gcn::Container *top = static_cast(gui->getTop()); top->add(viewport); @@ -459,14 +459,14 @@ static bool saveScreenshot() if (!config.getBoolValue("showip")) { - graphics->setSecure(true); + mainGraphics->setSecure(true); gui->draw(); - screenshot = graphics->getScreenshot(); - graphics->setSecure(false); + screenshot = mainGraphics->getScreenshot(); + mainGraphics->setSecure(false); } else { - screenshot = graphics->getScreenshot(); + screenshot = mainGraphics->getScreenshot(); } if (!screenshot) diff --git a/src/graphics.h b/src/graphics.h index 53b4b7c72..f3e0bd05d 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -292,6 +292,6 @@ class Graphics : public gcn::SDLGraphics bool mSecure; }; -extern Graphics *graphics; +extern Graphics *mainGraphics; #endif diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index c24624bc2..69af649e2 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -44,10 +44,10 @@ #include "debug.h" -ChangeEmailDialog::ChangeEmailDialog(LoginData *loginData): +ChangeEmailDialog::ChangeEmailDialog(LoginData *data): Window(_("Change Email Address"), true), mWrongDataNoticeListener(new WrongDataNoticeListener), - mLoginData(loginData) + mLoginData(data) { gcn::Label *accountLabel = new Label(strprintf(_("Account: %s"), mLoginData->username.c_str())); @@ -120,7 +120,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) logger->log("ChangeEmailDialog::Email change, Username is %s", username.c_str()); - std::stringstream errorMessage; + std::stringstream errorMsg; int error = 0; unsigned int min = Net::getLoginHandler()->getMinPasswordLength(); @@ -129,21 +129,21 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) if (newFirstEmail.length() < min) { // First email address too short - errorMessage << strprintf(_("The new email address needs to be at " - "least %d characters long."), min); + errorMsg << strprintf(_("The new email address needs to be at " + "least %d characters long."), min); error = 1; } else if (newFirstEmail.length() > max - 1 ) { // First email address too long - errorMessage << strprintf(_("The new email address needs to be " - "less than %d characters long."), max); + errorMsg << strprintf(_("The new email address needs to be " + "less than %d characters long."), max); error = 1; } else if (newFirstEmail != newSecondEmail) { // Second Pass mismatch - errorMessage << _("The email address entries mismatch."); + errorMsg << _("The email address entries mismatch."); error = 2; } @@ -154,7 +154,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) else if (error == 2) mWrongDataNoticeListener->setTarget(this->mSecondEmailField); - OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str()); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str()); if (dlg) dlg->addActionListener(mWrongDataNoticeListener); } diff --git a/src/gui/changeemaildialog.h b/src/gui/changeemaildialog.h index e130a9074..fccb5cb1c 100644 --- a/src/gui/changeemaildialog.h +++ b/src/gui/changeemaildialog.h @@ -46,7 +46,7 @@ class ChangeEmailDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - ChangeEmailDialog(LoginData *loginData); + ChangeEmailDialog(LoginData *data); /** * Destructor. diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 30012ae52..56db37ebb 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -46,10 +46,10 @@ #include "debug.h" -ChangePasswordDialog::ChangePasswordDialog(LoginData *loginData): +ChangePasswordDialog::ChangePasswordDialog(LoginData *data): Window(_("Change Password"), true), mWrongDataNoticeListener(new WrongDataNoticeListener), - mLoginData(loginData) + mLoginData(data) { gcn::Label *accountLabel = new Label( strprintf(_("Account: %s"), mLoginData->username.c_str())); @@ -101,7 +101,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) logger->log("ChangePasswordDialog::Password change, Username is %s", username.c_str()); - std::stringstream errorMessage; + std::stringstream errorMsg; int error = 0; unsigned int min = Net::getLoginHandler()->getMinPasswordLength(); @@ -111,27 +111,27 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) if (oldPassword.empty()) { // No old password - errorMessage << _("Enter the old password first."); + errorMsg << _("Enter the old password first."); error = 1; } else if (newFirstPass.length() < min) { // First password too short - errorMessage << strprintf(_("The new password needs to be at least" - " %d characters long."), min); + errorMsg << strprintf(_("The new password needs to be at least" + " %d characters long."), min); error = 2; } else if (newFirstPass.length() > max - 1 ) { // First password too long - errorMessage << strprintf(_("The new password needs to be less " - "than %d characters long."), max); + errorMsg << strprintf(_("The new password needs to be less " + "than %d characters long."), max); error = 2; } else if (newFirstPass != newSecondPass) { // Second Pass mismatch - errorMessage << _("The new password entries mismatch."); + errorMsg << _("The new password entries mismatch."); error = 3; } @@ -144,7 +144,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) else if (error == 3) mWrongDataNoticeListener->setTarget(this->mSecondPassField); - OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str()); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str()); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/changepassworddialog.h b/src/gui/changepassworddialog.h index 3b0626922..fca8b4946 100644 --- a/src/gui/changepassworddialog.h +++ b/src/gui/changepassworddialog.h @@ -46,7 +46,7 @@ class ChangePasswordDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - ChangePasswordDialog(LoginData *loginData); + ChangePasswordDialog(LoginData *data); /** * Destructor diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 75468d1ab..f926a90aa 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -121,20 +121,20 @@ class CharacterDisplay : public Container Button *mDelete; }; -CharSelectDialog::CharSelectDialog(LoginData *loginData): +CharSelectDialog::CharSelectDialog(LoginData *data): Window(_("Account and Character Management")), mLocked(false), mUnregisterButton(0), mChangeEmailButton(0), mCharacterEntries(0), - mLoginData(loginData), + mLoginData(data), mCharHandler(Net::getCharHandler()), mDeleteDialog(0), mDeleteIndex(-1) { setCloseButton(false); - mAccountNameLabel = new Label(loginData->username); + mAccountNameLabel = new Label(mLoginData->username); mSwitchLoginButton = new Button(_("Switch Login"), "switch", this); mChangePasswordButton = new Button(_("Change Password"), "change_password", this); @@ -373,7 +373,7 @@ void CharSelectDialog::setLocked(bool locked) } bool CharSelectDialog::selectByName(const std::string &name, - SelectAction action) + SelectAction selAction) { if (mLocked) return false; @@ -387,7 +387,7 @@ bool CharSelectDialog::selectByName(const std::string &name, { if (mCharacterEntries[i]) mCharacterEntries[i]->requestFocus(); - if (action == Choose) + if (selAction == Choose) attemptCharacterSelect(i); return true; } diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h index bcbbb7679..0dfe90733 100644 --- a/src/gui/charselectdialog.h +++ b/src/gui/charselectdialog.h @@ -60,7 +60,7 @@ class CharSelectDialog : public Window, public gcn::ActionListener, /** * Constructor. */ - CharSelectDialog(LoginData *loginData); + CharSelectDialog(LoginData *data); ~CharSelectDialog(); diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 639125739..1b9877363 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -666,8 +666,8 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event) { int newX = std::max(0, getX() + event.getX() - mDragOffsetX); int newY = std::max(0, getY() + event.getY() - mDragOffsetY); - newX = std::min(graphics->mWidth - getWidth(), newX); - newY = std::min(graphics->mHeight - getHeight(), newY); + newX = std::min(mainGraphics->mWidth - getWidth(), newX); + newY = std::min(mainGraphics->mHeight - getHeight(), newY); setPosition(newX, newY); } } diff --git a/src/gui/palette.h b/src/gui/palette.h index 1cebe236f..645260280 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -182,13 +182,14 @@ class Palette int delay; int committedDelay; - void set(int type, gcn::Color& color, GradientType grad, int delay) + void set(int type0, gcn::Color& color0, GradientType grad0, + int delay0) { - ColorElem::type = type; - ColorElem::color = color; - ColorElem::testColor = color; - ColorElem::grad = grad; - ColorElem::delay = delay; + ColorElem::type = type0; + ColorElem::color = color0; + ColorElem::testColor = color0; + ColorElem::grad = grad0; + ColorElem::delay = delay0; ColorElem::gradientIndex = rand(); } diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index a329488ce..7e43c9954 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -2029,10 +2029,10 @@ void PopupMenu::showUndressPopup(int x, int y, Being *being, Item *item) void PopupMenu::showPopup(int x, int y) { setContentSize(mBrowserBox->getWidth() + 8, mBrowserBox->getHeight() + 8); - if (graphics->mWidth < (x + getWidth() + 5)) - x = graphics->mWidth - getWidth(); - if (graphics->mHeight < (y + getHeight() + 5)) - y = graphics->mHeight - getHeight(); + if (mainGraphics->mWidth < (x + getWidth() + 5)) + x = mainGraphics->mWidth - getWidth(); + if (mainGraphics->mHeight < (y + getHeight() + 5)) + y = mainGraphics->mHeight - getHeight(); setPosition(x, y); setVisible(true); requestMoveToTop(); diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 0bfab1438..7bbcd9a2c 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -59,7 +59,7 @@ #include "debug.h" -extern Graphics *graphics; +extern Graphics *mainGraphics; /** * The list model for mode list. @@ -157,8 +157,8 @@ ModeListModel::ModeListModel() addCustomMode("1280x1024"); addCustomMode("1400x900"); addCustomMode("1500x990"); - addCustomMode(toString(graphics->mWidth) + "x" - + toString(graphics->mHeight)); + addCustomMode(toString(mainGraphics->mWidth) + "x" + + toString(mainGraphics->mHeight)); std::sort(mVideoModes.begin(), mVideoModes.end(), modeSorter); mVideoModes.push_back("custom"); @@ -348,8 +348,8 @@ Setup_Video::Setup_Video(): mFpsCheckBox->setSelected(mFps > 0); // Pre-select the current video mode. - std::string videoMode = toString(graphics->mWidth) + "x" - + toString(graphics->mHeight); + std::string videoMode = toString(mainGraphics->mWidth) + "x" + + toString(mainGraphics->mHeight); mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); mModeList->setActionEventId("videomode"); @@ -473,10 +473,10 @@ void Setup_Video::apply() if (!config.getIntValue("opengl")) { #endif - if (!graphics->setFullscreen(fullscreen)) + if (!mainGraphics->setFullscreen(fullscreen)) { fullscreen = !fullscreen; - if (!graphics->setFullscreen(fullscreen)) + if (!mainGraphics->setFullscreen(fullscreen)) { std::stringstream errorMessage; if (fullscreen) @@ -564,11 +564,11 @@ void Setup_Video::cancel() config.setValue("screen", mFullScreenEnabled); // Set back to the current video mode. - std::string videoMode = toString(graphics->mWidth) + "x" - + toString(graphics->mHeight); + std::string videoMode = toString(mainGraphics->mWidth) + "x" + + toString(mainGraphics->mHeight); mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); - config.setValue("screenwidth", graphics->mWidth); - config.setValue("screenheight", graphics->mHeight); + config.setValue("screenwidth", mainGraphics->mWidth); + config.setValue("screenheight", mainGraphics->mHeight); config.setValue("customcursor", mCustomCursorEnabled); config.setValue("particleeffects", mParticleEffectsEnabled); @@ -612,9 +612,9 @@ void Setup_Video::action(const gcn::ActionEvent &event) return; // TODO: Find out why the drawing area doesn't resize without a restart. - if (width != graphics->mWidth || height != graphics->mHeight) + if (width != mainGraphics->mWidth || height != mainGraphics->mHeight) { - if (width < graphics->mWidth || height < graphics->mHeight) + if (width < mainGraphics->mWidth || height < mainGraphics->mHeight) new OkDialog(_("Screen Resolution Changed"), _("Restart your client for the change to take effect.") + std::string("\n") + @@ -625,8 +625,8 @@ void Setup_Video::action(const gcn::ActionEvent &event) } config.setValue("oldscreen", config.getBoolValue("screen")); - config.setValue("oldscreenwidth", graphics->mWidth); - config.setValue("oldscreenheight", graphics->mHeight); + config.setValue("oldscreenwidth", mainGraphics->mWidth); + config.setValue("oldscreenheight", mainGraphics->mHeight); config.setValue("screenwidth", width); config.setValue("screenheight", height); } diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp index a918e037d..f87e691de 100644 --- a/src/gui/spellpopup.cpp +++ b/src/gui/spellpopup.cpp @@ -80,14 +80,14 @@ void SpellPopup::view(int x, int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->mWidth) + if (posX + getWidth() > mainGraphics->mWidth) { - if (graphics->mWidth > getWidth()) - posX = graphics->mWidth - getWidth(); + if (mainGraphics->mWidth > getWidth()) + posX = mainGraphics->mWidth - getWidth(); else posX = 0; } - if (posY + getHeight() > graphics->mHeight) + if (posY + getHeight() > mainGraphics->mHeight) { if (y > getHeight() + distance) posY = y - getHeight() - distance; diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp index bb7a295ab..9214f1406 100644 --- a/src/gui/statuspopup.cpp +++ b/src/gui/statuspopup.cpp @@ -169,9 +169,9 @@ void StatusPopup::view(int x, int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->mWidth) - posX = graphics->mWidth - getWidth(); - if (posY + getHeight() > graphics->mHeight) + if (posX + getWidth() > mainGraphics->mWidth) + posX = mainGraphics->mWidth - getWidth(); + if (posY + getHeight() > mainGraphics->mHeight) posY = y - getHeight() - distance; update(); diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp index 1ff601154..65c712461 100644 --- a/src/gui/textpopup.cpp +++ b/src/gui/textpopup.cpp @@ -96,9 +96,9 @@ void TextPopup::show(int x, int y, const std::string &str1, int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->mWidth) - posX = graphics->mWidth - getWidth(); - if (posY + getHeight() > graphics->mHeight) + if (posX + getWidth() > mainGraphics->mWidth) + posX = mainGraphics->mWidth - getWidth(); + if (posY + getHeight() > mainGraphics->mHeight) posY = y - getHeight() - distance; setPosition(posX, posY); diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index d4764cba5..29fca7662 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -373,7 +373,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) default: { Map *map = viewport->getMap(); - Avatar *ava = model->getAvatarAt(selected); + ava = model->getAvatarAt(selected); if (map && ava) { MapItem *mapItem = map->findPortalXY( @@ -384,7 +384,6 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) } } } - else if (event.getButton() == gcn::MouseEvent::MIDDLE) { if (ava->getType() == AVATAR_PLAYER && chatWindow) diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 65a25363d..c20eb4622 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -210,23 +210,23 @@ void BrowserBox::addRow(const std::string &row, bool atTop) for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); ++i) { - std::string row = *i; - for (unsigned int j = 0; j < row.size(); j++) + std::string tempRow = *i; + for (unsigned int j = 0; j < tempRow.size(); j++) { - std::string character = row.substr(j, 1); + std::string character = tempRow.substr(j, 1); x += font->getWidth(character); nextChar = j + 1; // Wraping between words (at blank spaces) - if ((nextChar < row.size()) && (row.at(nextChar) == ' ')) + if (nextChar < tempRow.size() && tempRow.at(nextChar) == ' ') { int nextSpacePos = static_cast( - row.find(" ", (nextChar + 1))); + tempRow.find(" ", (nextChar + 1))); if (nextSpacePos <= 0) - nextSpacePos = static_cast(row.size()) - 1; + nextSpacePos = static_cast(tempRow.size()) - 1; unsigned nextWordWidth = font->getWidth( - row.substr(nextChar, + tempRow.substr(nextChar, (nextSpacePos - nextChar))); if ((x + nextWordWidth + 10) > (unsigned)getWidth()) diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 38088770b..ebfdbe303 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -44,8 +44,8 @@ Popup::Popup(const std::string &name, const std::string &skin): mPopupName(name), mMinWidth(100), mMinHeight(40), - mMaxWidth(graphics->mWidth), - mMaxHeight(graphics->mHeight), + mMaxWidth(mainGraphics->mWidth), + mMaxHeight(mainGraphics->mHeight), mVertexes(new GraphicsVertexes()), mRedraw(true) { @@ -190,9 +190,9 @@ void Popup::position(int x, int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->mWidth) - posX = graphics->mWidth - getWidth(); - if (posY + getHeight() > graphics->mHeight) + if (posX + getWidth() > mainGraphics->mWidth) + posX = mainGraphics->mWidth - getWidth(); + if (posY + getHeight() > mainGraphics->mHeight) posY = y - getHeight() - distance; setPosition(posX, posY); diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 52a26ddac..36ed96bd2 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -94,8 +94,8 @@ class ProgressBar : public gcn::Widget, public gcn::WidgetListener /** * Sets the text shown on the progress bar. */ - void setText(const std::string &text) - { mText = text; } + void setText(const std::string &str) + { mText = str; } /** * Returns the text shown on the progress bar. diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 9709f4c8a..05509ab39 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -63,8 +63,8 @@ Window::Window(const std::string &caption, bool modal, Window *parent, mStickyButtonLock(false), mMinWinWidth(100), mMinWinHeight(40), - mMaxWinWidth(graphics->mWidth), - mMaxWinHeight(graphics->mHeight), + mMaxWinWidth(mainGraphics->mWidth), + mMaxWinHeight(mainGraphics->mHeight), mVertexes(new GraphicsVertexes()), mRedraw(true) { @@ -244,39 +244,39 @@ void Window::setLocationRelativeTo(ImageRect::ImagePosition position, } else if (position == ImageRect::UPPER_CENTER) { - offsetX += (graphics->mWidth - getWidth()) / 2; + offsetX += (mainGraphics->mWidth - getWidth()) / 2; } else if (position == ImageRect::UPPER_RIGHT) { - offsetX += graphics->mWidth - getWidth(); + offsetX += mainGraphics->mWidth - getWidth(); } else if (position == ImageRect::LEFT) { - offsetY += (graphics->mHeight - getHeight()) / 2; + offsetY += (mainGraphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::CENTER) { - offsetX += (graphics->mWidth - getWidth()) / 2; - offsetY += (graphics->mHeight - getHeight()) / 2; + offsetX += (mainGraphics->mWidth - getWidth()) / 2; + offsetY += (mainGraphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::RIGHT) { - offsetX += graphics->mWidth - getWidth(); - offsetY += (graphics->mHeight - getHeight()) / 2; + offsetX += mainGraphics->mWidth - getWidth(); + offsetY += (mainGraphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::LOWER_LEFT) { - offsetY += graphics->mHeight - getHeight(); + offsetY += mainGraphics->mHeight - getHeight(); } else if (position == ImageRect::LOWER_CENTER) { - offsetX += (graphics->mWidth - getWidth()) / 2; - offsetY += graphics->mHeight - getHeight(); + offsetX += (mainGraphics->mWidth - getWidth()) / 2; + offsetY += mainGraphics->mHeight - getHeight(); } else if (position == ImageRect::LOWER_RIGHT) { - offsetX += graphics->mWidth - getWidth(); - offsetY += graphics->mHeight - getHeight(); + offsetX += mainGraphics->mWidth - getWidth(); + offsetY += mainGraphics->mHeight - getHeight(); } setPosition(offsetX, offsetY); @@ -579,8 +579,8 @@ void Window::mouseDragged(gcn::MouseEvent &event) { int newX = std::max(0, getX()); int newY = std::max(0, getY()); - newX = std::min(graphics->mWidth - getWidth(), newX); - newY = std::min(graphics->mHeight - getHeight(), newY); + newX = std::min(mainGraphics->mWidth - getWidth(), newX); + newY = std::min(mainGraphics->mHeight - getHeight(), newY); setPosition(newX, newY); } @@ -621,14 +621,10 @@ void Window::mouseDragged(gcn::MouseEvent &event) newDim.height += newDim.y; newDim.y = 0; } - if (newDim.x + newDim.width > graphics->mWidth) - { - newDim.width = graphics->mWidth - newDim.x; - } - if (newDim.y + newDim.height > graphics->mHeight) - { - newDim.height = graphics->mHeight - newDim.y; - } + if (newDim.x + newDim.width > mainGraphics->mWidth) + newDim.width = mainGraphics->mWidth - newDim.x; + if (newDim.y + newDim.height > mainGraphics->mHeight) + newDim.height = mainGraphics->mHeight - newDim.y; // Update mouse offset when dragging bottom or right border if (mouseResize & BOTTOM) @@ -790,39 +786,39 @@ void Window::setDefaultSize(int defaultWidth, int defaultHeight, } else if (position == ImageRect::UPPER_CENTER) { - x = (graphics->mWidth - defaultWidth) / 2; + x = (mainGraphics->mWidth - defaultWidth) / 2; } else if (position == ImageRect::UPPER_RIGHT) { - x = graphics->mWidth - defaultWidth; + x = mainGraphics->mWidth - defaultWidth; } else if (position == ImageRect::LEFT) { - y = (graphics->mHeight - defaultHeight) / 2; + y = (mainGraphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::CENTER) { - x = (graphics->mWidth - defaultWidth) / 2; - y = (graphics->mHeight - defaultHeight) / 2; + x = (mainGraphics->mWidth - defaultWidth) / 2; + y = (mainGraphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::RIGHT) { - x = graphics->mWidth - defaultWidth; - y = (graphics->mHeight - defaultHeight) / 2; + x = mainGraphics->mWidth - defaultWidth; + y = (mainGraphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::LOWER_LEFT) { - y = graphics->mHeight - defaultHeight; + y = mainGraphics->mHeight - defaultHeight; } else if (position == ImageRect::LOWER_CENTER) { - x = (graphics->mWidth - defaultWidth) / 2; - y = graphics->mHeight - defaultHeight; + x = (mainGraphics->mWidth - defaultWidth) / 2; + y = mainGraphics->mHeight - defaultHeight; } else if (position == ImageRect::LOWER_RIGHT) { - x = graphics->mWidth - defaultWidth; - y = graphics->mHeight - defaultHeight; + x = mainGraphics->mWidth - defaultWidth; + y = mainGraphics->mHeight - defaultHeight; } mDefaultX = x - offsetX; @@ -994,11 +990,11 @@ void Window::checkIfIsOffScreen(bool partially, bool entirely) // Look if the window is partially off-screen limits... if (partially) { - if (winDimension.x + winDimension.width > graphics->mWidth) - winDimension.x = graphics->mWidth - winDimension.width; + if (winDimension.x + winDimension.width > mainGraphics->mWidth) + winDimension.x = mainGraphics->mWidth - winDimension.width; - if (winDimension.y + winDimension.height > graphics->mHeight) - winDimension.y = graphics->mHeight - winDimension.height; + if (winDimension.y + winDimension.height > mainGraphics->mHeight) + winDimension.y = mainGraphics->mHeight - winDimension.height; setDimension(winDimension); return; @@ -1006,11 +1002,11 @@ void Window::checkIfIsOffScreen(bool partially, bool entirely) if (entirely) { - if (winDimension.x > graphics->mWidth) - winDimension.x = graphics->mWidth - winDimension.width; + if (winDimension.x > mainGraphics->mWidth) + winDimension.x = mainGraphics->mWidth - winDimension.width; - if (winDimension.y > graphics->mHeight) - winDimension.y = graphics->mHeight - winDimension.height; + if (winDimension.y > mainGraphics->mHeight) + winDimension.y = mainGraphics->mHeight - winDimension.height; } setDimension(winDimension); } diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 8431cece1..eaec791ee 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -99,9 +99,9 @@ WindowMenu::WindowMenu(): KeyboardConfig::KEY_WINDOW_DIDYOUKNOW); addButton(N_("SET"), _("Setup"), x, h, KeyboardConfig::KEY_WINDOW_SETUP); - if (graphics) + if (mainGraphics) { - setDimension(gcn::Rectangle(graphics->mWidth - x - 3, + setDimension(gcn::Rectangle(mainGraphics->mWidth - x - 3, 3, x - 3, h)); } @@ -345,9 +345,9 @@ void WindowMenu::updateButtons() h = btn->getHeight(); } } - if (graphics) + if (mainGraphics) { - setDimension(gcn::Rectangle(graphics->mWidth - x - 3, + setDimension(gcn::Rectangle(mainGraphics->mWidth - x - 3, 3, x - 3, h)); } } diff --git a/src/guichan/cliprectangle.cpp b/src/guichan/cliprectangle.cpp index feaa47729..6effb48c8 100644 --- a/src/guichan/cliprectangle.cpp +++ b/src/guichan/cliprectangle.cpp @@ -61,15 +61,15 @@ namespace gcn yOffset = 0; } - ClipRectangle::ClipRectangle(int x, int y, int width, int height, - int xOffset, int yOffset) + ClipRectangle::ClipRectangle(int x0, int y0, int width0, int height0, + int xOffset0, int yOffset0) { - this->x = x; - this->y = y; - this->width = width; - this->height = height; - this->xOffset = xOffset; - this->yOffset = yOffset; + x = x0; + y = y0; + width = width0; + height = height0; + xOffset = xOffset0; + yOffset = yOffset0; } const ClipRectangle& ClipRectangle::operator=(const Rectangle& other) diff --git a/src/guichan/include/guichan/cliprectangle.hpp b/src/guichan/include/guichan/cliprectangle.hpp index 792c40bb9..b5aa5e4af 100644 --- a/src/guichan/include/guichan/cliprectangle.hpp +++ b/src/guichan/include/guichan/cliprectangle.hpp @@ -67,23 +67,23 @@ namespace gcn /** * Constructor. * - * @param x The rectangle x coordinate. - * @param y The rectangle y coordinate. - * @param width The rectangle width. - * @param height The rectangle height. - * @param xOffset The offset of the x coordinate. Used to for - * calculating the actual screen coordinate from - * the relative screen coordinate. - * @param yOffset The offset of the y coordinate. Used to for - * calculating the actual screen coordinate from - * the relative screen coordinate. + * @param x0 The rectangle x coordinate. + * @param y0 The rectangle y coordinate. + * @param width0 The rectangle width. + * @param height0 The rectangle height. + * @param xOffset0 The offset of the x coordinate. Used to for + * calculating the actual screen coordinate from + * the relative screen coordinate. + * @param yOffset0 The offset of the y coordinate. Used to for + * calculating the actual screen coordinate from + * the relative screen coordinate. */ - ClipRectangle(int x, - int y, - int width, - int height, - int xOffset, - int yOffset); + ClipRectangle(int x0, + int y0, + int width0, + int height0, + int xOffset0, + int yOffset0); /** * Copy constructor. Copies x, y, width and height diff --git a/src/guichan/include/guichan/inputevent.hpp b/src/guichan/include/guichan/inputevent.hpp index 8594d3dae..f252341cf 100644 --- a/src/guichan/include/guichan/inputevent.hpp +++ b/src/guichan/include/guichan/inputevent.hpp @@ -69,10 +69,10 @@ namespace gcn * @param isMetaPressed True if meta is pressed, false otherwise. */ InputEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed); + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed); /** * Checks if shift is pressed. diff --git a/src/guichan/include/guichan/keyevent.hpp b/src/guichan/include/guichan/keyevent.hpp index f42601235..5c10238c5 100644 --- a/src/guichan/include/guichan/keyevent.hpp +++ b/src/guichan/include/guichan/keyevent.hpp @@ -71,22 +71,22 @@ namespace gcn * Constructor. * * @param source The source widget of the event. - * @param isShiftPressed True if shift is pressed, false otherwise. - * @param isControlPressed True if control is pressed, false otherwise. - * @param isAltPressed True if alt is pressed, false otherwise. - * @param isMetaPressed True if meta is pressed, false otherwise. + * @param shiftPressed True if shift is pressed, false otherwise. + * @param controlPressed True if control is pressed, false otherwise. + * @param altPressed True if alt is pressed, false otherwise. + * @param metaPressed True if meta is pressed, false otherwise. * @param type The type of the event. A value from KeyEventType. - * @param isNumericPad True if the event occured on the numeric pad, + * @param numericPad True if the event occured on the numeric pad, * false otherwise. * @param key The key of the event. */ KeyEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed, + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed, unsigned int type, - bool isNumericPad, + bool numericPad, const Key& key); /** diff --git a/src/guichan/include/guichan/mouseevent.hpp b/src/guichan/include/guichan/mouseevent.hpp index 280d373e6..6f6dc828c 100644 --- a/src/guichan/include/guichan/mouseevent.hpp +++ b/src/guichan/include/guichan/mouseevent.hpp @@ -66,10 +66,10 @@ namespace gcn * Constructor. * * @param source The source widget of the mouse event. - * @param isShiftPressed True if shift is pressed, false otherwise. - * @param isControlPressed True if control is pressed, false otherwise. - * @param isAltPressed True if alt is pressed, false otherwise. - * @param isMetaPressed True if meta is pressed, false otherwise. + * @param shiftPressed True if shift is pressed, false otherwise. + * @param controlPressed True if control is pressed, false otherwise. + * @param altPressed True if alt is pressed, false otherwise. + * @param metaPressed True if meta is pressed, false otherwise. * @param type The type of the mouse event. * @param button The button of the mouse event. * @param x The x coordinate of the event relative to the source widget. @@ -78,10 +78,10 @@ namespace gcn * It's set to zero if another button is used. */ MouseEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed, + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed, unsigned int type, unsigned int button, int x, diff --git a/src/guichan/inputevent.cpp b/src/guichan/inputevent.cpp index 7a3bdb06d..a135b15b8 100644 --- a/src/guichan/inputevent.cpp +++ b/src/guichan/inputevent.cpp @@ -52,15 +52,15 @@ namespace gcn { InputEvent::InputEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed) + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed) :Event(source), - mShiftPressed(isShiftPressed), - mControlPressed(isControlPressed), - mAltPressed(isAltPressed), - mMetaPressed(isMetaPressed), + mShiftPressed(shiftPressed), + mControlPressed(controlPressed), + mAltPressed(altPressed), + mMetaPressed(metaPressed), mIsConsumed(false) { diff --git a/src/guichan/keyevent.cpp b/src/guichan/keyevent.cpp index 1bc8fe9d2..f9c14bb59 100644 --- a/src/guichan/keyevent.cpp +++ b/src/guichan/keyevent.cpp @@ -52,20 +52,20 @@ namespace gcn { KeyEvent::KeyEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed, + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed, unsigned int type, - bool isNumericPad, + bool numericPad, const Key& key) :InputEvent(source, - isShiftPressed, - isControlPressed, - isAltPressed, - isMetaPressed), + shiftPressed, + controlPressed, + altPressed, + metaPressed), mType(type), - mIsNumericPad(isNumericPad), + mIsNumericPad(numericPad), mKey(key) { diff --git a/src/guichan/mouseevent.cpp b/src/guichan/mouseevent.cpp index e5046ed15..5ff544a04 100644 --- a/src/guichan/mouseevent.cpp +++ b/src/guichan/mouseevent.cpp @@ -52,20 +52,20 @@ namespace gcn { MouseEvent::MouseEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed, + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed, unsigned int type, unsigned int button, int x, int y, int clickCount) :InputEvent(source, - isShiftPressed, - isControlPressed, - isAltPressed, - isMetaPressed), + shiftPressed, + controlPressed, + altPressed, + metaPressed), mType(type), mButton(button), mX(x), diff --git a/src/map.h b/src/map.h index c92a3c60f..e9a9df593 100644 --- a/src/map.h +++ b/src/map.h @@ -96,10 +96,10 @@ struct MetaTile class MapObject { public: - MapObject(int type, std::string data) + MapObject(int type0, std::string data0) { - this->type = type; - this->data = data; + type = type0; + data = data0; } int type; diff --git a/src/position.h b/src/position.h index 1d3070e1b..973a774f0 100644 --- a/src/position.h +++ b/src/position.h @@ -31,8 +31,8 @@ */ struct Position { - Position(int x, int y): - x(x), y(y) + Position(int x0, int y0): + x(x0), y(y0) { } int x; diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp index 10d70c2c7..319bc5b8c 100644 --- a/src/resources/ambientlayer.cpp +++ b/src/resources/ambientlayer.cpp @@ -41,16 +41,16 @@ AmbientLayer::AmbientLayer(Image *img, float parallax, if (keepRatio && !mImage->useOpenGL() /*&& defaultScreenWidth != 0 && defaultScreenHeight != 0*/ - && graphics->mWidth != defaultScreenWidth - && graphics->mHeight != defaultScreenHeight) + && mainGraphics->mWidth != defaultScreenWidth + && mainGraphics->mHeight != defaultScreenHeight) { // Rescale the overlay to keep the ratio as if we were on // the default resolution... Image *rescaledOverlay = ResourceManager::getInstance()-> getRescaled(mImage, static_cast(mImage->mBounds.w) - / defaultScreenWidth * graphics->mWidth, + / defaultScreenWidth * mainGraphics->mWidth, static_cast(mImage->mBounds.h) - / defaultScreenHeight * graphics->mHeight); + / defaultScreenHeight * mainGraphics->mHeight); if (rescaledOverlay) mImage = rescaledOverlay; diff --git a/src/resources/colordb.h b/src/resources/colordb.h index ce128578e..83bff57da 100644 --- a/src/resources/colordb.h +++ b/src/resources/colordb.h @@ -38,11 +38,11 @@ namespace ColorDB color("") { } - ItemColor(int id, std::string name, std::string color) + ItemColor(int id0, std::string name0, std::string color0) { - this->id = id; - this->name = name; - this->color = color; + this->id = id0; + this->name = name0; + this->color = color0; } int id; diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h index 267f60eef..c20961eff 100644 --- a/src/resources/itemdb.h +++ b/src/resources/itemdb.h @@ -68,10 +68,10 @@ namespace ItemDB struct Stat { - Stat(const std::string &tag, - const std::string &format): - tag(tag), - format(format) + Stat(const std::string &tag0, + const std::string &format0) : + tag(tag0), + format(format0) {} std::string tag; diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index 8fa64e7b9..ccad62b1b 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -43,10 +43,10 @@ struct SpriteReference sprite(""), variant(0) {} - SpriteReference(std::string sprite, int variant) + SpriteReference(std::string sprite0, int variant0) { - this->sprite = sprite; - this->variant = variant; + sprite = sprite0; + variant = variant0; } std::string sprite; diff --git a/src/vector.h b/src/vector.h index 87e9c647a..0f10bae96 100644 --- a/src/vector.h +++ b/src/vector.h @@ -46,10 +46,10 @@ class Vector /** * Constructor. */ - Vector(float x, float y, float z = 0.0f): - x(x), - y(y), - z(z) + Vector(float x0, float y0, float z0 = 0.0f): + x(x0), + y(y0), + z(z0) {} /** -- cgit v1.2.3-60-g2f50 From ee39f800bd1809b25cc7c05238e2fa7abccd8ab3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 10 Sep 2011 23:09:21 +0300 Subject: Allow load for each window own xml theme file. --- src/gui/botcheckerwindow.cpp | 2 +- src/gui/buydialog.cpp | 4 ++-- src/gui/buyselldialog.cpp | 4 ++-- src/gui/changeemaildialog.cpp | 2 +- src/gui/changepassworddialog.cpp | 2 +- src/gui/charcreatedialog.cpp | 2 +- src/gui/charselectdialog.cpp | 2 +- src/gui/chatwindow.cpp | 2 +- src/gui/debugwindow.cpp | 2 +- src/gui/didyouknowwindow.cpp | 2 +- src/gui/equipmentwindow.cpp | 2 +- src/gui/helpwindow.cpp | 2 +- src/gui/killstats.cpp | 3 ++- src/gui/logindialog.cpp | 2 +- src/gui/minimap.cpp | 2 +- src/gui/npcdialog.cpp | 2 +- src/gui/npcpostdialog.cpp | 2 +- src/gui/outfitwindow.cpp | 2 +- src/gui/quitdialog.cpp | 3 ++- src/gui/register.cpp | 2 +- src/gui/selldialog.cpp | 4 ++-- src/gui/serverdialog.cpp | 2 +- src/gui/setup.cpp | 2 +- src/gui/shopwindow.cpp | 2 +- src/gui/skilldialog.cpp | 2 +- src/gui/socialwindow.cpp | 2 +- src/gui/specialswindow.cpp | 2 +- src/gui/textcommandeditor.cpp | 2 +- src/gui/theme.cpp | 28 ++++++++++++++++++++++++++++ src/gui/theme.h | 2 ++ src/gui/tradewindow.cpp | 2 +- src/gui/unregisterdialog.cpp | 2 +- src/gui/updaterwindow.cpp | 2 +- src/gui/whoisonline.cpp | 2 +- src/gui/widgets/window.cpp | 26 +++++++++++++++++++------- src/gui/widgets/window.h | 2 +- src/gui/worldselectdialog.cpp | 2 +- 37 files changed, 88 insertions(+), 44 deletions(-) (limited to 'src/gui/widgets/window.cpp') diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index 8bc0d892e..34293e59d 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -263,7 +263,7 @@ protected: BotCheckerWindow::BotCheckerWindow(): - Window(_("Bot Checker")), + Window(_("Bot Checker"), false, 0, "botchecker.xml"), mEnabled(false) { int w = 500; diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index 94c2b88ff..8628afc6e 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -53,14 +53,14 @@ BuyDialog::DialogList BuyDialog::instances; BuyDialog::BuyDialog(int npcId): - Window(_("Buy")), + Window(_("Buy"), false, 0, "buy.xml"), mNpcId(npcId), mMoney(0), mAmountItems(0), mMaxItems(0), mNick("") { init(); } BuyDialog::BuyDialog(std::string nick): - Window(_("Buy")), + Window(_("Buy"), false, 0, "buy.xml"), mNpcId(-1), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(nick) { init(); diff --git a/src/gui/buyselldialog.cpp b/src/gui/buyselldialog.cpp index dfe7a422a..e1063192a 100644 --- a/src/gui/buyselldialog.cpp +++ b/src/gui/buyselldialog.cpp @@ -37,7 +37,7 @@ BuySellDialog::DialogList BuySellDialog::instances; BuySellDialog::BuySellDialog(int npcId): - Window(_("Shop")), + Window(_("Shop"), false, 0, "buysell.xml"), mNpcId(npcId), mNick(""), mBuyButton(0) @@ -46,7 +46,7 @@ BuySellDialog::BuySellDialog(int npcId): } BuySellDialog::BuySellDialog(std::string nick): - Window(_("Shop")), + Window(_("Shop"), false, 0, "buysell.xml"), mNpcId(-1), mNick(nick), mBuyButton(0) diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index 69af649e2..384ebf07f 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -45,7 +45,7 @@ #include "debug.h" ChangeEmailDialog::ChangeEmailDialog(LoginData *data): - Window(_("Change Email Address"), true), + Window(_("Change Email Address"), true, 0, "changeemail.xml"), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(data) { diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 56db37ebb..7a67279b6 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -47,7 +47,7 @@ #include "debug.h" ChangePasswordDialog::ChangePasswordDialog(LoginData *data): - Window(_("Change Password"), true), + Window(_("Change Password"), true, 0, "changepassword.xml"), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(data) { diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index d1773e7f3..efe7e804f 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -55,7 +55,7 @@ #include "debug.h" CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): - Window(_("Create Character"), true, parent), + Window(_("Create Character"), true, parent, "charcreate.xml"), mCharSelectDialog(parent), mRace(0), mSlot(slot) diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index e39b5ecfc..00cae41e6 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -122,7 +122,7 @@ class CharacterDisplay : public Container }; CharSelectDialog::CharSelectDialog(LoginData *data): - Window(_("Account and Character Management")), + Window(_("Account and Character Management"), false, 0, "char.xml"), mLocked(false), mUnregisterButton(0), mChangeEmailButton(0), diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 2bada256c..82d6c2ff5 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -149,7 +149,7 @@ public: ChatWindow::ChatWindow(): - Window(_("Chat")), + Window(_("Chat"), false, 0, "chat.xml"), mTmpVisible(false), mChatHistoryIndex(0) { diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index dc540a782..83e9791ef 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -51,7 +51,7 @@ #include "debug.h" DebugWindow::DebugWindow(): - Window(_("Debug")) + Window(_("Debug"), false, 0, "debug.xml") { setWindowName("Debug"); if (setupWindow) diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp index d62417fc4..df15e6ebd 100644 --- a/src/gui/didyouknowwindow.cpp +++ b/src/gui/didyouknowwindow.cpp @@ -44,7 +44,7 @@ static const int minTip = 1; static const int maxTip = 14; DidYouKnowWindow::DidYouKnowWindow(): - Window(_("Did You Know?")) + Window(_("Did You Know?"), false, 0, "didyouknow.xml") { setMinWidth(300); setMinHeight(250); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 0375d096f..f423cddf0 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -58,7 +58,7 @@ static const int BOX_HEIGHT = 36; EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being, bool foring): - Window(_("Equipment")), + Window(_("Equipment"), false, 0, "equipment.xml"), mEquipment(equipment), mSelected(-1), mForing(foring) diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp index b772ea36a..019baf503 100644 --- a/src/gui/helpwindow.cpp +++ b/src/gui/helpwindow.cpp @@ -40,7 +40,7 @@ #include "debug.h" HelpWindow::HelpWindow(): - Window(_("Help")) + Window(_("Help"), false, 0, "help.xml") { setMinWidth(300); setMinHeight(250); diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index 0cadc765b..4bcab0a09 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -43,7 +43,8 @@ #include "debug.h" KillStats::KillStats(): - Window(_("Kill stats")), mKillCounter(0), mExpCounter(0), + Window(_("Kill stats"), false, 0, "killstats.xml"), + mKillCounter(0), mExpCounter(0), mKillTCounter(0), mExpTCounter(0), mKillTimer(0), m1minExpTime(0), m1minExpNum(0), m1minSpeed(0), m5minExpTime(0), m5minExpNum(0), m5minSpeed(0), diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index 26248059c..136a01b37 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -83,7 +83,7 @@ public: LoginDialog::LoginDialog(LoginData *data, std::string serverName, std::string *updateHost): - Window(_("Login")), + Window(_("Login"), false, 0, "login.xml"), mLoginData(data), mUpdateHost(updateHost), mServerName(serverName) diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 70bbc1dad..e42f12336 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -47,7 +47,7 @@ bool Minimap::mShow = true; Minimap::Minimap(): - Window(_("Map")), + Window(_("Map"), false, 0, "map.xml"), mMapImage(0), mWidthProportion(0.5), mHeightProportion(0.5), diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 3956b47ac..3e1ee46d8 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -56,7 +56,7 @@ NpcDialog::DialogList NpcDialog::instances; NpcDialog::NpcDialog(int npcId) - : Window(_("NPC")), + : Window(_("NPC"), false, 0, "npc.xml"), mNpcId(npcId), mLogInteraction(config.getBoolValue("logNpcInGui")), mDefaultInt(0), diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp index 72dd76aa3..67fc57ba9 100644 --- a/src/gui/npcpostdialog.cpp +++ b/src/gui/npcpostdialog.cpp @@ -39,7 +39,7 @@ NpcPostDialog::DialogList NpcPostDialog::instances; NpcPostDialog::NpcPostDialog(int npcId): - Window(_("NPC")), + Window(_("NPC"), false, 0, "npcpost.xml"), mNpcId(npcId) { setContentSize(400, 180); diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 9601e3ca5..8e0791af1 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -57,7 +57,7 @@ float OutfitWindow::mAlpha = 1.0; OutfitWindow::OutfitWindow(): - Window(_("Outfits")), + Window(_("Outfits"), false, 0, "outfits.xml"), mBoxWidth(33), mBoxHeight(33), mGridWidth(4), diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index e71e291d1..05691c2d2 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -44,7 +44,8 @@ #include "debug.h" QuitDialog::QuitDialog(QuitDialog** pointerToMe): - Window(_("Quit"), true, NULL), mMyPointer(pointerToMe) + Window(_("Quit"), true, 0, "quit.xml"), + mMyPointer(pointerToMe) { mForceQuit = new RadioButton(_("Quit"), "quitdialog"); mLogoutQuit = new RadioButton(_("Quit"), "quitdialog"); diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 603810a0b..062275b80 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -63,7 +63,7 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event) } RegisterDialog::RegisterDialog(LoginData *data): - Window(_("Register")), + Window(_("Register"), false, 0, "register.xml"), mEmailField(0), mMaleButton(0), mFemaleButton(0), diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp index 82b4a1829..bbd0a71c1 100644 --- a/src/gui/selldialog.cpp +++ b/src/gui/selldialog.cpp @@ -50,14 +50,14 @@ SellDialog::DialogList SellDialog::instances; SellDialog::SellDialog(int npcId): - Window(_("Sell")), + Window(_("Sell"), false, 0, "sell.xml"), mNpcId(npcId), mMaxItems(0), mAmountItems(0), mNick("") { init(); } SellDialog::SellDialog(std::string nick): - Window(_("Sell")), + Window(_("Sell"), false, 0, "sell.xml"), mNpcId(-1), mMaxItems(0), mAmountItems(0), mNick(nick) { init(); diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index f9d6ebfd0..1b0dd22aa 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -234,7 +234,7 @@ private: ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): - Window(_("Choose Your Server")), + Window(_("Choose Your Server"), false, 0, "server.xml"), mDir(dir), // mDownloadStatus(DOWNLOADING_PREPARING), mDownloadStatus(DOWNLOADING_UNKNOWN), diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 113dd9081..33f379743 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -51,7 +51,7 @@ extern Window *statusWindow; Setup::Setup(): - Window(_("Setup")) + Window(_("Setup"), false, 0, "setup.xml") { setCloseButton(true); setResizable(true); diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index ccfed3efc..2215ce699 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -72,7 +72,7 @@ extern std::string tradePartnerName; ShopWindow::DialogList ShopWindow::instances; ShopWindow::ShopWindow(): - Window(_("Personal Shop")), + Window(_("Personal Shop"), false, 0, "shop.xml"), mSelectedItem(-1), mAnnonceTime(0), mLastRequestTimeList(0), diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index c2685b476..28dbca939 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -273,7 +273,7 @@ private: }; SkillDialog::SkillDialog(): - Window(_("Skills")) + Window(_("Skills"), false, 0, "skills.xml") { setWindowName("Skills"); setCloseButton(true); diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 886894564..a8d15f36c 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -1114,7 +1114,7 @@ private: }; SocialWindow::SocialWindow() : - Window(_("Social")), + Window(_("Social"), false, 0, "social.xml"), mGuildInvited(0), mGuildAcceptDialog(0), mPartyAcceptDialog(0), diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp index 64f61e3c3..c464b83b5 100644 --- a/src/gui/specialswindow.cpp +++ b/src/gui/specialswindow.cpp @@ -76,7 +76,7 @@ class SpecialEntry : public Container }; SpecialsWindow::SpecialsWindow(): - Window(_("Specials")) + Window(_("Specials"), false, 0, "specials.xml") { setWindowName("Specials"); setCloseButton(true); diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index 214cbff76..282f23ee1 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -165,7 +165,7 @@ public: TextCommandEditor::TextCommandEditor(TextCommand *command): - Window(_("Command Editor")) + Window(_("Command Editor"), false, 0, "commandeditor.xml") { int w = 350; int h = 350; diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 0607564f9..12e7736c0 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -215,6 +215,9 @@ Skin *Theme::load(const std::string &filename, const std::string &defaultPath) Skin *skin = readSkin(filename); + if (!skin) + skin = readSkin("window.xml"); + if (!skin) { // Try falling back on the defaultPath if this makes sense @@ -240,6 +243,31 @@ Skin *Theme::load(const std::string &filename, const std::string &defaultPath) return skin; } +void Theme::unload(Skin *skin) +{ + if (!skin) + return; + skin->instances --; +/* + // unload theme if no instances + if (!skin->instances) + { + SkinIterator it = mSkins.begin(); + SkinIterator it_end = mSkins.end(); + while (it != it_end) + { + if (it->second == skin) + { + mSkins.erase(it); + break; + } + ++ it; + } + delete skin; + } +*/ +} + void Theme::setMinimumOpacity(float minimumOpacity) { if (minimumOpacity > 1.0f) diff --git a/src/gui/theme.h b/src/gui/theme.h index fbc6f13da..46d2eee2d 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -238,6 +238,8 @@ class Theme : public Palette, public ConfigListener Skin *load(const std::string &filename, const std::string &defaultPath = getThemePath()); + void unload(Skin *skin); + /** * Updates the alpha values of all of the skins. */ diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index 3874a8301..bd7e9bb1e 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -63,7 +63,7 @@ #define CAPTION_ACCEPTED _("Agreed. Waiting...") TradeWindow::TradeWindow(): - Window(_("Trade: You")), + Window(_("Trade: You"), false, 0, "trade.xml"), mMyInventory(new Inventory(Inventory::TRADE)), mPartnerInventory(new Inventory(Inventory::TRADE)), mStatus(PROPOSING), diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index e875000c4..cc5caca60 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -47,7 +47,7 @@ #include "debug.h" UnRegisterDialog::UnRegisterDialog(LoginData *data): - Window(_("Unregister"), true), + Window(_("Unregister"), true, 0, "unregister.xml"), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(data) { diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index d6c74cc79..2efe82199 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -135,7 +135,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, const std::string &updatesDir, bool applyUpdates, int updateType): - Window(_("Updating...")), + Window(_("Updating..."), false, 0, "update.xml"), mDownloadStatus(UPDATE_NEWS), mUpdateHost(updateHost), mUpdatesDir(updatesDir), diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index ff855ed05..e1f69c2d7 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -78,7 +78,7 @@ bool stringCompare(const std::string &left, const std::string &right ) } WhoIsOnline::WhoIsOnline(): - Window(_("Who Is Online - Updating")), + Window(_("Who Is Online - Updating"), false, 0, "whoisonline.xml"), mThread(NULL), mDownloadStatus(UPDATE_LIST), mDownloadComplete(true), diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 05509ab39..1ffbac31e 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -47,7 +47,7 @@ int Window::instances = 0; int Window::mouseResize = 0; Window::Window(const std::string &caption, bool modal, Window *parent, - const std::string &skin): + std::string skin): gcn::Window(caption), mGrip(0), mParent(parent), @@ -79,8 +79,18 @@ Window::Window(const std::string &caption, bool modal, Window *parent, setPadding(3); setTitleBarHeight(20); + if (skin == "") + skin = "window.xml"; + // Loads the skin - mSkin = Theme::instance()->load(skin); + if (Theme::instance()) + { + mSkin = Theme::instance()->load(skin); + } + else + { + mSkin = 0; + } // Add this window to the window container windowContainer->add(this); @@ -113,8 +123,6 @@ Window::~Window() mWidgets.clear(); -// need mWidgets.clean ? - removeWidgetListener(this); delete mVertexes; mVertexes = 0; @@ -122,7 +130,11 @@ Window::~Window() instances--; if (mSkin) - mSkin->instances--; + { + if (Theme::instance()) + Theme::instance()->unload(mSkin); + mSkin = 0; + } } void Window::setWindowContainer(WindowContainer *wc) @@ -443,7 +455,7 @@ void Window::mousePressed(gcn::MouseEvent &event) const int y = event.getY(); // Handle close button - if (mCloseButton) + if (mCloseButton && mSkin) { Image *img = mSkin->getCloseImage(); if (img) @@ -464,7 +476,7 @@ void Window::mousePressed(gcn::MouseEvent &event) } // Handle sticky button - if (mStickyButton) + if (mStickyButton && mSkin) { Image *button = mSkin->getStickyImage(mSticky); if (button) diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index b9f65dceb..510a68323 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -65,7 +65,7 @@ class Window : public gcn::Window, gcn::WidgetListener * @param skin The location where the window's skin XML can be found. */ Window(const std::string &caption = "Window", bool modal = false, - Window *parent = NULL, const std::string &skin = "window.xml"); + Window *parent = NULL, std::string skin = ""); /** * Destructor. Deletes all the added widgets. diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp index 7e2afbaa3..b4f697ba3 100644 --- a/src/gui/worldselectdialog.cpp +++ b/src/gui/worldselectdialog.cpp @@ -74,7 +74,7 @@ class WorldListModel : public gcn::ListModel }; WorldSelectDialog::WorldSelectDialog(Worlds worlds): - Window(_("Select World")) + Window(_("Select World"), false, 0, "world.xml") { mWorldListModel = new WorldListModel(worlds); mWorldList = new ListBox(mWorldListModel); -- cgit v1.2.3-60-g2f50 From 632c1797013d8b0a987ab68341b50354afdb1f9d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 11 Sep 2011 00:46:34 +0300 Subject: Add support for padding in theme configuration files. --- src/gui/theme.cpp | 223 +++++++++++++++++++++++---------------------- src/gui/theme.h | 8 +- src/gui/widgets/window.cpp | 2 + 3 files changed, 122 insertions(+), 111 deletions(-) (limited to 'src/gui/widgets/window.cpp') diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 12e7736c0..15dafa997 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -65,14 +65,15 @@ static void initDefaultThemePath() Skin::Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown, const std::string &filePath, - const std::string &name): + const std::string &name, int padding): instances(0), mFilePath(filePath), mName(name), mBorder(skin), mCloseImage(close), mStickyImageUp(stickyUp), - mStickyImageDown(stickyDown) + mStickyImageDown(stickyDown), + mPadding(padding) {} Skin::~Skin() @@ -321,6 +322,7 @@ Skin *Theme::readSkin(const std::string &filename) Image *dBorders = Theme::getImageFromTheme(skinSetImage); ImageRect border; memset(&border, 0, sizeof(ImageRect)); + int padding = 3; // iterate 's for_each_xml_child_node(widgetNode, rootNode) @@ -332,140 +334,143 @@ Skin *Theme::readSkin(const std::string &filename) XML::getProperty(widgetNode, "type", "unknown"); if (widgetType == "Window") { - // Iterate through 's - // LEEOR / TODO: - // We need to make provisions to load in a CloseButton image. For - // now it can just be hard-coded. for_each_xml_child_node(partNode, widgetNode) { - if (!xmlStrEqual(partNode->name, BAD_CAST "part")) - continue; - - const std::string partType = - XML::getProperty(partNode, "type", "unknown"); - // TOP ROW - const int xPos = XML::getProperty(partNode, "xpos", 0); - const int yPos = XML::getProperty(partNode, "ypos", 0); - const int width = XML::getProperty(partNode, "width", 1); - const int height = XML::getProperty(partNode, "height", 1); - - if (partType == "top-left-corner") + if (xmlStrEqual(partNode->name, BAD_CAST "part")) { - if (dBorders) + const std::string partType = + XML::getProperty(partNode, "type", "unknown"); + // TOP ROW + const int xPos = XML::getProperty(partNode, "xpos", 0); + const int yPos = XML::getProperty(partNode, "ypos", 0); + const int width = XML::getProperty(partNode, "width", 1); + const int height = XML::getProperty(partNode, "height", 1); + + if (partType == "top-left-corner") { - border.grid[0] = dBorders->getSubImage( - xPos, yPos, width, height); + if (dBorders) + { + border.grid[0] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[0] = 0; + } } - else - { - border.grid[0] = 0; - } - } - else if (partType == "top-edge") - { - if (dBorders) + else if (partType == "top-edge") { - border.grid[1] = dBorders->getSubImage( - xPos, yPos, width, height); + if (dBorders) + { + border.grid[1] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[1] = 0; + } } - else + else if (partType == "top-right-corner") { - border.grid[1] = 0; + if (dBorders) + { + border.grid[2] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[2] = 0; + } } - } - else if (partType == "top-right-corner") - { - if (dBorders) - { - border.grid[2] = dBorders->getSubImage( - xPos, yPos, width, height); - } - else - { - border.grid[2] = 0; - } - } - // MIDDLE ROW - else if (partType == "left-edge") - { - if (dBorders) - { - border.grid[3] = dBorders->getSubImage( - xPos, yPos, width, height); - } - else - { - border.grid[3] = 0; - } - } - else if (partType == "bg-quad") - { - if (dBorders) + // MIDDLE ROW + else if (partType == "left-edge") { - border.grid[4] = dBorders->getSubImage( - xPos, yPos, width, height); + if (dBorders) + { + border.grid[3] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[3] = 0; + } } - else + else if (partType == "bg-quad") { - border.grid[4] = 0; + if (dBorders) + { + border.grid[4] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[4] = 0; + } } - } - else if (partType == "right-edge") - { - if (dBorders) + else if (partType == "right-edge") { - border.grid[5] = dBorders->getSubImage( - xPos, yPos, width, height); + if (dBorders) + { + border.grid[5] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[5] = 0; + } } - else - { - border.grid[5] = 0; - } - } - // BOTTOM ROW - else if (partType == "bottom-left-corner") - { - if (dBorders) + // BOTTOM ROW + else if (partType == "bottom-left-corner") { - border.grid[6] = dBorders->getSubImage( - xPos, yPos, width, height); + if (dBorders) + { + border.grid[6] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[6] = 0; + } } - else + else if (partType == "bottom-edge") { - border.grid[6] = 0; + if (dBorders) + { + border.grid[7] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[7] = 0; + } } - } - else if (partType == "bottom-edge") - { - if (dBorders) - { - border.grid[7] = dBorders->getSubImage( - xPos, yPos, width, height); - } - else - { - border.grid[7] = 0; - } - } - else if (partType == "bottom-right-corner") - { - if (dBorders) + else if (partType == "bottom-right-corner") { - border.grid[8] = dBorders->getSubImage( - xPos, yPos, width, height); + if (dBorders) + { + border.grid[8] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[8] = 0; + } } + else { - border.grid[8] = 0; + logger->log("Theme::readSkin(): Unknown part type '%s'", + partType.c_str()); } } - - else + else if (xmlStrEqual(partNode->name, BAD_CAST "option")) { - logger->log("Theme::readSkin(): Unknown part type '%s'", - partType.c_str()); + const std::string name = XML::getProperty( + partNode, "name", ""); + if (name == "padding") + padding = XML::getProperty(partNode, "value", 3); } } } @@ -495,7 +500,7 @@ Skin *Theme::readSkin(const std::string &filename) } Skin *skin = new Skin(border, closeImage, stickyImageUp, stickyImageDown, - filename); + filename, "", padding); skin->updateAlpha(mMinimumOpacity); return skin; } diff --git a/src/gui/theme.h b/src/gui/theme.h index 46d2eee2d..92b2c8878 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -43,8 +43,8 @@ class Skin { public: Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown, - const std::string &filePath, - const std::string &name = ""); + const std::string &filePath, const std::string &name = "", + int padding = 3); ~Skin(); @@ -95,6 +95,9 @@ class Skin */ void updateAlpha(float minimumOpacityAllowed = 0.0f); + int getPadding() + { return mPadding; } + int instances; private: @@ -104,6 +107,7 @@ class Skin Image *mCloseImage; /**< Close Button Image */ Image *mStickyImageUp; /**< Sticky Button Image */ Image *mStickyImageDown; /**< Sticky Button Image */ + int mPadding; }; class Theme : public Palette, public ConfigListener diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 1ffbac31e..2d4c443c6 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -86,6 +86,8 @@ Window::Window(const std::string &caption, bool modal, Window *parent, if (Theme::instance()) { mSkin = Theme::instance()->load(skin); + if (mSkin) + setPadding(mSkin->getPadding()); } else { -- cgit v1.2.3-60-g2f50 From c91bc5201596eda73f9df2222d76d9f413426a85 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 15 Sep 2011 04:22:11 +0300 Subject: Remove some diplicated code from embeded guichan. --- src/gui/widgets/window.cpp | 2 +- src/guichan/include/guichan/widgets/button.hpp | 8 -- src/guichan/include/guichan/widgets/checkbox.hpp | 14 -- src/guichan/include/guichan/widgets/dropdown.hpp | 6 +- .../include/guichan/widgets/radiobutton.hpp | 7 +- src/guichan/include/guichan/widgets/slider.hpp | 12 -- src/guichan/include/guichan/widgets/tab.hpp | 3 - src/guichan/include/guichan/widgets/tabbedarea.hpp | 18 +-- src/guichan/include/guichan/widgets/textfield.hpp | 8 -- src/guichan/include/guichan/widgets/window.hpp | 7 - src/guichan/widgets/button.cpp | 19 +-- src/guichan/widgets/checkbox.cpp | 51 ------- src/guichan/widgets/dropdown.cpp | 150 --------------------- src/guichan/widgets/radiobutton.cpp | 81 ----------- src/guichan/widgets/slider.cpp | 68 ---------- src/guichan/widgets/tab.cpp | 63 --------- src/guichan/widgets/tabbedarea.cpp | 99 -------------- src/guichan/widgets/textfield.cpp | 96 ------------- src/guichan/widgets/window.cpp | 91 ------------- 19 files changed, 7 insertions(+), 796 deletions(-) (limited to 'src/gui/widgets/window.cpp') diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 2d4c443c6..c52bf744e 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -1031,4 +1031,4 @@ gcn::Rectangle Window::getWindowArea() getPadding(), getWidth() - getPadding() * 2, getHeight() - getPadding() * 2); -} \ No newline at end of file +} diff --git a/src/guichan/include/guichan/widgets/button.hpp b/src/guichan/include/guichan/widgets/button.hpp index c0d0a237d..e3b8b98de 100644 --- a/src/guichan/include/guichan/widgets/button.hpp +++ b/src/guichan/include/guichan/widgets/button.hpp @@ -147,22 +147,14 @@ namespace gcn void adjustSize(); - //Inherited from Widget - - virtual void draw(Graphics* graphics); - - // Inherited from FocusListener virtual void focusLost(const Event& event); - // Inherited from MouseListener virtual void mousePressed(MouseEvent& mouseEvent); - virtual void mouseReleased(MouseEvent& mouseEvent); - virtual void mouseEntered(MouseEvent& mouseEvent); virtual void mouseExited(MouseEvent& mouseEvent); diff --git a/src/guichan/include/guichan/widgets/checkbox.hpp b/src/guichan/include/guichan/widgets/checkbox.hpp index ad43e2896..0ff328d72 100644 --- a/src/guichan/include/guichan/widgets/checkbox.hpp +++ b/src/guichan/include/guichan/widgets/checkbox.hpp @@ -126,17 +126,10 @@ namespace gcn */ void adjustSize(); - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - // Inherited from KeyListener virtual void keyPressed(KeyEvent& keyEvent); - // Inherited from MouseListener virtual void mouseClicked(MouseEvent& mouseEvent); @@ -145,13 +138,6 @@ namespace gcn protected: - /** - * Draws the box of the check box. - * - * @param graphics A Graphics object to draw with. - */ - virtual void drawBox(Graphics *graphics); - /** * Toggles the check box between being selected and * not being selected. diff --git a/src/guichan/include/guichan/widgets/dropdown.hpp b/src/guichan/include/guichan/widgets/dropdown.hpp index c096bb03f..600558d67 100644 --- a/src/guichan/include/guichan/widgets/dropdown.hpp +++ b/src/guichan/include/guichan/widgets/dropdown.hpp @@ -171,8 +171,6 @@ namespace gcn // Inherited from Widget - virtual void draw(Graphics* graphics); - void setBaseColor(const Color& color); void setBackgroundColor(const Color& color); @@ -206,7 +204,7 @@ namespace gcn // Inherited from KeyListener - virtual void keyPressed(KeyEvent& keyEvent); + virtual void keyPressed(KeyEvent& keyEvent) = 0; // Inherited from MouseListener @@ -232,7 +230,7 @@ namespace gcn * * @param graphics a Graphics object to draw with. */ - virtual void drawButton(Graphics *graphics); + virtual void drawButton(Graphics *graphics) = 0; /** * Sets the drop down to be dropped down. diff --git a/src/guichan/include/guichan/widgets/radiobutton.hpp b/src/guichan/include/guichan/widgets/radiobutton.hpp index 0fb5b4123..e15bf86b3 100644 --- a/src/guichan/include/guichan/widgets/radiobutton.hpp +++ b/src/guichan/include/guichan/widgets/radiobutton.hpp @@ -152,11 +152,6 @@ namespace gcn void adjustSize(); - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - // Inherited from KeyListener virtual void keyPressed(KeyEvent& keyEvent); @@ -174,7 +169,7 @@ namespace gcn * * @param graphics a Graphics object to draw with. */ - virtual void drawBox(Graphics *graphics); + virtual void drawBox(Graphics *graphics) = 0; /** * True if the radio button is selected, false otherwise. diff --git a/src/guichan/include/guichan/widgets/slider.hpp b/src/guichan/include/guichan/widgets/slider.hpp index eddf02c50..ec6b82e1e 100644 --- a/src/guichan/include/guichan/widgets/slider.hpp +++ b/src/guichan/include/guichan/widgets/slider.hpp @@ -204,12 +204,6 @@ namespace gcn */ double getStepLength() const; - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - // Inherited from MouseListener. virtual void mousePressed(MouseEvent& mouseEvent); @@ -226,12 +220,6 @@ namespace gcn virtual void keyPressed(KeyEvent& keyEvent); protected: - /** - * Draws the marker. - * - * @param graphics A graphics object to draw with. - */ - virtual void drawMarker(gcn::Graphics* graphics); /** * Converts a marker position to a value in the scale. diff --git a/src/guichan/include/guichan/widgets/tab.hpp b/src/guichan/include/guichan/widgets/tab.hpp index 91c09e270..55845c771 100644 --- a/src/guichan/include/guichan/widgets/tab.hpp +++ b/src/guichan/include/guichan/widgets/tab.hpp @@ -127,9 +127,6 @@ namespace gcn // Inherited from Widget - virtual void draw(Graphics *graphics); - - // Inherited from MouseListener virtual void mouseEntered(MouseEvent& mouseEvent); diff --git a/src/guichan/include/guichan/widgets/tabbedarea.hpp b/src/guichan/include/guichan/widgets/tabbedarea.hpp index 843bbde81..7be3b91e2 100644 --- a/src/guichan/include/guichan/widgets/tabbedarea.hpp +++ b/src/guichan/include/guichan/widgets/tabbedarea.hpp @@ -108,16 +108,6 @@ namespace gcn */ bool isOpaque() const; - /** - * Adds a tab to the tabbed area. The newly created tab will be - * automatically deleted by the tabbed area when it is removed. - * - * @param caption The caption of the tab to add. - * @param widget The widget to view when the tab is selected. - * @see removeTab, removeTabWithIndex - */ - virtual void addTab(const std::string& caption, Widget* widget); - /** * Adds a tab to the tabbed area. The tab will not be deleted by the * tabbed area when it is removed. @@ -142,7 +132,7 @@ namespace gcn * @param index The tab to remove. * @see addTab */ - virtual void removeTab(Tab* tab); + virtual void removeTab(Tab* tab) = 0; /** * Checks if a tab given an index is selected or not. @@ -195,13 +185,10 @@ namespace gcn */ Tab* getSelectedTab(); - // Inherited from Widget virtual void draw(Graphics *graphics); - virtual void logic(); - void setWidth(int width); void setHeight(int height); @@ -228,9 +215,6 @@ namespace gcn // Inherited from MouseListener - virtual void mousePressed(MouseEvent& mouseEvent); - - protected: /** * Adjusts the size of the tab container and the widget container. diff --git a/src/guichan/include/guichan/widgets/textfield.hpp b/src/guichan/include/guichan/widgets/textfield.hpp index 486660a8a..638b6e715 100644 --- a/src/guichan/include/guichan/widgets/textfield.hpp +++ b/src/guichan/include/guichan/widgets/textfield.hpp @@ -124,19 +124,11 @@ namespace gcn virtual void fontChanged(); - virtual void draw(Graphics* graphics); - - // Inherited from MouseListener virtual void mousePressed(MouseEvent& mouseEvent); virtual void mouseDragged(MouseEvent& mouseEvent); - - - // Inherited from KeyListener - - virtual void keyPressed(KeyEvent& keyEvent); protected: /** diff --git a/src/guichan/include/guichan/widgets/window.hpp b/src/guichan/include/guichan/widgets/window.hpp index 3b9c62160..12e669f9d 100644 --- a/src/guichan/include/guichan/widgets/window.hpp +++ b/src/guichan/include/guichan/widgets/window.hpp @@ -187,17 +187,10 @@ namespace gcn */ virtual void resizeToContent(); - // Inherited from BasicContainer virtual Rectangle getChildrenArea(); - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - // Inherited from MouseListener virtual void mousePressed(MouseEvent& mouseEvent); diff --git a/src/guichan/widgets/button.cpp b/src/guichan/widgets/button.cpp index 184b6235c..c27d0c8dd 100644 --- a/src/guichan/widgets/button.cpp +++ b/src/guichan/widgets/button.cpp @@ -121,6 +121,7 @@ namespace gcn return mSpacing; } +/* void Button::draw(Graphics* graphics) { Color faceColor = getBaseColor(); @@ -195,6 +196,7 @@ namespace gcn } } } +*/ void Button::adjustSize() { @@ -233,23 +235,6 @@ namespace gcn mHasMouse = true; } - void Button::mouseReleased(MouseEvent& mouseEvent) - { - if (mouseEvent.getButton() == MouseEvent::LEFT - && mMousePressed - && mHasMouse) - { - mMousePressed = false; - distributeActionEvent(); - mouseEvent.consume(); - } - else if (mouseEvent.getButton() == MouseEvent::LEFT) - { - mMousePressed = false; - mouseEvent.consume(); - } - } - void Button::mouseDragged(MouseEvent& mouseEvent) { mouseEvent.consume(); diff --git a/src/guichan/widgets/checkbox.cpp b/src/guichan/widgets/checkbox.cpp index 04423a6e9..89fee153e 100644 --- a/src/guichan/widgets/checkbox.cpp +++ b/src/guichan/widgets/checkbox.cpp @@ -78,57 +78,6 @@ namespace gcn adjustSize(); } - void CheckBox::draw(Graphics* graphics) - { - drawBox(graphics); - - graphics->setFont(getFont()); - graphics->setColor(getForegroundColor()); - - const int h = getHeight() + getHeight() / 2; - - graphics->drawText(getCaption(), h - 2, 0); - } - - void CheckBox::drawBox(Graphics *graphics) - { - const int h = getHeight() - 2; - const int alpha = getBaseColor().a; - Color faceColor = getBaseColor(); - faceColor.a = alpha; - Color highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - Color shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - graphics->setColor(shadowColor); - graphics->drawLine(1, 1, h, 1); - graphics->drawLine(1, 1, 1, h); - - graphics->setColor(highlightColor); - graphics->drawLine(h, 1, h, h); - graphics->drawLine(1, h, h - 1, h); - - graphics->setColor(getBackgroundColor()); - graphics->fillRectangle(Rectangle(2, 2, h - 2, h - 2)); - - graphics->setColor(getForegroundColor()); - - if (isFocused()) - { - graphics->drawRectangle(Rectangle(0, 0, h + 2, h + 2)); - } - - if (mSelected) - { - graphics->drawLine(3, 5, 3, h - 2); - graphics->drawLine(4, 5, 4, h - 2); - - graphics->drawLine(5, h - 3, h - 2, 4); - graphics->drawLine(5, h - 4, h - 4, 5); - } - } - bool CheckBox::isSelected() const { return mSelected; diff --git a/src/guichan/widgets/dropdown.cpp b/src/guichan/widgets/dropdown.cpp index 7af01e703..3ecbd75d8 100644 --- a/src/guichan/widgets/dropdown.cpp +++ b/src/guichan/widgets/dropdown.cpp @@ -122,131 +122,6 @@ namespace gcn setInternalFocusHandler(NULL); } - void DropDown::draw(Graphics* graphics) - { - int h; - - if (mDroppedDown) - h = mFoldedUpHeight; - else - h = getHeight(); - - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - // Draw a border. - graphics->setColor(shadowColor); - graphics->drawLine(0, 0, getWidth() - 1, 0); - graphics->drawLine(0, 1, 0, h - 2); - graphics->setColor(highlightColor); - graphics->drawLine(getWidth() - 1, 1, getWidth() - 1, h - 1); - graphics->drawLine(0, h - 1, getWidth() - 1, h - 1); - - // Push a clip area so the other drawings don't need to worry - // about the border. - graphics->pushClipArea(Rectangle(1, 1, getWidth() - 2, h - 2)); - const Rectangle currentClipArea = graphics->getCurrentClipArea(); - - graphics->setColor(getBackgroundColor()); - graphics->fillRectangle(Rectangle(0, 0, - currentClipArea.width, currentClipArea.height)); - - if (isFocused()) - { - graphics->setColor(getSelectionColor()); - graphics->fillRectangle(Rectangle(0, 0, - currentClipArea.width - currentClipArea.height, - currentClipArea.height)); - graphics->setColor(getForegroundColor()); - } - - if (mListBox->getListModel() - && mListBox->getSelected() >= 0) - { - graphics->setColor(getForegroundColor()); - graphics->setFont(getFont()); - - graphics->drawText(mListBox->getListModel()->getElementAt( - mListBox->getSelected()), 1, 0); - } - - // Push a clip area before drawing the button. - graphics->pushClipArea(Rectangle( - currentClipArea.width - currentClipArea.height, - 0, currentClipArea.height, currentClipArea.height)); - drawButton(graphics); - graphics->popClipArea(); - graphics->popClipArea(); - - if (mDroppedDown) - { - // Draw a border around the children. - graphics->setColor(shadowColor); - graphics->drawRectangle(Rectangle(0, mFoldedUpHeight, - getWidth(), getHeight() - mFoldedUpHeight)); - drawChildren(graphics); - } - } - - void DropDown::drawButton(Graphics *graphics) - { - Color faceColor, highlightColor, shadowColor; - int offset; - int alpha = getBaseColor().a; - - if (mPushed) - { - faceColor = getBaseColor() - 0x303030; - faceColor.a = alpha; - highlightColor = faceColor - 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor + 0x303030; - shadowColor.a = alpha; - offset = 1; - } - else - { - faceColor = getBaseColor(); - faceColor.a = alpha; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - offset = 0; - } - - const Rectangle currentClipArea = graphics->getCurrentClipArea(); - graphics->setColor(highlightColor); - graphics->drawLine(0, 0, currentClipArea.width - 1, 0); - graphics->drawLine(0, 1, 0, currentClipArea.height - 1); - graphics->setColor(shadowColor); - graphics->drawLine(currentClipArea.width - 1, 1, - currentClipArea.width - 1, currentClipArea.height - 1); - graphics->drawLine(1, currentClipArea.height - 1, - currentClipArea.width - 2, currentClipArea.height - 1); - - graphics->setColor(faceColor); - graphics->fillRectangle(Rectangle(1, 1, - currentClipArea.width - 2, currentClipArea.height - 2)); - - graphics->setColor(getForegroundColor()); - - int i; - int n = currentClipArea.height / 3; - int dx = currentClipArea.height / 2; - int dy = (currentClipArea.height * 2) / 3; - for (i = 0; i < n; i++) - { - graphics->drawLine(dx - i + offset, dy - i + offset, - dx + i + offset, dy - i + offset); - } - } - int DropDown::getSelected() const { return mListBox->getSelected(); @@ -258,31 +133,6 @@ namespace gcn mListBox->setSelected(selected); } - void DropDown::keyPressed(KeyEvent& keyEvent) - { - if (keyEvent.isConsumed()) - return; - - Key key = keyEvent.getKey(); - - if ((key.getValue() == Key::ENTER || key.getValue() == Key::SPACE) - && !mDroppedDown) - { - dropDown(); - keyEvent.consume(); - } - else if (key.getValue() == Key::UP) - { - setSelected(getSelected() - 1); - keyEvent.consume(); - } - else if (key.getValue() == Key::DOWN) - { - setSelected(getSelected() + 1); - keyEvent.consume(); - } - } - void DropDown::mousePressed(MouseEvent& mouseEvent) { // If we have a mouse press on the widget. diff --git a/src/guichan/widgets/radiobutton.cpp b/src/guichan/widgets/radiobutton.cpp index 37fd4a0f0..48a690767 100644 --- a/src/guichan/widgets/radiobutton.cpp +++ b/src/guichan/widgets/radiobutton.cpp @@ -93,87 +93,6 @@ namespace gcn setGroup(""); } - void RadioButton::draw(Graphics* graphics) - { - graphics->pushClipArea(Rectangle(1, 1, - getWidth() - 1, getHeight() - 1)); - - drawBox(graphics); - graphics->popClipArea(); - - graphics->setFont(getFont()); - graphics->setColor(getForegroundColor()); - - if (isFocused()) - { - int fh; - - if (getHeight() % 2 == 0) - fh = getHeight() - 4; - else - fh = getHeight() - 3; - - int hh = (fh + 1) / 2; - - graphics->drawLine(0, hh + 1, hh + 1, 0); - graphics->drawLine(hh + 2, 1, fh + 2, hh + 1); - graphics->drawLine(fh + 1, hh + 2, hh + 1, fh + 2); - graphics->drawLine(hh + 1, fh + 2, 1, hh + 2); - } - - int h = getHeight() + getHeight() / 2; - - graphics->drawText(getCaption(), h - 2, 0); - } - - void RadioButton::drawBox(Graphics *graphics) - { - int h; - - if (getHeight() % 2 == 0) - h = getHeight() - 4; - else - h = getHeight() - 3; - - int alpha = getBaseColor().a; - Color faceColor = getBaseColor(); - faceColor.a = alpha; - Color highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - Color shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - graphics->setColor(getBackgroundColor()); - - int i; - int hh = (h + 1) / 2; - - for (i = 1; i <= hh; ++i) - graphics->drawLine(hh - i + 1, i, hh + i - 1, i); - - for (i = 1; i < hh; ++i) - graphics->drawLine(hh - i + 1, h - i, hh + i - 1, h - i); - - graphics->setColor(shadowColor); - graphics->drawLine(hh, 0, 0, hh); - graphics->drawLine(hh + 1, 1, h - 1, hh - 1); - - graphics->setColor(highlightColor); - graphics->drawLine(1, hh + 1, hh, h); - graphics->drawLine(hh + 1, h - 1, h, hh); - - graphics->setColor(getForegroundColor()); - - int hhh = hh - 3; - if (mSelected) - { - for (i = 0; i < hhh; ++i) - graphics->drawLine(hh - i, 4 + i, hh + i, 4 + i); - for (i = 0; i < hhh; ++i) - graphics->drawLine(hh - i, h - 4 - i, hh + i, h - 4 - i); - } - } - bool RadioButton::isSelected() const { return mSelected; diff --git a/src/guichan/widgets/slider.cpp b/src/guichan/widgets/slider.cpp index eba88382c..f0eabd627 100644 --- a/src/guichan/widgets/slider.cpp +++ b/src/guichan/widgets/slider.cpp @@ -117,74 +117,6 @@ namespace gcn mScaleEnd = scaleEnd; } - void Slider::draw(gcn::Graphics* graphics) - { - Color shadowColor = getBaseColor() - 0x101010; - int alpha = getBaseColor().a; - shadowColor.a = alpha; - - graphics->setColor(shadowColor); - graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); - - drawMarker(graphics); - } - - void Slider::drawMarker(gcn::Graphics* graphics) - { - gcn::Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - graphics->setColor(faceColor); - - if (getOrientation() == HORIZONTAL) - { - int v = getMarkerPosition(); - graphics->fillRectangle(gcn::Rectangle(v + 1, 1, - getMarkerLength() - 2, getHeight() - 2)); - graphics->setColor(highlightColor); - graphics->drawLine(v, 0, v + getMarkerLength() - 1, 0); - graphics->drawLine(v, 0, v, getHeight() - 1); - graphics->setColor(shadowColor); - graphics->drawLine(v + getMarkerLength() - 1, 1, - v + getMarkerLength() - 1, getHeight() - 1); - graphics->drawLine(v + 1, getHeight() - 1, - v + getMarkerLength() - 1, getHeight() - 1); - - if (isFocused()) - { - graphics->setColor(getForegroundColor()); - graphics->drawRectangle(Rectangle(v + 2, 2, - getMarkerLength() - 4, getHeight() - 4)); - } - } - else - { - int v = (getHeight() - getMarkerLength()) - getMarkerPosition(); - graphics->fillRectangle(gcn::Rectangle(1, v + 1, getWidth() - 2, - getMarkerLength() - 2)); - graphics->setColor(highlightColor); - graphics->drawLine(0, v, 0, v + getMarkerLength() - 1); - graphics->drawLine(0, v, getWidth() - 1, v); - graphics->setColor(shadowColor); - graphics->drawLine(1, v + getMarkerLength() - 1, getWidth() - 1, - v + getMarkerLength() - 1); - graphics->drawLine(getWidth() - 1, v + 1, getWidth() - 1, - v + getMarkerLength() - 1); - - if (isFocused()) - { - graphics->setColor(getForegroundColor()); - graphics->drawRectangle(Rectangle(2, v + 2, getWidth() - 4, - getMarkerLength() - 4)); - } - } - } - void Slider::mousePressed(MouseEvent& mouseEvent) { if (mouseEvent.getButton() == gcn::MouseEvent::LEFT diff --git a/src/guichan/widgets/tab.cpp b/src/guichan/widgets/tab.cpp index 1a3df3ede..9b7424748 100644 --- a/src/guichan/widgets/tab.cpp +++ b/src/guichan/widgets/tab.cpp @@ -105,69 +105,6 @@ namespace gcn return mLabel->getCaption(); } - void Tab::draw(Graphics *graphics) - { - const Color &faceColor = getBaseColor(); - const int alpha = getBaseColor().a; - Color highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - Color shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - Color borderColor; - Color baseColor; - - if ((mTabbedArea != NULL && mTabbedArea->isTabSelected(this)) - || mHasMouse) - { - // Draw a border. - graphics->setColor(highlightColor); - graphics->drawLine(0, 0, getWidth() - 1, 0); - graphics->drawLine(0, 1, 0, getHeight() - 1); - graphics->setColor(shadowColor); - graphics->drawLine(getWidth() - 1, 1, - getWidth() - 1, getHeight() - 1); - - borderColor = highlightColor; - baseColor = getBaseColor(); - } - else - { - // Draw a border. - graphics->setColor(shadowColor); - graphics->drawLine(0, 0, getWidth() - 1, 0); - graphics->drawLine(0, 1, 0, getHeight() - 1); - graphics->drawLine(getWidth() - 1, 1, getWidth() - 1, - getHeight() - 1); - - baseColor = getBaseColor() - 0x151515; - baseColor.a = alpha; - } - - // Push a clip area so the other drawings don't need to worry - // about the border. - graphics->pushClipArea(Rectangle(1, 1, - getWidth() - 2, getHeight() - 1)); - const Rectangle currentClipArea = graphics->getCurrentClipArea(); - - graphics->setColor(baseColor); - graphics->fillRectangle(Rectangle(0, 0, - currentClipArea.width, currentClipArea.height)); - - drawChildren(graphics); - - if (mTabbedArea != NULL - && mTabbedArea->isFocused() - && mTabbedArea->isTabSelected(this)) - { - graphics->setColor(Color(0x000000)); - graphics->drawRectangle(Rectangle(2, 2, - currentClipArea.width - 4, currentClipArea.height - 4)); - } - - graphics->popClipArea(); - } - void Tab::mouseEntered(MouseEvent& mouseEvent A_UNUSED) { mHasMouse = true; diff --git a/src/guichan/widgets/tabbedarea.cpp b/src/guichan/widgets/tabbedarea.cpp index b22d615e9..3c556eeca 100644 --- a/src/guichan/widgets/tabbedarea.cpp +++ b/src/guichan/widgets/tabbedarea.cpp @@ -94,15 +94,6 @@ namespace gcn } } - void TabbedArea::addTab(const std::string& caption, Widget* widget) - { - Tab* tab = new Tab(); - tab->setCaption(caption); - mTabsToDelete.push_back(tab); - - addTab(tab, widget); - } - void TabbedArea::addTab(Tab* tab, Widget* widget) { tab->setTabbedArea(this); @@ -126,69 +117,6 @@ namespace gcn removeTab(mTabs[index].first); } - void TabbedArea::removeTab(Tab* tab) - { - int tabIndexToBeSelected = - 1; - - if (tab == mSelectedTab) - { - int index = getSelectedTabIndex(); - - if (index == (int)mTabs.size() - 1 - && mTabs.size() >= 2) - { - tabIndexToBeSelected = index--; - } - else if (index == (int)mTabs.size() - 1 - && mTabs.size() == 1) - { - tabIndexToBeSelected = -1; - } - else - { - tabIndexToBeSelected = index; - } - } - - std::vector >::iterator iter; - for (iter = mTabs.begin(); iter != mTabs.end(); ++ iter) - { - if (iter->first == tab) - { - mTabContainer->remove(tab); - mTabs.erase(iter); - break; - } - } - - std::vector::iterator iter2; - for (iter2 = mTabsToDelete.begin(); - iter2 != mTabsToDelete.end(); - ++ iter2) - { - if (*iter2 == tab) - { - mTabsToDelete.erase(iter2); - delete tab; - tab = 0; - break; - } - } - - if (tabIndexToBeSelected == -1) - { - mSelectedTab = NULL; - mWidgetContainer->clear(); - } - else - { - setSelectedTab(tabIndexToBeSelected); - } - - adjustSize(); - adjustTabPositions(); - } - bool TabbedArea::isTabSelected(unsigned int index) const { if (index >= mTabs.size()) @@ -309,10 +237,6 @@ namespace gcn drawChildren(graphics); } - void TabbedArea::logic() - { - } - void TabbedArea::adjustSize() { int maxTabHeight = 0; @@ -404,29 +328,6 @@ namespace gcn } } - - void TabbedArea::mousePressed(MouseEvent& mouseEvent) - { - if (mouseEvent.isConsumed()) - return; - - if (mouseEvent.getButton() == MouseEvent::LEFT) - { - Widget* widget = mTabContainer->getWidgetAt( - mouseEvent.getX(), mouseEvent.getY()); - Tab* tab = dynamic_cast(widget); - - if (tab != NULL) - setSelectedTab(tab); - } - - // Request focus only if the source of the event - // is not focusble. If the source of the event - // is focused we don't want to steal the focus. - if (!mouseEvent.getSource()->isFocusable()) - requestFocus(); - } - void TabbedArea::death(const Event& event) { Tab* tab = dynamic_cast(event.getSource()); diff --git a/src/guichan/widgets/textfield.cpp b/src/guichan/widgets/textfield.cpp index af2b9582f..d224e483f 100644 --- a/src/guichan/widgets/textfield.cpp +++ b/src/guichan/widgets/textfield.cpp @@ -89,55 +89,6 @@ namespace gcn mText = text; } - void TextField::draw(Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - // Draw a border. - graphics->setColor(shadowColor); - graphics->drawLine(0, 0, getWidth() - 1, 0); - graphics->drawLine(0, 1, 0, getHeight() - 2); - graphics->setColor(highlightColor); - graphics->drawLine(getWidth() - 1, 1, getWidth() - 1, getHeight() - 1); - graphics->drawLine(0, getHeight() - 1, - getWidth() - 1, getHeight() - 1); - - // Push a clip area so the other drawings don't need to worry - // about the border. - graphics->pushClipArea(Rectangle(1, 1, - getWidth() - 2, getHeight() - 2)); - - graphics->setColor(getBackgroundColor()); - graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight())); - - if (isFocused()) - { - graphics->setColor(getSelectionColor()); - graphics->drawRectangle(Rectangle(0, 0, - getWidth() - 2, getHeight() - 2)); - graphics->drawRectangle(Rectangle(1, 1, - getWidth() - 4, getHeight() - 4)); - } - - if (isFocused()) - { - drawCaret(graphics, getFont()->getWidth( - mText.substr(0, mCaretPosition)) - mXScroll); - } - - graphics->setColor(getForegroundColor()); - graphics->setFont(getFont()); - graphics->drawText(mText, 3 - mXScroll, 1); - - graphics->popClipArea(); - } - void TextField::drawCaret(Graphics* graphics, int x) { // Check the current clip area as a clip area with a different @@ -164,53 +115,6 @@ namespace gcn { mouseEvent.consume(); } - - void TextField::keyPressed(KeyEvent& keyEvent) - { - Key key = keyEvent.getKey(); - - if (key.getValue() == Key::LEFT && mCaretPosition > 0) - { - --mCaretPosition; - } - else if (key.getValue() == Key::RIGHT && mCaretPosition < mText.size()) - { - ++mCaretPosition; - } - else if (key.getValue() == Key::DELETE - && mCaretPosition < mText.size()) - { - mText.erase(mCaretPosition, 1); - } - else if (key.getValue() == Key::BACKSPACE && mCaretPosition > 0) - { - mText.erase(mCaretPosition - 1, 1); - --mCaretPosition; - } - else if (key.getValue() == Key::ENTER) - { - distributeActionEvent(); - } - else if (key.getValue() == Key::HOME) - { - mCaretPosition = 0; - } - else if (key.getValue() == Key::END) - { - mCaretPosition = mText.size(); - } - else if (key.isCharacter() - && key.getValue() != Key::TAB) - { - mText.insert(mCaretPosition, std::string(1, (char)key.getValue())); - ++mCaretPosition; - } - - if (key.getValue() != Key::TAB) - keyEvent.consume(); - - fixScroll(); - } void TextField::adjustSize() { diff --git a/src/guichan/widgets/window.cpp b/src/guichan/widgets/window.cpp index d0ba32f47..550b23749 100644 --- a/src/guichan/widgets/window.cpp +++ b/src/guichan/widgets/window.cpp @@ -125,97 +125,6 @@ namespace gcn return mAlignment; } - void Window::draw(Graphics* graphics) - { - const Color &faceColor = getBaseColor(); - Color highlightColor, shadowColor; - const int alpha = getBaseColor().a; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - Rectangle d = getChildrenArea(); - - // Fill the background around the content - graphics->setColor(faceColor); - // Fill top - graphics->fillRectangle(Rectangle(0, 0, getWidth(), d.y - 1)); - // Fill left - graphics->fillRectangle(Rectangle(0, d.y - 1, d.x - 1, - getHeight() - d.y + 1)); - // Fill right - graphics->fillRectangle(Rectangle(d.x + d.width + 1, d.y - 1, - getWidth() - d.x - d.width - 1, getHeight() - d.y + 1)); - // Fill bottom - graphics->fillRectangle(Rectangle(d.x - 1, d.y + d.height + 1, - d.width + 2, getHeight() - d.height - d.y - 1)); - - if (isOpaque()) - graphics->fillRectangle(d); - - // Construct a rectangle one pixel bigger than the content - d.x -= 1; - d.y -= 1; - d.width += 2; - d.height += 2; - - // Draw a border around the content - graphics->setColor(shadowColor); - // Top line - graphics->drawLine(d.x, - d.y, - d.x + d.width - 2, - d.y); - - // Left line - graphics->drawLine(d.x, - d.y + 1, - d.x, - d.y + d.height - 1); - - graphics->setColor(highlightColor); - // Right line - graphics->drawLine(d.x + d.width - 1, - d.y, - d.x + d.width - 1, - d.y + d.height - 2); - // Bottom line - graphics->drawLine(d.x + 1, - d.y + d.height - 1, - d.x + d.width - 1, - d.y + d.height - 1); - - drawChildren(graphics); - - int textX; - int textY; - - textY = ((int)getTitleBarHeight() - getFont()->getHeight()) / 2; - - switch (getAlignment()) - { - case Graphics::LEFT: - textX = 4; - break; - case Graphics::CENTER: - textX = getWidth() / 2; - break; - case Graphics::RIGHT: - textX = getWidth() - 4; - break; - default: - throw GCN_EXCEPTION("Unknown alignment."); - } - - graphics->setColor(getForegroundColor()); - graphics->setFont(getFont()); - graphics->pushClipArea(Rectangle(0, 0, getWidth(), - getTitleBarHeight() - 1)); - graphics->drawText(getCaption(), textX, textY, getAlignment()); - graphics->popClipArea(); - } - void Window::mousePressed(MouseEvent& mouseEvent) { if (mouseEvent.getSource() != this) -- cgit v1.2.3-60-g2f50