summaryrefslogtreecommitdiff
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
parent255b1c29f47ef3b1e7a9b058c56ef72bfa10c5e3 (diff)
downloadplus-c91bc5201596eda73f9df2222d76d9f413426a85.tar.gz
plus-c91bc5201596eda73f9df2222d76d9f413426a85.tar.bz2
plus-c91bc5201596eda73f9df2222d76d9f413426a85.tar.xz
plus-c91bc5201596eda73f9df2222d76d9f413426a85.zip
Remove some diplicated code from embeded guichan.
-rw-r--r--src/gui/widgets/window.cpp2
-rw-r--r--src/guichan/include/guichan/widgets/button.hpp8
-rw-r--r--src/guichan/include/guichan/widgets/checkbox.hpp14
-rw-r--r--src/guichan/include/guichan/widgets/dropdown.hpp6
-rw-r--r--src/guichan/include/guichan/widgets/radiobutton.hpp7
-rw-r--r--src/guichan/include/guichan/widgets/slider.hpp12
-rw-r--r--src/guichan/include/guichan/widgets/tab.hpp3
-rw-r--r--src/guichan/include/guichan/widgets/tabbedarea.hpp18
-rw-r--r--src/guichan/include/guichan/widgets/textfield.hpp8
-rw-r--r--src/guichan/include/guichan/widgets/window.hpp7
-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
19 files changed, 7 insertions, 796 deletions
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);
@@ -146,13 +139,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
@@ -109,16 +109,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<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)