YSTest: YBrush.cpp 源文件

YSTest PreAlpha_b400_20130424 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
YBrush.cpp
浏览该文件的文档.
1 ﻿/*
2 Copyright by FrankHB 2012 - 2013.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #include "YSLib/UI/YBrush.h"
29 #include "YSLib/Service/ydraw.h"
30 #include "YSLib/UI/ygui.h"
31 #include "YSLib/UI/ywidget.h"
32
33 YSL_BEGIN
34
35 using namespace Drawing;
36
37 YSL_BEGIN_NAMESPACE(UI)
38
39 void
40 SolidBrush::operator()(PaintEventArgs&& e)
41 {
42 Drawing::FillRect(e.Target, e.ClipArea, Color);
43 }
44
45
46 void
47 ImageBrush::operator()(PaintEventArgs&& e)
48 {
49 if(bool(Image))
50 {
51 const auto& g(e.Target);
52 const Rect& r(e.ClipArea);
53
54 CopyTo(g.GetBufferPtr(), Image->GetContext(), g.GetSize(),
55 r.GetPoint(), r.GetPoint(), r.GetSize());
56 }
57 }
58
59
60 BorderStyle::BorderStyle()
61 : ActiveColor(FetchGUIState().Colors[Styles::ActiveBorder]),
62 InactiveColor(FetchGUIState().Colors[Styles::InactiveBorder])
63 {}
64
65
66 void
67 BorderBrush::operator()(PaintEventArgs&& e)
68 {
69 auto& sender(e.GetSender());
70
71 DrawRect(e.Target, Rect(e.Location, GetSizeOf(sender)), IsFocused(sender)
72 ? Style.ActiveColor : Style.InactiveColor);
73 }
74
75 YSL_END_NAMESPACE(UI)
76
77 YSL_END
78