File: basicframe.cpp

package info (click to toggle)
kicad 0.0.20060829-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 56,544 kB
  • ctags: 9,194
  • sloc: cpp: 88,990; ansic: 4,790; makefile: 88; sh: 39
file content (269 lines) | stat: -rw-r--r-- 7,478 bytes parent folder | download
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
	/******************************************************************/
	/* basicframe.cpp - fonctions des classes du type WinEDA_BasicFrame */
	/******************************************************************/

#ifdef __GNUG__
#pragma implementation
#endif

#include "fctsys.h"
#include <wx/fontdlg.h>
#include "common.h"
#include "id.h"


	/*******************************************************/
	/* Constructeur de WinEDA_BasicFrame: la fenetre generale */
	/*******************************************************/

WinEDA_BasicFrame::WinEDA_BasicFrame( wxWindow * father, int idtype,
						WinEDA_App *parent, const wxString & title,
						const wxPoint& pos, const wxSize& size):
		wxFrame(father, -1, title, pos, size,
			wxDEFAULT_FRAME_STYLE|wxWANTS_CHARS)
{
wxSize minsize;

	m_Ident = idtype;
	m_Parent = parent;
	SetFont(*g_StdFont);
	m_MenuBar = NULL;		// menu du haut d'ecran
	m_HToolBar = NULL;
	m_FrameIsActive = FALSE;
	m_MsgFrameHeight = MSG_PANEL_DEFAULT_HEIGHT;

	minsize.x = 470;
	minsize.y = 350 + m_MsgFrameHeight;
	SetSizeHints( minsize.x, minsize.y, -1,-1, -1,-1);

	/* Verification des parametres de creation */
	if ( (size.x < minsize.x) || (size.y < minsize.y) )
		SetSize(0,0, minsize.x, minsize.y);

	// Create child subwindows.
	GetClientSize(&m_FrameSize.x, &m_FrameSize.y);	/* dimx, dimy = dimensions utiles de la
								zone utilisateur de la fenetre principale */
	m_FramePos.x = m_FramePos.y = 0;
	m_FrameSize.y -= m_MsgFrameHeight;
}

/******************************************/
WinEDA_BasicFrame::~WinEDA_BasicFrame(void)
/******************************************/
{
	if ( m_Parent->m_HtmlCtrl ) delete m_Parent->m_HtmlCtrl;
	m_Parent->m_HtmlCtrl = NULL;
}

/********************************************/
void WinEDA_BasicFrame::ReCreateMenuBar(void)
/********************************************/
// Virtual function
{
}


/*********************************************/
void WinEDA_BasicFrame::GetSettings(void)
/*********************************************/
{
wxString text;
int Ypos_min;

	if( m_Parent->m_EDA_Config )
	{
		text = m_FrameName + wxT("Pos_x");
		m_Parent->m_EDA_Config->Read(text, &m_FramePos.x);
		text = m_FrameName + wxT("Pos_y");
		m_Parent->m_EDA_Config->Read(text, &m_FramePos.y);
		text = m_FrameName + wxT("Size_x");
		m_Parent->m_EDA_Config->Read(text, &m_FrameSize.x, 600);
		text = m_FrameName + wxT("Size_y");
		m_Parent->m_EDA_Config->Read(text, &m_FrameSize.y, 400);
	}

	// Ensure Window title bar is visible
#ifdef __WXMAC__
	// for macOSX, the window must be below system (macOSX) toolbar
	Ypos_min = GetMBarHeight();
#else
	Ypos_min = 0;
#endif
	if ( m_FramePos.y < Ypos_min ) m_FramePos.y = Ypos_min;
}


/*****************************************/
void WinEDA_BasicFrame::SaveSettings(void)
/*****************************************/
{
wxString text;

	if ( !m_Parent || !m_Parent->m_EDA_Config ) return;

	if( ! m_Parent->m_EDA_Config || IsIconized() ) return;

	m_FrameSize = GetSize();
	m_FramePos = GetPosition();

	text = m_FrameName + wxT("Pos_x");
	m_Parent->m_EDA_Config->Write(text, (long)m_FramePos.x);
	text = m_FrameName + wxT("Pos_y");
	m_Parent->m_EDA_Config->Write(text, (long)m_FramePos.y);
	text = m_FrameName + wxT("Size_x");
	m_Parent->m_EDA_Config->Write(text, (long)m_FrameSize.x);
	text = m_FrameName + wxT("Size_y");
	m_Parent->m_EDA_Config->Write(text, (long)m_FrameSize.y);
}



/******************************************************/
void WinEDA_BasicFrame::PrintMsg(const wxString & text)
/******************************************************/
{
	SetStatusText(text);
}

/*************************************************************************/
void WinEDA_BasicFrame::DisplayActivity(int PerCent, const wxString & Text)
/*************************************************************************/
/* Display a bargraph (0 to 50 point length) for a PerCent value from 0 to 100
*/
{
wxString Line;

	Line = Text;

	PerCent = (PerCent < 0) ? 0 : PerCent;
	PerCent = (PerCent > 100) ? 100 : PerCent;
	PerCent /= 2;	// Bargraph is 0 .. 50 points from 0% to 100%
	if (PerCent) Line.Pad(PerCent, '*');

	SetStatusText(Line);
}

/*******************************************************************/
void WinEDA_BasicFrame::SetLastProject(const wxString & FullFileName)
/*******************************************************************/
/* Met a jour la liste des anciens projets
*/
{
unsigned ii;

	if ( FullFileName.IsEmpty() ) return;

	//suppression d'une ancienne trace eventuelle du meme fichier
	for ( ii = 0; ii < m_Parent->m_LastProject.GetCount(); )
	{
		if(m_Parent->m_LastProject[ii].IsEmpty() ) break;
#ifdef __WINDOWS__
		if ( m_Parent->m_LastProject[ii].CmpNoCase(FullFileName) == 0 )
#else
		if ( m_Parent->m_LastProject[ii] == FullFileName )
#endif
		{
#if ( (wxMAJOR_VERSION < 2) || ((wxMAJOR_VERSION == 2)&& (wxMINOR_VERSION <= 4)) )
			m_Parent->m_LastProject.Remove(ii);
#else
			m_Parent->m_LastProject.RemoveAt(ii);
#endif
		}
		else ii++;
	}

    while (m_Parent->m_LastProject.GetCount() >= m_Parent->m_LastProjectMaxCount)
    {
#if ( (wxMAJOR_VERSION < 2) || ((wxMAJOR_VERSION == 2)&& (wxMINOR_VERSION <= 4)) )
        files.Remove(files.GetCount() - 1);
#else
        m_Parent->m_LastProject.RemoveAt(m_Parent->m_LastProject.GetCount() - 1);
#endif
    }
	m_Parent->m_LastProject.Insert(FullFileName, 0);

	ReCreateMenuBar();
}

/**************************************************/
wxString WinEDA_BasicFrame::GetLastProject(int rang)
/**************************************************/
{
	if ( rang < 0 ) rang = 0;
	if ( (unsigned) rang >= m_Parent->m_LastProject.GetCount() )
		return wxEmptyString;
	return m_Parent->m_LastProject[rang];
}


/**************************************************************/
void WinEDA_BasicFrame::GetKicadHelp(wxCommandEvent& event)
/**************************************************************/
{
	if ( m_Parent->m_HtmlCtrl == NULL )
	{
		m_Parent->InitOnLineHelp();
	}


	if ( m_Parent->m_HtmlCtrl )
	{
		m_Parent->m_HtmlCtrl->DisplayContents();
		m_Parent->m_HtmlCtrl->Display(m_Parent->m_HelpFileName);
	}
	else DisplayError(this, _("Help files not found"));
}

/***********************************************************/
void WinEDA_BasicFrame::GetKicadAbout(wxCommandEvent& event)
/**********************************************************/
{
	Affiche_InfosLicence(this);
}

/********************************************************************/
void WinEDA_BasicFrame::ProcessFontPreferences(int id)
/********************************************************************/
{
wxFont font;
	
	switch (id)
	{
		
		case ID_PREFERENCES_FONT:
			break;

		case ID_PREFERENCES_FONT_STATUS:
		{
			font = wxGetFontFromUser(this, *g_StdFont);
			if ( font.Ok() )
			{
				int pointsize = font.GetPointSize();
				*g_StdFont = font;
				SetFont(*g_StdFont);
				if ( GetStatusBar() )
					GetStatusBar()->SetFont(*g_StdFont);
				g_StdFontPointSize = pointsize;
			}
			break;
		}

		case ID_PREFERENCES_FONT_DIALOG:
		{
			font = wxGetFontFromUser(this, *g_DialogFont);
			if ( font.Ok() )
			{
				int pointsize = font.GetPointSize();
				*g_DialogFont = font;
				SetFont(*g_DialogFont);
				g_DialogFontPointSize = pointsize;
				g_FixedFontPointSize = pointsize;
				g_FixedFont->SetPointSize(g_FixedFontPointSize);
			}
			break;
		}

		default: DisplayError(this, wxT("WinEDA_BasicFrame::ProcessFontPreferences Internal Error") );
			break;
	}
}