home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
vos2-121.zip
/
v
/
srcos2
/
vchkboxc.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1999-02-03
|
4KB
|
129 lines
//===============================================================
// vchkboxc.cxx - Checkbox - Windows version
//
// Copyright (C) 1995,1996,1997,1998 Bruce E. Wampler
//
// This file is part of the V C++ GUI Framework, and is covered
// under the terms of the GNU Library General Public License,
// Version 2. This library has NO WARRANTY. See the source file
// vapp.cxx for more complete information about license terms.
//===============================================================
#include <v/vos2.h> // for OS/2 stuff
#include <v/vchkboxc.h> // our definitions
#include <v/vcmdprnt.h> // a command parent
#include <v/vapp.h>
#include <v/vutil.h>
//=================>>> vCheckBoxCmd::~vCheckBoxCmd <<<=======================
vCheckBoxCmd::~vCheckBoxCmd()
{
SysDebug(Destructor,"vCheckBoxCmd::~vCheckBoxCmd() destructor\n")
}
//=================>>> vCheckBoxCmd::vCheckBoxCmd <<<=======================
vCheckBoxCmd::vCheckBoxCmd(vCmdParent* dp, CommandObject* dc) :
vCmd(dp, dc)
{
SysDebug(Constructor,"vCheckBoxCmd::vCheckBoxCmd() constructor\n")
initialize(); // and initialize
}
//=====================>>> vCheckBoxCmd::initialize <<<=======================
void vCheckBoxCmd::initialize(void)
{
long style = WS_TABSTOP | WS_GROUP | BS_CHECKBOX; // default for a button
if (!(dlgCmd->attrs & CA_Hidden)) // Check for Hidden
style |= WS_VISIBLE;
if (_parentWin->_dialogType == aCmdBar)
style |= BS_NOPOINTERFOCUS; // don't want focus in Command Bars
CopyToLocal(); // Make local copies of CmdObject
_w = LabelWidth(_title) + 14; // set my width
_h = 10; // default height
_parentWin->SetPosition(_x, _y, _w, _h, dlgCmd->cFrame, dlgCmd->cRightOf,
dlgCmd->cBelow);
// inc y positions control lower in the allocated dialog space
// dec h makes control smaller in allocated space
_y += 3;
_h -= 3; // we play this game to get better positioning in a frame
_CtrlOffset = _parentWin->AddDlgControl(_x, _y, _w, _h, _cmdId,
style, WC_BUTTON, _title, NULL, 0, NULL);
}
//================>>> vCheckBoxCmd::ResetItemValue <<<======================
void vCheckBoxCmd::ResetItemValue(void)
{
// We have to toggle things
if (_retVal == _origVal) // No op if no change
return;
_retVal = _origVal; // restore
if (_retVal) // depends on state
{
SetCmdVal(1, Checked);
}
else
{
SetCmdVal(0, Checked);
}
// let parent window handle now
_parentWin->ProcessCmd(_cmdId, _retVal, dlgCmd->cmdType);
}
//==================>>> vCheckBoxCmd::GetCmdValue <<<=========================
int vCheckBoxCmd::GetCmdValue(ItemVal id) VCONST
{
if (id != _cmdId)
return -1;
return _retVal;
}
//================>>> vCheckBoxCmd::SetCmdVal <<<============================
void vCheckBoxCmd::SetCmdVal(ItemVal val, ItemSetType st)
{
SysDebug2(Misc,"vCheckBoxCmd::SetCmdVal(id:%d val:%d)\n",_cmdId, val)
HWND myHwnd = GetMyHwnd(_cmdId);
if (st == Sensitive)
{
_Sensitive = val; // set
WinEnableWindow (myHwnd, val);
}
else if (st == Hidden) // hide or unhide
{
if (val)
{
WinShowWindow (myHwnd, FALSE);
}
else
{
WinShowWindow (myHwnd, TRUE);
}
}
else if (st == Value || st == Checked)
{
_retVal = val; // set
WinCheckButton(_parentWin->getParent(),_cmdId, val);
}
}
//================>>> vCheckBoxCmd::SetCmdStr <<<============================
void vCheckBoxCmd::SetCmdStr(VCONST char* str)
{
SysDebug1(Misc,"vCheckBoxCmd::SetCmdStr(str:%s)\n",str)
WinSetDlgItemText(_parentWin->getParent(), _cmdId, str);
_title = str;
}
//====================>>> vCheckBoxCmd::CmdCallback <<<=======================
void vCheckBoxCmd::CmdCallback(UINT uMsg, MPARAM mp1, MPARAM mp2)
{
if (_retVal) // depends on state
{
SetCmdVal(0, Checked);
}
else
{
SetCmdVal(1, Checked);
}
// let parent window handle now
_parentWin->ProcessCmd(_cmdId, _retVal, dlgCmd->cmdType);
}