forked from ChrisVeigl/BrainBay
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathob_constant.cpp
105 lines (79 loc) · 2.22 KB
/
ob_constant.cpp
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
/* -----------------------------------------------------------------------------
BrainBay Version 1.7, GPL 2003-2010, contact: [email protected]
MODULE: OB_CONSTANT.CPP: contains functions for the Constant-Source Object
Author: Chris Veigl
This Object outputs a constant value on it's port.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; See the
GNU General Public License for more details.
-----------------------------------------------------------------------------*/
#include "brainBay.h"
#include "ob_constant.h"
CONSTANTOBJ::CONSTANTOBJ(int num) : BASE_CL()
{
outports = 1;
inports = 0;
width=75;
strcpy(out_ports[0].out_name,"out");
out_ports[0].get_range=-1;
strcpy(out_ports[0].out_dim,"none");
strcpy(out_ports[0].out_desc,"Constant");
out_ports[0].out_max=1000.0f;
out_ports[0].out_min=-1000.0f;
value=0.0f;
}
void CONSTANTOBJ::make_dialog(void)
{
display_toolbox(hDlg=CreateDialog(hInst, (LPCTSTR)IDD_CONSTANTBOX, ghWndStatusbox, (DLGPROC)ConstantDlgHandler));
}
void CONSTANTOBJ::load(HANDLE hFile)
{
load_object_basics(this);
load_property("value",P_FLOAT,&value);
}
void CONSTANTOBJ::save(HANDLE hFile)
{
save_object_basics(hFile, this);
save_property(hFile,"value",P_FLOAT,&value);
}
void CONSTANTOBJ::incoming_data(int port, float value)
{
}
void CONSTANTOBJ::work(void)
{
pass_values(0, value);
}
CONSTANTOBJ::~CONSTANTOBJ() {}
LRESULT CALLBACK ConstantDlgHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
char tmp[50];
CONSTANTOBJ * st;
st = (CONSTANTOBJ *) actobject;
if ((st==NULL)||(st->type!=OB_CONSTANT)) return(FALSE);
switch( message )
{
case WM_INITDIALOG:
sprintf(tmp,"%.2f",st->value);
SetDlgItemText(hDlg, IDC_VALUE, tmp);
break;
case WM_CLOSE:
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_VALUE:
GetDlgItemText(hDlg,IDC_VALUE,tmp,30);
sscanf(tmp,"%f",&st->value);
break;
}
return TRUE;
case WM_SIZE:
case WM_MOVE: update_toolbox_position(hDlg);
break;
return(TRUE);
}
return FALSE;
}