File: vclabelc.cpp

package info (click to toggle)
v1 1.20-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 6,240 kB
  • ctags: 9,439
  • sloc: cpp: 48,033; ansic: 8,939; makefile: 1,369; sh: 30
file content (90 lines) | stat: -rw-r--r-- 2,587 bytes parent folder | download | duplicates (4)
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
//===============================================================
// vclabelc.xxx	- Color label Cmd - 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/vclabelc.h>	// our definitions
#include <v/vcmdprnt.h>	// a command parent

//=================>>> vColorLabelCmd::vColorLabelCmd <<<=======================
  vColorLabelCmd::vColorLabelCmd(vCmdParent* dp, CommandObject* dc) :
	vLabelCmd(dp, dc)
  {
    initColor();
  }

//====================>>> vColorLabelCmd::~vColorLabelCmd <<<===================
  vColorLabelCmd::~vColorLabelCmd()
  {

    SysDebug(Destructor,"vColorLabelCmd::~vColorLabelCmd() destructor\n")
  }

//=====================>>> vColorLabelCmd::initColor <<<=======================
  void vColorLabelCmd::initColor(void)
  {
    // wCmd is the widget of this button

    SysDebug(Constructor,"vColorLabelCmd::vColorLabelCmd() constructor\n")

    _origColor = 0;
    
    if (_itemList != 0)				// an RGB provided
      {
	_origColor = (vColor*)_itemList;	// point to the rgb
	_color = *_origColor;
      }
    
  }

//================>>> vColorLabelCmd::SetCmdVal <<<============================
  void vColorLabelCmd::SetCmdVal(ItemVal val, ItemSetType st)
  {

    SysDebug1(Misc,"vColorLabelCmd::SetCmdVal(val:%d)\n",val)

    switch (st)
      {
	case ChangeColor:		// changed original vColor
	  {
	    _color = *_origColor;	// recopy color
	    HWND dH = _parentWin->getParent();
	    char buff[80];
	    ::GetDlgItemText(dH, _cmdId, buff, 80);  // make it redraw
	    ::SetDlgItemText(dH, _cmdId, buff);      // by "changing" text
	    break;
	  }

	case Red:
	    _color.SetR(val);
	    break;

	case Green:
	    _color.SetG(val);
	    break;

	case Blue:
	  {
	    _color.SetB(val);
	    // Now that the colors are set, we have to make the button
	    // redraw. There must be some better way, but this kludge
	    // is all I could figure out to force a redraw of the new color
	    HWND dH = _parentWin->getParent();
	    char buff[80];
	    ::GetDlgItemText(dH, _cmdId, buff, 80);  // make it redraw
	    ::SetDlgItemText(dH, _cmdId, buff);      // by "changing" text
	    break;
	  }

	default:
	    vLabelCmd::SetCmdVal(val, st);
	    break;
      }
  }