// Matt Streeter
// 2/27/00
// ESSTATIC.CPP
// Implementation of class TESStatic; custom implementation of TStatic control
// Copyright Matt Streeter, 2000. All rights reserved
#include <string.h>
#include "esstatic.h"
// The following three #defines determine the face, height, and weight,
// respectively, of the text in a TESStatic.
#define STATIC_FONT_FACE "MS Sans Serif"
#define STATIC_FONT_HEIGHT 18
#define STATIC_FONT_WEIGHT FW_NORMAL
#if(!USE_ES_STATICS)
TESStatic::TESStatic(TWindow* parent, int id, const char far* title,
int x, int y,int w,int h,uint textLen, TModule* module)
:TStatic(parent,id,title,x,y,w,h,textLen,module)
{
}
#else
DEFINE_RESPONSE_TABLE1(TESStatic,TWindow)
EV_WM_MOUSEMOVE,
END_RESPONSE_TABLE;
// Public member functions
TESStatic::TESStatic(TESWindow* parent, int, const char far* title,
int x, int y,int w,int h,uint, TModule*)
:TWindow((TWindow*)parent,(char*)title)
{
Attr.X=x;
Attr.Y=y;
Attr.W=w;
Attr.H=h;
mpESParent=parent;
}
void TESStatic::SetText(const char far* str)
{
SetCaption(str);
Invalidate(true);
}
int TESStatic::GetText(char far* str, int maxChars)
{
strncpy(str,Title,maxChars);
return(strlen(str));
}
int TESStatic::GetTextLen()
{
return(strlen(Title));
}
void TESStatic::EvMouseMove(uint modKeys, TPoint& point)
{
ClientToScreen(point);
mpESParent->EvChildMouseMove(modKeys,point);
}
// Protected member functions
void TESStatic::GetWindowClass(WNDCLASS& WndClass)
{
TWindow::GetWindowClass(WndClass);
WndClass.hbrBackground=(HBRUSH)(TESWindow::mBackgroundFillBrush);
}
void TESStatic::Paint(TDC& dc, bool, TRect&)
{
dc.SetBkColor(TESWindow::mBackgroundColor);
dc.SetTextColor(TESWindow::mTextColor);
TRect ClientRect;
GetClientRect(ClientRect);
TFont LabelFont(STATIC_FONT_FACE,STATIC_FONT_HEIGHT,0,0,0,STATIC_FONT_WEIGHT,
DEFAULT_PITCH|FF_DONTCARE,false,false,false,1,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,PROOF_QUALITY);
dc.SelectObject(LabelFont);
TSize Size=dc.GetTextExtent(Title,strlen(Title));
TPoint TextPos(ClientRect.left,
ClientRect.top+(ClientRect.Height()+1-Size.cy)/2);
dc.TextOut(TextPos,Title,strlen(Title));
}
#endif