1//============================================================================
2//
3// SSSS tt lll lll
4// SS SS tt ll ll
5// SS tttttt eeee ll ll aaaa
6// SSSS tt ee ee ll ll aa
7// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
8// SS SS tt ee ll ll aa aa
9// SSSS ttt eeeee llll llll aaaaa
10//
11// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony
12// and the Stella Team
13//
14// See the file "License.txt" for information on usage and redistribution of
15// this file, and for a DISCLAIMER OF ALL WARRANTIES.
16//============================================================================
17
18#include "bspf.hxx"
19#include "Command.hxx"
20#include "Dialog.hxx"
21#include "FBSurface.hxx"
22#include "GuiObject.hxx"
23#include "OSystem.hxx"
24#include "ColorWidget.hxx"
25
26// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
27ColorWidget::ColorWidget(GuiObject* boss, const GUI::Font& font,
28 int x, int y, int w, int h, int cmd)
29 : Widget(boss, font, x, y, w, h),
30 CommandSender(boss),
31 _color(kNone),
32 _cmd(cmd),
33 _crossGrid(false)
34{
35 _flags = Widget::FLAG_ENABLED | Widget::FLAG_CLEARBG | Widget::FLAG_RETAIN_FOCUS;
36}
37
38// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
39void ColorWidget::setColor(ColorId color)
40{
41 _color = color;
42 setDirty();
43}
44
45// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
46void ColorWidget::drawWidget(bool hilite)
47{
48 FBSurface& s = dialog().surface();
49 bool onTop = _boss->dialog().isOnTop();
50
51 // Draw a thin frame around us.
52 s.frameRect(_x, _y, _w, _h + 1, kColor);
53
54 // Show the currently selected color
55 s.fillRect(_x+1, _y+1, _w-2, _h-1, onTop ? isEnabled() ? _color : kWidColor : kBGColorLo);
56
57 // Cross out the grid?
58 if(_crossGrid)
59 {
60 s.line(_x + 1, _y + 1, _x + _w - 2, _y + _h - 1, kColor);
61 s.line(_x + _w - 2, _y + 1, _x + 1, _y + _h - 1, kColor);
62 }
63}
64