root/trunk/GUIComponents/ElephantEdit.cpp

Revision 5, 1.8 kB (checked in by qbert, 3 years ago)

Initial ( and last :( ) commit

Line 
1 // ElephantEdit.cpp : implementation file
2 //
3  
4 #include "StdAfx.h"
5 #include "../Elephant.h"
6 #include "ElephantEdit.h"
7
8 #ifdef _DEBUG
9 #define new DEBUG_NEW
10 #undef THIS_FILE
11 static char THIS_FILE[] = __FILE__;
12 #endif
13
14 /////////////////////////////////////////////////////////////////////////////
15 // CElephantEdit
16
17
18
19 CElephantEdit::CElephantEdit()
20 {
21     defaultFont->CreateFont(
22
23         13,                        // nHeight
24         0,                         // nWidth
25         0,                         // nEscapement
26         0,                         // nOrientation
27         FW_NORMAL,                 // nWeight
28         FALSE,                     // bItalic
29         FALSE,                     // bUnderline
30         0,                         // cStrikeOut
31         ANSI_CHARSET,              // nCharSet
32         OUT_DEFAULT_PRECIS,        // nOutPrecision
33         CLIP_DEFAULT_PRECIS,       // nClipPrecision
34         DEFAULT_QUALITY,           // nQuality
35         DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
36         "Verdana") ;                 // lpszFacename
37
38 }
39
40 CElephantEdit::~CElephantEdit()
41 {
42 }
43
44
45 BEGIN_MESSAGE_MAP(CElephantEdit, CEdit)
46     //{{AFX_MSG_MAP(CElephantEdit)
47     ON_CONTROL_REFLECT(EN_SETFOCUS, OnSetfocus)
48     ON_CONTROL_REFLECT(EN_KILLFOCUS, OnKillfocus)
49     //}}AFX_MSG_MAP
50 END_MESSAGE_MAP()
51
52 /////////////////////////////////////////////////////////////////////////////
53 // CElephantEdit message handlers
54
55 void CElephantEdit::OnSetfocus()
56 {
57    
58     CString text;
59     this->GetWindowText(text);
60    
61     if ( text == CString(m_text.c_str()))
62     {
63         SetWindowText(""); 
64     }
65    
66 }
67
68
69 void CElephantEdit::OnKillfocus()
70 {
71    
72     CString text;
73     this->GetWindowText(text);
74    
75     if ( text == "")
76     {
77         SetWindowText(m_text.c_str());
78     }
79 }
80
81
82 void CElephantEdit::SetText(const string& text, bool disable) {
83     m_text = text;
84     SetWindowText(text.c_str() );
85     SetFont(defaultFont);
86     DisableFlatLook(disable);
87 }
Note: See TracBrowser for help on using the browser.