summaryrefslogtreecommitdiff
path: root/src/guichan/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-09-15 04:22:11 +0300
committerAndrei Karas <akaras@inbox.ru>2011-09-15 04:22:11 +0300
commitc91bc5201596eda73f9df2222d76d9f413426a85 (patch)
treecbdcf7fb76eee35baf7265e5c04da2f13633ab5d /src/guichan/widgets
parent255b1c29f47ef3b1e7a9b058c56ef72bfa10c5e3 (diff)
downloadmv-c91bc5201596eda73f9df2222d76d9f413426a85.tar.gz
mv-c91bc5201596eda73f9df2222d76d9f413426a85.tar.bz2
mv-c91bc5201596eda73f9df2222d76d9f413426a85.tar.xz
mv-c91bc5201596eda73f9df2222d76d9f413426a85.zip
Remove some diplicated code from embeded guichan.
Diffstat (limited to 'src/guichan/widgets')
-rw-r--r--src/guichan/widgets/button.cpp19
-rw-r--r--src/guichan/widgets/checkbox.cpp51
-rw-r--r--src/guichan/widgets/dropdown.cpp150
-rw-r--r--src/guichan/widgets/radiobutton.cpp81
-rw-r--r--src/guichan/widgets/slider.cpp68
-rw-r--r--src/guichan/widgets/tab.cpp63
-rw-r--r--src/guichan/widgets/tabbedarea.cpp99
-rw-r--r--src/guichan/widgets/textfield.cpp96
-rw-r--r--src/guichan/widgets/window.cpp91
9 files changed, 2 insertions, 716 deletions
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<std::pair<Tab*, Widget*> >::iterator iter;
- for (iter = mTabs.begin(); iter != mTabs.end(); ++ iter)
- {
- if (iter->first == tab)
- {
- mTabContainer->remove(tab);
- mTabs.erase(iter);
- break;
- }
- }
-
- std::vector<Tab*>::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<Tab*>(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<Tab*>(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)