soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SEdit.cpp
1#include <souistd.h>
2#include <control/SEdit.h>
3
4SNSBEGIN
5
7 : m_crCue(RGBA(0xcc, 0xcc, 0xcc, 0xff))
8 , m_strCue(this)
9{
10 m_fRich = 0;
11 m_fAutoSel = TRUE;
12}
13
14void SEdit::OnKillFocus(SWND wndFocus)
15{
16 SRichEdit::OnKillFocus(wndFocus);
17 if (!m_strCue.GetText(FALSE).IsEmpty() && GetWindowTextLength() == 0)
18 Invalidate();
19}
20
21void SEdit::OnSetFocus(SWND wndOld)
22{
24 if (!m_strCue.GetText(FALSE).IsEmpty() && GetWindowTextLength() == 0)
25 Invalidate();
26}
27
29{
30 UINT algin = SWindow::GetTextAlign();
31 algin &= ~(DT_CENTER | DT_RIGHT);
32 if (m_dwStyle & ES_CENTER)
33 algin |= DT_CENTER;
34 else if (m_dwStyle & ES_RIGHT)
35 algin |= DT_RIGHT;
36 return algin;
37}
38
40{
42 SStringT strCue = GetCueText();
43 if (!strCue.IsEmpty() && GetWindowTextLength() == 0 && !IsFocused())
44 {
45 SPainter painter;
46 BeforePaint(pRT, painter);
47 COLORREF crOld = pRT->SetTextColor(m_crCue);
48
49 CRect rc;
50 GetClientRect(&rc);
51 CRect rcInsetPixel = GetStyle().GetPadding();
52 rc.DeflateRect(rcInsetPixel.left, rcInsetPixel.top, rcInsetPixel.right, rcInsetPixel.bottom);
53 pRT->DrawText(strCue, strCue.GetLength(), &rc, GetCueTextAlign());
54
55 pRT->SetTextColor(crOld);
56 AfterPaint(pRT, painter);
57 }
58}
59
60SStringT SEdit::GetCueText(BOOL bRawText) const
61{
62 return m_strCue.GetText(bRawText);
63}
64
66{
67 HRESULT hr = __baseCls::OnLanguageChanged();
68 m_strCue.TranslateText();
69 return hr;
70}
71
72SNSEND
COLORREF m_crCue
Definition SEdit.h:96
void OnSetFocus(SWND wndOld)
Handle set focus event.
Definition SEdit.cpp:21
STrText m_strCue
Definition SEdit.h:97
void OnKillFocus(SWND wndFocus)
Handle kill focus event.
Definition SEdit.cpp:14
virtual HRESULT OnLanguageChanged()
Handle language change event.
Definition SEdit.cpp:65
void OnPaint(IRenderTarget *pRT)
Paint the control.
Definition SEdit.cpp:39
SEdit()
Constructor.
Definition SEdit.cpp:6
void GetCueText(IStringT *pStr) SCONST
Get the cue text.
Definition SEdit.h:27
UINT GetCueTextAlign()
Get the alignment of the cue text.
Definition SEdit.cpp:28
Helper class for painting.
Definition SWnd.h:178
void OnSetFocus(SWND wndOld)
Handle set focus message.
void OnPaint(IRenderTarget *pRT)
Handle paint message.
void OnKillFocus(SWND wndFocus)
Handle kill focus message.
UINT GetTextAlign() const
Retrieves the text alignment of the window.
Definition Swnd.cpp:218
Interface for rendering target objects.
Definition SRender-i.h:1440
HRESULT DrawText(LPCTSTR pszText, int cchLen, LPRECT pRc, UINT uFormat) PURE
Draw text within a rectangle.
COLORREF SetTextColor(COLORREF color) PURE
Sets the current text color.