1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
//===============================================================
// vframec.cxx - a frame for holding commands - Windows
//
// 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/vwin32.h> // for Win 32 stuff
#include <v/vapp.h>
#include <v/vframec.h> // our definitions
#include <v/vcmdprnt.h> // a command parent
//=====================>>> vFrameCmd::vFrameCmd <<<=======================
vFrameCmd::vFrameCmd(vCmdParent* dp, CommandObject* dc) :
vCmd(dp, dc)
{
initialize();
}
//=====================>>> vFrameCmd::~vFrameCmd <<<=======================
vFrameCmd::~vFrameCmd()
{
SysDebug(Destructor,"vFrameCmd::~vFrameCmd() destructor\n")
}
//=====================>>> vFrameCmd::initialize <<<=======================
void vFrameCmd::initialize(void)
{
// build a button command for use in a parent window
SysDebug(Constructor,"vFrameCmd::vFrameCmd() constructor\n")
long style = BS_OWNERDRAW | WS_GROUP; // default for a button
CopyToLocal(); // Make local copies of CmdObject
_title = ""; // never a label, sigh...
// if (!(dlgCmd->attrs & CA_NoBorder)) // Check for Hidden
style |= WS_VISIBLE;
_w = StdMargin; // set my width
_h = StdMargin; /* +2 */ // default height
_parentWin->SetPosition(_x, _y, _w, _h, dlgCmd->cFrame, dlgCmd->cRightOf,
dlgCmd->cBelow);
_CtrlOffset = _parentWin->AddDlgControl(_x, _y, _w, _h, _cmdId,
style, "BUTTON", _title, sizeof(vCmd*), (LPBYTE)this);
}
//================>>> vFrameCmd::SetCmdVal <<<============================
void vFrameCmd::SetCmdVal(ItemVal val, ItemSetType st)
{
SysDebug1(Misc,"vFrameCmd::SetCmdVal(val:%d)\n",val)
HWND myHwnd = GetMyHwnd(_cmdId);
if (st == Sensitive) // used so icons won't get
{ // focus -- icons use ownerdraw,
_Sensitive = val; // which behave like buttons, not
::EnableWindow(myHwnd, val); // static labels -- this fixes that
}
else if (st == Hidden) // hide or unhide
{
if (val)
{
::ShowWindow(myHwnd,SW_HIDE);
}
else
{
::ShowWindow(myHwnd,SW_SHOW);
}
}
else if (st == Value && dlgCmd->cmdType == C_ToggleFrame) // Toggle?
{
if (val) // have to hide/show me first
{
::ShowWindow(myHwnd,SW_SHOW);
}
else
{
::ShowWindow(myHwnd,SW_HIDE);
}
_parentWin->SetFrameChildren(_cmdId,val); // and now set value of childern
}
}
//================>>> vFrameCmd::MEASUREITEM <<<============================
int vFrameCmd::MEASUREITEM(int id, MEASUREITEMSTRUCT* mis)
{
mis->CtlType = ODT_BUTTON;
mis->CtlID = id;
mis->itemWidth = _w;
mis->itemHeight = _h;
return 1;
}
//================>>> vFrameCmd::DRAWITEM <<<============================
int vFrameCmd::DRAWITEM(int /*id */, DRAWITEMSTRUCT* dis)
{
switch (dis->itemAction)
{
case ODA_DRAWENTIRE: // redraw entire control
{
// This gets called after the CTLCOLOR message has been
// processed in the dialog/commandpane procs.
// We are using LTGRAY_BRUSH for dialogs and command bars.
// We need to draw the icon properly on the background.
// We will use a null pen, and the same background. We have
// to use left-1, top-1, right+1, and bottom+1 to have the
// interior of the rectangle in the icon's area. We end up
// with a white line otherwise. First, fill gray background
HPEN oldpen = (HPEN) ::SelectObject(dis->hDC, GetStockObject(NULL_PEN));
HBRUSH oldbrush = static_cast<HBRUSH>(::SelectObject(dis->hDC, theApp->_BarBrush));
(void)::Rectangle(dis->hDC,dis->rcItem.left, dis->rcItem.top,
dis->rcItem.right+1, dis->rcItem.bottom+1);
if (!(dlgCmd->attrs & CA_NoBorder))
{
::SelectObject(dis->hDC, theApp->_ShadowPen);
::MoveTo(dis->hDC, dis->rcItem.left+1, dis->rcItem.bottom-1);
::LineTo(dis->hDC, dis->rcItem.left+1, dis->rcItem.top+1);
::LineTo(dis->hDC, dis->rcItem.right-1, dis->rcItem.top+1);
::SelectObject(dis->hDC,theApp->_LightPen);
::MoveTo(dis->hDC, dis->rcItem.right-1, dis->rcItem.top+1);
::LineTo(dis->hDC, dis->rcItem.right-1, dis->rcItem.bottom-1);
::LineTo(dis->hDC, dis->rcItem.left+1, dis->rcItem.bottom-1);
}
::SelectObject(dis->hDC, oldpen); // restore hdc
::SelectObject(dis->hDC, oldbrush);
return 1;
}
case ODA_SELECT: // indicated selected
{
return 1; // no op for icon Frame
}
case ODA_FOCUS: // gets focus
{
return 1; // no op for icon Frame
}
}
return 0;
}
//===================>>> vFrameCmd::vCmdCallback <<<=======================
void vFrameCmd::CmdCallback(int /*id*/, WORD codeNotify)
{
// No Op for a Frame - the icon button may generate one of these!
}
|