KiCad PCB EDA Suite
events_functions.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2013 CERN
5  * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Jean-Pierre Charras, jp.charras at wanadoo.fr
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
31 #include <fctsys.h>
32 #include <wx/treectrl.h>
33 #include <pgm_base.h>
34 #include <class_drawpanel.h>
35 #include <common.h>
36 #include <macros.h>
37 
38 #include <pl_editor_frame.h>
39 #include <kicad_device_context.h>
40 #include <pl_editor_id.h>
41 #include <dialog_helpers.h>
42 #include <menus_helpers.h>
45 #include <design_tree_frame.h>
46 #include <properties_frame.h>
47 #include <dialog_page_settings.h>
49 
50 
51 BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME )
52  EVT_CLOSE( PL_EDITOR_FRAME::OnCloseWindow )
53 
54  // Desing tree event:
55  EVT_TREE_SEL_CHANGED( ID_DESIGN_TREE_FRAME, PL_EDITOR_FRAME::OnTreeSelection )
56  EVT_TREE_ITEM_MIDDLE_CLICK( ID_DESIGN_TREE_FRAME, PL_EDITOR_FRAME::OnTreeMiddleClick )
57  EVT_TREE_ITEM_RIGHT_CLICK( ID_DESIGN_TREE_FRAME, PL_EDITOR_FRAME::OnTreeRightClick )
58 
59  // Menu Files:
60  EVT_MENU( wxID_NEW, PL_EDITOR_FRAME::Files_io )
61  EVT_MENU( wxID_OPEN, PL_EDITOR_FRAME::Files_io )
62  EVT_MENU( wxID_SAVE, PL_EDITOR_FRAME::Files_io )
63  EVT_MENU( wxID_SAVEAS, PL_EDITOR_FRAME::Files_io )
64  EVT_MENU( wxID_FILE, PL_EDITOR_FRAME::Files_io )
66 
67  EVT_MENU( ID_GEN_PLOT, PL_EDITOR_FRAME::ToPlotter )
68 
69  EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, PL_EDITOR_FRAME::OnFileHistory )
70 
71  EVT_MENU( wxID_EXIT, PL_EDITOR_FRAME::OnQuit )
72 
73  // menu Preferences
76  EVT_MENU( wxID_PREFERENCES, PL_EDITOR_FRAME::Process_Config )
78  EVT_MENU( ID_MENU_GRID_ONOFF, PL_EDITOR_FRAME::Process_Config )
79 
80  // Menu Help
81  EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
82  EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp )
83  EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute )
84  EVT_MENU( wxID_ABOUT, EDA_DRAW_FRAME::GetKicadAbout )
85 
86  EVT_TOOL( wxID_CUT, PL_EDITOR_FRAME::Process_Special_Functions )
87  EVT_TOOL( wxID_UNDO, PL_EDITOR_FRAME::GetLayoutFromUndoList )
88  EVT_TOOL( wxID_REDO, PL_EDITOR_FRAME::GetLayoutFromRedoList )
89  EVT_TOOL( wxID_PRINT, PL_EDITOR_FRAME::ToPrinter )
90  EVT_TOOL( wxID_PREVIEW, PL_EDITOR_FRAME::ToPrinter )
91  EVT_TOOL( ID_SHEET_SET, PL_EDITOR_FRAME::Process_Special_Functions )
92  EVT_TOOL( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode )
93  EVT_TOOL( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode )
94  EVT_TOOL( ID_NO_TOOL_SELECTED, PL_EDITOR_FRAME::Process_Special_Functions )
95  EVT_TOOL( ID_ZOOM_SELECTION, PL_EDITOR_FRAME::Process_Special_Functions )
96  EVT_CHOICE( ID_SELECT_COORDINATE_ORIGIN, PL_EDITOR_FRAME::OnSelectCoordOriginCorner)
97  EVT_CHOICE( ID_SELECT_PAGE_NUMBER, PL_EDITOR_FRAME::Process_Special_Functions)
98 
99  // the ID_NO_TOOL_SELECTED id TOOL does not existing currently, but the right click
100  // popup menu can generate this event.
101  EVT_TOOL( ID_NO_TOOL_SELECTED, PL_EDITOR_FRAME::Process_Special_Functions )
102 
104  PL_EDITOR_FRAME::Process_Special_Functions )
105 
106  EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, PL_EDITOR_FRAME::OnUpdateSelectTool )
107 
108  EVT_UPDATE_UI( ID_ZOOM_SELECTION, PL_EDITOR_FRAME::OnUpdateSelectTool )
109  EVT_UPDATE_UI( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayNormalMode )
110  EVT_UPDATE_UI( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplaySpecialMode )
111 
112 END_EVENT_TABLE()
113 
114 
115 /* Handles the selection of tools, menu, and popup menu commands.
116  */
117 void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event )
118 {
119  int id = event.GetId();
120  int idx;
121  wxString msg;
123  WORKSHEET_DATAITEM* item = NULL;
124  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
125  cmd.SetEventObject( this );
126 
127  switch( id )
128  {
129  case ID_NO_TOOL_SELECTED:
130  SetNoToolSelected();
131  break;
132 
133  case ID_ZOOM_SELECTION:
134  // This tool is located on the main toolbar: switch it on or off on click
135  if( GetToolId() != ID_ZOOM_SELECTION )
136  SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
137  else
138  SetNoToolSelected();
139  break;
140 
141  case ID_SELECT_PAGE_NUMBER:
142  m_canvas->Refresh();
143  break;
144 
145  case ID_SHEET_SET:
146  {
147  DIALOG_PAGES_SETTINGS dlg( this );
148  dlg.SetWksFileName( GetCurrFileName() );
149  dlg.EnableWksFileNamePicker( false );
150  dlg.ShowModal();
151 
152  cmd.SetId( ID_ZOOM_PAGE );
153  wxPostEvent( this, cmd );
154  }
155  break;
156 
158  break;
159 
162  case wxID_CUT:
163  // Delete item, and select the previous item
164  item = m_treePagelayout->GetPageLayoutSelectedItem();
165 
166  if( item == NULL )
167  break;
168 
169  SaveCopyInUndoList();
170  idx = pglayout.GetItemIndex( item );
171  pglayout.Remove( item );
172  RebuildDesignTree();
173 
175  {
176  item = pglayout.GetItem( (unsigned) (idx-1) );
177 
178  if( item )
179  m_treePagelayout->SelectCell( item );
180  }
181 
182  item = NULL;
183  OnModify();
184  m_canvas->Refresh();
185  break;
186 
188  SaveCopyInUndoList();
189  idx = m_treePagelayout->GetSelectedItemIndex();
190  item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_SEGMENT, idx );
191 
192  if( InvokeDialogNewItem( this, item ) == wxID_CANCEL )
193  {
194  RemoveLastCommandInUndoList();
195  pglayout.Remove( item );
196  RebuildDesignTree();
197  item = NULL;
198  }
199  else
200  {
201  // Put the new item in move mode, after putting the cursor
202  // on the start point:
203  wxPoint position = item->GetStartPosUi();
204  SetCrossHairPosition( position, false );
205  position = GetCrossHairPosition();
206 
207  if( m_canvas->IsPointOnDisplay( position ) )
208  m_canvas->MoveCursorToCrossHair();
209  else
210  RedrawScreen( position, true );
211 
212  item->SetFlags( NEW_ITEM );
213  MoveItem( item );
214  }
215  break;
216 
218  SaveCopyInUndoList();
219  idx = m_treePagelayout->GetSelectedItemIndex();
220  item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_RECT, idx );
221 
222  if( InvokeDialogNewItem( this, item ) == wxID_CANCEL )
223  {
224  RemoveLastCommandInUndoList();
225  pglayout.Remove( item );
226  RebuildDesignTree();
227  item = NULL;
228  }
229  else
230  {
231  // Put the new item in move mode, after putting the cursor
232  // on the start point:
233  wxPoint position = item->GetStartPosUi();
234  SetCrossHairPosition( position, false );
235  position = GetCrossHairPosition();
236 
237  if( m_canvas->IsPointOnDisplay( position ) )
238  m_canvas->MoveCursorToCrossHair();
239  else
240  RedrawScreen( position, true );
241 
242  item->SetFlags( NEW_ITEM );
243  MoveItem( item );
244  }
245  break;
246 
248  SaveCopyInUndoList();
249  idx = m_treePagelayout->GetSelectedItemIndex();
250  item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_TEXT, idx );
251  if( InvokeDialogNewItem( this, item ) == wxID_CANCEL )
252  {
253  RemoveLastCommandInUndoList();
254  pglayout.Remove( item );
255  RebuildDesignTree();
256  item = NULL;
257  }
258  else
259  {
260  // Put the new text in move mode:
262  MoveItem( item );
263  }
264  break;
265 
267  SaveCopyInUndoList();
268  idx = m_treePagelayout->GetSelectedItemIndex();
269  item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_BITMAP, idx );
270  if( item && InvokeDialogNewItem( this, item ) == wxID_CANCEL )
271  {
272  RemoveLastCommandInUndoList();
273  pglayout.Remove( item );
274  RebuildDesignTree();
275  item = NULL;
276  }
277  if( item )
278  {
279  // Put the new text in move mode:
281  MoveItem( item );
282  }
283  break;
284 
286  cmd.SetId( ID_APPEND_DESCR_FILE );
287  wxPostEvent( this, cmd );
288  break;
289 
290  case ID_POPUP_ITEM_PLACE:
291  item = GetScreen()->GetCurItem();
292  PlaceItem( item );
293  break;
294 
296  if( m_canvas->IsMouseCaptured() )
297  m_canvas->EndMouseCapture();
298  break;
299 
301  item = m_treePagelayout->GetPageLayoutSelectedItem();
302  // Ensure flags are properly set
303  item->ClearFlags( LOCATE_ENDPOINT );
304  item->SetFlags( LOCATE_STARTPOINT );
305  MoveItem( item );
306  break;
307 
309  item = m_treePagelayout->GetPageLayoutSelectedItem();
310  // Ensure flags are properly set
311  item->ClearFlags( LOCATE_STARTPOINT );
312  item->SetFlags( LOCATE_ENDPOINT );
313  MoveItem( item );
314  break;
315 
316  case ID_POPUP_ITEM_MOVE:
317  item = m_treePagelayout->GetPageLayoutSelectedItem();
319  MoveItem( item );
320  break;
321 
322  default:
323  wxMessageBox( wxT( "PL_EDITOR_FRAME::Process_Special_Functions error" ) );
324  break;
325  }
326 
327  if( item )
328  {
329  OnModify();
330  m_propertiesPagelayout->CopyPrmsFromItemToPanel( item );
331  m_treePagelayout->SelectCell( item );
332  }
333 
334 }
335 
336 
337 /*
338  * Function moveItem: called when the mouse cursor is moving
339  * moves the item currently selected (or the start point or the end point)
340  * to the cursor position
341  */
342 DPOINT initialPosition; // The initial position of the item to move, in mm
343 wxPoint initialPositionUi; // The initial position of the item to move, in Ui
344 wxPoint initialCursorPosition; // The initial position of the cursor
345 
346 static void moveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase )
347 {
348  PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) aPanel->GetScreen();
349  WORKSHEET_DATAITEM *item = screen->GetCurItem();
350 
351  wxCHECK_RET( (item != NULL), wxT( "Cannot move NULL item." ) );
352  wxPoint position = aPanel->GetParent()->GetCrossHairPosition()
353  - ( initialCursorPosition - initialPositionUi );
354  wxPoint previous_position;
355 
356  if( (item->GetFlags() & LOCATE_STARTPOINT) )
357  {
358  previous_position = item->GetStartPosUi();
359  item->MoveStartPointToUi( position );
360  }
361  else if( (item->GetFlags() & LOCATE_ENDPOINT) )
362  {
363  previous_position = item->GetEndPosUi();
364  item->MoveEndPointToUi( position );
365  }
366  else
367  {
368  previous_position = item->GetStartPosUi();
369  item->MoveToUi( position );
370  }
371 
372  // Draw the item item at it's new position, if it is modified,
373  // (does not happen each time the mouse is moved, because the
374  // item is placed on grid)
375  // to avoid useless computation time.
376  if( previous_position != position )
377  aPanel->Refresh();
378 }
379 
380 
381 /*
382  * Function abortMoveItem: called when an item is currently moving,
383  * and when the user aborts the move command.
384  * Restores the initial position of the item
385  */
386 static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
387 {
388  PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) aPanel->GetScreen();
389  WORKSHEET_DATAITEM *item = screen->GetCurItem();
390 
391  if( item->GetFlags() & NEW_ITEM )
392  {
393  PL_EDITOR_FRAME* plframe = (PL_EDITOR_FRAME*) aPanel->GetParent();
394  plframe->RemoveLastCommandInUndoList();
396  pglayout.Remove( item );
397  plframe->RebuildDesignTree();
398  }
399  else
400  {
401  if( (item->GetFlags() & LOCATE_STARTPOINT) )
402  {
403  item->MoveStartPointTo( initialPosition );
404  }
405  else if( (item->GetFlags() & LOCATE_ENDPOINT) )
406  {
407  item->MoveEndPointTo( initialPosition );
408  }
409  else
410  item->MoveTo( initialPosition );
411  }
412 
413  aPanel->SetMouseCapture( NULL, NULL );
414  screen->SetCurItem( NULL );
415  aPanel->Refresh();
416 }
417 
418 
420 {
421  wxCHECK_RET( aItem != NULL, wxT( "Cannot move NULL item" ) );
422  initialPosition = aItem->GetStartPos();
423  initialPositionUi = aItem->GetStartPosUi();
424  initialCursorPosition = GetCrossHairPosition();
425 
426  if( (aItem->GetFlags() & LOCATE_ENDPOINT) )
427  {
428  initialPosition = aItem->GetEndPos();
429  initialPositionUi = aItem->GetEndPosUi();
430  }
431 
432  if( aItem->GetFlags() & (LOCATE_STARTPOINT|LOCATE_ENDPOINT) )
433  {
434  SetCrossHairPosition( initialPositionUi, false );
435  initialCursorPosition = GetCrossHairPosition();
436 
437  if( m_canvas->IsPointOnDisplay( initialCursorPosition ) )
438  {
440  m_canvas->Refresh();
441  }
442  else
443  {
444  RedrawScreen( initialCursorPosition, true );
445  }
446  }
447 
449  GetScreen()->SetCurItem( aItem );
450 }
451 
452 
458 {
459  DPOINT currStartPos = aItem->GetStartPos();
460  DPOINT currEndPos = aItem->GetEndPos();
461 
462  aItem->ClearFlags( NEW_ITEM );
463 
464  // Save the curren layout before changes
465  if( (aItem->GetFlags() & LOCATE_STARTPOINT) )
466  {
467  aItem->MoveStartPointTo( initialPosition );
468  }
469  else if( aItem->GetFlags() & LOCATE_ENDPOINT )
470  {
471  aItem->MoveEndPointTo( initialPosition );
472  }
473  else
474  aItem->MoveTo( initialPosition );
475 
477 
478  // Re-place the item
479  aItem->MoveStartPointTo( currStartPos );
480  aItem->MoveEndPointTo( currEndPos );
481 
482  m_canvas->SetMouseCapture( NULL, NULL );
483  GetScreen()->SetCurItem( NULL );
484 }
485 
486 
487 /* called when the user select one of the 4 page corner as corner
488  * reference (or the left top paper corner)
489  */
490 void PL_EDITOR_FRAME::OnSelectCoordOriginCorner( wxCommandEvent& event )
491 {
492  m_originSelectChoice = m_originSelectBox->GetSelection();
493  UpdateStatusBar(); // Update grid origin
494  m_canvas->Refresh();
495 }
496 
497 
499 {
501  m_canvas->Refresh();
502 }
503 
504 
505 void PL_EDITOR_FRAME::OnQuit( wxCommandEvent& event )
506 {
507  Close( true );
508 }
509 
510 
511 void PL_EDITOR_FRAME::ToPlotter(wxCommandEvent& event)
512 {
513  wxMessageBox( wxT( "Not yet available" ) );
514 }
515 
516 
517 void PL_EDITOR_FRAME::ToPrinter(wxCommandEvent& event)
518 {
519  // static print data and page setup data, to remember settings during the session
520  static wxPrintData* s_PrintData;
521  static wxPageSetupDialogData* s_pageSetupData = (wxPageSetupDialogData*) NULL;
522 
523  const PAGE_INFO& pageInfo = GetPageSettings();
524 
525  if( s_PrintData == NULL ) // First print
526  {
527  s_PrintData = new wxPrintData();
528  s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGH;
529  }
530 
531  if( !s_PrintData->Ok() )
532  {
533  wxMessageBox( _( "Error Init Printer info" ) );
534  return;
535  }
536 
537  if( s_pageSetupData == NULL )
538  s_pageSetupData = new wxPageSetupDialogData( *s_PrintData );
539 
540  s_pageSetupData->SetPaperId( pageInfo.GetPaperId() );
541  s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() );
542 
543  if( pageInfo.IsCustom() )
544  {
545  if( pageInfo.IsPortrait() )
546  s_pageSetupData->SetPaperSize( wxSize( Mils2mm( pageInfo.GetWidthMils() ),
547  Mils2mm( pageInfo.GetHeightMils() ) ) );
548  else
549  s_pageSetupData->SetPaperSize( wxSize( Mils2mm( pageInfo.GetHeightMils() ),
550  Mils2mm( pageInfo.GetWidthMils() ) ) );
551  }
552 
553  *s_PrintData = s_pageSetupData->GetPrintData();
554 
555  if( event.GetId() == wxID_PREVIEW )
556  InvokeDialogPrintPreview( this, s_PrintData );
557  else
558  InvokeDialogPrint( this, s_PrintData, s_pageSetupData );
559 }
560 
561 
562 void PL_EDITOR_FRAME::OnTreeSelection( wxTreeEvent& event )
563 {
565 
566  if( item )
568 
569  m_canvas->Refresh();
570 }
571 
572 
573 void PL_EDITOR_FRAME::OnTreeMiddleClick( wxTreeEvent& event )
574 {
575 }
576 
577 
578 extern void AddNewItemsCommand( wxMenu* aMainMenu );
579 
580 
581 void PL_EDITOR_FRAME::OnTreeRightClick( wxTreeEvent& event )
582 {
583  m_treePagelayout->SelectCell( event.GetItem() );
584 
585  wxMenu popMenu;
586  AddNewItemsCommand( &popMenu );
587 
588  popMenu.AppendSeparator();
589  AddMenuItem( &popMenu, ID_POPUP_DESIGN_TREE_ITEM_DELETE, _( "Delete" ),
590  KiBitmap( delete_xpm ) );
591 
592  PopupMenu( &popMenu );
593 }
594 
595 
597 {
598  event.Check( WORKSHEET_DATAITEM::m_SpecialMode == false );
599 }
600 
601 
603 {
604  event.Check( WORKSHEET_DATAITEM::m_SpecialMode == true );
605 }
606 
607 
608 void PL_EDITOR_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
609 {
610  aEvent.Check( GetToolId() == aEvent.GetId() );
611 }
static wxPrintData * s_PrintData
WORKSHEET_DATAITEM * GetCurItem() const
Function GetCurItem returns the currently selected WORKSHEET_DATAITEM, overriding BASE_SCREEN::GetCur...
EVT_MENU_RANGE(ID_POPUP_START_RANGE, ID_POPUP_END_RANGE, PL_EDITOR_FRAME::Process_Special_Functions) void PL_EDITOR_FRAME
const PAGE_INFO & GetPageSettings() const override
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
void RemoveLastCommandInUndoList()
Remove the last command in Undo List.
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:55
void CopyPrmsFromItemToPanel(WORKSHEET_DATAITEM *aItem)
const DPOINT GetStartPos(int ii=0) const
void UpdateStatusBar() override
Function UpdateStatusBar updates the status bar information.
void SetCurItem(WORKSHEET_DATAITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
void OnTreeMiddleClick(wxTreeEvent &event)
int InvokeDialogPrint(PL_EDITOR_FRAME *aCaller, wxPrintData *aPrintData, wxPageSetupDialogData *aPageSetupData)
Create and show a print dialog returns 1 if OK, 0 , there is a problem.
void SetWksFileName(const wxString &aFilename)
int InvokeDialogPrintPreview(PL_EDITOR_FRAME *aCaller, wxPrintData *aPrintData)
Create and show a print preview dialog returns 1 if OK, 0 , there is a problem.
description of graphic items and texts to build a title block
void MoveEndPointTo(DPOINT aPosition)
move the ending point of the item to a new position has meaning only for items defined by 2 points (s...
void SelectCell(WORKSHEET_DATAITEM *aItem)
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:54
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:347
const wxPoint GetStartPosUi(int ii=0) const
int GetItemIndex(WORKSHEET_DATAITEM *aItem) const
static WORKSHEET_LAYOUT & GetTheInstance()
static function: returns the instance of WORKSHEET_LAYOUT used in the application ...
This file contains miscellaneous commonly used macros and functions.
void MoveStartPointTo(DPOINT aPosition)
move the starting point of the item to a new position
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
bool IsPointOnDisplay(const wxPoint &aPosition)
Function IsPointOnDisplay.
Definition: draw_panel.cpp:287
void MoveToUi(wxPoint aPosition)
move item to a new position
bool IsPortrait() const
a helper to handle the real device context used in KiCad
WORKSHEET_DATAITEM * GetItem(unsigned aIdx) const
void EnableWksFileNamePicker(bool aEnable)
DPOINT initialPosition
static wxPageSetupDialogData * s_pageSetupData
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
bool Remove(unsigned aIdx)
Remove the item to the list of items at position aIdx.
void OnSelectCoordOriginCorner(wxCommandEvent &event)
called when the user select one of the 4 page corner as corner reference (or the left top paper corne...
wxPoint initialPositionUi
EVT_MENU(ID_SELECT_PREFERED_PDF_BROWSER_NAME, KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser) EVT_MENU_RANGE(ID_LANGUAGE_CHOICE
int Mils2mm(double x)
Convert mils to mm.
Definition: base_units.h:44
void OnUpdateTitleBlockDisplaySpecialMode(wxUpdateUIEvent &event)
void MoveTo(DPOINT aPosition)
move item to a new position
wxPoint initialCursorPosition
const wxPoint GetEndPosUi(int ii=0) const
Helper dialog and control classes.
PL_EDITOR_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
void ToPrinter(wxCommandEvent &event)
Function ToPrinter Open a dialog frame to print layers.
void OnTreeRightClick(wxTreeEvent &event)
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
EVT_TOOL(ID_FOOTPRINT_WIZARD_SELECT_WIZARD, FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard) EVT_TOOL(ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT
int GetWidthMils() const
WORKSHEET_LAYOUT handles the graphic items list to draw/plot the title block and other items (page re...
void ToPlotter(wxCommandEvent &event)
Function ToPlotter Open a dialog frame to create plot and drill files relative to the current board...
#define NEW_ITEM
#define LOCATE_STARTPOINT
ID_PREFERENCES_HOTKEY_END
void OnTreeSelection(wxTreeEvent &event)
const DPOINT GetEndPos(int ii=0) const
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
void RedrawScreen(const wxPoint &aCenterPoint, bool aWarpPointer)
Function RedrawScreen redraws the entire screen area by updating the scroll bars and mouse pointer in...
Definition: zoom.cpp:46
bool IsCustom() const
Function IsCustom returns true if the type is Custom.
wxPaperSize GetPaperId() const
Function GetPaperId.
see class PGM_BASE
WORKSHEET_DATAITEM * GetSelectedItem()
Function GetSelectedItem.
void OnQuit(wxCommandEvent &event)
Function OnQuit called on request of application quit.
KICAD_MANAGER_FRAME::language_change KICAD_MANAGER_FRAME::OnChangeIconsOptions EVT_UPDATE_UI(ID_SELECT_PREFERED_PDF_BROWSER, KICAD_MANAGER_FRAME::OnUpdatePreferredPdfBrowser) EVT_UPDATE_UI_RANGE(ID_TO_SCH
PROPERTIES_FRAME * m_propertiesPagelayout
int GetToolId() const
Definition: draw_frame.h:458
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
Definition: wxstruct.h:117
void PlaceItem(WORKSHEET_DATAITEM *aItem)
Save in Undo list the layout, and place an item being moved.
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
The common library.
void SaveCopyInUndoList()
Save a copy of the description (in a S expr string) for Undo/redo commands.
void RebuildDesignTree()
Function RebuildDesignTree Re creates the design graphic tree list items, and ensures each item has a...
Definition: id.h:96
void MoveItem(WORKSHEET_DATAITEM *aItem)
Initialize a move item command.
classes and function to generate graphics to plt or draw titles blocks and frame references ...
static void moveItem(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
void MoveEndPointToUi(wxPoint aPosition)
move the ending point of the item to a new position has meaning only for items defined by 2 points (s...
void AddNewItemsCommand(wxMenu *aMainMenu)
int InvokeDialogNewItem(PL_EDITOR_FRAME *aCaller, WORKSHEET_DATAITEM *aItem)
Create and show DIALOG_NEW_DATAITEM and return whatever DIALOG_NEW_DATAITEM::ShowModal() returns...
wxPrintOrientation GetWxOrientation() const
Function GetWxOrientation.
void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Function SetCrossHairPosition sets the screen cross hair position to aPosition in logical (drawing) u...
#define LOCATE_ENDPOINT
void MoveStartPointToUi(wxPoint aPosition)
move the starting point of the item to a new position
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
void OnUpdateTitleBlockDisplayNormalMode(wxUpdateUIEvent &event)
void OnSelectTitleBlockDisplayMode(wxCommandEvent &event)
Toggle the display mode between the normal mode and the editor mode: In normal mode, title block texts are shown like they will be shown in other kicad applications: the format symbols in texts are replaced by the actual text.
int GetHeightMils() const
wxChoice * m_originSelectBox
void OnUpdateSelectTool(wxUpdateUIEvent &aEvent)
static void abortMoveItem(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
DESIGN_TREE_FRAME * m_treePagelayout