1 #include "studiox_includes.h"
2 #include "splash_screen.h"
3
4 #ifdef _DEBUG
5 #define new DEBUG_NEW
6 #endif
7
8 extern CString studiox_version_string;
9
BEGIN_MESSAGE_MAP(splash_screen,CDialog)10 BEGIN_MESSAGE_MAP(splash_screen, CDialog)
11 ON_WM_PAINT()
12 ON_WM_CREATE()
13 ON_WM_TIMER()
14 ON_BN_CLICKED(IDOK, OnDoneClicked)
15 END_MESSAGE_MAP()
16
17
18
19 ///////////////////////////////////////////////////////////////////////////////
20 splash_screen::splash_screen(BOOL AutoClose)
21 {
22 mAutoClose = AutoClose;
23 memset(date_built, 0, DATE_STRING_SIZE);
24 }
25
26 ///////////////////////////////////////////////////////////////////////////////
PreCreateWindow(CREATESTRUCT & cs)27 BOOL splash_screen::PreCreateWindow(CREATESTRUCT& cs)
28 {
29 if( !CWnd::PreCreateWindow(cs) )
30 return FALSE;
31 // TODO: Modify the Window class or styles here by modifying
32 // the CREATESTRUCT cs
33
34 return TRUE;
35 }
36
37
ScreenReaderMessage()38 void splash_screen::ScreenReaderMessage()
39 {
40 CString HelpString = _T("Azure RTOS GUIX Studio. ");
41 CString version;
42
43 version = "Version: ";
44 version += studiox_version_string;
45 version += _T(". Build Date: ");
46 CString date(__DATE__);
47 CString month = date.Left(3);
48 CString day = date.Mid(4, 2);
49 CString year = date.Right(4);
50
51 version += month + ' ' + day + ' ' + year;
52 HelpString += version;
53
54 SetWindowText(HelpString);
55 }
56
57
58 ///////////////////////////////////////////////////////////////////////////////
OnCreate(LPCREATESTRUCT lpCreateStruct)59 int splash_screen::OnCreate(LPCREATESTRUCT lpCreateStruct)
60 {
61 CWnd::OnCreate(lpCreateStruct);
62 CenterWindow();
63 ScreenReaderMessage();
64
65 if (mAutoClose)
66 {
67 SetTimer(1, 2000, NULL);
68 }
69 else
70 {
71 CRect button_rect;
72 GetClientRect(button_rect);
73 button_rect.bottom -= 10;
74 button_rect.top = button_rect.bottom - 20;
75 button_rect.left += 220;
76 button_rect.right -= 100;
77 CloseButton.Create(_T("Close"), BS_PUSHBUTTON|BS_CENTER|BS_VCENTER|WS_CHILD|WS_VISIBLE, button_rect, this, IDOK);
78 CloseButton.SetFocus();
79 }
80
81 return 0;
82 }
83
84 extern CFont TitleFont;
85 extern CFont TinyFont;
86
MonthToNumber(CString Month)87 CString MonthToNumber(CString Month)
88 {
89 if (Month == "Jan")
90 {
91 return CString("01");
92 }
93 if (Month == "Feb")
94 {
95 return CString("02");
96 }
97 if (Month == "Mar")
98 {
99 return CString("03");
100 }
101 if (Month == "Apr")
102 {
103 return CString("04");
104 }
105 if (Month == "May")
106 {
107 return CString("05");
108 }
109 if (Month == "Jun")
110 {
111 return CString("06");
112 }
113 if (Month == "Jul")
114 {
115 return CString("07");
116 }
117 if (Month == "Aug")
118 {
119 return CString("08");
120 }
121 if (Month == "Sep")
122 {
123 return CString("09");
124 }
125 if (Month == "Oct")
126 {
127 return CString("10");
128 }
129 if (Month == "Nov")
130 {
131 return CString("11");
132 }
133 if (Month == "Dec")
134 {
135 return CString("12");
136 }
137 return CString("xx");
138 }
139
140 ///////////////////////////////////////////////////////////////////////////////
OnPaint()141 void splash_screen::OnPaint()
142 {
143 CWnd::OnPaint();
144 CDC *dc = GetDC();
145 PaintBmp(dc, 0, 0, IDB_SPLASH_BACKGROUND);
146 CFont *OldFont;
147
148 CString temp;
149 CRect rc;
150 CRect client;
151
152 int xpos = 200;
153 int ypos = 120;
154 int line_height = 16;
155
156 dc->SetTextColor(RGB(248, 208, 40));
157 dc->SetBkColor(RGB(0, 0, 0));
158 dc->SetBkMode(TRANSPARENT);
159
160 OldFont = dc->SelectObject(&TitleFont);
161
162 dc->TextOut(xpos, ypos, _T("Azure RTOS GUIX Studio"));
163 ypos += 30;
164
165 temp = "Version ";
166 temp += studiox_version_string;
167 dc->TextOut(xpos, ypos, temp);
168 ypos += 30;
169 dc->SelectObject(&TinyFont);
170
171 GetClientRect(&client);
172 rc.SetRect(xpos, ypos, client.right - 10, ypos + line_height);
173 rc.OffsetRect(0, line_height);
174
175 CString date(__DATE__);
176 CString month = date.Left(3);
177 CString day = date.Mid(4, 2);
178 CString year = date.Right(4);
179
180 temp = "Studio Build Date: ";
181 temp += month + '-' + day + '-' + year;
182 dc->DrawText(temp, rc, DT_LEFT|DT_SINGLELINE);
183 rc.OffsetRect(0, line_height);
184
185 dc->SelectObject(OldFont);
186 ReleaseDC(dc);
187 }
188
OnTimer(UINT_PTR nIdEvent)189 void splash_screen::OnTimer(UINT_PTR nIdEvent)
190 {
191 EndModalLoop(0);
192 }
193
OnDoneClicked()194 void splash_screen::OnDoneClicked()
195 {
196 EndModalLoop(0);
197 }