Skip to content

Commit

Permalink
Apply guichan's changes from 753608c0c8cd0196c19c467db0f8df5f61d99b3c…
Browse files Browse the repository at this point in the history
… (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).
  • Loading branch information
Jarod42 committed Jul 9, 2024
1 parent 5ecd27d commit 03de336
Show file tree
Hide file tree
Showing 39 changed files with 219 additions and 575 deletions.
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion include/guisan/widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/button.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawFrame(Graphics* graphics);


// Inherited from FocusListener

Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/checkbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawFrame(Graphics* graphics);


// Inherited from KeyListener

Expand Down
1 change: 0 additions & 1 deletion include/guisan/widgets/container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawFrame(Graphics* graphics);

protected:
/**
Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/dropdown.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion include/guisan/widgets/icon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawFrame(Graphics* graphics);

protected:
/**
Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/inputbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawFrame(Graphics* graphics);


// Inherited from MouseListener

Expand Down
1 change: 0 additions & 1 deletion include/guisan/widgets/label.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawFrame(Graphics* graphics);

protected:
/**
Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/listbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawFrame(Graphics* graphics);

virtual void logic();


Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/messagebox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawFrame(Graphics* graphics);


// Inherited from MouseListener

Expand Down
1 change: 0 additions & 1 deletion include/guisan/widgets/progressbar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawFrame(Graphics* graphics);

protected:
/**
Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/radiobutton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawFrame(Graphics* graphics);


// Inherited from KeyListener

Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/scrollarea.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,6 @@ namespace gcn

virtual void draw(Graphics *graphics);

virtual void drawFrame(Graphics* graphics);

virtual void logic();

void setWidth(int width);
Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/slider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawFrame(Graphics* graphics);


// Inherited from MouseListener.

Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/tab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ namespace gcn

virtual void draw(Graphics *graphics);

virtual void drawFrame(Graphics* graphics);


// Inherited from MouseListener

Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/tabbedarea.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ namespace gcn

virtual void draw(Graphics *graphics);

virtual void drawFrame(Graphics* graphics);

virtual void logic();

void setWidth(int width);
Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/textbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawFrame(Graphics* graphics);

virtual void fontChanged();


Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/textfield.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawFrame(Graphics* graphics);


// Inherited from MouseListener

Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawFrame(Graphics* graphics);


// Inherited from MouseListener

Expand Down
25 changes: 25 additions & 0 deletions src/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
24 changes: 0 additions & 24 deletions src/widgets/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
24 changes: 0 additions & 24 deletions src/widgets/checkbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 0 additions & 24 deletions src/widgets/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 03de336

Please sign in to comment.