diff options
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/button.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/desktop.cpp | 24 | ||||
-rw-r--r-- | src/gui/widgets/dropdown.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/emoteshortcutcontainer.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/itemshortcutcontainer.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/playerbox.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/progressbar.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.cpp | 6 | ||||
-rw-r--r-- | src/gui/widgets/tab.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/textfield.cpp | 46 | ||||
-rw-r--r-- | src/gui/widgets/textfield.h | 6 |
11 files changed, 33 insertions, 63 deletions
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 4a31fa63..9247f67a 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -182,7 +182,7 @@ Button::~Button() { for (int mode = 0; mode < BUTTON_COUNT; ++mode) { - for_each(mButton[mode].grid, mButton[mode].grid + 9, + std::for_each(mButton[mode].grid, mButton[mode].grid + 9, dtor<Image*>()); } delete[] mButton; diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index ec76f861..c9974fec 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -94,14 +94,9 @@ void Desktop::draw(gcn::Graphics *graphics) if (mWallpaper) { - if (!Image::useOpenGL()) - g->drawImage(mWallpaper, - (getWidth() - mWallpaper->getWidth()) / 2, - (getHeight() - mWallpaper->getHeight()) / 2); - else - g->drawRescaledImage(mWallpaper, 0, 0, 0, 0, - mWallpaper->getWidth(), mWallpaper->getHeight(), - getWidth(), getHeight(), false); + g->drawRescaledImage(mWallpaper, 0, 0, 0, 0, + mWallpaper->getWidth(), mWallpaper->getHeight(), + getWidth(), getHeight(), false); } mBgSkin->setAlpha(1.0f); @@ -168,19 +163,6 @@ void Desktop::setBestFittingWallpaper() mWallpaper->decRef(Resource::DeleteImmediately); mWallpaper = wallpaper; - - // In software mode we try to prescale the image for performance - if (!wallpaper->useOpenGL() && - (wallpaper->getWidth() != width || - wallpaper->getHeight() != height)) - { - if (Image *prescaled = wallpaper->SDLgetScaledImage(width, height)) - { - // Make sure the original can be freed - wallpaper->decRef(); - mWallpaper = prescaled; - } - } } else { diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index e90f6073..101afaef 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -102,7 +102,7 @@ DropDown::~DropDown() buttons[1][0]->decRef(); buttons[1][1]->decRef(); - for_each(skin.grid, skin.grid + 9, dtor<Image*>()); + std::for_each(skin.grid, skin.grid + 9, dtor<Image*>()); } delete mScrollArea; diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 3105a762..cdb2d3c4 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -92,7 +92,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics) // Draw emote keyboard shortcut. const char *key = SDL_GetKeyName( - (SDLKey) keyboard.getKeyValue(keyboard.KEY_EMOTE_1 + i)); + (SDL_Scancode) keyboard.getKeyValue(keyboard.KEY_EMOTE_1 + i)); graphics->setColor(Theme::getThemeColor(Theme::TEXT)); g->drawText(key, emoteX + 2, emoteY + 2, gcn::Graphics::LEFT); diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index f1690d43..396de3bd 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -86,7 +86,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) // Draw item keyboard shortcut. const char *key = SDL_GetKeyName( - (SDLKey) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_1 + i)); + (SDL_Scancode) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_1 + i)); graphics->setColor(Theme::getThemeColor(Theme::TEXT)); g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT); diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 5c5976c1..4f341af0 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -75,7 +75,7 @@ PlayerBox::~PlayerBox() if (instances == 0) { - for_each(background.grid, background.grid + 9, dtor<Image*>()); + std::for_each(background.grid, background.grid + 9, dtor<Image*>()); } } diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 27b194ff..4695f5ab 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -88,7 +88,7 @@ ProgressBar::~ProgressBar() if (mInstances == 0) { - for_each(mBorder.grid, mBorder.grid + 9, dtor<Image*>()); + std::for_each(mBorder.grid, mBorder.grid + 9, dtor<Image*>()); } } diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index d5e824e1..c95adeaa 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -66,9 +66,9 @@ ScrollArea::~ScrollArea() if (instances == 0) { - for_each(background.grid, background.grid + 9, dtor<Image*>()); - for_each(vMarker.grid, vMarker.grid + 9, dtor<Image*>()); - for_each(vMarkerHi.grid, vMarkerHi.grid + 9, dtor<Image*>()); + std::for_each(background.grid, background.grid + 9, dtor<Image*>()); + std::for_each(vMarker.grid, vMarker.grid + 9, dtor<Image*>()); + std::for_each(vMarkerHi.grid, vMarkerHi.grid + 9, dtor<Image*>()); buttons[UP][0]->decRef(); buttons[UP][1]->decRef(); diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index 17b7108f..c8ed2141 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -76,7 +76,7 @@ Tab::~Tab() { for (int mode = 0; mode < TAB_COUNT; mode++) { - for_each(tabImg[mode].grid, tabImg[mode].grid + 9, dtor<Image*>()); + std::for_each(tabImg[mode].grid, tabImg[mode].grid + 9, dtor<Image*>()); } } } diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index ec57f1c7..35ce09c5 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -24,7 +24,6 @@ #include "configuration.h" #include "graphics.h" -#include "gui/palette.h" #include "gui/sdlinput.h" #include "resources/image.h" @@ -36,6 +35,8 @@ #include <guichan/font.hpp> +#include <SDL.h> + #undef DELETE //Win32 compatibility hack int TextField::instances = 0; @@ -84,7 +85,7 @@ TextField::~TextField() instances--; if (instances == 0) - for_each(skin.grid, skin.grid + 9, dtor<Image*>()); + std::for_each(skin.grid, skin.grid + 9, dtor<Image*>()); } void TextField::updateAlpha() @@ -162,33 +163,7 @@ int TextField::getValue() const void TextField::keyPressed(gcn::KeyEvent &keyEvent) { - int val = keyEvent.getKey().getValue(); - - if (val >= 32) - { - int l; - if (val < 128) l = 1; // 0xxxxxxx - else if (val < 0x800) l = 2; // 110xxxxx 10xxxxxx - else if (val < 0x10000) l = 3; // 1110xxxx 10xxxxxx 10xxxxxx - else l = 4; // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - - char buf[4]; - for (int i = 0; i < l; ++i) - { - buf[i] = val >> (6 * (l - i - 1)); - if (i > 0) buf[i] = (buf[i] & 63) | 128; - } - - if (l > 1) buf[0] |= 255 << (8 - l); - - mText.insert(mCaretPosition, std::string(buf, buf + l)); - mCaretPosition += l; - } - - /* In UTF-8, 10xxxxxx is only used for inner parts of characters. So skip - them when processing key presses. */ - - switch (val) + switch (keyEvent.getKey().getValue()) { case Key::LEFT: { @@ -302,8 +277,9 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent) return; break; - case 22: // Control code 22, SYNCHRONOUS IDLE, sent on Ctrl+v - handlePaste(); + case SDLK_v: + if (keyEvent.isControlPressed()) + handlePaste(); break; } @@ -311,6 +287,12 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent) fixScroll(); } +void TextField::textInput(const TextInput &textInput) +{ + mText.insert(mCaretPosition, textInput.getText()); + mCaretPosition += textInput.getText().length(); +} + void TextField::autoComplete() { if (mAutoComplete && mText.size() > 0) @@ -383,7 +365,7 @@ void TextField::handlePaste() std::string text = getText(); std::string::size_type caretPos = getCaretPosition(); - if (RetrieveBuffer(text, caretPos)) { + if (insertFromClipboard(text, caretPos)) { setText(text); setCaretPosition(caretPos); } diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 94cada41..bf60cbc3 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -26,6 +26,7 @@ #include <vector> +class TextInput; class ImageRect; class TextField; @@ -116,6 +117,11 @@ class TextField : public gcn::TextField void keyPressed(gcn::KeyEvent &keyEvent); /** + * Handle text input (should possibly be new event in Guichan). + */ + void textInput(const TextInput &textInput); + + /** * Set the minimum value for a range */ void setMinimum(int min) { mMinimum = min; } |