-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDlgAddText_old.cpp
133 lines (118 loc) · 3.33 KB
/
DlgAddText_old.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
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
// DlgAddText.cpp : implementation file
//
#include "stdafx.h"
#include "FreePcb.h"
#include "DlgAddText.h"
#include "layers.h"
// CDlgAddText dialog
IMPLEMENT_DYNAMIC(CDlgAddText, CDialog)
CDlgAddText::CDlgAddText(CWnd* pParent /*=NULL*/)
: CDialog(CDlgAddText::IDD, pParent)
{
}
CDlgAddText::~CDlgAddText()
{
}
void CDlgAddText::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST_LAYER, m_layer_list);
DDX_Control(pDX, IDC_EDIT_HEIGHT, m_height);
DDX_Control(pDX, IDC_SET_WIDTH, m_button_set_width);
DDX_Control(pDX, IDC_DEF_WIDTH, m_button_def_width);
DDX_Control(pDX, IDC_EDIT_WIDTH, m_width);
DDX_Control(pDX, IDC_EDIT_TEXT, m_text);
DDX_Control(pDX, IDC_Y, m_edit_y);
DDX_Control(pDX, IDC_X, m_edit_x);
DDX_Control(pDX, IDC_LIST_ANGLE, m_list_angle);
}
BEGIN_MESSAGE_MAP(CDlgAddText, CDialog)
ON_BN_CLICKED(IDC_SET_WIDTH, OnBnClickedSetWidth)
ON_BN_CLICKED(IDC_DEF_WIDTH, OnBnClickedDefWidth)
ON_EN_CHANGE(IDC_EDIT_HEIGHT, OnEnChangeEditHeight)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()
// CDlgAddText message handlers
BOOL CDlgAddText::OnInitDialog()
{
CDialog::OnInitDialog();
m_layer_list.InsertString( -1, layer_str[LAY_SILK_TOP] );
m_layer_list.InsertString( -1, layer_str[LAY_SILK_BOTTOM] );
for( int i=LAY_TOP_COPPER; i<m_num_layers; i++ )
m_layer_list.InsertString( -1, layer_str[i] );
m_layer_list.SetCurSel( 0 );
m_height.SetWindowText( "100" );
m_width.SetWindowText( "10" );
m_button_set_width.SetCheck( 0 );
m_button_def_width.SetCheck( 1 );
m_width.EnableWindow( 0 );
m_list_angle.InsertString( -1, "0" );
m_list_angle.InsertString( -1, "90" );
m_list_angle.InsertString( -1, "180" );
m_list_angle.InsertString( -1, "270" );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgAddText::OnBnClickedSetWidth()
{
m_button_set_width.SetCheck( 1 );
m_button_def_width.SetCheck( 0 );
m_width.EnableWindow( 1 );
}
void CDlgAddText::OnBnClickedDefWidth()
{
m_button_set_width.SetCheck( 0 );
m_button_def_width.SetCheck( 1 );
m_width.EnableWindow( 0 );
}
void CDlgAddText::OnEnChangeEditHeight()
{
if( m_button_def_width.GetCheck() )
{
char str[80];
m_height.GetWindowText( str, 20 );
double h = atof( str );
if( h != 0.0 )
{
CString w_str;
int w = (int)h/10;
if( w < 5 )
w = 5;
w_str.Format( "%d", w );
m_width.SetWindowText( (LPCTSTR)w_str );
}
}
}
void CDlgAddText::OnBnClickedOk()
{
// check and set output variables
char str[255];
m_height.GetWindowText( str, 80 );
m_output_height = atoi( str );
if( m_output_height <=0 || m_output_height > 1000 )
{
CString mess;
mess.Format( "Illegal height: %s", str );
AfxMessageBox( mess );
return;
}
m_width.GetWindowText( str, 80 );
m_output_width = atoi( str );
if( m_output_width <=0 || m_output_width > 1000 )
{
CString mess;
mess.Format( "Illegal width: %s", str );
AfxMessageBox( mess );
return;
}
int layer = m_layer_list.GetCurSel();
if( layer == 0 )
m_output_layer = LAY_SILK_TOP;
else if( layer == 1 )
m_output_layer = LAY_SILK_BOTTOM;
else
m_output_layer = layer - 2 + LAY_TOP_COPPER;
m_text.GetWindowText( str, 255 );
m_output_str = str;
OnOK();
}