461 lines
18 KiB
C++
461 lines
18 KiB
C++
#include <statbar/statbar.hpp>
|
|
#include <common/purehdc.hpp>
|
|
|
|
StatusBar::StatusBar(Window &mainWindow)
|
|
: mDisplayWindow(mainWindow), mLastCapLockState(FALSE), mLastNumLockState(FALSE), mLastItemID(-1),
|
|
mCapLockString("CAPS"), mNumLockString("NUM"), mBlankString(" "), mKeyDownState(FALSE),
|
|
StatusBarMenu(mainWindow), mLastDisplayString(mBlankString)
|
|
{
|
|
mPaintCallback.setCallback(this,&StatusBar::paintHandler);
|
|
mSetFocusCallback.setCallback(this,&StatusBar::setFocusHandler);
|
|
mKeyUpCallback.setCallback(this,&StatusBar::keyUpHandler);
|
|
mKeyDownCallback.setCallback(this,&StatusBar::keyDownHandler);
|
|
mSizeCallback.setCallback(this,&StatusBar::sizeHandler);
|
|
mMinMaxCallback.setCallback(this,&StatusBar::minMaxHandler);
|
|
mMenuSelectCallback.setCallback(this,&StatusBar::menuSelectHandler);
|
|
mDestroyCallback.setCallback(this,&StatusBar::destroyHandler);
|
|
mDisplayWindow.insertHandler(VectorHandler::PaintHandler,&mPaintCallback,VectorHandler::FirstHandler);
|
|
mDisplayWindow.insertHandler(VectorHandler::SetFocusHandler,&mSetFocusCallback);
|
|
mDisplayWindow.insertHandler(VectorHandler::KeyUpHandler,&mKeyUpCallback);
|
|
mDisplayWindow.insertHandler(VectorHandler::KeyDownHandler,&mKeyDownCallback);
|
|
mDisplayWindow.insertHandler(VectorHandler::SizeHandler,&mSizeCallback);
|
|
mDisplayWindow.insertHandler(VectorHandler::MinMaxHandler,&mMinMaxCallback);
|
|
mDisplayWindow.insertHandler(VectorHandler::MenuSelectHandler,&mMenuSelectCallback);
|
|
mDisplayWindow.insertHandler(VectorHandler::DestroyHandler,&mDestroyCallback);
|
|
::InvalidateRect(mainWindow,0,TRUE);
|
|
}
|
|
|
|
StatusBar::StatusBar(GUIWindow &guiWindow)
|
|
: mDisplayWindow(guiWindow), mLastCapLockState(FALSE), mLastNumLockState(FALSE), mLastItemID(-1),
|
|
mCapLockString("CAPS"), mNumLockString("NUM"), mBlankString(" "), mKeyDownState(FALSE),
|
|
StatusBarMenu(guiWindow), mLastDisplayString(mBlankString)
|
|
{
|
|
mSetFocusCallback.setCallback(this,&StatusBar::setFocusHandler);
|
|
mKeyUpCallback.setCallback(this,&StatusBar::keyUpHandler);
|
|
mKeyDownCallback.setCallback(this,&StatusBar::keyDownHandler);
|
|
mSizeCallback.setCallback(this,&StatusBar::sizeHandler);
|
|
mMinMaxCallback.setCallback(this,&StatusBar::minMaxHandler);
|
|
mMenuSelectCallback.setCallback(this,&StatusBar::menuSelectHandler);
|
|
mDestroyCallback.setCallback(this,&StatusBar::destroyHandler);
|
|
mPaintCallback.setCallback(this,&StatusBar::paintHandler);
|
|
mDisplayWindow.insertHandler(VectorHandler::PaintHandler,&mPaintCallback,VectorHandler::FirstHandler);
|
|
mDisplayWindow.insertHandler(VectorHandler::SetFocusHandler,&mSetFocusCallback);
|
|
mDisplayWindow.insertHandler(VectorHandler::KeyUpHandler,&mKeyUpCallback);
|
|
mDisplayWindow.insertHandler(VectorHandler::KeyDownHandler,&mKeyDownCallback);
|
|
mDisplayWindow.insertHandler(VectorHandler::SizeHandler,&mSizeCallback);
|
|
mDisplayWindow.insertHandler(VectorHandler::MinMaxHandler,&mMinMaxCallback);
|
|
mDisplayWindow.insertHandler(VectorHandler::MenuSelectHandler,&mMenuSelectCallback);
|
|
mDisplayWindow.insertHandler(VectorHandler::DestroyHandler,&mDestroyCallback);
|
|
::InvalidateRect(guiWindow,0,TRUE);
|
|
}
|
|
|
|
StatusBar::~StatusBar()
|
|
{
|
|
removeHandlers();
|
|
}
|
|
|
|
CallbackData::ReturnType StatusBar::keyUpHandler(CallbackData &/*someCallbackData*/)
|
|
{
|
|
mKeyDownState=FALSE;
|
|
return (CallbackData::ReturnType)0;
|
|
}
|
|
|
|
CallbackData::ReturnType StatusBar::keyDownHandler(CallbackData &someCallbackData)
|
|
{
|
|
if(!mKeyDownState)
|
|
{
|
|
if(VK_CAPITAL==someCallbackData.wParam())setCapLockText();
|
|
else if(VK_NUMLOCK==someCallbackData.wParam())setNumLockText();
|
|
mKeyDownState=TRUE;
|
|
}
|
|
return (CallbackData::ReturnType)0;
|
|
}
|
|
|
|
CallbackData::ReturnType StatusBar::setFocusHandler(CallbackData &/*someCallbackData*/)
|
|
{
|
|
setCapLockText();
|
|
setNumLockText();
|
|
return (CallbackData::ReturnType)0;
|
|
}
|
|
|
|
CallbackData::ReturnType StatusBar::destroyHandler(CallbackData &/*someCallbackData*/)
|
|
{
|
|
removeHandlers();
|
|
return (CallbackData::ReturnType)0;
|
|
}
|
|
|
|
void StatusBar::removeHandlers(void)
|
|
{
|
|
mDisplayWindow.removeHandler(VectorHandler::PaintHandler,&mPaintCallback);
|
|
mDisplayWindow.removeHandler(VectorHandler::SetFocusHandler,&mSetFocusCallback);
|
|
mDisplayWindow.removeHandler(VectorHandler::KeyUpHandler,&mKeyUpCallback);
|
|
mDisplayWindow.removeHandler(VectorHandler::KeyDownHandler,&mKeyDownCallback);
|
|
mDisplayWindow.removeHandler(VectorHandler::SizeHandler,&mSizeCallback);
|
|
mDisplayWindow.removeHandler(VectorHandler::MinMaxHandler,&mMinMaxCallback);
|
|
mDisplayWindow.removeHandler(VectorHandler::MenuSelectHandler,&mMenuSelectCallback);
|
|
mDisplayWindow.removeHandler(VectorHandler::DestroyHandler,&mDestroyCallback);
|
|
}
|
|
|
|
void StatusBar::setCapLockText(void)
|
|
{
|
|
RECT clientRect;
|
|
RECT tempRectOne;
|
|
RECT tempRectTwo;
|
|
HFONT hOldFont;
|
|
String tempString;
|
|
PureDevice windowDevice;
|
|
WORD capLockLeft;
|
|
|
|
if(::GetKeyState(VK_CAPITAL)&0x0001)
|
|
{
|
|
if(TRUE==mLastCapLockState)return;
|
|
mLastCapLockState=TRUE;
|
|
tempString=mCapLockString;
|
|
}
|
|
else
|
|
{
|
|
if(FALSE==mLastCapLockState)return;
|
|
mLastCapLockState=FALSE;
|
|
tempString=mBlankString;
|
|
}
|
|
windowDevice=mDisplayWindow;
|
|
::GetClientRect(mDisplayWindow,(RECT FAR*)&clientRect);
|
|
clientRect.top=clientRect.bottom-statusBarHeight();
|
|
capLockLeft=clientRect.left+systemBorderDeltaTimesNine()+statusInfoWidth();
|
|
hOldFont=(HFONT)::SelectObject((HDC)windowDevice,statusFont());
|
|
::SetTextColor((HDC)windowDevice,::GetSysColor(COLOR_BTNTEXT));
|
|
::SetBkColor((HDC)windowDevice,::GetSysColor(COLOR_BTNFACE));
|
|
tempRectOne.top=clientRect.top+systemBorderDelta()*4;
|
|
tempRectOne.bottom=clientRect.bottom-systemBorderDeltaTimesThree();
|
|
tempRectOne.left=capLockLeft+systemBorderDeltaTimesNine();
|
|
tempRectOne.right=tempRectOne.left+stateInfoWidth()-systemBorderDelta();
|
|
tempRectTwo=tempRectOne;
|
|
::ExtTextOut((HDC)windowDevice,tempRectOne.left+systemBorderDeltaTimesTwo(),tempRectOne.top,
|
|
ETO_OPAQUE|ETO_CLIPPED,&tempRectTwo,(LPSTR)tempString,tempString.length(),0);
|
|
::SelectObject((HDC)windowDevice,hOldFont);
|
|
}
|
|
|
|
void StatusBar::setNumLockText(void)
|
|
{
|
|
RECT clientRect;
|
|
RECT tempRectOne;
|
|
RECT tempRectTwo;
|
|
HFONT hOldFont;
|
|
WORD numLockLeft;
|
|
WORD capLockLeft;
|
|
PureDevice windowDevice;
|
|
String tempString;
|
|
|
|
if(::GetKeyState(VK_NUMLOCK)&0x0001)
|
|
{
|
|
if(TRUE==mLastNumLockState)return;
|
|
mLastNumLockState=TRUE;
|
|
tempString=mNumLockString;
|
|
}
|
|
else
|
|
{
|
|
if(FALSE==mLastNumLockState)return;
|
|
mLastNumLockState=FALSE;
|
|
tempString=mBlankString;
|
|
}
|
|
windowDevice=mDisplayWindow;
|
|
::GetClientRect(mDisplayWindow,(RECT FAR*)&clientRect);
|
|
clientRect.top=clientRect.bottom-statusBarHeight();
|
|
capLockLeft=clientRect.left+systemBorderDeltaTimesNine()+statusInfoWidth();
|
|
numLockLeft=capLockLeft+systemBorderDeltaTimesNine()+stateInfoWidth();
|
|
hOldFont=(HFONT)::SelectObject((HDC)windowDevice,statusFont());
|
|
::SetTextColor((HDC)windowDevice,::GetSysColor(COLOR_BTNTEXT));
|
|
::SetBkColor((HDC)windowDevice,::GetSysColor(COLOR_BTNFACE));
|
|
tempRectOne.top=clientRect.top+systemBorderDelta()*4;
|
|
tempRectOne.bottom=clientRect.bottom-systemBorderDeltaTimesThree();
|
|
tempRectOne.left=numLockLeft+systemBorderDeltaTimesNine();
|
|
tempRectOne.right=tempRectOne.left+stateInfoWidth()-systemBorderDelta();
|
|
tempRectTwo=tempRectOne;
|
|
::ExtTextOut((HDC)windowDevice,tempRectOne.left+systemBorderDeltaTimesTwo(),
|
|
tempRectOne.top,ETO_OPAQUE | ETO_CLIPPED,&tempRectTwo,(LPSTR)tempString,tempString.length(),0);
|
|
::SelectObject(windowDevice,hOldFont);
|
|
}
|
|
|
|
CallbackData::ReturnType StatusBar::sizeHandler(CallbackData &/*someCallbackData*/)
|
|
{
|
|
RECT clientRect;
|
|
|
|
::GetClientRect(mDisplayWindow,(RECT FAR*)&clientRect);
|
|
clientRect.top=clientRect.bottom-statusBarHeight();
|
|
if(clientRect.top<mStatRectSizeAdv.top)
|
|
::InvalidateRect(mDisplayWindow,(RECT FAR *)&clientRect,FALSE);
|
|
else
|
|
::InvalidateRect(mDisplayWindow,(RECT FAR*)&mStatRectSizeAdv,TRUE);
|
|
return (CallbackData::ReturnType)0;
|
|
}
|
|
|
|
CallbackData::ReturnType StatusBar::minMaxHandler(CallbackData &/*someCallbackData*/)
|
|
{
|
|
::GetClientRect(mDisplayWindow,(RECT FAR*)&mStatRectSizeAdv);
|
|
mStatRectSizeAdv.top=mStatRectSizeAdv.bottom-statusBarHeight();
|
|
return (CallbackData::ReturnType)0;
|
|
}
|
|
|
|
CallbackData::ReturnType StatusBar::paintHandler(CallbackData &/*someCallbackData*/)
|
|
{
|
|
paintBar();
|
|
return (CallbackData::ReturnType)0;
|
|
}
|
|
|
|
void StatusBar::paintBar(void)
|
|
{
|
|
RECT tempRectOne;
|
|
RECT tempRectTwo;
|
|
RECT clientRect;
|
|
HFONT hOldFont;
|
|
HBRUSH hTempBrush;
|
|
PureDevice windowDevice;
|
|
WORD capLockLeft;
|
|
WORD numLockLeft;
|
|
String tempString;
|
|
|
|
windowDevice=mDisplayWindow;
|
|
::GetClientRect(mDisplayWindow,(RECT FAR *)&clientRect);
|
|
clientRect.top=clientRect.bottom-statusBarHeight();
|
|
capLockLeft=clientRect.left+systemBorderDeltaTimesNine()+statusInfoWidth();
|
|
numLockLeft=capLockLeft+systemBorderDeltaTimesNine()+stateInfoWidth();
|
|
hTempBrush=::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
|
|
|
|
tempRectOne=clientRect;
|
|
tempRectOne.bottom=tempRectOne.top+systemBorderDeltaTimesThree();
|
|
tempRectOne.top+=systemBorderDeltaTimesTwo();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
|
|
tempRectOne=clientRect;
|
|
tempRectOne.top=tempRectOne.bottom-systemBorderDeltaTimesTwo();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
|
|
tempRectOne=clientRect;
|
|
tempRectOne.right=systemBorderDeltaTimesEight();
|
|
tempRectOne.top+=systemBorderDeltaTimesTwo();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
|
|
tempRectOne.left=capLockLeft;
|
|
tempRectOne.right=tempRectOne.left+systemBorderDeltaTimesEight();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
|
|
tempRectOne.left=numLockLeft;
|
|
tempRectOne.right=tempRectOne.left+systemBorderDeltaTimesEight();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
|
|
tempRectOne.left=numLockLeft+systemBorderDeltaTimesNine()+stateInfoWidth();
|
|
tempRectOne.right=clientRect.right;
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
::DeleteObject(hTempBrush);
|
|
|
|
hTempBrush=::CreateSolidBrush(::GetSysColor(COLOR_BTNSHADOW));
|
|
tempRectOne=clientRect;
|
|
tempRectOne.top=clientRect.top+systemBorderDeltaTimesThree();
|
|
tempRectOne.bottom=tempRectOne.top+systemBorderDelta();
|
|
tempRectOne.left=systemBorderDeltaTimesEight();
|
|
tempRectOne.right=tempRectOne.left+statusInfoWidth();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
|
|
tempRectOne.left=capLockLeft+systemBorderDeltaTimesEight();
|
|
tempRectOne.right=tempRectOne.left+stateInfoWidth();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
|
|
tempRectOne.left=numLockLeft+systemBorderDeltaTimesEight();
|
|
tempRectOne.right=tempRectOne.left+stateInfoWidth();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
|
|
tempRectOne=clientRect;
|
|
tempRectOne.top+=systemBorderDeltaTimesThree();
|
|
tempRectOne.bottom-=systemBorderDeltaTimesTwo();
|
|
tempRectOne.left=systemBorderDeltaTimesEight();
|
|
tempRectOne.right=tempRectOne.left+systemBorderDelta();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
|
|
tempRectOne.left=capLockLeft+systemBorderDeltaTimesEight();
|
|
tempRectOne.right=tempRectOne.left+systemBorderDelta();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
|
|
tempRectOne.left=numLockLeft+systemBorderDeltaTimesEight();
|
|
tempRectOne.right=tempRectOne.left+systemBorderDelta();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
::DeleteObject(hTempBrush);
|
|
|
|
if(WIN30==windowsVersion()){hTempBrush=(HBRUSH)::GetStockObject(WHITE_BRUSH);::MessageBeep(0);}
|
|
else hTempBrush=::CreateSolidBrush(::GetSysColor(COLOR_BTNHIGHLIGHT));
|
|
|
|
tempRectOne=clientRect;
|
|
tempRectOne.top=clientRect.bottom-systemBorderDeltaTimesThree();
|
|
tempRectOne.bottom=tempRectOne.top+systemBorderDelta();
|
|
tempRectOne.left=systemBorderDeltaTimesEight();
|
|
tempRectOne.right=tempRectOne.left+statusInfoWidth();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
|
|
tempRectOne.left=capLockLeft+systemBorderDeltaTimesEight();
|
|
tempRectOne.right=tempRectOne.left+stateInfoWidth();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
|
|
tempRectOne.left=numLockLeft+systemBorderDeltaTimesEight();
|
|
tempRectOne.right=tempRectOne.left+stateInfoWidth();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
|
|
tempRectOne=clientRect;
|
|
tempRectOne.top+=systemBorderDeltaTimesThree();
|
|
tempRectOne.bottom-=systemBorderDeltaTimesTwo();
|
|
tempRectOne.left=capLockLeft-systemBorderDelta();
|
|
tempRectOne.right=tempRectOne.left+systemBorderDelta();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
|
|
tempRectOne.left=numLockLeft-systemBorderDelta();
|
|
tempRectOne.right=tempRectOne.left+systemBorderDelta();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
|
|
tempRectOne.left=numLockLeft+systemBorderDeltaTimesEight()+stateInfoWidth();
|
|
tempRectOne.right=tempRectOne.left+systemBorderDelta();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
|
|
tempRectOne=clientRect;
|
|
tempRectOne.top+=systemBorderDelta();
|
|
tempRectOne.bottom=tempRectOne.top+systemBorderDelta();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
::DeleteObject(hTempBrush);
|
|
|
|
hTempBrush=::CreateSolidBrush(::GetSysColor(COLOR_WINDOWTEXT));
|
|
tempRectOne=clientRect;
|
|
tempRectOne.bottom=tempRectOne.top;
|
|
tempRectOne.bottom+=systemBorderDelta();
|
|
::FillRect((HDC)windowDevice,(RECT FAR*)&tempRectOne,hTempBrush);
|
|
::DeleteObject(hTempBrush);
|
|
|
|
hOldFont=(HFONT)::SelectObject((HDC)windowDevice,statusFont());
|
|
::SetTextColor((HDC)windowDevice,::GetSysColor(COLOR_BTNTEXT));
|
|
::SetBkColor((HDC)windowDevice,::GetSysColor(COLOR_BTNFACE));
|
|
|
|
tempRectOne.top=clientRect.top+(systemBorderDelta()*4);
|
|
tempRectOne.bottom=clientRect.bottom-systemBorderDeltaTimesThree();
|
|
tempRectOne.left=systemBorderDeltaTimesNine();
|
|
tempRectOne.right=tempRectOne.left+statusInfoWidth()-systemBorderDelta();
|
|
tempRectTwo=tempRectOne;
|
|
::ExtTextOut((HDC)windowDevice,tempRectOne.left+systemBorderDeltaTimesTwo(),tempRectOne.top,
|
|
ETO_OPAQUE|ETO_CLIPPED,&tempRectTwo,(LPSTR)mLastDisplayString,mLastDisplayString.length(),0);
|
|
|
|
if(::GetKeyState(VK_CAPITAL)&0x0001)tempString=mCapLockString;
|
|
else tempString=mBlankString;
|
|
tempRectOne.left=capLockLeft+systemBorderDeltaTimesNine();
|
|
tempRectOne.right=tempRectOne.left+stateInfoWidth()-systemBorderDelta();
|
|
tempRectTwo=tempRectOne;
|
|
::ExtTextOut((HDC)windowDevice,tempRectOne.left+systemBorderDeltaTimesTwo(),tempRectOne.top,
|
|
ETO_OPAQUE|ETO_CLIPPED,&tempRectTwo,(LPSTR)tempString,tempString.length(),0);
|
|
|
|
if(::GetKeyState(VK_NUMLOCK)&0x0001)tempString=mNumLockString;
|
|
else tempString=mBlankString;
|
|
tempRectOne.left=numLockLeft+systemBorderDeltaTimesNine();
|
|
tempRectOne.right=tempRectOne.left+stateInfoWidth()-systemBorderDelta();
|
|
tempRectTwo=tempRectOne;
|
|
::ExtTextOut((HDC)windowDevice,tempRectOne.left+systemBorderDeltaTimesTwo(),tempRectOne.top,
|
|
ETO_OPAQUE|ETO_CLIPPED,&tempRectTwo,(LPSTR)tempString,tempString.length(),0);
|
|
::SelectObject(windowDevice,hOldFont);
|
|
Rect paintRect(postPaintRect());
|
|
postPaint(windowDevice,paintRect);
|
|
}
|
|
|
|
Rect StatusBar::postPaintRect(void)const
|
|
{
|
|
WORD numLockLeft;
|
|
WORD capLockLeft;
|
|
RECT clientRect;
|
|
Rect postPaintRect;
|
|
|
|
::GetClientRect(mDisplayWindow,(RECT FAR *)&clientRect);
|
|
clientRect.top=clientRect.bottom-statusBarHeight();
|
|
capLockLeft=clientRect.left+systemBorderDeltaTimesNine()+statusInfoWidth();
|
|
numLockLeft=capLockLeft+systemBorderDeltaTimesNine()+stateInfoWidth();
|
|
postPaintRect.left(numLockLeft+systemBorderDeltaTimesNine()+stateInfoWidth()+1);
|
|
postPaintRect.top(clientRect.top+systemBorderDeltaTimesThree());
|
|
postPaintRect.right(clientRect.right-systemBorderDeltaTimesNine());
|
|
postPaintRect.bottom(clientRect.bottom-systemBorderDeltaTimesTwo());
|
|
postPaintRect.right(postPaintRect.right()-postPaintRect.left());
|
|
postPaintRect.bottom(postPaintRect.bottom()-postPaintRect.top());
|
|
return postPaintRect;
|
|
}
|
|
|
|
WORD StatusBar::setSequentialResourceDescriptors(UINT menuID,UINT stringID,WORD itemCount)
|
|
{
|
|
for(int i=0;i<itemCount;i++)
|
|
setMenuItemDescriptor(MenuItem(String((int)(stringID+i)),menuID+i));
|
|
return TRUE;
|
|
}
|
|
|
|
WORD StatusBar::setSequentialResourceLabels(UINT stringID,WORD itemCount)
|
|
{
|
|
Block<String> menuLabels;
|
|
|
|
for(int itemIndex=0;itemIndex<itemCount;itemIndex++)
|
|
menuLabels.insert(&String((int)stringID+itemIndex));
|
|
setMenuLabelDescriptors(menuLabels);
|
|
return TRUE;
|
|
}
|
|
|
|
void StatusBar::setStatBarText(PureMenu &somePureMenu,WORD redrawFlag)
|
|
{
|
|
MenuItem menuItem;
|
|
|
|
if(!getMenuItemDescriptor(somePureMenu,menuItem))return;
|
|
if(!redrawFlag)return;
|
|
setText(menuItem.itemString());
|
|
}
|
|
|
|
void StatusBar::setStatBarText(int itemID,WORD redrawFlag)
|
|
{
|
|
MenuItem menuItem;
|
|
|
|
menuItem.itemID(itemID);
|
|
if(mLastItemID!=itemID)if(!getMenuItemDescriptor(menuItem))return;
|
|
if(!redrawFlag)return;
|
|
setText(menuItem.itemString());
|
|
}
|
|
|
|
void StatusBar::setText(const String &itemText)
|
|
{
|
|
RECT clientRect;
|
|
RECT tempRectOne;
|
|
RECT tempRectTwo;
|
|
HFONT hOldFont;
|
|
PureDevice windowDevice;
|
|
|
|
if(!itemText.length())return;
|
|
mLastDisplayString=itemText;
|
|
windowDevice=mDisplayWindow;
|
|
::GetClientRect(mDisplayWindow,(RECT FAR*)&clientRect);
|
|
clientRect.top=clientRect.bottom-statusBarHeight();
|
|
tempRectOne.top=clientRect.top+systemBorderDelta()*4;
|
|
tempRectOne.bottom=clientRect.bottom-systemBorderDeltaTimesThree();
|
|
tempRectOne.left=systemBorderDeltaTimesNine();
|
|
tempRectOne.right=tempRectOne.left+statusInfoWidth()-systemBorderDelta();
|
|
tempRectTwo=tempRectOne;
|
|
hOldFont=(HFONT)::SelectObject((HDC)windowDevice,statusFont());
|
|
::SetTextColor((HDC)windowDevice,::GetSysColor(COLOR_BTNTEXT));
|
|
::SetBkColor((HDC)windowDevice,::GetSysColor(COLOR_BTNFACE));
|
|
::ExtTextOut((HDC)windowDevice,tempRectOne.left+systemBorderDeltaTimesTwo(),
|
|
tempRectOne.top,ETO_OPAQUE|ETO_CLIPPED,&tempRectTwo,(LPSTR)itemText,itemText.length(),0);
|
|
::SelectObject(windowDevice,hOldFont);
|
|
}
|
|
|
|
CallbackData::ReturnType StatusBar::menuSelectHandler(CallbackData &someCallbackData)
|
|
{
|
|
UINT itemID(someCallbackData.menuSelectID());
|
|
WORD menuFlags(someCallbackData.menuSelectFlags());
|
|
HMENU hMenu(someCallbackData.menuSelectMenu());
|
|
|
|
if(0==hMenu&&0xFFFF==menuFlags){setText(mBlankString);return (CallbackData::ReturnType)0;}
|
|
if(menuFlags&MF_POPUP)setStatBarText(PureMenu(someCallbackData.menuSelectIDPopup()),TRUE);
|
|
else setStatBarText(itemID,TRUE);
|
|
return (CallbackData::ReturnType)0;
|
|
}
|
|
|
|
// ** virtuals
|
|
|
|
void StatusBar::postPaint(PureDevice &/*screnDevice*/,const Rect &/*paintRect*/)
|
|
{
|
|
}
|
|
|