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>
44 #include <worksheet_dataitem.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 
70 
71  EVT_MENU( wxID_EXIT, PL_EDITOR_FRAME::OnQuit )
72 
73  // menu Preferences
75  EVT_MENU( wxID_PREFERENCES, PL_EDITOR_FRAME::Process_Config )
77  EVT_MENU( ID_MENU_GRID_ONOFF, PL_EDITOR_FRAME::Process_Config )
78 
79  // Menu Help
80  EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
81  EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp )
82  EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute )
83  EVT_MENU( wxID_ABOUT, EDA_DRAW_FRAME::GetKicadAbout )
84 
85  EVT_TOOL( wxID_CUT, PL_EDITOR_FRAME::Process_Special_Functions )
86  EVT_TOOL( wxID_UNDO, PL_EDITOR_FRAME::GetLayoutFromUndoList )
87  EVT_TOOL( wxID_REDO, PL_EDITOR_FRAME::GetLayoutFromRedoList )
88  EVT_TOOL( wxID_PRINT, PL_EDITOR_FRAME::ToPrinter )
89  EVT_TOOL( wxID_PREVIEW, PL_EDITOR_FRAME::ToPrinter )
90  EVT_TOOL( ID_SHEET_SET, PL_EDITOR_FRAME::Process_Special_Functions )
91  EVT_TOOL( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode )
92  EVT_TOOL( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode )
93  EVT_TOOL( ID_NO_TOOL_SELECTED, PL_EDITOR_FRAME::Process_Special_Functions )
94  EVT_MENU( ID_MENU_ZOOM_SELECTION, 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  EVT_TOOL( ID_POPUP_CANCEL_CURRENT_COMMAND, PL_EDITOR_FRAME::Process_Special_Functions )
103 
105  PL_EDITOR_FRAME::Process_Special_Functions )
106 
107  EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, PL_EDITOR_FRAME::OnUpdateSelectTool )
108 
109  EVT_UPDATE_UI( ID_ZOOM_SELECTION, PL_EDITOR_FRAME::OnUpdateSelectTool )
110  EVT_UPDATE_UI( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayNormalMode )
111  EVT_UPDATE_UI( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplaySpecialMode )
112 
113 END_EVENT_TABLE()
114 
115 
116 /* Handles the selection of tools, menu, and popup menu commands.
117  */
118 void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event )
119 {
120  int id = event.GetId();
121  int idx;
122  wxString msg;
124  WORKSHEET_DATAITEM* item = NULL;
125  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
126  cmd.SetEventObject( this );
127 
128  switch( id )
129  {
130  case ID_NO_TOOL_SELECTED:
131  SetNoToolSelected();
132  break;
133 
134  case ID_MENU_ZOOM_SELECTION:
135  case ID_ZOOM_SELECTION:
136  // This tool is located on the main toolbar: switch it on or off on click
137  if( GetToolId() != ID_ZOOM_SELECTION )
138  SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
139  else
140  SetNoToolSelected();
141  break;
142 
143  case ID_SELECT_PAGE_NUMBER:
144  m_canvas->Refresh();
145  break;
146 
147  case ID_SHEET_SET:
148  {
151  dlg.SetWksFileName( GetCurrFileName() );
152  dlg.EnableWksFileNamePicker( false );
153  dlg.ShowModal();
154 
155  cmd.SetId( ID_ZOOM_PAGE );
156  wxPostEvent( this, cmd );
157  }
158  break;
159 
160  case ID_POPUP_CANCEL_CURRENT_COMMAND:
161  if( m_canvas->IsMouseCaptured() )
162  {
163  m_canvas->EndMouseCapture();
164  SetToolID( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString );
165  }
166  else
167  {
168  SetNoToolSelected();
169  }
170  break;
171 
174  case wxID_CUT:
175  // Delete item, and select the previous item
176  item = m_treePagelayout->GetPageLayoutSelectedItem();
177 
178  if( item == NULL )
179  break;
180 
181  SaveCopyInUndoList();
182  idx = pglayout.GetItemIndex( item );
183  pglayout.Remove( item );
184  RebuildDesignTree();
185 
187  {
188  item = pglayout.GetItem( (unsigned) (idx-1) );
189 
190  if( item )
191  m_treePagelayout->SelectCell( item );
192  }
193 
194  item = NULL;
195  OnModify();
196  m_canvas->Refresh();
197  break;
198 
200  SaveCopyInUndoList();
201  idx = m_treePagelayout->GetSelectedItemIndex();
202  item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_SEGMENT, idx );
203 
204  if( InvokeDialogNewItem( this, item ) == wxID_CANCEL )
205  {
206  RemoveLastCommandInUndoList();
207  pglayout.Remove( item );
208  RebuildDesignTree();
209  item = NULL;
210  }
211  else
212  {
213  // Put the new item in move mode, after putting the cursor
214  // on the start point:
215  wxPoint position = item->GetStartPosUi();
216  SetCrossHairPosition( position, false );
217  position = GetCrossHairPosition();
218 
219  if( m_canvas->IsPointOnDisplay( position ) )
220  m_canvas->MoveCursorToCrossHair();
221  else
222  RedrawScreen( position, true );
223 
224  item->SetFlags( NEW_ITEM );
225  MoveItem( item );
226  }
227  break;
228 
230  SaveCopyInUndoList();
231  idx = m_treePagelayout->GetSelectedItemIndex();
232  item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_RECT, idx );
233 
234  if( InvokeDialogNewItem( this, item ) == wxID_CANCEL )
235  {
236  RemoveLastCommandInUndoList();
237  pglayout.Remove( item );
238  RebuildDesignTree();
239  item = NULL;
240  }
241  else
242  {
243  // Put the new item in move mode, after putting the cursor
244  // on the start point:
245  wxPoint position = item->GetStartPosUi();
246  SetCrossHairPosition( position, false );
247  position = GetCrossHairPosition();
248 
249  if( m_canvas->IsPointOnDisplay( position ) )
250  m_canvas->MoveCursorToCrossHair();
251  else
252  RedrawScreen( position, true );
253 
254  item->SetFlags( NEW_ITEM );
255  MoveItem( item );
256  }
257  break;
258 
260  SaveCopyInUndoList();
261  idx = m_treePagelayout->GetSelectedItemIndex();
262  item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_TEXT, idx );
263  if( InvokeDialogNewItem( this, item ) == wxID_CANCEL )
264  {
265  RemoveLastCommandInUndoList();
266  pglayout.Remove( item );
267  RebuildDesignTree();
268  item = NULL;
269  }
270  else
271  {
272  // Put the new text in move mode:
274  MoveItem( item );
275  }
276  break;
277 
279  SaveCopyInUndoList();
280  idx = m_treePagelayout->GetSelectedItemIndex();
281  item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_BITMAP, idx );
282  if( item && InvokeDialogNewItem( this, item ) == wxID_CANCEL )
283  {
284  RemoveLastCommandInUndoList();
285  pglayout.Remove( item );
286  RebuildDesignTree();
287  item = NULL;
288  }
289  if( item )
290  {
291  // Put the new text in move mode:
293  MoveItem( item );
294  }
295  break;
296 
298  cmd.SetId( ID_APPEND_DESCR_FILE );
299  wxPostEvent( this, cmd );
300  break;
301 
302  case ID_POPUP_ITEM_PLACE:
303  item = GetScreen()->GetCurItem();
304  PlaceItem( item );
305  break;
306 
308  if( m_canvas->IsMouseCaptured() )
309  m_canvas->EndMouseCapture();
310  break;
311 
313  item = m_treePagelayout->GetPageLayoutSelectedItem();
314  // Ensure flags are properly set
315  item->ClearFlags( LOCATE_ENDPOINT );
316  item->SetFlags( LOCATE_STARTPOINT );
317  MoveItem( item );
318  break;
319 
321  item = m_treePagelayout->GetPageLayoutSelectedItem();
322  // Ensure flags are properly set
323  item->ClearFlags( LOCATE_STARTPOINT );
324  item->SetFlags( LOCATE_ENDPOINT );
325  MoveItem( item );
326  break;
327 
328  case ID_POPUP_ITEM_MOVE:
329  item = m_treePagelayout->GetPageLayoutSelectedItem();
331  MoveItem( item );
332  break;
333 
334  default:
335  wxMessageBox( wxT( "PL_EDITOR_FRAME::Process_Special_Functions error" ) );
336  break;
337  }
338 
339  if( item )
340  {
341  OnModify();
342  m_propertiesPagelayout->CopyPrmsFromItemToPanel( item );
343  m_treePagelayout->SelectCell( item );
344  }
345 
346 }
347 
348 
349 /*
350  * Function moveItem: called when the mouse cursor is moving
351  * moves the item currently selected (or the start point or the end point)
352  * to the cursor position
353  */
354 DPOINT initialPosition; // The initial position of the item to move, in mm
355 wxPoint initialPositionUi; // The initial position of the item to move, in Ui
356 wxPoint initialCursorPosition; // The initial position of the cursor
357 
358 static void moveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase )
359 {
360  PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) aPanel->GetScreen();
361  WORKSHEET_DATAITEM *item = screen->GetCurItem();
362 
363  wxCHECK_RET( (item != NULL), wxT( "Cannot move NULL item." ) );
364  wxPoint position = aPanel->GetParent()->GetCrossHairPosition()
365  - ( initialCursorPosition - initialPositionUi );
366  wxPoint previous_position;
367 
368  if( (item->GetFlags() & LOCATE_STARTPOINT) )
369  {
370  previous_position = item->GetStartPosUi();
371  item->MoveStartPointToUi( position );
372  }
373  else if( (item->GetFlags() & LOCATE_ENDPOINT) )
374  {
375  previous_position = item->GetEndPosUi();
376  item->MoveEndPointToUi( position );
377  }
378  else
379  {
380  previous_position = item->GetStartPosUi();
381  item->MoveToUi( position );
382  }
383 
384  // Draw the item item at it's new position, if it is modified,
385  // (does not happen each time the mouse is moved, because the
386  // item is placed on grid)
387  // to avoid useless computation time.
388  if( previous_position != position )
389  aPanel->Refresh();
390 }
391 
392 
393 /*
394  * Function abortMoveItem: called when an item is currently moving,
395  * and when the user aborts the move command.
396  * Restores the initial position of the item
397  */
398 static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
399 {
400  PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) aPanel->GetScreen();
401  WORKSHEET_DATAITEM *item = screen->GetCurItem();
402 
403  if( item->GetFlags() & NEW_ITEM )
404  {
405  PL_EDITOR_FRAME* plframe = (PL_EDITOR_FRAME*) aPanel->GetParent();
406  plframe->RemoveLastCommandInUndoList();
408  pglayout.Remove( item );
409  plframe->RebuildDesignTree();
410  }
411  else
412  {
413  if( (item->GetFlags() & LOCATE_STARTPOINT) )
414  {
415  item->MoveStartPointTo( initialPosition );
416  }
417  else if( (item->GetFlags() & LOCATE_ENDPOINT) )
418  {
419  item->MoveEndPointTo( initialPosition );
420  }
421  else
422  item->MoveTo( initialPosition );
423  }
424 
425  aPanel->SetMouseCapture( NULL, NULL );
426  screen->SetCurItem( NULL );
427  aPanel->Refresh();
428 }
429 
430 
432 {
433  wxCHECK_RET( aItem != NULL, wxT( "Cannot move NULL item" ) );
434  initialPosition = aItem->GetStartPos();
435  initialPositionUi = aItem->GetStartPosUi();
436  initialCursorPosition = GetCrossHairPosition();
437 
438  if( (aItem->GetFlags() & LOCATE_ENDPOINT) )
439  {
440  initialPosition = aItem->GetEndPos();
441  initialPositionUi = aItem->GetEndPosUi();
442  }
443 
444  if( aItem->GetFlags() & (LOCATE_STARTPOINT|LOCATE_ENDPOINT) )
445  {
446  SetCrossHairPosition( initialPositionUi, false );
447  initialCursorPosition = GetCrossHairPosition();
448 
449  if( m_canvas->IsPointOnDisplay( initialCursorPosition ) )
450  {
452  m_canvas->Refresh();
453  }
454  else
455  {
456  RedrawScreen( initialCursorPosition, true );
457  }
458  }
459 
461  GetScreen()->SetCurItem( aItem );
462 }
463 
464 
470 {
471  DPOINT currStartPos = aItem->GetStartPos();
472  DPOINT currEndPos = aItem->GetEndPos();
473 
474  aItem->ClearFlags( NEW_ITEM );
475 
476  // Save the curren layout before changes
477  if( (aItem->GetFlags() & LOCATE_STARTPOINT) )
478  {
479  aItem->MoveStartPointTo( initialPosition );
480  }
481  else if( aItem->GetFlags() & LOCATE_ENDPOINT )
482  {
483  aItem->MoveEndPointTo( initialPosition );
484  }
485  else
486  aItem->MoveTo( initialPosition );
487 
489 
490  // Re-place the item
491  aItem->MoveStartPointTo( currStartPos );
492  aItem->MoveEndPointTo( currEndPos );
493 
494  m_canvas->SetMouseCapture( NULL, NULL );
495  GetScreen()->SetCurItem( NULL );
496 }
497 
498 
499 /* called when the user select one of the 4 page corner as corner
500  * reference (or the left top paper corner)
501  */
502 void PL_EDITOR_FRAME::OnSelectCoordOriginCorner( wxCommandEvent& event )
503 {
504  m_originSelectChoice = m_originSelectBox->GetSelection();
505  UpdateStatusBar(); // Update grid origin
506  m_canvas->Refresh();
507 }
508 
509 
511 {
513  m_canvas->Refresh();
514 }
515 
516 
517 void PL_EDITOR_FRAME::OnQuit( wxCommandEvent& event )
518 {
519  Close( true );
520 }
521 
522 
523 void PL_EDITOR_FRAME::ToPlotter(wxCommandEvent& event)
524 {
525  wxMessageBox( wxT( "Not yet available" ) );
526 }
527 
528 
529 void PL_EDITOR_FRAME::ToPrinter(wxCommandEvent& event)
530 {
531  // static print data and page setup data, to remember settings during the session
532  static wxPrintData* s_PrintData;
533  static wxPageSetupDialogData* s_pageSetupData = (wxPageSetupDialogData*) NULL;
534 
535  const PAGE_INFO& pageInfo = GetPageSettings();
536 
537  if( s_PrintData == NULL ) // First print
538  {
539  s_PrintData = new wxPrintData();
540  s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGH;
541  }
542 
543  if( !s_PrintData->Ok() )
544  {
545  wxMessageBox( _( "Error Init Printer info" ) );
546  return;
547  }
548 
549  if( s_pageSetupData == NULL )
550  s_pageSetupData = new wxPageSetupDialogData( *s_PrintData );
551 
552  s_pageSetupData->SetPaperId( pageInfo.GetPaperId() );
553  s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() );
554 
555  if( pageInfo.IsCustom() )
556  {
557  if( pageInfo.IsPortrait() )
558  s_pageSetupData->SetPaperSize( wxSize( Mils2mm( pageInfo.GetWidthMils() ),
559  Mils2mm( pageInfo.GetHeightMils() ) ) );
560  else
561  s_pageSetupData->SetPaperSize( wxSize( Mils2mm( pageInfo.GetHeightMils() ),
562  Mils2mm( pageInfo.GetWidthMils() ) ) );
563  }
564 
565  *s_PrintData = s_pageSetupData->GetPrintData();
566 
567  if( event.GetId() == wxID_PREVIEW )
568  InvokeDialogPrintPreview( this, s_PrintData );
569  else
570  InvokeDialogPrint( this, s_PrintData, s_pageSetupData );
571 }
572 
573 
574 void PL_EDITOR_FRAME::OnTreeSelection( wxTreeEvent& event )
575 {
577 
578  if( item )
580 
581  m_canvas->Refresh();
582 }
583 
584 
585 void PL_EDITOR_FRAME::OnTreeMiddleClick( wxTreeEvent& event )
586 {
587 }
588 
589 
590 extern void AddNewItemsCommand( wxMenu* aMainMenu );
591 
592 
593 void PL_EDITOR_FRAME::OnTreeRightClick( wxTreeEvent& event )
594 {
595  m_treePagelayout->SelectCell( event.GetItem() );
596 
597  wxMenu popMenu;
598  AddNewItemsCommand( &popMenu );
599 
600  popMenu.AppendSeparator();
601  AddMenuItem( &popMenu, ID_POPUP_DESIGN_TREE_ITEM_DELETE, _( "Delete" ),
602  KiBitmap( delete_xpm ) );
603 
604  PopupMenu( &popMenu );
605 }
606 
607 
609 {
610  event.Check( WORKSHEET_DATAITEM::m_SpecialMode == false );
611 }
612 
613 
615 {
616  event.Check( WORKSHEET_DATAITEM::m_SpecialMode == true );
617 }
618 
619 
620 void PL_EDITOR_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
621 {
622  aEvent.Check( GetToolId() == aEvent.GetId() );
623 }
virtual BASE_SCREEN * GetScreen()=0
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions EVT_UPDATE_UI(ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard) EVT_UPDATE_UI(ID_MODEDIT_INSERT_MODULE_IN_BOARD
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
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:223
void CopyPrmsFromItemToPanel(WORKSHEET_DATAITEM *aItem)
const DPOINT GetStartPos(int ii=0) const
Class PL_EDITOR_FRAME is the main window used in the page layout editor.
void UpdateStatusBar() override
Update 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)
#define LOCATE_STARTPOINT
int InvokeDialogPrintPreview(PL_EDITOR_FRAME *aCaller, wxPrintData *aPrintData)
Create and show a print preview dialog returns 1 if OK, 0 , there is a problem.
void ClearFlags(int aMask)
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)
The base class for create windows for drawing purpose.
Definition: draw_frame.h:78
virtual void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
const wxPoint GetStartPosUi(int ii=0) const
#define LOCATE_ENDPOINT
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.
#define NEW_ITEM
void MoveStartPointTo(DPOINT aPosition)
move the starting point of the item to a new position
virtual EDA_DRAW_FRAME * GetParent() const =0
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
virtual bool IsPointOnDisplay(const wxPoint &aPosition)
Function IsPointOnDisplay.
void SetFlags(int aMask)
void MoveToUi(wxPoint aPosition)
move item to a new position
bool IsPortrait() const
Definition: page_info.h:121
a helper to handle the real device context used in KiCad
WORKSHEET_DATAITEM * GetItem(unsigned aIdx) const
void EnableWksFileNamePicker(bool aEnable)
DPOINT initialPosition
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:54
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...
virtual void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
wxPoint initialPositionUi
int Mils2mm(double x)
Convert mils to mm.
Definition: base_units.h:52
void OnUpdateTitleBlockDisplaySpecialMode(wxUpdateUIEvent &event)
void MoveTo(DPOINT aPosition)
move item to a new position
wxPoint initialCursorPosition
const wxPoint GetEndPosUi(int ii=0) const
description of graphic items and texts to build a title block
Helper dialog and control classes.
PL_EDITOR_SCREEN * GetScreen() const override
Return 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)
EVT_TOOL(ID_FOOTPRINT_WIZARD_SELECT_WIZARD, FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard) EVT_TOOL(ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT
int GetWidthMils() const
Definition: page_info.h:137
#define MAX_PAGE_SIZE_EDITORS_MILS
Definition: page_info.h:41
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...
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar EVT_MENU(ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, FOOTPRINT_EDIT_FRAME::ProcessPreferences) EVT_MENU(ID_PCB_LIB_TABLE_EDIT
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:123
virtual void RedrawScreen(const wxPoint &aCenterPoint, bool aWarpPointer)
Redraw the entire screen area by updating the scroll bars and mouse pointer in order to have aCenterP...
bool IsCustom() const
Function IsCustom returns true if the type is Custom.
Definition: page_info.cpp:176
wxPaperSize GetPaperId() const
Function GetPaperId.
Definition: page_info.h:134
see class PGM_BASE
WORKSHEET_DATAITEM * GetSelectedItem()
Function GetSelectedItem.
void OnQuit(wxCommandEvent &event)
Function OnQuit called on request of application quit.
PROPERTIES_FRAME * m_propertiesPagelayout
int GetToolId() const
Definition: draw_frame.h:519
void PlaceItem(WORKSHEET_DATAITEM *aItem)
Save in Undo list the layout, and place an item being moved.
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:97
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...
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
wxPrintOrientation GetWxOrientation() const
Function GetWxOrientation.
Definition: page_info.h:127
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Set the screen cross hair position to aPosition in logical (drawing) units.
void MoveStartPointToUi(wxPoint aPosition)
move the starting point of the item to a new position
wxPoint GetCrossHairPosition(bool aInvertY=false) const
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
Definition: page_info.h:140
wxChoice * m_originSelectBox
void OnUpdateSelectTool(wxUpdateUIEvent &aEvent)
static void abortMoveItem(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
DESIGN_TREE_FRAME * m_treePagelayout