#include <owl/gadget.h> #include <owl/uihelper.h> #include <winsys/uimetric.h> // // TFlatButtonGadget class // ~~~~~~~~~~~~~~~~~~~~~~~ // Implements a flat "IE 3" style button gadget. Currently // does not support button gadgets used as "radio" buttons. // class TFlatButtonGadget : public TButtonGadget { public: TFlatButtonGadget(TResId glyphResIdOrIndex, int id, TType type = Command, bool enabled = false, TState state = Up, bool sharedGlyph = false); virtual ~TFlatButtonGadget(); protected: bool MouseIsIn; public: virtual void PaintBorder(TDC& dc); virtual void MouseEnter(uint modKeys, TPoint& point); virtual void MouseLeave(uint modKeys, TPoint& point); }; TFlatButtonGadget::TFlatButtonGadget(TResId glyphResIdOrIndex, int id, TType type, bool enabled, TState state, bool sharedGlyph) : TButtonGadget(glyphResIdOrIndex, id, type, enabled, state, sharedGlyph), MouseIsIn(false) { SetBorderStyle(Raised); } TFlatButtonGadget::~TFlatButtonGadget() { } void TFlatButtonGadget::PaintBorder(TDC& dc) { if ((MouseIsIn && GetEnabled()) || GetButtonState()) { TRect rect(0, 0, Bounds.Width(), Bounds.Height()); TUIBorder::DrawEdge(dc, rect, Pressed || GetButtonState() ? TUIBorder::SunkenOuter : TUIBorder::RaisedInner, TUIBorder::Rect); } } void TFlatButtonGadget::MouseEnter(uint modKeys, TPoint& point) { TButtonGadget::MouseEnter(modKeys, point); MouseIsIn = true; Invalidate(); } void TFlatButtonGadget::MouseLeave(uint modKeys, TPoint& point) { MouseIsIn = false; TGadget::Invalidate(true); TButtonGadget::MouseLeave(modKeys, point); } // // TFlatSeparatorGadget // ~~~~~~~~~~~~~~~~~~~~ // Draws an etched vertical line as a separator. // class TFlatSeparatorGadget : public TSeparatorGadget { public: TFlatSeparatorGadget(int width = 0, int height = 0, int id = 0); virtual ~TFlatSeparatorGadget(); public: virtual void Paint(TDC& dc); }; TFlatSeparatorGadget::TFlatSeparatorGadget(int width, int height, int id) : TSeparatorGadget(width, id) { Bounds.bottom = (height ? height : TUIMetric::CySizeFrame * 5); } TFlatSeparatorGadget::~TFlatSeparatorGadget() { } void TFlatSeparatorGadget::Paint(TDC& dc) { TSeparatorGadget::Paint(dc); if (!IsEndOfRow()) { TRect rect(0, 0, Bounds.Width() / 2 + 1, Bounds.Height()); TUIBorder::DrawEdge(dc, rect, TUIBorder::EdgeEtched, TUIBorder::Right); } }