From 5ecd27dcaf1553f142cee0a89400d2335ba504f6 Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Sat, 2 Dec 2023 11:30:45 +0100 Subject: [PATCH 1/2] Apply part of guichan's changes 753608c0c8cd0196c19c467db0f8df5f61d99b3c (25/dec/2007): - `Widget::drawBorder`, `Widget::getBorderSize` and `Widget::setBorderSize` have been renamed to `Widget::drawFrame`, `Widget::getFrameSize` and `Widget::setFrameSize`. --- demo/ff/src/ffcharacterchooser.cpp | 2 +- demo/ff/src/ffcontainer.cpp | 2 +- demo/ff/src/ffdemo.cpp | 36 ++++++------- demo/ff/src/fflistbox.cpp | 2 +- demo/ff/src/ffscrollarea.cpp | 2 +- examples/openglwidgets.cpp | 6 +-- examples/sdl2widgets.cpp | 6 +-- examples/sdlwidgets.cpp | 6 +-- include/guisan/widget.hpp | 73 +++++++++++++++++--------- include/guisan/widgets/button.hpp | 2 +- include/guisan/widgets/checkbox.hpp | 2 +- include/guisan/widgets/container.hpp | 2 +- include/guisan/widgets/dropdown.hpp | 2 +- include/guisan/widgets/icon.hpp | 2 +- include/guisan/widgets/inputbox.hpp | 2 +- include/guisan/widgets/label.hpp | 2 +- include/guisan/widgets/listbox.hpp | 2 +- include/guisan/widgets/messagebox.hpp | 2 +- include/guisan/widgets/progressbar.hpp | 2 +- include/guisan/widgets/radiobutton.hpp | 2 +- include/guisan/widgets/scrollarea.hpp | 2 +- include/guisan/widgets/slider.hpp | 2 +- include/guisan/widgets/tab.hpp | 2 +- include/guisan/widgets/tabbedarea.hpp | 2 +- include/guisan/widgets/textbox.hpp | 2 +- include/guisan/widgets/textfield.hpp | 2 +- include/guisan/widgets/window.hpp | 2 +- src/basiccontainer.cpp | 14 ++--- src/gui.cpp | 14 ++--- src/widget.cpp | 4 +- src/widgets/button.cpp | 12 ++--- src/widgets/checkbox.cpp | 8 +-- src/widgets/container.cpp | 8 +-- src/widgets/dropdown.cpp | 10 ++-- src/widgets/icon.cpp | 8 +-- src/widgets/inputbox.cpp | 26 ++++----- src/widgets/label.cpp | 8 +-- src/widgets/listbox.cpp | 8 +-- src/widgets/messagebox.cpp | 12 ++--- src/widgets/progressbar.cpp | 14 ++--- src/widgets/radiobutton.cpp | 8 +-- src/widgets/scrollarea.cpp | 20 +++---- src/widgets/slider.cpp | 12 ++--- src/widgets/tab.cpp | 10 ++-- src/widgets/tabbedarea.cpp | 18 +++---- src/widgets/textbox.cpp | 12 ++--- src/widgets/textfield.cpp | 12 ++--- src/widgets/window.cpp | 16 +++--- 48 files changed, 224 insertions(+), 201 deletions(-) diff --git a/demo/ff/src/ffcharacterchooser.cpp b/demo/ff/src/ffcharacterchooser.cpp index 646e4ae..a188e77 100644 --- a/demo/ff/src/ffcharacterchooser.cpp +++ b/demo/ff/src/ffcharacterchooser.cpp @@ -52,7 +52,7 @@ FFCharacterChooser::FFCharacterChooser() mHand = gcn::Image::load("images/hand.png"); setFocusable(true); addKeyListener(this); - setBorderSize(0); + setFrameSize(0); } FFCharacterChooser::~FFCharacterChooser() diff --git a/demo/ff/src/ffcontainer.cpp b/demo/ff/src/ffcontainer.cpp index 5f78c56..2b5917a 100644 --- a/demo/ff/src/ffcontainer.cpp +++ b/demo/ff/src/ffcontainer.cpp @@ -79,7 +79,7 @@ FFContainer::FFContainer() Container::setHeight(0); mSlideTarget = 0; mCurrentSlide = 0; - setBorderSize(0); + setFrameSize(0); } FFContainer::~FFContainer() diff --git a/demo/ff/src/ffdemo.cpp b/demo/ff/src/ffdemo.cpp index 360fceb..3ebae5f 100644 --- a/demo/ff/src/ffdemo.cpp +++ b/demo/ff/src/ffdemo.cpp @@ -96,7 +96,7 @@ FFDemo::FFDemo() mGoldFootsteps = new FFContainer(); mGoldFootsteps->setDimension(gcn::Rectangle(210, 170, 110, 70)); mGoldFootsteps->setOpaque(false); - mGoldFootsteps->setBorderSize(0); + mGoldFootsteps->setFrameSize(0); mTop->add(mGoldFootsteps); mTime = new FFContainer(); @@ -109,13 +109,13 @@ FFDemo::FFDemo() mGoldFootstepsInfo1->setOpaque(false); mGoldFootstepsInfo1->setEditable(false); mGoldFootstepsInfo1->setFocusable(false); - mGoldFootstepsInfo1->setBorderSize(0); + mGoldFootstepsInfo1->setFrameSize(0); mGoldFootstepsInfo2 = new gcn::TextBox("\n 9119092\n\n 1009213"); mGoldFootstepsInfo2->setOpaque(false); mGoldFootstepsInfo2->setEditable(false); mGoldFootstepsInfo2->setFocusable(false); - mGoldFootstepsInfo2->setBorderSize(0); + mGoldFootstepsInfo2->setFrameSize(0); mTimeLabel1 = new gcn::Label("Time"); mTimeLabel1->setFont(mFontCyan); @@ -210,39 +210,39 @@ void FFDemo::initMain() mPerInfo1->setOpaque(false); mPerInfo1->setEditable(false); mPerInfo1->setFocusable(false); - mPerInfo1->setBorderSize(0); + mPerInfo1->setFrameSize(0); mPerInfo2 = new gcn::TextBox("FINALMAN\n 13\n 12/ 336\n 33/ 40"); mPerInfo2->setOpaque(false); mPerInfo2->setEditable(false); mPerInfo2->setFocusable(false); - mPerInfo2->setBorderSize(0); + mPerInfo2->setFrameSize(0); mOlofInfo1 = new gcn::TextBox("\n LV\n HP\n MP"); mOlofInfo1->setFont(mFontCyan); mOlofInfo1->setOpaque(false); mOlofInfo1->setEditable(false); mOlofInfo1->setFocusable(false); - mOlofInfo1->setBorderSize(0); + mOlofInfo1->setFrameSize(0); mOlofInfo2 = new gcn::TextBox("YAKSLEM\n 41\n 1304/2932\n 298/ 300"); mOlofInfo2->setOpaque(false); mOlofInfo2->setEditable(false); mOlofInfo2->setFocusable(false); - mOlofInfo2->setBorderSize(0); + mOlofInfo2->setFrameSize(0); mTomasInfo1 = new gcn::TextBox("\n LV\n HP\n MP"); mTomasInfo1->setFont(mFontCyan); mTomasInfo1->setOpaque(false); mTomasInfo1->setEditable(false); mTomasInfo1->setFocusable(false); - mTomasInfo1->setBorderSize(0); + mTomasInfo1->setFrameSize(0); mTomasInfo2 = new gcn::TextBox("PEAK\n 6\n 101/ 101\n 0/ 0"); mTomasInfo2->setOpaque(false); mTomasInfo2->setEditable(false); mTomasInfo2->setFocusable(false); - mTomasInfo2->setBorderSize(0); + mTomasInfo2->setFrameSize(0); int offset = 6; mMain->add(mPerIcon, 10, offset); @@ -308,7 +308,7 @@ void FFDemo::initStatus() mPerStatus1->setEditable(false); mPerStatus1->setFocusable(false); mPerStatus1->setVisible(false); - mPerStatus1->setBorderSize(0); + mPerStatus1->setFrameSize(0); mPerStatus2 = new gcn::TextBox(" 32 12382\n" " 56 13872\n" @@ -321,7 +321,7 @@ void FFDemo::initStatus() mPerStatus2->setEditable(false); mPerStatus2->setFocusable(false); mPerStatus2->setVisible(false); - mPerStatus2->setBorderSize(0); + mPerStatus2->setFrameSize(0); mOlofStatus1 = new gcn::TextBox(" STR EXP\n" " INT NEXT\n" @@ -332,7 +332,7 @@ void FFDemo::initStatus() mOlofStatus1->setEditable(false); mOlofStatus1->setFocusable(false); mOlofStatus1->setVisible(false); - mOlofStatus1->setBorderSize(0); + mOlofStatus1->setFrameSize(0); mOlofStatus2 = new gcn::TextBox(" 2 412382\n" " 72 513872\n" @@ -345,7 +345,7 @@ void FFDemo::initStatus() mOlofStatus2->setEditable(false); mOlofStatus2->setFocusable(false); mOlofStatus2->setVisible(false); - mOlofStatus2->setBorderSize(0); + mOlofStatus2->setFrameSize(0); mTomasStatus1 = new gcn::TextBox(" STR EXP\n" " INT NEXT\n" @@ -356,7 +356,7 @@ void FFDemo::initStatus() mTomasStatus1->setEditable(false); mTomasStatus1->setFocusable(false); mTomasStatus1->setVisible(false); - mTomasStatus1->setBorderSize(0); + mTomasStatus1->setFrameSize(0); mTomasStatus2 = new gcn::TextBox(" 1 412382\n" " 3 513872\n" @@ -369,7 +369,7 @@ void FFDemo::initStatus() mTomasStatus2->setEditable(false); mTomasStatus2->setFocusable(false); mTomasStatus2->setVisible(false); - mTomasStatus2->setBorderSize(0); + mTomasStatus2->setFrameSize(0); mStatus->add(mPerStatus2, 5, 10); mStatus->add(mPerStatus1, 5, 10); @@ -509,7 +509,7 @@ void FFDemo::initItems() mItemsInfoInfo->setEditable(false); mItemsInfoInfo->setFocusable(false); mItemsInfoInfo->setDimension(gcn::Rectangle(5, 5, 310, 40)); - mItemsInfoInfo->setBorderSize(0); + mItemsInfoInfo->setFrameSize(0); mItemsInfo->add(mItemsInfoInfo); mItemsList = new FFListBox(); @@ -584,9 +584,9 @@ void FFDemo::initAbout() mAboutScrollArea->setContent(mAboutInfo); mAboutScrollArea->setFocusable(true); mAboutScrollArea->setDimension(gcn::Rectangle(5, 5, 310, 230)); - mAboutScrollArea->setBorderSize(0); + mAboutScrollArea->setFrameSize(0); mAbout->add(mAboutScrollArea); - mAbout->setBorderSize(0); + mAbout->setFrameSize(0); } void FFDemo::cleanAbout() diff --git a/demo/ff/src/fflistbox.cpp b/demo/ff/src/fflistbox.cpp index 3b04dc6..fdbe5ea 100644 --- a/demo/ff/src/fflistbox.cpp +++ b/demo/ff/src/fflistbox.cpp @@ -61,7 +61,7 @@ FFListBox::FFListBox() } mInstances++; - setBorderSize(0); + setFrameSize(0); setWrappingEnabled(true); } diff --git a/demo/ff/src/ffscrollarea.cpp b/demo/ff/src/ffscrollarea.cpp index 61cc9a9..d4dfc4a 100644 --- a/demo/ff/src/ffscrollarea.cpp +++ b/demo/ff/src/ffscrollarea.cpp @@ -50,7 +50,7 @@ FFScrollArea::FFScrollArea() setScrollPolicy(SHOW_NEVER, SHOW_NEVER); addKeyListener(this); setFocusable(false); - setBorderSize(0); + setFrameSize(0); } void FFScrollArea::draw(gcn::Graphics *graphics) diff --git a/examples/openglwidgets.cpp b/examples/openglwidgets.cpp index 5bf3d7f..5dfdb96 100644 --- a/examples/openglwidgets.cpp +++ b/examples/openglwidgets.cpp @@ -138,10 +138,10 @@ void initWidgets() textBoxScrollArea = new gcn::ScrollArea(textBox); textBoxScrollArea->setWidth(270); textBoxScrollArea->setHeight(100); - textBoxScrollArea->setBorderSize(1); + textBoxScrollArea->setFrameSize(1); listBox = new gcn::ListBox(&demoListModel); - listBox->setBorderSize(1); + listBox->setFrameSize(1); dropDown = new gcn::DropDown(&demoListModel); @@ -172,7 +172,7 @@ void initWidgets() nestedScrollArea = new gcn::ScrollArea(nestedContainer); nestedScrollArea->setSize(180, 90); - nestedScrollArea->setBorderSize(1); + nestedScrollArea->setFrameSize(1); /* * Add them to the top container diff --git a/examples/sdl2widgets.cpp b/examples/sdl2widgets.cpp index 423abd6..37af935 100644 --- a/examples/sdl2widgets.cpp +++ b/examples/sdl2widgets.cpp @@ -120,10 +120,10 @@ initWidgets() textBoxScrollArea = new gcn::ScrollArea(textBox); textBoxScrollArea->setWidth(270); textBoxScrollArea->setHeight(100); - textBoxScrollArea->setBorderSize(1); + textBoxScrollArea->setFrameSize(1); listBox = new gcn::ListBox(&demoListModel); - listBox->setBorderSize(1); + listBox->setFrameSize(1); dropDown = new gcn::DropDown(&demoListModel); @@ -154,7 +154,7 @@ initWidgets() nestedScrollArea = new gcn::ScrollArea(nestedContainer); nestedScrollArea->setSize(180, 90); - nestedScrollArea->setBorderSize(1); + nestedScrollArea->setFrameSize(1); /* * Add them to the top container diff --git a/examples/sdlwidgets.cpp b/examples/sdlwidgets.cpp index 01af829..4d25164 100644 --- a/examples/sdlwidgets.cpp +++ b/examples/sdlwidgets.cpp @@ -121,10 +121,10 @@ initWidgets() textBoxScrollArea = new gcn::ScrollArea(textBox); textBoxScrollArea->setWidth(270); textBoxScrollArea->setHeight(100); - textBoxScrollArea->setBorderSize(1); + textBoxScrollArea->setFrameSize(1); listBox = new gcn::ListBox(&demoListModel); - listBox->setBorderSize(1); + listBox->setFrameSize(1); dropDown = new gcn::DropDown(&demoListModel); @@ -159,7 +159,7 @@ initWidgets() nestedScrollArea = new gcn::ScrollArea(nestedContainer); nestedScrollArea->setSize(180, 90); - nestedScrollArea->setBorderSize(1); + nestedScrollArea->setFrameSize(1); /* * Add them to the top container diff --git a/include/guisan/widget.hpp b/include/guisan/widget.hpp index d9c4826..29aed85 100644 --- a/include/guisan/widget.hpp +++ b/include/guisan/widget.hpp @@ -117,14 +117,57 @@ namespace gcn virtual void draw(Graphics* graphics) = 0; /** - * Draws the widget border. A border is drawn around a widget. - * The width and height of the border is therefore the widgets - * height+2*bordersize. Think of a painting that has a certain size, - * the border surrounds the painting. + * Called when a widget is given a chance to draw a frame around itself. + * The frame is not considered a part of the widget, it only allows a frame + * to be drawn around the widget, thus a frame will never be included when + * calculating if a widget should receive events from user input. Also + * a widget's frame will never be included when calculating a widget's + * position. + * + * The size of the frame is calculated using the widget's frame size. + * If a widget has a frame size of 10 pixels than the area the drawFrame + * function can draw to will be the size of the widget with an additional + * extension of 10 pixels in each direction. * * @param graphics a Graphics object to draw with. + * An example when drawFrame is a useful function is if a widget needs + * a glow around itself. + * + * @param graphics a graphics object to draw with. + * @see setFrameSize, getFrameSize + */ + virtual void drawFrame(Graphics* graphics) { } + + /** + * Sets the size of the widget's frame. The frame is not considered a part of + * the widget, it only allows a frame to be drawn around the widget, thus a frame + * will never be included when calculating if a widget should receive events + * from user input. Also a widget's frame will never be included when calculating + * a widget's position. + * + * A frame size of 0 means that the widget has no frame. The default frame size + * is 0. + * + * @param frameSize The size of the widget's frame. + * @see getFrameSize, drawFrame + */ + void setFrameSize(unsigned int frameSize); + + /** + * Gets the size of the widget's frame. The frame is not considered a part of + * the widget, it only allows a frame to be drawn around the widget, thus a frame + * will never be included when calculating if a widget should receive events + * from user input. Also a widget's frame will never be included when calculating + * a widget's position. + * + * A frame size of 0 means that the widget has no frame. The default frame size + * is 0. + * + * @return The size of the widget's frame. + * @see setFrameSize, drawFrame */ - virtual void drawBorder(Graphics* graphics) { } + unsigned int getFrameSize() const; + /** * Called for all widgets in the gui each time Gui::logic is called. @@ -221,26 +264,6 @@ namespace gcn */ void setDimension(const Rectangle& dimension); - /** - * Sets the size of the border, or the width if you so like. The size - * is the number of pixels that the border extends outside the widget. - * Border size = 0 means no border. - * - * @param borderSize the size of the border. - * @see drawBorder - */ - void setBorderSize(unsigned int borderSize); - - /** - * Gets the size of the border, or the width if you so like. The size - * is the number of pixels that the border extends outside the widget. - * Border size = 0 means no border. - * - * @return the size of the border. - * @see drawBorder - */ - unsigned int getBorderSize() const; - /** * Gets the dimension of the widget. It is relative to its parent. * diff --git a/include/guisan/widgets/button.hpp b/include/guisan/widgets/button.hpp index c565132..c4a6968 100644 --- a/include/guisan/widgets/button.hpp +++ b/include/guisan/widgets/button.hpp @@ -149,7 +149,7 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); // Inherited from FocusListener diff --git a/include/guisan/widgets/checkbox.hpp b/include/guisan/widgets/checkbox.hpp index 995fd6c..1ca0aff 100644 --- a/include/guisan/widgets/checkbox.hpp +++ b/include/guisan/widgets/checkbox.hpp @@ -144,7 +144,7 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); // Inherited from KeyListener diff --git a/include/guisan/widgets/container.hpp b/include/guisan/widgets/container.hpp index 6a2d4d4..5396f0a 100644 --- a/include/guisan/widgets/container.hpp +++ b/include/guisan/widgets/container.hpp @@ -164,7 +164,7 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); protected: /** diff --git a/include/guisan/widgets/dropdown.hpp b/include/guisan/widgets/dropdown.hpp index f854df0..738892d 100644 --- a/include/guisan/widgets/dropdown.hpp +++ b/include/guisan/widgets/dropdown.hpp @@ -177,7 +177,7 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); void setBaseColor(const Color& color); diff --git a/include/guisan/widgets/icon.hpp b/include/guisan/widgets/icon.hpp index 6360414..d444e80 100644 --- a/include/guisan/widgets/icon.hpp +++ b/include/guisan/widgets/icon.hpp @@ -93,7 +93,7 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); protected: /** diff --git a/include/guisan/widgets/inputbox.hpp b/include/guisan/widgets/inputbox.hpp index df4ec60..57406f1 100644 --- a/include/guisan/widgets/inputbox.hpp +++ b/include/guisan/widgets/inputbox.hpp @@ -119,7 +119,7 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); // Inherited from MouseListener diff --git a/include/guisan/widgets/label.hpp b/include/guisan/widgets/label.hpp index 8a3b0f3..89fe25f 100644 --- a/include/guisan/widgets/label.hpp +++ b/include/guisan/widgets/label.hpp @@ -130,7 +130,7 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); protected: /** diff --git a/include/guisan/widgets/listbox.hpp b/include/guisan/widgets/listbox.hpp index eac472c..c7d04d3 100644 --- a/include/guisan/widgets/listbox.hpp +++ b/include/guisan/widgets/listbox.hpp @@ -189,7 +189,7 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); virtual void logic(); diff --git a/include/guisan/widgets/messagebox.hpp b/include/guisan/widgets/messagebox.hpp index e1856a6..44a9d04 100644 --- a/include/guisan/widgets/messagebox.hpp +++ b/include/guisan/widgets/messagebox.hpp @@ -209,7 +209,7 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); // Inherited from MouseListener diff --git a/include/guisan/widgets/progressbar.hpp b/include/guisan/widgets/progressbar.hpp index 8349f35..6030ce5 100644 --- a/include/guisan/widgets/progressbar.hpp +++ b/include/guisan/widgets/progressbar.hpp @@ -190,7 +190,7 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); protected: /** diff --git a/include/guisan/widgets/radiobutton.hpp b/include/guisan/widgets/radiobutton.hpp index bf05979..0acbf99 100644 --- a/include/guisan/widgets/radiobutton.hpp +++ b/include/guisan/widgets/radiobutton.hpp @@ -169,7 +169,7 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); // Inherited from KeyListener diff --git a/include/guisan/widgets/scrollarea.hpp b/include/guisan/widgets/scrollarea.hpp index 695f857..37ad2df 100644 --- a/include/guisan/widgets/scrollarea.hpp +++ b/include/guisan/widgets/scrollarea.hpp @@ -306,7 +306,7 @@ namespace gcn virtual void draw(Graphics *graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); virtual void logic(); diff --git a/include/guisan/widgets/slider.hpp b/include/guisan/widgets/slider.hpp index 3248245..eadb793 100644 --- a/include/guisan/widgets/slider.hpp +++ b/include/guisan/widgets/slider.hpp @@ -221,7 +221,7 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); // Inherited from MouseListener. diff --git a/include/guisan/widgets/tab.hpp b/include/guisan/widgets/tab.hpp index 121b4a2..1bcabb7 100644 --- a/include/guisan/widgets/tab.hpp +++ b/include/guisan/widgets/tab.hpp @@ -134,7 +134,7 @@ namespace gcn virtual void draw(Graphics *graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); // Inherited from MouseListener diff --git a/include/guisan/widgets/tabbedarea.hpp b/include/guisan/widgets/tabbedarea.hpp index 14497d3..8db17e9 100644 --- a/include/guisan/widgets/tabbedarea.hpp +++ b/include/guisan/widgets/tabbedarea.hpp @@ -184,7 +184,7 @@ namespace gcn virtual void draw(Graphics *graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); virtual void logic(); diff --git a/include/guisan/widgets/textbox.hpp b/include/guisan/widgets/textbox.hpp index 74a250b..7368b6d 100644 --- a/include/guisan/widgets/textbox.hpp +++ b/include/guisan/widgets/textbox.hpp @@ -242,7 +242,7 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); virtual void fontChanged(); diff --git a/include/guisan/widgets/textfield.hpp b/include/guisan/widgets/textfield.hpp index b946894..4a9dd7d 100644 --- a/include/guisan/widgets/textfield.hpp +++ b/include/guisan/widgets/textfield.hpp @@ -139,7 +139,7 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); // Inherited from MouseListener diff --git a/include/guisan/widgets/window.hpp b/include/guisan/widgets/window.hpp index d16ae03..9c35cfe 100644 --- a/include/guisan/widgets/window.hpp +++ b/include/guisan/widgets/window.hpp @@ -204,7 +204,7 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawBorder(Graphics* graphics); + virtual void drawFrame(Graphics* graphics); // Inherited from MouseListener diff --git a/src/basiccontainer.cpp b/src/basiccontainer.cpp index 08bd85a..a0c1cec 100644 --- a/src/basiccontainer.cpp +++ b/src/basiccontainer.cpp @@ -296,17 +296,17 @@ namespace gcn { if ((*iter)->isVisible()) { - // If the widget has a border, + // If the widget has a frame, // draw it before drawing the widget - if ((*iter)->getBorderSize() > 0) + if ((*iter)->getFrameSize() > 0) { Rectangle rec = (*iter)->getDimension(); - rec.x -= (*iter)->getBorderSize(); - rec.y -= (*iter)->getBorderSize(); - rec.width += 2 * (*iter)->getBorderSize(); - rec.height += 2 * (*iter)->getBorderSize(); + rec.x -= (*iter)->getFrameSize(); + rec.y -= (*iter)->getFrameSize(); + rec.width += 2 * (*iter)->getFrameSize(); + rec.height += 2 * (*iter)->getFrameSize(); graphics->pushClipArea(rec); - (*iter)->drawBorder(graphics); + (*iter)->drawFrame(graphics); graphics->popClipArea(); } diff --git a/src/gui.cpp b/src/gui.cpp index cd7bdc2..b3403b8 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -181,17 +181,17 @@ namespace gcn mGraphics->_beginDraw(); - // If top has a border, + // If top has a frame, // draw it before drawing top - if (mTop->getBorderSize() > 0) + if (mTop->getFrameSize() > 0) { Rectangle rec = mTop->getDimension(); - rec.x -= mTop->getBorderSize(); - rec.y -= mTop->getBorderSize(); - rec.width += 2 * mTop->getBorderSize(); - rec.height += 2 * mTop->getBorderSize(); + rec.x -= mTop->getFrameSize(); + rec.y -= mTop->getFrameSize(); + rec.width += 2 * mTop->getFrameSize(); + rec.height += 2 * mTop->getFrameSize(); mGraphics->pushClipArea(rec); - mTop->drawBorder(mGraphics); + mTop->drawFrame(mGraphics); mGraphics->popClipArea(); } diff --git a/src/widget.cpp b/src/widget.cpp index 43baca6..ff7e496 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -203,12 +203,12 @@ namespace gcn } } - void Widget::setBorderSize(unsigned int borderSize) + void Widget::setFrameSize(unsigned int borderSize) { mBorderSize = borderSize; } - unsigned int Widget::getBorderSize() const + unsigned int Widget::getFrameSize() const { return mBorderSize; } diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 77be28e..4b8b4e0 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -78,7 +78,7 @@ namespace gcn { setFocusable(true); adjustSize(); - setBorderSize(1); + setFrameSize(1); addMouseListener(this); addKeyListener(this); @@ -95,7 +95,7 @@ namespace gcn { setFocusable(true); adjustSize(); - setBorderSize(1); + setFrameSize(1); addMouseListener(this); addKeyListener(this); @@ -207,20 +207,20 @@ namespace gcn } } - void Button::drawBorder(Graphics* graphics) + void Button::drawFrame(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->setColor(shadowColor); graphics->drawLine(i,i, width - i, i); diff --git a/src/widgets/checkbox.cpp b/src/widgets/checkbox.cpp index 1fd4bfb..7520d7a 100644 --- a/src/widgets/checkbox.cpp +++ b/src/widgets/checkbox.cpp @@ -104,20 +104,20 @@ namespace gcn graphics->drawText(getCaption(), h - 2, 0); } - void CheckBox::drawBorder(Graphics* graphics) + void CheckBox::drawFrame(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->setColor(shadowColor); graphics->drawLine(i,i, width - i, i); diff --git a/src/widgets/container.cpp b/src/widgets/container.cpp index 5cc51a9..649e6f4 100644 --- a/src/widgets/container.cpp +++ b/src/widgets/container.cpp @@ -87,20 +87,20 @@ namespace gcn drawChildren(graphics); } - void Container::drawBorder(Graphics* graphics) + void Container::drawFrame(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->setColor(shadowColor); graphics->drawLine(i,i, width - i, i); diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 7384087..700f77f 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -118,7 +118,7 @@ namespace gcn addFocusListener(this); adjustHeight(); - setBorderSize(1); + setFrameSize(1); } DropDown::~DropDown() @@ -194,20 +194,20 @@ namespace gcn } } - void DropDown::drawBorder(Graphics* graphics) + void DropDown::drawFrame(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->setColor(shadowColor); graphics->drawLine(i,i, width - i, i); diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 3091983..5759116 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -95,20 +95,20 @@ namespace gcn graphics->drawImage(mImage, 0, 0); } - void Icon::drawBorder(Graphics* graphics) + void Icon::drawFrame(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->setColor(shadowColor); graphics->drawLine(i,i, width - i, i); diff --git a/src/widgets/inputbox.cpp b/src/widgets/inputbox.cpp index 6cadb3a..31a140a 100644 --- a/src/widgets/inputbox.cpp +++ b/src/widgets/inputbox.cpp @@ -101,19 +101,19 @@ namespace gcn mButtonCancel->setWidth(mButtonOK->getWidth()); } - setHeight((int)getTitleBarHeight() + mLabel->getHeight() + mText->getHeight() + 6 * mPadding + mButtonOK->getHeight() + 2 * getBorderSize()); - setWidth(mLabel->getWidth() + 2 * mPadding + 2 * getBorderSize()); - if(2 * mButtonOK->getWidth() + 4 * mPadding + 2 * getBorderSize() > getWidth()) + setHeight((int)getTitleBarHeight() + mLabel->getHeight() + mText->getHeight() + 6 * mPadding + mButtonOK->getHeight() + 2 * getFrameSize()); + setWidth(mLabel->getWidth() + 2 * mPadding + 2 * getFrameSize()); + if(2 * mButtonOK->getWidth() + 4 * mPadding + 2 * getFrameSize() > getWidth()) { - setWidth(2 * mButtonOK->getWidth() + 4*mPadding + 2 * getBorderSize()); + setWidth(2 * mButtonOK->getWidth() + 4*mPadding + 2 * getFrameSize()); } - mText->setWidth(getWidth() - 2 * getBorderSize() - 5 * mPadding); + mText->setWidth(getWidth() - 2 * getFrameSize() - 5 * mPadding); this->add(mLabel, (getWidth() - mLabel->getWidth())/2 - mPadding, mPadding); this->add(mText, 2*mPadding, 2 * mPadding + mLabel->getHeight()); - int yButtons = getHeight() - (int)getTitleBarHeight() - getBorderSize() - 2*mPadding - mButtonOK->getHeight(); + int yButtons = getHeight() - (int)getTitleBarHeight() - getFrameSize() - 2*mPadding - mButtonOK->getHeight(); this->add(mButtonOK, (getWidth() - 2 * mButtonOK->getWidth())/4, yButtons); - this->add(mButtonCancel, getWidth() - 2*getBorderSize() - mButtonOK->getWidth() - mPadding, yButtons); + this->add(mButtonCancel, getWidth() - 2*getFrameSize() - mButtonOK->getWidth() - mPadding, yButtons); try { @@ -140,8 +140,8 @@ namespace gcn Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - //int width = getWidth() + getBorderSize() * 2 - 1; - //int height = getHeight() + getBorderSize() * 2 - 1; + //int width = getWidth() + getFrameSize() * 2 - 1; + //int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; @@ -232,20 +232,20 @@ namespace gcn graphics->popClipArea(); } - void InputBox::drawBorder(Graphics* graphics) + void InputBox::drawFrame(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->setColor(highlightColor); graphics->drawLine(i,i, width - i, i); diff --git a/src/widgets/label.cpp b/src/widgets/label.cpp index a558499..16311eb 100644 --- a/src/widgets/label.cpp +++ b/src/widgets/label.cpp @@ -128,20 +128,20 @@ namespace gcn graphics->drawText(getCaption(), textX, textY, getAlignment()); } - void Label::drawBorder(Graphics* graphics) + void Label::drawFrame(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->setColor(shadowColor); graphics->drawLine(i, i, width - i, i); diff --git a/src/widgets/listbox.cpp b/src/widgets/listbox.cpp index 5d8adc5..ebd15da 100644 --- a/src/widgets/listbox.cpp +++ b/src/widgets/listbox.cpp @@ -171,20 +171,20 @@ namespace gcn } } - void ListBox::drawBorder(Graphics* graphics) + void ListBox::drawFrame(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->setColor(shadowColor); graphics->drawLine(i,i, width - i, i); diff --git a/src/widgets/messagebox.cpp b/src/widgets/messagebox.cpp index e29490e..c4fd096 100644 --- a/src/widgets/messagebox.cpp +++ b/src/widgets/messagebox.cpp @@ -247,8 +247,8 @@ namespace gcn Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - //int width = getWidth() + getBorderSize() * 2 - 1; - //int height = getHeight() + getBorderSize() * 2 - 1; + //int width = getWidth() + getFrameSize() * 2 - 1; + //int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; @@ -339,20 +339,20 @@ namespace gcn graphics->popClipArea(); } - void MessageBox::drawBorder(Graphics* graphics) + void MessageBox::drawFrame(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->setColor(highlightColor); graphics->drawLine(i,i, width - i, i); diff --git a/src/widgets/progressbar.cpp b/src/widgets/progressbar.cpp index e2226be..c238469 100644 --- a/src/widgets/progressbar.cpp +++ b/src/widgets/progressbar.cpp @@ -74,7 +74,7 @@ namespace gcn mEnd = 100; setHeight(getFont()->getHeight()); - setBorderSize(1); + setFrameSize(1); } ProgressBar::ProgressBar(const unsigned int start, @@ -103,7 +103,7 @@ namespace gcn } setHeight(getFont()->getHeight()); - setBorderSize(1); + setFrameSize(1); } ProgressBar::ProgressBar(const std::string& caption) : Label(caption) @@ -112,7 +112,7 @@ namespace gcn mAlignment = Graphics::CENTER; setHeight(getFont()->getHeight()); - setBorderSize(1); + setFrameSize(1); } const std::string &ProgressBar::getCaption() const @@ -191,20 +191,20 @@ namespace gcn graphics->drawText(getCaption(), textX, textY, getAlignment()); } - void ProgressBar::drawBorder(Graphics* graphics) + void ProgressBar::drawFrame(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->setColor(shadowColor); graphics->drawLine(i, i, width - i, i); diff --git a/src/widgets/radiobutton.cpp b/src/widgets/radiobutton.cpp index 1b51313..996c511 100644 --- a/src/widgets/radiobutton.cpp +++ b/src/widgets/radiobutton.cpp @@ -122,20 +122,20 @@ namespace gcn graphics->drawText(getCaption(), h - 2, 0); } - void RadioButton::drawBorder(Graphics* graphics) + void RadioButton::drawFrame(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->setColor(shadowColor); graphics->drawLine(i, i, width - i, i); diff --git a/src/widgets/scrollarea.cpp b/src/widgets/scrollarea.cpp index dbd0f41..dc116ec 100644 --- a/src/widgets/scrollarea.cpp +++ b/src/widgets/scrollarea.cpp @@ -249,7 +249,7 @@ namespace gcn } int value = getContent()->getWidth() - getChildrenArea().width + - 2 * getContent()->getBorderSize(); + 2 * getContent()->getFrameSize(); if (value < 0) { @@ -271,7 +271,7 @@ namespace gcn int value; value = getContent()->getHeight() - getChildrenArea().height + - 2 * getContent()->getBorderSize(); + 2 * getContent()->getFrameSize(); if (value < 0) { @@ -454,20 +454,20 @@ namespace gcn drawChildren(graphics); } - void ScrollArea::drawBorder(Graphics* graphics) + void ScrollArea::drawFrame(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->setColor(shadowColor); graphics->drawLine(i,i, width - i, i); @@ -833,8 +833,8 @@ namespace gcn if (getContent() != NULL) { - getContent()->setPosition(-mHScroll + getContent()->getBorderSize(), - -mVScroll + getContent()->getBorderSize()); + getContent()->setPosition(-mHScroll + getContent()->getFrameSize(), + -mVScroll + getContent()->getFrameSize()); getContent()->logic(); } } @@ -1170,8 +1170,8 @@ namespace gcn BasicContainer::showWidgetPart(widget, area); - setHorizontalScrollAmount(getContent()->getBorderSize() - getContent()->getX()); - setVerticalScrollAmount(getContent()->getBorderSize() - getContent()->getY()); + setHorizontalScrollAmount(getContent()->getFrameSize() - getContent()->getX()); + setVerticalScrollAmount(getContent()->getFrameSize() - getContent()->getY()); } Widget *ScrollArea::getWidgetAt(int x, int y) diff --git a/src/widgets/slider.cpp b/src/widgets/slider.cpp index 9546f3e..ce0575c 100644 --- a/src/widgets/slider.cpp +++ b/src/widgets/slider.cpp @@ -74,7 +74,7 @@ namespace gcn mScaleEnd = scaleEnd; setFocusable(true); - setBorderSize(1); + setFrameSize(1); setOrientation(HORIZONTAL); setValue(0); setStepLength(scaleEnd / 10); @@ -92,7 +92,7 @@ namespace gcn mScaleEnd = scaleEnd; setFocusable(true); - setBorderSize(1); + setFrameSize(1); setOrientation(HORIZONTAL); setValue(scaleStart); setStepLength((scaleEnd - scaleStart) / 10); @@ -146,20 +146,20 @@ namespace gcn drawMarker(graphics); } - void Slider::drawBorder(gcn::Graphics* graphics) + void Slider::drawFrame(gcn::Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->setColor(shadowColor); graphics->drawLine(i, i, width - i, i); diff --git a/src/widgets/tab.cpp b/src/widgets/tab.cpp index dde493b..4a92d9d 100644 --- a/src/widgets/tab.cpp +++ b/src/widgets/tab.cpp @@ -74,7 +74,7 @@ namespace gcn mLabel = new Label(); mLabel->setPosition(4, 4); add(mLabel); - setBorderSize(1); + setFrameSize(1); addMouseListener(this); } @@ -134,20 +134,20 @@ namespace gcn } } - void Tab::drawBorder(Graphics* graphics) + void Tab::drawFrame(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->setColor(highlightColor); graphics->drawLine(i,i, width - i, i); diff --git a/src/widgets/tabbedarea.cpp b/src/widgets/tabbedarea.cpp index dd29942..06821c3 100644 --- a/src/widgets/tabbedarea.cpp +++ b/src/widgets/tabbedarea.cpp @@ -75,7 +75,7 @@ namespace gcn TabbedArea::TabbedArea() :mSelectedTab(NULL) { - setBorderSize(1); + setFrameSize(1); setFocusable(true); addKeyListener(this); addMouseListener(this); @@ -288,20 +288,20 @@ namespace gcn drawChildren(graphics); } - void TabbedArea::drawBorder(Graphics* graphics) + void TabbedArea::drawFrame(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->setColor(highlightColor); graphics->drawLine(i,i + mWidgetContainer->getY(), i, height - i - 1); @@ -363,7 +363,7 @@ namespace gcn if (x == 0) { - x = tab->getBorderSize() + 2; + x = tab->getFrameSize() + 2; } tab->setX(x); @@ -372,14 +372,14 @@ namespace gcn { tab->setY(maxTabHeight - tab->getHeight() - + tab->getBorderSize()); + + tab->getFrameSize()); } else { - tab->setY(mTabs[i].first->getBorderSize()); + tab->setY(mTabs[i].first->getFrameSize()); } - x += tab->getWidth() + tab->getBorderSize() * 2; + x += tab->getWidth() + tab->getFrameSize() * 2; } } diff --git a/src/widgets/textbox.cpp b/src/widgets/textbox.cpp index 47d7066..05b08bf 100644 --- a/src/widgets/textbox.cpp +++ b/src/widgets/textbox.cpp @@ -80,7 +80,7 @@ namespace gcn addMouseListener(this); addKeyListener(this); adjustSize(); - setBorderSize(1); + setFrameSize(1); setText(""); } @@ -98,7 +98,7 @@ namespace gcn addMouseListener(this); addKeyListener(this); adjustSize(); - setBorderSize(1); + setFrameSize(1); } void TextBox::setText(const std::string& text) @@ -156,15 +156,15 @@ namespace gcn } } - void TextBox::drawBorder(Graphics* graphics) + void TextBox::drawFrame(Graphics* graphics) { - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; graphics->setColor(getBackgroundColor()); unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->drawLine(i,i, width - i, i); graphics->drawLine(i,i + 1, i, height - i - 1); diff --git a/src/widgets/textfield.cpp b/src/widgets/textfield.cpp index 8737d37..3e10f10 100644 --- a/src/widgets/textfield.cpp +++ b/src/widgets/textfield.cpp @@ -77,7 +77,7 @@ namespace gcn addMouseListener(this); addKeyListener(this); adjustHeight(); - setBorderSize(1); + setFrameSize(1); } TextField::TextField(const std::string& text) @@ -87,7 +87,7 @@ namespace gcn mText = text; adjustSize(); - setBorderSize(1); + setFrameSize(1); setFocusable(true); @@ -125,20 +125,20 @@ namespace gcn graphics->drawText(mText, 1 - mXScroll, 2); } - void TextField::drawBorder(Graphics* graphics) + void TextField::drawFrame(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->setColor(shadowColor); graphics->drawLine(i, i, width - i, i); diff --git a/src/widgets/window.cpp b/src/widgets/window.cpp index 51b2dd9..4be331b 100644 --- a/src/widgets/window.cpp +++ b/src/widgets/window.cpp @@ -70,7 +70,7 @@ namespace gcn Window::Window() :mMoved(false) { - setBorderSize(1); + setFrameSize(1); setPadding(2); setTitleBarHeight(getFont()->getHeight() + 2); setAlignment(Graphics::CENTER); @@ -83,7 +83,7 @@ namespace gcn :mMoved(false) { setCaption(caption); - setBorderSize(1); + setFrameSize(1); setPadding(2); setTitleBarHeight(16); setAlignment(Graphics::CENTER); @@ -141,8 +141,8 @@ namespace gcn Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - //int width = getWidth() + getBorderSize() * 2 - 1; - //int height = getHeight() + getBorderSize() * 2 - 1; + //int width = getWidth() + getFrameSize() * 2 - 1; + //int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; @@ -233,20 +233,20 @@ namespace gcn graphics->popClipArea(); } - void Window::drawBorder(Graphics* graphics) + void Window::drawFrame(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getBorderSize() * 2 - 1; - int height = getHeight() + getBorderSize() * 2 - 1; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; unsigned int i; - for (i = 0; i < getBorderSize(); ++i) + for (i = 0; i < getFrameSize(); ++i) { graphics->setColor(highlightColor); graphics->drawLine(i, i, width - i, i); From 03de33661b6e3b76fd490f9d582706d09186c9f0 Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Sat, 2 Dec 2023 11:40:52 +0100 Subject: [PATCH 2/2] Apply guichan's changes from 753608c0c8cd0196c19c467db0f8df5f61d99b3c (25/dec/2007) to 8a4565b962dc5c71d1c115bdce4ddc3906575fa1 (31/dec/2007): - The drawing of the text field widget and the drop down widget have been enhanced. - Drawing has been enhanced. + Fix dropdown keyPressed event (handled by both listbox and dropdown). --- TODO | 2 +- include/guisan/widget.hpp | 2 +- include/guisan/widgets/button.hpp | 2 - include/guisan/widgets/checkbox.hpp | 2 - include/guisan/widgets/container.hpp | 1 - include/guisan/widgets/dropdown.hpp | 2 - include/guisan/widgets/icon.hpp | 1 - include/guisan/widgets/inputbox.hpp | 2 - include/guisan/widgets/label.hpp | 1 - include/guisan/widgets/listbox.hpp | 2 - include/guisan/widgets/messagebox.hpp | 2 - include/guisan/widgets/progressbar.hpp | 1 - include/guisan/widgets/radiobutton.hpp | 2 - include/guisan/widgets/scrollarea.hpp | 2 - include/guisan/widgets/slider.hpp | 2 - include/guisan/widgets/tab.hpp | 2 - include/guisan/widgets/tabbedarea.hpp | 2 - include/guisan/widgets/textbox.hpp | 2 - include/guisan/widgets/textfield.hpp | 2 - include/guisan/widgets/window.hpp | 2 - src/widget.cpp | 25 ++++ src/widgets/button.cpp | 24 ---- src/widgets/checkbox.cpp | 24 ---- src/widgets/container.cpp | 24 ---- src/widgets/dropdown.cpp | 155 +++++++++++-------------- src/widgets/icon.cpp | 23 ---- src/widgets/inputbox.cpp | 24 ---- src/widgets/label.cpp | 24 ---- src/widgets/listbox.cpp | 33 +----- src/widgets/messagebox.cpp | 24 ---- src/widgets/progressbar.cpp | 24 ---- src/widgets/radiobutton.cpp | 24 ---- src/widgets/scrollarea.cpp | 24 ---- src/widgets/slider.cpp | 24 ---- src/widgets/tab.cpp | 74 ++++++------ src/widgets/tabbedarea.cpp | 91 ++++++--------- src/widgets/textbox.cpp | 33 +++--- src/widgets/textfield.cpp | 60 +++++----- src/widgets/window.cpp | 24 ---- 39 files changed, 219 insertions(+), 575 deletions(-) diff --git a/TODO b/TODO index 84fff90..e393ac8 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -* Continue rebasing from 753608c0c8cd0196c19c467db0f8df5f61d99b3c +* Continue rebasing from b62d153a5dd699add2109671d4569578dd4f2671 * Add a focus listener interface. * Make focus apply synchronously. * Graphics and input objects for DirectX. diff --git a/include/guisan/widget.hpp b/include/guisan/widget.hpp index 29aed85..6cdf44f 100644 --- a/include/guisan/widget.hpp +++ b/include/guisan/widget.hpp @@ -136,7 +136,7 @@ namespace gcn * @param graphics a graphics object to draw with. * @see setFrameSize, getFrameSize */ - virtual void drawFrame(Graphics* graphics) { } + virtual void drawFrame(Graphics* graphics); /** * Sets the size of the widget's frame. The frame is not considered a part of diff --git a/include/guisan/widgets/button.hpp b/include/guisan/widgets/button.hpp index c4a6968..63307c0 100644 --- a/include/guisan/widgets/button.hpp +++ b/include/guisan/widgets/button.hpp @@ -149,8 +149,6 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawFrame(Graphics* graphics); - // Inherited from FocusListener diff --git a/include/guisan/widgets/checkbox.hpp b/include/guisan/widgets/checkbox.hpp index 1ca0aff..ec2abe2 100644 --- a/include/guisan/widgets/checkbox.hpp +++ b/include/guisan/widgets/checkbox.hpp @@ -144,8 +144,6 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawFrame(Graphics* graphics); - // Inherited from KeyListener diff --git a/include/guisan/widgets/container.hpp b/include/guisan/widgets/container.hpp index 5396f0a..5423f63 100644 --- a/include/guisan/widgets/container.hpp +++ b/include/guisan/widgets/container.hpp @@ -164,7 +164,6 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawFrame(Graphics* graphics); protected: /** diff --git a/include/guisan/widgets/dropdown.hpp b/include/guisan/widgets/dropdown.hpp index 738892d..0fcd0ed 100644 --- a/include/guisan/widgets/dropdown.hpp +++ b/include/guisan/widgets/dropdown.hpp @@ -177,8 +177,6 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawFrame(Graphics* graphics); - void setBaseColor(const Color& color); void setBackgroundColor(const Color& color); diff --git a/include/guisan/widgets/icon.hpp b/include/guisan/widgets/icon.hpp index d444e80..9f6bbc1 100644 --- a/include/guisan/widgets/icon.hpp +++ b/include/guisan/widgets/icon.hpp @@ -93,7 +93,6 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawFrame(Graphics* graphics); protected: /** diff --git a/include/guisan/widgets/inputbox.hpp b/include/guisan/widgets/inputbox.hpp index 57406f1..a76baac 100644 --- a/include/guisan/widgets/inputbox.hpp +++ b/include/guisan/widgets/inputbox.hpp @@ -119,8 +119,6 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawFrame(Graphics* graphics); - // Inherited from MouseListener diff --git a/include/guisan/widgets/label.hpp b/include/guisan/widgets/label.hpp index 89fe25f..cd3cfe6 100644 --- a/include/guisan/widgets/label.hpp +++ b/include/guisan/widgets/label.hpp @@ -130,7 +130,6 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawFrame(Graphics* graphics); protected: /** diff --git a/include/guisan/widgets/listbox.hpp b/include/guisan/widgets/listbox.hpp index c7d04d3..5e4e84c 100644 --- a/include/guisan/widgets/listbox.hpp +++ b/include/guisan/widgets/listbox.hpp @@ -189,8 +189,6 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawFrame(Graphics* graphics); - virtual void logic(); diff --git a/include/guisan/widgets/messagebox.hpp b/include/guisan/widgets/messagebox.hpp index 44a9d04..87c797c 100644 --- a/include/guisan/widgets/messagebox.hpp +++ b/include/guisan/widgets/messagebox.hpp @@ -209,8 +209,6 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawFrame(Graphics* graphics); - // Inherited from MouseListener diff --git a/include/guisan/widgets/progressbar.hpp b/include/guisan/widgets/progressbar.hpp index 6030ce5..932f716 100644 --- a/include/guisan/widgets/progressbar.hpp +++ b/include/guisan/widgets/progressbar.hpp @@ -190,7 +190,6 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawFrame(Graphics* graphics); protected: /** diff --git a/include/guisan/widgets/radiobutton.hpp b/include/guisan/widgets/radiobutton.hpp index 0acbf99..66a3ef6 100644 --- a/include/guisan/widgets/radiobutton.hpp +++ b/include/guisan/widgets/radiobutton.hpp @@ -169,8 +169,6 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawFrame(Graphics* graphics); - // Inherited from KeyListener diff --git a/include/guisan/widgets/scrollarea.hpp b/include/guisan/widgets/scrollarea.hpp index 37ad2df..131267b 100644 --- a/include/guisan/widgets/scrollarea.hpp +++ b/include/guisan/widgets/scrollarea.hpp @@ -306,8 +306,6 @@ namespace gcn virtual void draw(Graphics *graphics); - virtual void drawFrame(Graphics* graphics); - virtual void logic(); void setWidth(int width); diff --git a/include/guisan/widgets/slider.hpp b/include/guisan/widgets/slider.hpp index eadb793..9fe0719 100644 --- a/include/guisan/widgets/slider.hpp +++ b/include/guisan/widgets/slider.hpp @@ -221,8 +221,6 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawFrame(Graphics* graphics); - // Inherited from MouseListener. diff --git a/include/guisan/widgets/tab.hpp b/include/guisan/widgets/tab.hpp index 1bcabb7..25bf3b3 100644 --- a/include/guisan/widgets/tab.hpp +++ b/include/guisan/widgets/tab.hpp @@ -134,8 +134,6 @@ namespace gcn virtual void draw(Graphics *graphics); - virtual void drawFrame(Graphics* graphics); - // Inherited from MouseListener diff --git a/include/guisan/widgets/tabbedarea.hpp b/include/guisan/widgets/tabbedarea.hpp index 8db17e9..b16d312 100644 --- a/include/guisan/widgets/tabbedarea.hpp +++ b/include/guisan/widgets/tabbedarea.hpp @@ -184,8 +184,6 @@ namespace gcn virtual void draw(Graphics *graphics); - virtual void drawFrame(Graphics* graphics); - virtual void logic(); void setWidth(int width); diff --git a/include/guisan/widgets/textbox.hpp b/include/guisan/widgets/textbox.hpp index 7368b6d..27676a1 100644 --- a/include/guisan/widgets/textbox.hpp +++ b/include/guisan/widgets/textbox.hpp @@ -242,8 +242,6 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawFrame(Graphics* graphics); - virtual void fontChanged(); diff --git a/include/guisan/widgets/textfield.hpp b/include/guisan/widgets/textfield.hpp index 4a9dd7d..84c94e5 100644 --- a/include/guisan/widgets/textfield.hpp +++ b/include/guisan/widgets/textfield.hpp @@ -139,8 +139,6 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawFrame(Graphics* graphics); - // Inherited from MouseListener diff --git a/include/guisan/widgets/window.hpp b/include/guisan/widgets/window.hpp index 9c35cfe..a3e9303 100644 --- a/include/guisan/widgets/window.hpp +++ b/include/guisan/widgets/window.hpp @@ -204,8 +204,6 @@ namespace gcn virtual void draw(Graphics* graphics); - virtual void drawFrame(Graphics* graphics); - // Inherited from MouseListener diff --git a/src/widget.cpp b/src/widget.cpp index ff7e496..36113ac 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -68,6 +68,7 @@ #include "guisan/event.hpp" #include "guisan/exception.hpp" #include "guisan/focushandler.hpp" +#include "guisan/graphics.hpp" #include "guisan/keyinput.hpp" #include "guisan/keylistener.hpp" #include "guisan/mouseinput.hpp" @@ -114,6 +115,30 @@ namespace gcn mWidgets.remove(this); } + void Widget::drawFrame(Graphics* graphics) + { + Color faceColor = getBaseColor(); + Color highlightColor, shadowColor; + int alpha = getBaseColor().a; + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; + highlightColor = faceColor + 0x303030; + highlightColor.a = alpha; + shadowColor = faceColor - 0x303030; + shadowColor.a = alpha; + + unsigned int i; + for (i = 0; i < getFrameSize(); ++i) + { + graphics->setColor(shadowColor); + graphics->drawLine(i,i, width - i, i); + graphics->drawLine(i,i + 1, i, height - i - 1); + graphics->setColor(highlightColor); + graphics->drawLine(width - i,i + 1, width - i, height - i); + graphics->drawLine(i,height - i, width - i - 1, height - i); + } + } + void Widget::_setParent(Widget* parent) { mParent = parent; diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 4b8b4e0..9965d49 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -207,30 +207,6 @@ namespace gcn } } - void Button::drawFrame(Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(shadowColor); - graphics->drawLine(i,i, width - i, i); - graphics->drawLine(i,i + 1, i, height - i - 1); - graphics->setColor(highlightColor); - graphics->drawLine(width - i,i + 1, width - i, height - i); - graphics->drawLine(i,height - i, width - i - 1, height - i); - } - } - void Button::adjustSize() { setWidth(getFont()->getWidth(mCaption) + 2*mSpacing); diff --git a/src/widgets/checkbox.cpp b/src/widgets/checkbox.cpp index 7520d7a..c72fa91 100644 --- a/src/widgets/checkbox.cpp +++ b/src/widgets/checkbox.cpp @@ -104,30 +104,6 @@ namespace gcn graphics->drawText(getCaption(), h - 2, 0); } - void CheckBox::drawFrame(Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(shadowColor); - graphics->drawLine(i,i, width - i, i); - graphics->drawLine(i,i + 1, i, height - i - 1); - graphics->setColor(highlightColor); - graphics->drawLine(width - i,i + 1, width - i, height - i); - graphics->drawLine(i,height - i, width - i - 1, height - i); - } - } - void CheckBox::drawBox(Graphics* graphics) { int h = getHeight() - 2; diff --git a/src/widgets/container.cpp b/src/widgets/container.cpp index 649e6f4..b2cf292 100644 --- a/src/widgets/container.cpp +++ b/src/widgets/container.cpp @@ -87,30 +87,6 @@ namespace gcn drawChildren(graphics); } - void Container::drawFrame(Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(shadowColor); - graphics->drawLine(i,i, width - i, i); - graphics->drawLine(i,i + 1, i, height - i - 1); - graphics->setColor(highlightColor); - graphics->drawLine(width - i,i + 1, width - i, height - i); - graphics->drawLine(i,height - i, width - i - 1, height - i); - } - } - void Container::setOpaque(bool opaque) { mOpaque = opaque; diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 700f77f..7b7a3de 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -118,7 +118,6 @@ namespace gcn addFocusListener(this); adjustHeight(); - setFrameSize(1); } DropDown::~DropDown() @@ -156,65 +155,63 @@ namespace gcn Color shadowColor = faceColor - 0x303030; shadowColor.a = alpha; - Color backCol = getBackgroundColor(); - if (!isEnabled()) - backCol = backCol - 0x303030; - graphics->setColor(backCol); - graphics->fillRectangle(Rectangle(0, 0, getWidth(), h)); + // 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); - if (isEnabled()) - graphics->setColor(getForegroundColor()); - else - graphics->setColor(Color(128, 128, 128)); + // 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->setFont(getFont()); + Color backgroundColor = getBackgroundColor(); + if (!isEnabled()) + { + backgroundColor = backgroundColor - 0x303030; + } + graphics->setColor(backgroundColor); + graphics->fillRectangle(Rectangle(0, 0, currentClipArea.width, currentClipArea.height)); if (isFocused()) { graphics->setColor(getSelectionColor()); - graphics->fillRectangle(Rectangle(0, 0, getWidth() - h, h)); + graphics->fillRectangle(Rectangle( + 0, 0, currentClipArea.width - currentClipArea.height, currentClipArea.height)); graphics->setColor(getForegroundColor()); } + if (isEnabled()) + graphics->setColor(getForegroundColor()); + else + graphics->setColor(Color(128, 128, 128)); + + graphics->setFont(getFont()); + if (mListBox->getListModel() && mListBox->getSelected() >= 0) - graphics->drawText(mListBox->getListModel()->getElementAt(mListBox->getSelected()), 2, 1); + 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) { - drawChildren(graphics); - - // Draw two lines separating the ListBox with se selected - // element view. - graphics->setColor(highlightColor); - graphics->drawLine(0, h, getWidth(), h); + // Draw a border around the children. graphics->setColor(shadowColor); - graphics->drawLine(0, h + 1, getWidth(), h + 1); - } - } - - void DropDown::drawFrame(Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; + graphics->drawRectangle( + Rectangle(0, mFoldedUpHeight, getWidth(), getHeight() - mFoldedUpHeight)); - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(shadowColor); - graphics->drawLine(i,i, width - i, i); - graphics->drawLine(i,i + 1, i, height - i - 1); - graphics->setColor(highlightColor); - graphics->drawLine(width - i,i + 1, width - i, height - i); - graphics->drawLine(i,height - i, width - i - 1, height - i); + drawChildren(graphics); } } @@ -245,55 +242,29 @@ namespace gcn offset = 0; } - int h; - if (mDroppedDown) - { - h = mFoldedUpHeight; - } - else - { - h = getHeight(); - } - int x = getWidth() - h; - int y = 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(x + 1, - y + 1, - h - 2, - h - 2)); - - graphics->setColor(highlightColor); - graphics->drawLine(x, - y, - x + h - 1, - y); - graphics->drawLine(x, - y + 1, - x, - y + h - 1); + graphics->fillRectangle( + Rectangle(1, 1, currentClipArea.width - 2, currentClipArea.height - 2)); - graphics->setColor(shadowColor); - graphics->drawLine(x + h - 1, - y + 1, - x + h - 1, - y + h - 1); - graphics->drawLine(x + 1, - y + h - 1, - x + h - 2, - y + h - 1); graphics->setColor(getForegroundColor()); int i; - int hh = h / 3; - int hx = x + h / 2; - int hy = y + (h * 2) / 3; - for (i = 0; i < hh; 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(hx - i + offset, - hy - i + offset, - hx + i + offset, - hy - i + offset); + graphics->drawLine(dx - i + offset, dy - i + offset, dx + i + offset, dy - i + offset); } } @@ -312,6 +283,10 @@ namespace gcn void DropDown::keyPressed(KeyEvent& keyEvent) { + if (keyEvent.isConsumed()) + { + return; + } Key key = keyEvent.getKey(); if ((key.getValue() == Key::ENTER || key.getValue() == Key::SPACE) @@ -434,7 +409,8 @@ namespace gcn throw GCN_EXCEPTION("List box has been deleted."); int listBoxHeight = mListBox->getHeight(); - int h2 = getFont()->getHeight(); + // We add 2 for the border + int h2 = getFont()->getHeight() + 2; setHeight(h2); @@ -517,10 +493,9 @@ namespace gcn { if (mDroppedDown) { - return Rectangle(0, - mFoldedUpHeight + 2, - getWidth(), - getHeight() - mFoldedUpHeight); + // Calculate the children area (with the one pixel border in mind) + return Rectangle( + 1, mFoldedUpHeight + 1, getWidth() - 2, getHeight() - mFoldedUpHeight - 2); } return Rectangle(); diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 5759116..9bff176 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -95,27 +95,4 @@ namespace gcn graphics->drawImage(mImage, 0, 0); } - void Icon::drawFrame(Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(shadowColor); - graphics->drawLine(i,i, width - i, i); - graphics->drawLine(i,i + 1, i, height - i - 1); - graphics->setColor(highlightColor); - graphics->drawLine(width - i,i + 1, width - i, height - i); - graphics->drawLine(i,height - i, width - i - 1, height - i); - } - } } diff --git a/src/widgets/inputbox.cpp b/src/widgets/inputbox.cpp index 31a140a..de21805 100644 --- a/src/widgets/inputbox.cpp +++ b/src/widgets/inputbox.cpp @@ -232,30 +232,6 @@ namespace gcn graphics->popClipArea(); } - void InputBox::drawFrame(Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(highlightColor); - graphics->drawLine(i,i, width - i, i); - graphics->drawLine(i,i + 1, i, height - i - 1); - graphics->setColor(shadowColor); - graphics->drawLine(width - i,i + 1, width - i, height - i); - graphics->drawLine(i,height - i, width - i - 1, height - i); - } - } - void InputBox::mousePressed(MouseEvent& mouseEvent) { if (mouseEvent.getSource() != this) diff --git a/src/widgets/label.cpp b/src/widgets/label.cpp index 16311eb..4b20ba2 100644 --- a/src/widgets/label.cpp +++ b/src/widgets/label.cpp @@ -128,30 +128,6 @@ namespace gcn graphics->drawText(getCaption(), textX, textY, getAlignment()); } - void Label::drawFrame(Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(shadowColor); - graphics->drawLine(i, i, width - i, i); - graphics->drawLine(i, i + 1, i, height - i - 1); - graphics->setColor(highlightColor); - graphics->drawLine(width - i, i + 1, width - i, height - i); - graphics->drawLine(i, height - i, width - i - 1, height - i); - } - } - void Label::adjustSize() { setWidth(getFont()->getWidth(getCaption())); diff --git a/src/widgets/listbox.cpp b/src/widgets/listbox.cpp index ebd15da..d353939 100644 --- a/src/widgets/listbox.cpp +++ b/src/widgets/listbox.cpp @@ -70,11 +70,8 @@ namespace gcn { - ListBox::ListBox() + ListBox::ListBox() : mListModel(NULL), mSelected(-1), mWrappingEnabled(false) { - mSelected = -1; - mListModel = NULL; - mWrappingEnabled = false; setWidth(100); setFocusable(true); @@ -82,10 +79,8 @@ namespace gcn addKeyListener(this); } - ListBox::ListBox(ListModel *listModel) + ListBox::ListBox(ListModel *listModel) : mSelected(-1), mWrappingEnabled(false) { - mSelected = -1; - mWrappingEnabled = false; setWidth(100); setListModel(listModel); setFocusable(true); @@ -171,30 +166,6 @@ namespace gcn } } - void ListBox::drawFrame(Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(shadowColor); - graphics->drawLine(i,i, width - i, i); - graphics->drawLine(i,i + 1, i, height - i - 1); - graphics->setColor(highlightColor); - graphics->drawLine(width - i,i + 1, width - i, height - i); - graphics->drawLine(i,height - i, width - i - 1, height - i); - } - } - void ListBox::logic() { adjustSize(); diff --git a/src/widgets/messagebox.cpp b/src/widgets/messagebox.cpp index c4fd096..db801f0 100644 --- a/src/widgets/messagebox.cpp +++ b/src/widgets/messagebox.cpp @@ -339,30 +339,6 @@ namespace gcn graphics->popClipArea(); } - void MessageBox::drawFrame(Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(highlightColor); - graphics->drawLine(i,i, width - i, i); - graphics->drawLine(i,i + 1, i, height - i - 1); - graphics->setColor(shadowColor); - graphics->drawLine(width - i,i + 1, width - i, height - i); - graphics->drawLine(i,height - i, width - i - 1, height - i); - } - } - void MessageBox::mousePressed(MouseEvent& mouseEvent) { if (mouseEvent.getSource() != this) diff --git a/src/widgets/progressbar.cpp b/src/widgets/progressbar.cpp index c238469..00aa390 100644 --- a/src/widgets/progressbar.cpp +++ b/src/widgets/progressbar.cpp @@ -191,30 +191,6 @@ namespace gcn graphics->drawText(getCaption(), textX, textY, getAlignment()); } - void ProgressBar::drawFrame(Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(shadowColor); - graphics->drawLine(i, i, width - i, i); - graphics->drawLine(i, i + 1, i, height - i - 1); - graphics->setColor(highlightColor); - graphics->drawLine(width - i, i + 1, width - i, height - i); - graphics->drawLine(i, height - i, width - i - 1, height - i); - } - } - void ProgressBar::adjustSize() { setHeight(getFont()->getHeight()); diff --git a/src/widgets/radiobutton.cpp b/src/widgets/radiobutton.cpp index 996c511..ea5ef81 100644 --- a/src/widgets/radiobutton.cpp +++ b/src/widgets/radiobutton.cpp @@ -122,30 +122,6 @@ namespace gcn graphics->drawText(getCaption(), h - 2, 0); } - void RadioButton::drawFrame(Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(shadowColor); - graphics->drawLine(i, i, width - i, i); - graphics->drawLine(i, i + 1, i, height - i - 1); - graphics->setColor(highlightColor); - graphics->drawLine(width - i, i + 1, width - i, height - i); - graphics->drawLine(i, height - i, width - i - 1, height - i); - } - } - void RadioButton::drawBox(Graphics* graphics) { int h; diff --git a/src/widgets/scrollarea.cpp b/src/widgets/scrollarea.cpp index dc116ec..df572e7 100644 --- a/src/widgets/scrollarea.cpp +++ b/src/widgets/scrollarea.cpp @@ -454,30 +454,6 @@ namespace gcn drawChildren(graphics); } - void ScrollArea::drawFrame(Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(shadowColor); - graphics->drawLine(i,i, width - i, i); - graphics->drawLine(i,i + 1, i, height - i - 1); - graphics->setColor(highlightColor); - graphics->drawLine(width - i,i + 1, width - i, height - i); - graphics->drawLine(i,height - i, width - i - 1, height - i); - } - } - void ScrollArea::drawHBar(Graphics* graphics) { Rectangle dim = getHorizontalBarDimension(); diff --git a/src/widgets/slider.cpp b/src/widgets/slider.cpp index ce0575c..2eb91b1 100644 --- a/src/widgets/slider.cpp +++ b/src/widgets/slider.cpp @@ -146,30 +146,6 @@ namespace gcn drawMarker(graphics); } - void Slider::drawFrame(gcn::Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(shadowColor); - graphics->drawLine(i, i, width - i, i); - graphics->drawLine(i, i + 1, i, height - i - 1); - graphics->setColor(highlightColor); - graphics->drawLine(width - i, i + 1, width - i, height - i); - graphics->drawLine(i, height - i, width - i - 1, height - i); - } - } - void Slider::drawMarker(gcn::Graphics* graphics) { gcn::Color faceColor = getBaseColor(); diff --git a/src/widgets/tab.cpp b/src/widgets/tab.cpp index 4a92d9d..9538507 100644 --- a/src/widgets/tab.cpp +++ b/src/widgets/tab.cpp @@ -68,8 +68,7 @@ namespace gcn { - Tab::Tab() - :mHasMouse(false) + Tab::Tab() : mTabbedArea(NULL), mHasMouse(false) { mLabel = new Label(); mLabel->setPosition(4, 4); @@ -112,50 +111,59 @@ namespace gcn } void Tab::draw(Graphics *graphics) - { - if (mTabbedArea->isTabSelected(this) || mHasMouse) - { - graphics->setColor(getBaseColor()); - } - else - { - graphics->setColor(getBaseColor() - 0x151515); - } - - graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight())); - - drawChildren(graphics); - - if (mTabbedArea->isFocused() - && mTabbedArea->isTabSelected(this)) - { - graphics->setColor(Color(0x000000)); - graphics->drawRectangle(Rectangle(2, 2, getWidth() - 4, getHeight() - 4)); - } - } - - void Tab::drawFrame(Graphics* graphics) { Color faceColor = getBaseColor(); Color highlightColor, shadowColor; int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; highlightColor = faceColor + 0x303030; highlightColor.a = alpha; shadowColor = faceColor - 0x303030; shadowColor.a = alpha; - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) + Color borderColor; + Color baseColor; + + if ((mTabbedArea != NULL && mTabbedArea->isTabSelected(this)) || mHasMouse) { + // Draw a border. graphics->setColor(highlightColor); - graphics->drawLine(i,i, width - i, i); - graphics->drawLine(i,i + 1, i, height - i - 1); + graphics->drawLine(0, 0, getWidth() - 1, 0); + graphics->drawLine(0, 1, 0, getHeight() - 1); graphics->setColor(shadowColor); - graphics->drawLine(width - i,i + 1, width - i, height - i); - graphics->drawLine(i,height - i, width - i - 1, height - i); + 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) diff --git a/src/widgets/tabbedarea.cpp b/src/widgets/tabbedarea.cpp index 06821c3..77759de 100644 --- a/src/widgets/tabbedarea.cpp +++ b/src/widgets/tabbedarea.cpp @@ -265,53 +265,51 @@ namespace gcn { return mSelectedTab; } - - + + void TabbedArea::draw(Graphics *graphics) { - graphics->setColor(getBaseColor() + 0x303030); - graphics->drawLine(0, + 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(highlightColor); + graphics->drawLine(0, mTabContainer->getHeight(), 0, getHeight() - 2); + graphics->setColor(shadowColor); + graphics->drawLine( + getWidth() - 1, mTabContainer->getHeight() + 1, getWidth() - 1, getHeight() - 1); + graphics->drawLine(1, getHeight() - 1, getWidth() - 1, getHeight() - 1); + + graphics->setColor(getBaseColor()); + graphics->fillRectangle(Rectangle(1, 1, getWidth() - 2, getHeight() - 2)); + + // Draw a line underneath the tabs. + graphics->setColor(highlightColor); + graphics->drawLine(1, mTabContainer->getHeight(), - getWidth(), + getWidth() - 1, mTabContainer->getHeight()); + // If a tab is selected, + // remove the line right underneath the selected tab. if (mSelectedTab != NULL) { graphics->setColor(getBaseColor()); - graphics->drawLine(mSelectedTab->getX(), + graphics->drawLine(mSelectedTab->getX() + 1, mTabContainer->getHeight(), - mSelectedTab->getX() + mSelectedTab->getWidth(), + mSelectedTab->getX() + mSelectedTab->getWidth() - 2, mTabContainer->getHeight()); } drawChildren(graphics); } - - void TabbedArea::drawFrame(Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(highlightColor); - graphics->drawLine(i,i + mWidgetContainer->getY(), i, height - i - 1); - graphics->setColor(shadowColor); - graphics->drawLine(width - i,i + 1 + mWidgetContainer->getY(), width - i, height - i); - graphics->drawLine(i,height - i, width - i - 1, height - i); - } - } - void TabbedArea::logic() { @@ -328,20 +326,13 @@ namespace gcn maxTabHeight = mTabs[i].first->getHeight(); } } - - if (getHeight() < maxTabHeight) - { - mTabContainer->setHeight(maxTabHeight); - } - else - { - mTabContainer->setHeight(maxTabHeight); - mWidgetContainer->setHeight(getHeight() - maxTabHeight - 1); - mWidgetContainer->setY(maxTabHeight + 1); - } - mTabContainer->setWidth(getWidth()); - mWidgetContainer->setWidth(getWidth()); + mTabContainer->setWidth(getWidth() - 2); + mTabContainer->setHeight(maxTabHeight); + + mWidgetContainer->setPosition(1, maxTabHeight + 1); + mWidgetContainer->setWidth(getWidth() - 2); + mWidgetContainer->setHeight(getHeight() - maxTabHeight - 2); } void TabbedArea::adjustTabPositions() @@ -361,25 +352,19 @@ namespace gcn { Tab* tab = mTabs[i].first; - if (x == 0) - { - x = tab->getFrameSize() + 2; - } - tab->setX(x); if (tab->getHeight() < maxTabHeight) { tab->setY(maxTabHeight - - tab->getHeight() - + tab->getFrameSize()); + - tab->getHeight()); } else { - tab->setY(mTabs[i].first->getFrameSize()); + tab->setY(0); } - x += tab->getWidth() + tab->getFrameSize() * 2; + x += tab->getWidth(); } } diff --git a/src/widgets/textbox.cpp b/src/widgets/textbox.cpp index 05b08bf..c33eeef 100644 --- a/src/widgets/textbox.cpp +++ b/src/widgets/textbox.cpp @@ -133,6 +133,22 @@ namespace gcn void TextBox::draw(Graphics* graphics) { + /* + int width = getWidth() + getFrameSize() * 2 - 1; + int height = getHeight() + getFrameSize() * 2 - 1; + + graphics->setColor(getBackgroundColor()); + + unsigned int i; + for (i = 0; i < getFrameSize(); ++i) + { + graphics->drawLine(i,i, width - i, i); + graphics->drawLine(i,i + 1, i, height - i - 1); + graphics->drawLine(width - i,i + 1, width - i, height - i); + graphics->drawLine(i,height - i, width - i - 1, height - i); + } + */ + unsigned int i; if (mOpaque) @@ -156,23 +172,6 @@ namespace gcn } } - void TextBox::drawFrame(Graphics* graphics) - { - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - - graphics->setColor(getBackgroundColor()); - - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) - { - graphics->drawLine(i,i, width - i, i); - graphics->drawLine(i,i + 1, i, height - i - 1); - graphics->drawLine(width - i,i + 1, width - i, height - i); - graphics->drawLine(i,height - i, width - i - 1, height - i); - } - } - void TextBox::drawCaret(Graphics* graphics, int x, int y) { graphics->setColor(getForegroundColor()); diff --git a/src/widgets/textfield.cpp b/src/widgets/textfield.cpp index 3e10f10..ca058fe 100644 --- a/src/widgets/textfield.cpp +++ b/src/widgets/textfield.cpp @@ -77,7 +77,6 @@ namespace gcn addMouseListener(this); addKeyListener(this); adjustHeight(); - setFrameSize(1); } TextField::TextField(const std::string& text) @@ -87,7 +86,6 @@ namespace gcn mText = text; adjustSize(); - setFrameSize(1); setFocusable(true); @@ -107,8 +105,27 @@ namespace gcn void TextField::draw(Graphics* graphics) { - Color faceColor = getBackgroundColor(); - graphics->setColor(faceColor); + 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(Color(0xffffff)); graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight())); if (isFocused()) @@ -122,37 +139,20 @@ namespace gcn graphics->setColor(Color(128, 128, 128)); graphics->setFont(getFont()); - graphics->drawText(mText, 1 - mXScroll, 2); - } - - void TextField::drawFrame(Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(shadowColor); - graphics->drawLine(i, i, width - i, i); - graphics->drawLine(i, i + 1, i, height - i - 1); - graphics->setColor(highlightColor); - graphics->drawLine(width - i, i + 1, width - i, height - i); - graphics->drawLine(i, height - i, width - i - 1, height - i); - } + graphics->drawText(mText, 1 - mXScroll, 1); + graphics->popClipArea(); } void TextField::drawCaret(Graphics* graphics, int x) { + // Check the current clip area as a clip area with a different + // size than the widget might have been pushed (which is the + // case in the draw method when we push a clip area after we have + // drawn a border). + const Rectangle clipArea = graphics->getCurrentClipArea(); + graphics->setColor(getForegroundColor()); - graphics->drawLine(x, getHeight() - 2, x, 1); + graphics->drawLine(x, clipArea.height - 2, x, 1); } void TextField::mousePressed(MouseEvent& mouseEvent) diff --git a/src/widgets/window.cpp b/src/widgets/window.cpp index 4be331b..34c24c8 100644 --- a/src/widgets/window.cpp +++ b/src/widgets/window.cpp @@ -233,30 +233,6 @@ namespace gcn graphics->popClipArea(); } - void Window::drawFrame(Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - unsigned int i; - for (i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(highlightColor); - graphics->drawLine(i, i, width - i, i); - graphics->drawLine(i, i + 1, i, height - i - 1); - graphics->setColor(shadowColor); - graphics->drawLine(width - i, i + 1, width - i, height - i); - graphics->drawLine(i, height - i, width - i - 1, height - i); - } - } - void Window::mousePressed(MouseEvent& mouseEvent) { if (mouseEvent.getSource() != this)