From 889970a4494304712627df43ce534b3097c425e9 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 12 Oct 2021 21:05:37 +0100 Subject: [PATCH] SCH_NETCLASS_FLAGs and SCH_FIELDs for labels. ADDED: a new label type for netclass flags. ADDED: the ability to define fields on labels. --- bitmaps_png/CMakeLists.txt | 17 + bitmaps_png/png/add_class_flag_24.png | Bin 0 -> 391 bytes bitmaps_png/png/add_class_flag_dark_24.png | Bin 0 -> 582 bytes bitmaps_png/png/label_align_bottom_16.png | Bin 0 -> 137 bytes bitmaps_png/png/label_align_left_16.png | Bin 0 -> 134 bytes bitmaps_png/png/label_align_right_16.png | Bin 0 -> 133 bytes bitmaps_png/png/label_align_top_16.png | Bin 0 -> 135 bytes bitmaps_png/png/text_align_bottom_16.png | Bin 0 -> 91 bytes bitmaps_png/png/text_align_center_16.png | Bin 0 -> 90 bytes bitmaps_png/png/text_align_left_16.png | Bin 0 -> 82 bytes bitmaps_png/png/text_align_right_16.png | Bin 0 -> 85 bytes bitmaps_png/png/text_align_top_16.png | Bin 0 -> 85 bytes bitmaps_png/png/text_bold_16.png | Bin 0 -> 202 bytes bitmaps_png/png/text_horizontal_16.png | Bin 0 -> 156 bytes bitmaps_png/png/text_italic_16.png | Bin 0 -> 174 bytes bitmaps_png/png/text_valign_bottom_16.png | Bin 0 -> 81 bytes bitmaps_png/png/text_valign_center_16.png | Bin 0 -> 80 bytes bitmaps_png/png/text_valign_top_16.png | Bin 0 -> 84 bytes bitmaps_png/png/text_vertical_16.png | Bin 0 -> 155 bytes bitmaps_png/sources/dark/add_class_flag.svg | 108 + bitmaps_png/sources/light/add_class_flag.svg | 108 + .../sources/light/label_align_bottom.svg | 94 + .../sources/light/label_align_left.svg | 93 + .../sources/light/label_align_right.svg | 93 + bitmaps_png/sources/light/label_align_top.svg | 94 + .../sources/light/text_align_bottom.svg | 106 + .../sources/light/text_align_center.svg | 102 + bitmaps_png/sources/light/text_align_left.svg | 102 + .../sources/light/text_align_right.svg | 102 + bitmaps_png/sources/light/text_align_top.svg | 102 + bitmaps_png/sources/light/text_bold.svg | 93 + bitmaps_png/sources/light/text_horizontal.svg | 93 + bitmaps_png/sources/light/text_italic.svg | 93 + .../sources/light/text_valign_bottom.svg | 94 + .../sources/light/text_valign_center.svg | 94 + bitmaps_png/sources/light/text_valign_top.svg | 94 + bitmaps_png/sources/light/text_vertical.svg | 94 + common/eda_item.cpp | 1 + common/layer_id.cpp | 2 + common/settings/builtin_color_themes.h | 2 + common/settings/color_settings.cpp | 1 + common/tool/selection.cpp | 2 +- common/widgets/bitmap_button.cpp | 104 +- common/widgets/grid_combobox.cpp | 3 + eeschema/CMakeLists.txt | 6 +- eeschema/connection_graph.cpp | 5 +- eeschema/dialogs/dialog_field_properties.cpp | 127 +- eeschema/dialogs/dialog_field_properties.h | 5 + eeschema/dialogs/dialog_label_properties.cpp | 696 +++++ eeschema/dialogs/dialog_label_properties.h | 84 + .../dialogs/dialog_label_properties_base.cpp | 283 ++ .../dialogs/dialog_label_properties_base.fbp | 2315 +++++++++++++++++ .../dialogs/dialog_label_properties_base.h | 107 + .../dialogs/dialog_lib_text_properties.cpp | 160 +- eeschema/dialogs/dialog_lib_text_properties.h | 9 +- .../dialog_lib_text_properties_base.cpp | 198 +- .../dialog_lib_text_properties_base.fbp | 2125 +++++++++------ .../dialogs/dialog_lib_text_properties_base.h | 39 +- .../dialogs/dialog_sheet_pin_properties.cpp | 2 +- eeschema/dialogs/dialog_sheet_properties.cpp | 9 +- eeschema/dialogs/dialog_sheet_properties.h | 31 +- .../dialogs/dialog_sheet_properties_base.cpp | 4 +- .../dialogs/dialog_sheet_properties_base.fbp | 6 +- eeschema/dialogs/dialog_symbol_properties.cpp | 4 +- .../dialog_text_and_label_properties.cpp | 409 --- .../dialog_text_and_label_properties_base.cpp | 177 -- .../dialog_text_and_label_properties_base.fbp | 1098 -------- eeschema/dialogs/dialog_text_properties.cpp | 296 +++ ..._properties.h => dialog_text_properties.h} | 27 +- .../dialogs/dialog_text_properties_base.cpp | 171 ++ .../dialogs/dialog_text_properties_base.fbp | 1216 +++++++++ ...s_base.h => dialog_text_properties_base.h} | 55 +- eeschema/ee_collectors.cpp | 56 +- eeschema/eeschema_settings.cpp | 7 +- eeschema/eeschema_settings.h | 3 +- eeschema/fields_grid_table.cpp | 87 +- eeschema/fields_grid_table.h | 4 + eeschema/menubar.cpp | 1 + eeschema/sch_base_frame.cpp | 8 +- eeschema/sch_edit_frame.cpp | 20 +- eeschema/sch_edit_frame.h | 1 - eeschema/sch_field.cpp | 94 +- eeschema/sch_field.h | 2 +- eeschema/sch_file_versions.h | 8 +- eeschema/sch_item.h | 9 +- eeschema/sch_line.cpp | 2 + eeschema/sch_line.h | 20 + eeschema/sch_painter.cpp | 175 +- eeschema/sch_painter.h | 7 +- .../sch_plugins/altium/sch_altium_plugin.cpp | 18 +- .../cadstar/cadstar_sch_archive_loader.cpp | 10 +- .../sch_plugins/eagle/sch_eagle_plugin.cpp | 18 +- .../sch_plugins/kicad/sch_sexpr_parser.cpp | 72 +- .../sch_plugins/kicad/sch_sexpr_plugin.cpp | 55 +- .../sch_plugins/legacy/sch_legacy_plugin.cpp | 38 +- eeschema/sch_screen.cpp | 9 +- eeschema/sch_sheet.cpp | 13 +- eeschema/sch_sheet_pin.cpp | 10 +- eeschema/sch_symbol.cpp | 11 +- eeschema/sch_symbol.h | 13 +- eeschema/sch_text.cpp | 1765 +++++++------ eeschema/sch_text.h | 316 ++- eeschema/sch_view.h | 1 + eeschema/schematic.keywords | 4 + .../symbol_editor/symbol_editor_settings.cpp | 29 +- eeschema/toolbars_sch_editor.cpp | 1 + eeschema/tools/backannotate.cpp | 2 + eeschema/tools/ee_actions.cpp | 10 + eeschema/tools/ee_actions.h | 2 + eeschema/tools/ee_grid_helper.cpp | 1 + eeschema/tools/ee_selection_tool.cpp | 54 +- eeschema/tools/sch_drawing_tools.cpp | 73 +- eeschema/tools/sch_drawing_tools.h | 6 +- eeschema/tools/sch_edit_tool.cpp | 121 +- eeschema/tools/sch_line_wire_bus_tool.cpp | 1 + eeschema/tools/sch_move_tool.cpp | 4 +- include/bitmaps/bitmap_info.h | 18 + include/bitmaps/bitmaps_list.h | 17 + include/core/typeinfo.h | 4 +- include/layer_ids.h | 2 + include/widgets/bitmap_button.h | 35 +- 121 files changed, 10811 insertions(+), 3981 deletions(-) create mode 100644 bitmaps_png/png/add_class_flag_24.png create mode 100644 bitmaps_png/png/add_class_flag_dark_24.png create mode 100644 bitmaps_png/png/label_align_bottom_16.png create mode 100644 bitmaps_png/png/label_align_left_16.png create mode 100644 bitmaps_png/png/label_align_right_16.png create mode 100644 bitmaps_png/png/label_align_top_16.png create mode 100644 bitmaps_png/png/text_align_bottom_16.png create mode 100644 bitmaps_png/png/text_align_center_16.png create mode 100644 bitmaps_png/png/text_align_left_16.png create mode 100644 bitmaps_png/png/text_align_right_16.png create mode 100644 bitmaps_png/png/text_align_top_16.png create mode 100644 bitmaps_png/png/text_bold_16.png create mode 100644 bitmaps_png/png/text_horizontal_16.png create mode 100644 bitmaps_png/png/text_italic_16.png create mode 100644 bitmaps_png/png/text_valign_bottom_16.png create mode 100644 bitmaps_png/png/text_valign_center_16.png create mode 100644 bitmaps_png/png/text_valign_top_16.png create mode 100644 bitmaps_png/png/text_vertical_16.png create mode 100644 bitmaps_png/sources/dark/add_class_flag.svg create mode 100644 bitmaps_png/sources/light/add_class_flag.svg create mode 100644 bitmaps_png/sources/light/label_align_bottom.svg create mode 100644 bitmaps_png/sources/light/label_align_left.svg create mode 100644 bitmaps_png/sources/light/label_align_right.svg create mode 100644 bitmaps_png/sources/light/label_align_top.svg create mode 100644 bitmaps_png/sources/light/text_align_bottom.svg create mode 100644 bitmaps_png/sources/light/text_align_center.svg create mode 100644 bitmaps_png/sources/light/text_align_left.svg create mode 100644 bitmaps_png/sources/light/text_align_right.svg create mode 100644 bitmaps_png/sources/light/text_align_top.svg create mode 100644 bitmaps_png/sources/light/text_bold.svg create mode 100644 bitmaps_png/sources/light/text_horizontal.svg create mode 100644 bitmaps_png/sources/light/text_italic.svg create mode 100644 bitmaps_png/sources/light/text_valign_bottom.svg create mode 100644 bitmaps_png/sources/light/text_valign_center.svg create mode 100644 bitmaps_png/sources/light/text_valign_top.svg create mode 100644 bitmaps_png/sources/light/text_vertical.svg create mode 100644 eeschema/dialogs/dialog_label_properties.cpp create mode 100644 eeschema/dialogs/dialog_label_properties.h create mode 100644 eeschema/dialogs/dialog_label_properties_base.cpp create mode 100644 eeschema/dialogs/dialog_label_properties_base.fbp create mode 100644 eeschema/dialogs/dialog_label_properties_base.h delete mode 100644 eeschema/dialogs/dialog_text_and_label_properties.cpp delete mode 100644 eeschema/dialogs/dialog_text_and_label_properties_base.cpp delete mode 100644 eeschema/dialogs/dialog_text_and_label_properties_base.fbp create mode 100644 eeschema/dialogs/dialog_text_properties.cpp rename eeschema/dialogs/{dialog_text_and_label_properties.h => dialog_text_properties.h} (63%) create mode 100644 eeschema/dialogs/dialog_text_properties_base.cpp create mode 100644 eeschema/dialogs/dialog_text_properties_base.fbp rename eeschema/dialogs/{dialog_text_and_label_properties_base.h => dialog_text_properties_base.h} (54%) diff --git a/bitmaps_png/CMakeLists.txt b/bitmaps_png/CMakeLists.txt index c4509e4ff8..7809e3fe65 100644 --- a/bitmaps_png/CMakeLists.txt +++ b/bitmaps_png/CMakeLists.txt @@ -77,6 +77,10 @@ set( BMAPS_SMALL icon_pagelayout_editor_16 icon_pcbcalculator_16 icon_pcbnew_16 + label_align_left + label_align_right + label_align_top + label_align_bottom list_nets_16 options_generic_16 pinorient_right @@ -113,6 +117,18 @@ set( BMAPS_SMALL small_trash small_up small_warning + text_horizontal + text_vertical + text_align_left + text_align_center + text_align_right + text_align_bottom + text_align_top + text_valign_top + text_valign_center + text_valign_bottom + text_bold + text_italic tree_nosel tree_sel visibility @@ -130,6 +146,7 @@ set( BMAPS_MID add_bus2bus add_bus add_center_dimension + add_class_flag add_circle add_component add_corner diff --git a/bitmaps_png/png/add_class_flag_24.png b/bitmaps_png/png/add_class_flag_24.png new file mode 100644 index 0000000000000000000000000000000000000000..7d08770c97d113f87eb82722cc1b496d26c63534 GIT binary patch literal 391 zcmV;20eJq2P);g5jDWXF~o%VDQpVeuPW|Q^?7X zLqPEYB;~Q(!FPZ{w}RV)Cx?6hX+g*ZCx!e8)eU(SG7(8bNEuN1iBL|kUCJOWLDmo% zKi-gMA(I#wLQjQmLedbr9;hJ*uDu7ytA(@Q1quV{RiT%WZP)|!lq;N957f{KHb^Dp zM`#XMtUKfj10%wnT|gxZptf;_+yH710kgLTUrS>JvvNZI2Z|w_q!{uU=+*h5HlZG& z$AQYvf|P}N!@>;$gDj986$;VfXdl|Z-(p)c7edq1fVfdC@~SL7`7zjOUUQY zx>#;#$o&dchs*K+HB_U;Xs`yze2CW~#esp_hb$ZNHh2ym4WUjU9Z`ZPE+`5~#G`>I lK(dBVAz*5)WEcgQ007@Gm5~h!hLQjP002ovPDHLkV1g8do3a1^ literal 0 HcmV?d00001 diff --git a/bitmaps_png/png/add_class_flag_dark_24.png b/bitmaps_png/png/add_class_flag_dark_24.png new file mode 100644 index 0000000000000000000000000000000000000000..fceb1bcea34a123fca120db3e4e479a739fc2d09 GIT binary patch literal 582 zcmV-M0=fN(P)Nu@Jjh7zv7?MJlmSi&%&jVj+r^g=xh`P_Q^fK_p@$7J?$C(Mqte6A^6G zV)fXanajm_@69fk;tKHx6(oq~H@CZSlbcH*sMS4q%<|^F_s#qEo86(If&DLYF&&oJ z9yP{{ESnfb(ORe7Ay#}*6rIJod!^=?%8rQQU+|7g_;laIRHZwe;>agf-D!Tv5pN9D zSZjxoQ!nc>#g~K4+i`mXlBj6<9!;-{rrUV_T!Mt^M9F#V|Fp_ZI4vJA!Tm6Ynl5yk zC;X=Ms_2eBWbrS>O}?qH(t&bf6VE^p+g zl<8{R(}j4myJzIMk99hoHJJ1TE3%|$OO|Atyo0JM#UaOg6%?mq*!b@(;)vJvY`x2a=s(PA8&F5o1)Bi4D z5=`(IO}`=eBUEw8OL##HUcQRwsZM*B);8njSaI2=mc5y&rUS+4+tv8o%-jyv^abGe zLUsP#cva!fJX#fiYq*nQ=$5>bt^I02^Homx+^PWnn*DPCNOZLPnht(M16$F4189~E Ui1->9X8-^I07*qoM6N<$g2|mC#Q*>R literal 0 HcmV?d00001 diff --git a/bitmaps_png/png/label_align_bottom_16.png b/bitmaps_png/png/label_align_bottom_16.png new file mode 100644 index 0000000000000000000000000000000000000000..a1e67ed2cb0a39b3351f45423730acac0e92e1fa GIT binary patch literal 137 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf60z6$DLp07OCp0hxt3EdNC=g|~ zGPr8CFFS>&@z}y+;Ttq}H1*mtiPjj~B^TZMA!Z=6J}EHaBqy(PL4{P7VFJ5D@j9ai k%u}=trW?L;7G-2Ou+r$wzV@>*K(iSYPA>89ZJ6T-G@yGywpEgDofk literal 0 HcmV?d00001 diff --git a/bitmaps_png/png/label_align_right_16.png b/bitmaps_png/png/label_align_right_16.png new file mode 100644 index 0000000000000000000000000000000000000000..f6cff98a02b671086306c02e7cf8872297bc6625 GIT binary patch literal 133 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6d^}woLp07OCrGdy*m3rUmYT`O zW^IG0l$gv_ytSq+jO)K-fEbq2UN}A>FVdQ&MBb@0H%}|y8r+H literal 0 HcmV?d00001 diff --git a/bitmaps_png/png/text_align_center_16.png b/bitmaps_png/png/text_align_center_16.png new file mode 100644 index 0000000000000000000000000000000000000000..efc1a72271966913dfbe8e17b7ffefbde2a2bd7f GIT binary patch literal 90 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf66g^!WLp07OCoJGMh->AQiky(v n6*%Lg49gW!nU#49WEmK~glYWQ@yaL!sF=ai)z4*}Q$iB}u45SV literal 0 HcmV?d00001 diff --git a/bitmaps_png/png/text_align_left_16.png b/bitmaps_png/png/text_align_left_16.png new file mode 100644 index 0000000000000000000000000000000000000000..260f66c0d018ce4a11e1e4dab599a5015df58511 GIT binary patch literal 82 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6Bt2amLp07OCoJGMh->AQiky&t e$fJ}wmyzMCt9DOQg9{r_5re0zpUXO@geCyX&=fBK literal 0 HcmV?d00001 diff --git a/bitmaps_png/png/text_align_right_16.png b/bitmaps_png/png/text_align_right_16.png new file mode 100644 index 0000000000000000000000000000000000000000..b9db61941f47882af871726b77a7bcfb44d13af6 GIT binary patch literal 85 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6WISCQLp07OCoJGM*klmb$~!4f i=%*TwzWD_<28K*|?Vhs*$5Mdm7(8A5T-G@yGywn-;1!er literal 0 HcmV?d00001 diff --git a/bitmaps_png/png/text_align_top_16.png b/bitmaps_png/png/text_align_top_16.png new file mode 100644 index 0000000000000000000000000000000000000000..32ef10d46a0cca50ce1e7f06d1314b1f0641272b GIT binary patch literal 85 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6WISCQLp07OCoB*$h->Y1U&WMT iA}T5onXr5%Bg2IG+C5Ky3A_cWWAJqKb6Mw<&;$S?q!zOP literal 0 HcmV?d00001 diff --git a/bitmaps_png/png/text_bold_16.png b/bitmaps_png/png/text_bold_16.png new file mode 100644 index 0000000000000000000000000000000000000000..ffd362f536823ef045720887e935fd76f0bfd5e4 GIT binary patch literal 202 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6CVIL!hG?8mPFNshaLy=>wY|7! zQ?Kg<(KF`%`kCTqoK6T#*mP*eogK%2aChW}w7ND1@^s{yNG@lZToSD6?EUz)!?$SX z%9^|%sY0E1C&u^Om#lBoFnW3XC7W~Y@COMs4J@O1TaS?83{1OUCs BPbvTa literal 0 HcmV?d00001 diff --git a/bitmaps_png/png/text_horizontal_16.png b/bitmaps_png/png/text_horizontal_16.png new file mode 100644 index 0000000000000000000000000000000000000000..28510a3825ae7dff99b905d6049f96e120e2d4c3 GIT binary patch literal 156 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6l097ViW6&!r8kV7R-}i7G-2Gn5uMIi*;=T&^iWBS3j3^P6_OX{LdnbI&Pr(V8R;*-9dL#d1Jp14r4{-f|7E}uTh{qBJc zN4X+JSlw36=ra*^+xCcKUH}8@l)xE + + + + + + + + + image/svg+xml + + label + + + + + + + + + + + + + + + label + A + + + diff --git a/bitmaps_png/sources/light/add_class_flag.svg b/bitmaps_png/sources/light/add_class_flag.svg new file mode 100644 index 0000000000..207d5cb8b0 --- /dev/null +++ b/bitmaps_png/sources/light/add_class_flag.svg @@ -0,0 +1,108 @@ + + + + + + + + + + image/svg+xml + + label + + + + + + + + + + + + + + + label + A + + + diff --git a/bitmaps_png/sources/light/label_align_bottom.svg b/bitmaps_png/sources/light/label_align_bottom.svg new file mode 100644 index 0000000000..d0e8d9bf69 --- /dev/null +++ b/bitmaps_png/sources/light/label_align_bottom.svg @@ -0,0 +1,94 @@ + + + + + + + + + + image/svg+xml + + add_glabel + + + + + + + + + + + + + + + add_glabel + + + diff --git a/bitmaps_png/sources/light/label_align_left.svg b/bitmaps_png/sources/light/label_align_left.svg new file mode 100644 index 0000000000..3a5ccdf8fb --- /dev/null +++ b/bitmaps_png/sources/light/label_align_left.svg @@ -0,0 +1,93 @@ + + + + + + + + + + image/svg+xml + + add_glabel + + + + + + + + + + + + + + + add_glabel + + + diff --git a/bitmaps_png/sources/light/label_align_right.svg b/bitmaps_png/sources/light/label_align_right.svg new file mode 100644 index 0000000000..2937395740 --- /dev/null +++ b/bitmaps_png/sources/light/label_align_right.svg @@ -0,0 +1,93 @@ + + + + + + + + + + image/svg+xml + + add_glabel + + + + + + + + + + + + + + + add_glabel + + + diff --git a/bitmaps_png/sources/light/label_align_top.svg b/bitmaps_png/sources/light/label_align_top.svg new file mode 100644 index 0000000000..e8d70796a1 --- /dev/null +++ b/bitmaps_png/sources/light/label_align_top.svg @@ -0,0 +1,94 @@ + + + + + + + + + + image/svg+xml + + add_glabel + + + + + + + + + + + + + + + add_glabel + + + diff --git a/bitmaps_png/sources/light/text_align_bottom.svg b/bitmaps_png/sources/light/text_align_bottom.svg new file mode 100644 index 0000000000..964f15ceb5 --- /dev/null +++ b/bitmaps_png/sources/light/text_align_bottom.svg @@ -0,0 +1,106 @@ + + + + + + + + + + image/svg+xml + + add_glabel + + + + + + + + + + + + + + + add_glabel + + + + + + + + diff --git a/bitmaps_png/sources/light/text_align_center.svg b/bitmaps_png/sources/light/text_align_center.svg new file mode 100644 index 0000000000..343c159c8a --- /dev/null +++ b/bitmaps_png/sources/light/text_align_center.svg @@ -0,0 +1,102 @@ + + + + + + + + + + image/svg+xml + + add_glabel + + + + + + + + + + + + + + + add_glabel + + + + + + diff --git a/bitmaps_png/sources/light/text_align_left.svg b/bitmaps_png/sources/light/text_align_left.svg new file mode 100644 index 0000000000..98824edc18 --- /dev/null +++ b/bitmaps_png/sources/light/text_align_left.svg @@ -0,0 +1,102 @@ + + + + + + + + + + image/svg+xml + + add_glabel + + + + + + + + + + + + + + + add_glabel + + + + + + diff --git a/bitmaps_png/sources/light/text_align_right.svg b/bitmaps_png/sources/light/text_align_right.svg new file mode 100644 index 0000000000..05c27aa6c8 --- /dev/null +++ b/bitmaps_png/sources/light/text_align_right.svg @@ -0,0 +1,102 @@ + + + + + + + + + + image/svg+xml + + add_glabel + + + + + + + + + + + + + + + add_glabel + + + + + + diff --git a/bitmaps_png/sources/light/text_align_top.svg b/bitmaps_png/sources/light/text_align_top.svg new file mode 100644 index 0000000000..d1709cd95e --- /dev/null +++ b/bitmaps_png/sources/light/text_align_top.svg @@ -0,0 +1,102 @@ + + + + + + + + + + image/svg+xml + + add_glabel + + + + + + + + + + + + + + + add_glabel + + + + + + diff --git a/bitmaps_png/sources/light/text_bold.svg b/bitmaps_png/sources/light/text_bold.svg new file mode 100644 index 0000000000..e7a36d7567 --- /dev/null +++ b/bitmaps_png/sources/light/text_bold.svg @@ -0,0 +1,93 @@ + + + + + + + + + + image/svg+xml + + add_glabel + + + + + + + + + + + + + + + add_glabel + B + diff --git a/bitmaps_png/sources/light/text_horizontal.svg b/bitmaps_png/sources/light/text_horizontal.svg new file mode 100644 index 0000000000..695f867954 --- /dev/null +++ b/bitmaps_png/sources/light/text_horizontal.svg @@ -0,0 +1,93 @@ + + + + + + + + + + image/svg+xml + + add_glabel + + + + + + + + + + + + + + + add_glabel + T + diff --git a/bitmaps_png/sources/light/text_italic.svg b/bitmaps_png/sources/light/text_italic.svg new file mode 100644 index 0000000000..2c0f0c951c --- /dev/null +++ b/bitmaps_png/sources/light/text_italic.svg @@ -0,0 +1,93 @@ + + + + + + + + + + image/svg+xml + + add_glabel + + + + + + + + + + + + + + + add_glabel + I + diff --git a/bitmaps_png/sources/light/text_valign_bottom.svg b/bitmaps_png/sources/light/text_valign_bottom.svg new file mode 100644 index 0000000000..523218c807 --- /dev/null +++ b/bitmaps_png/sources/light/text_valign_bottom.svg @@ -0,0 +1,94 @@ + + + + + + + + + + image/svg+xml + + add_glabel + + + + + + + + + + + + + + + add_glabel + + + + diff --git a/bitmaps_png/sources/light/text_valign_center.svg b/bitmaps_png/sources/light/text_valign_center.svg new file mode 100644 index 0000000000..c942738701 --- /dev/null +++ b/bitmaps_png/sources/light/text_valign_center.svg @@ -0,0 +1,94 @@ + + + + + + + + + + image/svg+xml + + add_glabel + + + + + + + + + + + + + + + add_glabel + + + + diff --git a/bitmaps_png/sources/light/text_valign_top.svg b/bitmaps_png/sources/light/text_valign_top.svg new file mode 100644 index 0000000000..a27b7f25bb --- /dev/null +++ b/bitmaps_png/sources/light/text_valign_top.svg @@ -0,0 +1,94 @@ + + + + + + + + + + image/svg+xml + + add_glabel + + + + + + + + + + + + + + + add_glabel + + + + diff --git a/bitmaps_png/sources/light/text_vertical.svg b/bitmaps_png/sources/light/text_vertical.svg new file mode 100644 index 0000000000..d6a6dab033 --- /dev/null +++ b/bitmaps_png/sources/light/text_vertical.svg @@ -0,0 +1,94 @@ + + + + + + + + + + image/svg+xml + + add_glabel + + + + + + + + + + + + + + + add_glabel + T + diff --git a/common/eda_item.cpp b/common/eda_item.cpp index 34a5b28e3e..5a93f24903 100644 --- a/common/eda_item.cpp +++ b/common/eda_item.cpp @@ -342,6 +342,7 @@ static struct EDA_ITEM_DESC .Map( SCH_BITMAP_T, _HKI( "Bitmap" ) ) .Map( SCH_TEXT_T, _HKI( "Text" ) ) .Map( SCH_LABEL_T, _HKI( "Net Label" ) ) + .Map( SCH_NETCLASS_FLAG_T, _HKI( "Net Class Flag" ) ) .Map( SCH_GLOBAL_LABEL_T, _HKI( "Global Label" ) ) .Map( SCH_HIER_LABEL_T, _HKI( "Hierarchical Label" ) ) .Map( SCH_FIELD_T, _HKI( "Field" ) ) diff --git a/common/layer_id.cpp b/common/layer_id.cpp index 21d33edcd8..da7a960bba 100644 --- a/common/layer_id.cpp +++ b/common/layer_id.cpp @@ -114,6 +114,8 @@ wxString LayerName( int aLayer ) case LAYER_REFERENCEPART: return _( "Symbol references" ); case LAYER_VALUEPART: return _( "Symbol values" ); case LAYER_FIELDS: return _( "Symbol fields" ); + case LAYER_INTERSHEET_REFS: return _( "Sheet references" ); + case LAYER_NETCLASS_REFS: return _( "Net class references" ); case LAYER_DEVICE: return _( "Symbol body outlines" ); case LAYER_DEVICE_BACKGROUND: return _( "Symbol body fills" ); case LAYER_NOTES: return _( "Schematic text && graphics" ); diff --git a/common/settings/builtin_color_themes.h b/common/settings/builtin_color_themes.h index cc83b3c812..cb63efdc2b 100644 --- a/common/settings/builtin_color_themes.h +++ b/common/settings/builtin_color_themes.h @@ -46,6 +46,7 @@ static const std::map s_defaultTheme = { LAYER_GLOBLABEL, CSS_COLOR( 132, 0, 0, 1 ) }, { LAYER_HIERLABEL, CSS_COLOR( 114, 86, 0, 1 ) }, { LAYER_LOCLABEL, CSS_COLOR( 15, 15, 15, 1 ) }, + { LAYER_NETCLASS_REFS, CSS_COLOR( 72, 72, 72, 1 ) }, { LAYER_NOCONNECT, CSS_COLOR( 0, 0, 132, 1 ) }, { LAYER_NOTES, CSS_COLOR( 0, 0, 194, 1 ) }, { LAYER_NOTES_BACKGROUND, CSS_COLOR( 0, 0, 0, 0 ) }, @@ -192,6 +193,7 @@ static const std::map s_classicTheme = { LAYER_GLOBLABEL, COLOR4D( RED ) }, { LAYER_HIERLABEL, COLOR4D( BROWN ) }, { LAYER_LOCLABEL, COLOR4D( BLACK ) }, + { LAYER_NETCLASS_REFS, COLOR4D( BLACK ) }, { LAYER_NOCONNECT, COLOR4D( BLUE ) }, { LAYER_NOTES, COLOR4D( LIGHTBLUE ) }, { LAYER_NOTES_BACKGROUND, COLOR4D( UNSPECIFIED_COLOR ) }, diff --git a/common/settings/color_settings.cpp b/common/settings/color_settings.cpp index 93dbfcfb15..3823597ad3 100644 --- a/common/settings/color_settings.cpp +++ b/common/settings/color_settings.cpp @@ -92,6 +92,7 @@ COLOR_SETTINGS::COLOR_SETTINGS( const wxString& aFilename, bool aAbsolutePath ) CLR( "schematic.label_global", LAYER_GLOBLABEL ); CLR( "schematic.label_hier", LAYER_HIERLABEL ); CLR( "schematic.label_local", LAYER_LOCLABEL ); + CLR( "schematic.netclass_flag", LAYER_NETCLASS_REFS ); CLR( "schematic.no_connect", LAYER_NOCONNECT ); CLR( "schematic.note", LAYER_NOTES ); CLR( "schematic.note_background", LAYER_NOTES_BACKGROUND ); diff --git a/common/tool/selection.cpp b/common/tool/selection.cpp index 65e7ea6386..7805fba153 100644 --- a/common/tool/selection.cpp +++ b/common/tool/selection.cpp @@ -70,7 +70,7 @@ bool SELECTION::Contains( EDA_ITEM* aItem ) const /// Returns the center point of the selection area bounding box. VECTOR2I SELECTION::GetCenter() const { - KICAD_T textTypes[] = { SCH_TEXT_T, SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, EOT }; + KICAD_T textTypes[] = { SCH_TEXT_T, SCH_LABEL_LOCATE_ANY_T, EOT }; bool hasOnlyText = true; // If the selection contains only texts calculate the center as the mean of all positions diff --git a/common/widgets/bitmap_button.cpp b/common/widgets/bitmap_button.cpp index 952992b726..2f52ef70fc 100644 --- a/common/widgets/bitmap_button.cpp +++ b/common/widgets/bitmap_button.cpp @@ -29,6 +29,8 @@ #include #include +#define wxCONTROL_SEPARATOR wxCONTROL_SPECIAL + BITMAP_BUTTON::BITMAP_BUTTON( wxWindow* aParent, wxWindowID aId, const wxPoint& aPos, const wxSize& aSize, int aStyles ) : @@ -38,8 +40,28 @@ BITMAP_BUTTON::BITMAP_BUTTON( wxWindow* aParent, wxWindowID aId, const wxPoint& m_acceptDraggedInClicks( false ) { if( aSize == wxDefaultSize ) - SetMinSize( wxButton::GetDefaultSize() ); + SetMinSize( wxButton::GetDefaultSize() + wxSize( m_padding * 2, m_padding * 2) ); + setupEvents(); +} + + +BITMAP_BUTTON::BITMAP_BUTTON( wxWindow* aParent, wxWindowID aId, const wxBitmap& aDummyBitmap, + const wxPoint& aPos, const wxSize& aSize, int aStyles ) : + wxPanel( aParent, aId, aPos, aSize, aStyles ), + m_buttonState( 0 ), + m_padding( 5 ), + m_acceptDraggedInClicks( false ) +{ + if( aSize == wxDefaultSize ) + SetMinSize( wxButton::GetDefaultSize() + wxSize( m_padding * 2, m_padding * 2) ); + + setupEvents(); +} + + +void BITMAP_BUTTON::setupEvents() +{ Bind( wxEVT_PAINT, &BITMAP_BUTTON::OnPaint, this ); Bind( wxEVT_LEFT_UP, &BITMAP_BUTTON::OnLeftButtonUp, this ); Bind( wxEVT_LEFT_DOWN, &BITMAP_BUTTON::OnLeftButtonDown, this ); @@ -58,7 +80,7 @@ BITMAP_BUTTON::~BITMAP_BUTTON() void BITMAP_BUTTON::SetPadding( int aPadding ) { m_padding = aPadding; - SetMinSize( m_unadjustedMinSize + wxSize( aPadding * 2, aPadding * 2) ); + SetMinSize( m_unadjustedMinSize + wxSize( aPadding * 2, aPadding * 2 ) ); } @@ -109,7 +131,9 @@ void BITMAP_BUTTON::OnKillFocus( wxEvent& aEvent ) void BITMAP_BUTTON::OnSetFocus( wxEvent& aEvent ) { - setFlag( wxCONTROL_FOCUSED ); + if( !hasFlag( wxCONTROL_CHECKABLE ) ) + setFlag( wxCONTROL_FOCUSED ); + Refresh(); aEvent.Skip(); } @@ -119,19 +143,15 @@ void BITMAP_BUTTON::OnLeftButtonUp( wxMouseEvent& aEvent ) { // Only create a button event when the control is enabled // and only accept clicks that came without prior mouse-down if configured - if( !hasFlag( wxCONTROL_DISABLED ) && - ( m_acceptDraggedInClicks || hasFlag( wxCONTROL_PRESSED | wxCONTROL_FOCUSED ) ) ) + if( !hasFlag( wxCONTROL_DISABLED ) + && ( m_acceptDraggedInClicks || hasFlag( wxCONTROL_PRESSED | wxCONTROL_FOCUSED ) ) ) { - wxEvtHandler* pEventHandler = GetEventHandler(); - wxASSERT( pEventHandler ); - - pEventHandler->CallAfter( - [=]() - { - wxCommandEvent evt( wxEVT_BUTTON, GetId() ); - evt.SetEventObject( this ); - GetEventHandler()->ProcessEvent( evt ); - } ); + GetEventHandler()->CallAfter( [=]() + { + wxCommandEvent evt( wxEVT_BUTTON, GetId() ); + evt.SetEventObject( this ); + GetEventHandler()->ProcessEvent( evt ); + } ); } clearFlag( wxCONTROL_PRESSED ); @@ -143,7 +163,29 @@ void BITMAP_BUTTON::OnLeftButtonUp( wxMouseEvent& aEvent ) void BITMAP_BUTTON::OnLeftButtonDown( wxMouseEvent& aEvent ) { - setFlag( wxCONTROL_PRESSED ); + if( hasFlag( wxCONTROL_CHECKABLE ) ) + { + if( hasFlag( wxCONTROL_CHECKED ) ) + { + clearFlag( wxCONTROL_CHECKED ); + } + else + { + setFlag( wxCONTROL_CHECKED ); + + GetEventHandler()->CallAfter( [=]() + { + wxCommandEvent evt( wxEVT_BUTTON, GetId() ); + evt.SetEventObject( this ); + GetEventHandler()->ProcessEvent( evt ); + } ); + } + } + else + { + setFlag( wxCONTROL_PRESSED ); + } + Refresh(); aEvent.Skip(); @@ -159,6 +201,13 @@ void BITMAP_BUTTON::OnPaint( wxPaintEvent& aEvent ) wxRect rect( wxPoint( 0, 0 ), GetSize() ); wxPaintDC dc( this ); + if( hasFlag( wxCONTROL_SEPARATOR ) ) + { + dc.SetPen( wxPen( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) ) ); + dc.DrawLine( wxPoint( GetSize().x / 2, 0 ), wxPoint( GetSize().x / 2, GetSize().y ) ); + return; + } + // This drawing is done so the button looks the same as an AUI toolbar button if( !hasFlag( wxCONTROL_DISABLED ) ) { @@ -214,8 +263,23 @@ bool BITMAP_BUTTON::Enable( bool aEnable ) } +void BITMAP_BUTTON::SetIsCheckButton() +{ + setFlag( wxCONTROL_CHECKABLE ); +} + + +void BITMAP_BUTTON::SetIsSeparator() +{ + setFlag( wxCONTROL_SEPARATOR | wxCONTROL_DISABLED ); + SetMinSize( wxSize( m_padding * 2, wxButton::GetDefaultSize().y ) ); +} + + void BITMAP_BUTTON::Check( bool aCheck ) { + wxASSERT_MSG( hasFlag( wxCONTROL_CHECKABLE ), "Button is not a checkButton." ); + if( aCheck ) setFlag( wxCONTROL_CHECKED ); else @@ -223,3 +287,11 @@ void BITMAP_BUTTON::Check( bool aCheck ) Refresh(); } + + +bool BITMAP_BUTTON::IsChecked() const +{ + wxASSERT_MSG( hasFlag( wxCONTROL_CHECKABLE ), "Button is not a checkButton." ); + + return hasFlag( wxCONTROL_CHECKED ); +} \ No newline at end of file diff --git a/common/widgets/grid_combobox.cpp b/common/widgets/grid_combobox.cpp index 80f12907f7..1ccc3c2a5d 100644 --- a/common/widgets/grid_combobox.cpp +++ b/common/widgets/grid_combobox.cpp @@ -90,6 +90,9 @@ void GRID_CELL_COMBOBOX::BeginEdit( int aRow, int aCol, wxGrid* aGrid ) // Work around a wxWidgets bug where the drop-down is the wrong width on the first drop. Combo()->Set( Combo()->GetStrings() ); + Combo()->ChangeValue( m_value ); + Combo()->SelectAll(); + #ifdef __WXOSX_COCOA__ // This is a work around for the combobox being simply dismissed when a // choice is made in it under OS X. The bug is almost certainly due to a diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 4918e0ec35..52f9116560 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -67,6 +67,8 @@ set( EESCHEMA_DLGS dialogs/dialog_global_edit_text_and_graphics_base.cpp dialogs/dialog_junction_props.cpp dialogs/dialog_junction_props_base.cpp + dialogs/dialog_label_properties.cpp + dialogs/dialog_label_properties_base.cpp dialogs/dialog_lib_edit_pin_table.cpp dialogs/dialog_lib_edit_pin_table_base.cpp dialogs/dialog_lib_text_properties.cpp @@ -106,8 +108,8 @@ set( EESCHEMA_DLGS dialogs/dialog_symbol_properties_base.cpp dialogs/dialog_symbol_remap.cpp dialogs/dialog_symbol_remap_base.cpp - dialogs/dialog_text_and_label_properties.cpp - dialogs/dialog_text_and_label_properties_base.cpp + dialogs/dialog_text_properties.cpp + dialogs/dialog_text_properties_base.cpp dialogs/dialog_update_from_pcb.cpp dialogs/dialog_update_from_pcb_base.cpp dialogs/dialog_update_symbol_fields.cpp diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 6e25ddb25f..75a656588b 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -119,7 +119,7 @@ bool CONNECTION_SUBGRAPH::ResolveDrivers( bool aCheckMultipleDrivers ) { SCH_SHEET_PIN* p = static_cast( c ); - if( p->GetShape() == PINSHEETLABEL_SHAPE::PS_OUTPUT ) + if( p->GetShape() == LABEL_FLAG_SHAPE::L_OUTPUT ) { m_driver = c; break; @@ -258,7 +258,8 @@ std::vector CONNECTION_SUBGRAPH::GetBusLabels() const break; } - default: break; + default: + break; } } diff --git a/eeschema/dialogs/dialog_field_properties.cpp b/eeschema/dialogs/dialog_field_properties.cpp index 0e18219a87..3896bc64cb 100644 --- a/eeschema/dialogs/dialog_field_properties.cpp +++ b/eeschema/dialogs/dialog_field_properties.cpp @@ -23,6 +23,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include #include #include @@ -69,6 +70,51 @@ DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES( SCH_BASE_FRAME* aParent, const } ); m_StyledTextCtrl->SetEOLMode( wxSTC_EOL_LF ); // Normalize EOL across platforms + m_separator1->SetIsSeparator(); + + m_horizontal->SetIsCheckButton(); + m_horizontal->SetBitmap( KiBitmap( BITMAPS::text_horizontal ) ); + m_vertical->SetIsCheckButton(); + m_vertical->SetBitmap( KiBitmap( BITMAPS::text_vertical ) ); + + m_separator2->SetIsSeparator(); + + m_bold->SetIsCheckButton(); + m_bold->SetBitmap( KiBitmap( BITMAPS::text_bold ) ); + m_italic->SetIsCheckButton(); + m_italic->SetBitmap( KiBitmap( BITMAPS::text_italic ) ); + + m_separator3->SetIsSeparator(); + + m_hAlignLeft->SetIsCheckButton(); + m_hAlignLeft->SetBitmap( KiBitmap( BITMAPS::text_align_left ) ); + m_hAlignCenter->SetIsCheckButton(); + m_hAlignCenter->SetBitmap( KiBitmap( BITMAPS::text_align_center ) ); + m_hAlignRight->SetIsCheckButton(); + m_hAlignRight->SetBitmap( KiBitmap( BITMAPS::text_align_right ) ); + + m_separator4->SetIsSeparator(); + + m_vAlignTop->SetIsCheckButton(); + m_vAlignTop->SetBitmap( KiBitmap( BITMAPS::text_valign_top ) ); + m_vAlignCenter->SetIsCheckButton(); + m_vAlignCenter->SetBitmap( KiBitmap( BITMAPS::text_valign_center ) ); + m_vAlignBottom->SetIsCheckButton(); + m_vAlignBottom->SetBitmap( KiBitmap( BITMAPS::text_valign_bottom ) ); + + m_separator5->SetIsSeparator(); + + m_horizontal->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onOrientButton, this ); + m_vertical->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onOrientButton, this ); + + m_hAlignLeft->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this ); + m_hAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this ); + m_hAlignRight->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this ); + + m_vAlignTop->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this ); + m_vAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this ); + m_vAlignBottom->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this ); + m_text = aTextItem->GetText(); m_isItalic = aTextItem->IsItalic(); m_isBold = aTextItem->IsBold(); @@ -210,6 +256,36 @@ void DIALOG_FIELD_PROPERTIES::OnSetFocusText( wxFocusEvent& event ) } +void DIALOG_FIELD_PROPERTIES::onOrientButton( wxCommandEvent& aEvent ) +{ + for( BITMAP_BUTTON* btn : { m_horizontal, m_vertical } ) + { + if( btn->IsChecked() && btn != aEvent.GetEventObject() ) + btn->Check( false ); + } +} + + +void DIALOG_FIELD_PROPERTIES::onHAlignButton( wxCommandEvent& aEvent ) +{ + for( BITMAP_BUTTON* btn : { m_hAlignLeft, m_hAlignCenter, m_hAlignRight } ) + { + if( btn->IsChecked() && btn != aEvent.GetEventObject() ) + btn->Check( false ); + } +} + + +void DIALOG_FIELD_PROPERTIES::onVAlignButton( wxCommandEvent& aEvent ) +{ + for( BITMAP_BUTTON* btn : { m_vAlignTop, m_vAlignTop, m_vAlignBottom } ) + { + if( btn->IsChecked() && btn != aEvent.GetEventObject() ) + btn->Check( false ); + } +} + + bool DIALOG_FIELD_PROPERTIES::TransferDataToWindow() { if( m_TextCtrl->IsShown() ) @@ -220,12 +296,28 @@ bool DIALOG_FIELD_PROPERTIES::TransferDataToWindow() m_posX.SetValue( m_position.x ); m_posY.SetValue( m_position.y ); m_textSize.SetValue( m_size ); - m_orientChoice->SetSelection( m_isVertical ? 1 : 0 ); - m_hAlignChoice->SetSelection( m_horizontalJustification ); - m_vAlignChoice->SetSelection( m_verticalJustification ); + + m_horizontal->Check( !m_isVertical ); + m_vertical->Check( m_isVertical ); + + m_italic->Check( m_isItalic ); + m_bold->Check( m_isBold ); + + switch ( m_horizontalJustification ) + { + case GR_TEXT_HJUSTIFY_LEFT: m_hAlignLeft->Check( true ); break; + case GR_TEXT_HJUSTIFY_CENTER: m_hAlignCenter->Check( true ); break; + case GR_TEXT_HJUSTIFY_RIGHT: m_hAlignRight->Check( true ); break; + } + + switch ( m_verticalJustification ) + { + case GR_TEXT_VJUSTIFY_TOP: m_vAlignTop->Check( true ); break; + case GR_TEXT_VJUSTIFY_CENTER: m_vAlignCenter->Check( true ); break; + case GR_TEXT_VJUSTIFY_BOTTOM: m_vAlignBottom->Check( true ); break; + } + m_visible->SetValue( m_isVisible ); - m_italic->SetValue( m_isItalic ); - m_bold->SetValue( m_isBold ); return true; } @@ -268,14 +360,29 @@ bool DIALOG_FIELD_PROPERTIES::TransferDataFromWindow() } } - m_isVertical = m_orientChoice->GetSelection() == 1; m_position = wxPoint( m_posX.GetValue(), m_posY.GetValue() ); m_size = m_textSize.GetValue(); - m_horizontalJustification = m_hAlignChoice->GetSelection(); - m_verticalJustification = m_vAlignChoice->GetSelection(); + + m_isVertical = m_vertical->IsChecked(); + + m_isBold = m_bold->IsChecked(); + m_isItalic = m_italic->IsChecked(); + + if( m_hAlignLeft->IsChecked() ) + m_horizontalJustification = GR_TEXT_HJUSTIFY_LEFT; + else if( m_hAlignCenter->IsChecked() ) + m_horizontalJustification = GR_TEXT_HJUSTIFY_CENTER; + else + m_horizontalJustification = GR_TEXT_HJUSTIFY_RIGHT; + + if( m_vAlignTop->IsChecked() ) + m_verticalJustification = GR_TEXT_VJUSTIFY_TOP; + else if( m_vAlignCenter->IsChecked() ) + m_verticalJustification = GR_TEXT_VJUSTIFY_CENTER; + else + m_verticalJustification = GR_TEXT_VJUSTIFY_BOTTOM; + m_isVisible = m_visible->GetValue(); - m_isItalic = m_italic->GetValue(); - m_isBold = m_bold->GetValue(); return true; } diff --git a/eeschema/dialogs/dialog_field_properties.h b/eeschema/dialogs/dialog_field_properties.h index bd1df2df43..443d8d6498 100644 --- a/eeschema/dialogs/dialog_field_properties.h +++ b/eeschema/dialogs/dialog_field_properties.h @@ -80,6 +80,11 @@ protected: */ virtual void OnSetFocusText( wxFocusEvent& event ) override; + void onOrientButton( wxCommandEvent &aEvent ); + void onHAlignButton( wxCommandEvent &aEvent ); + void onVAlignButton( wxCommandEvent &aEvent ); + +protected: UNIT_BINDER m_posX; UNIT_BINDER m_posY; UNIT_BINDER m_textSize; diff --git a/eeschema/dialogs/dialog_label_properties.cpp b/eeschema/dialogs/dialog_label_properties.cpp new file mode 100644 index 0000000000..445dce2fc1 --- /dev/null +++ b/eeschema/dialogs/dialog_label_properties.cpp @@ -0,0 +1,696 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2013 Wayne Stambaugh + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * + * 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; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class SCH_EDIT_FRAME; +class SCH_TEXT; + + +DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_LABEL_BASE* aLabel ) : + DIALOG_LABEL_PROPERTIES_BASE( aParent ), + m_activeTextEntry( nullptr ), + m_netNameValidator( true ), + m_fields( nullptr ), + m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, false ), + m_helpWindow( nullptr ) +{ + m_Parent = aParent; + m_currentLabel = aLabel; + + m_fields = new FIELDS_GRID_TABLE( this, aParent, m_grid, m_currentLabel ); + m_width = 100; // Will be later set to a better value + m_delayedFocusRow = -1; + m_delayedFocusColumn = FDC_VALUE; + + if( m_currentLabel->Type() == SCH_GLOBAL_LABEL_T || m_currentLabel->Type() == SCH_LABEL_T ) + { + m_activeTextEntry = m_valueCombo; + SetInitialFocus( m_valueCombo ); + + m_labelSingleLine->Show( false ); + m_valueSingleLine->Show( false ); + + m_valueCombo->SetValidator( m_netNameValidator ); + } + else if( m_currentLabel->Type() == SCH_HIER_LABEL_T ) + { + m_activeTextEntry = m_valueSingleLine; + SetInitialFocus( m_valueSingleLine ); + + m_labelCombo->Show( false ); + m_valueCombo->Show( false ); + + m_valueSingleLine->SetValidator( m_netNameValidator ); + } + else if( m_currentLabel->Type() == SCH_NETCLASS_FLAG_T ) + { + SetInitialFocus( m_grid ); + m_delayedFocusRow = 0; + + m_labelSingleLine->Show( false ); + m_valueSingleLine->Show( false ); + m_labelCombo->Show( false ); + m_valueCombo->Show( false ); + m_syntaxHelp->Show( false ); + + m_textSizeLabel->SetLabel( _( "Pin length:" ) ); + } + + switch( m_currentLabel->Type() ) + { + case SCH_GLOBAL_LABEL_T: SetTitle( _( "Global Label Properties" ) ); break; + case SCH_HIER_LABEL_T: SetTitle( _( "Hierarchical Label Properties" ) ); break; + case SCH_LABEL_T: SetTitle( _( "Label Properties" ) ); break; + case SCH_NETCLASS_FLAG_T: SetTitle( _( "Net Class Flag Properties" ) ); break; + case SCH_SHEET_PIN_T: SetTitle( _( "Hierarchical Sheet Pin Properties" ) ); break; + default: UNIMPLEMENTED_FOR( m_currentLabel->GetClass() ); break; + } + + // Give a bit more room for combobox editors + m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 ); + + m_grid->SetTable( m_fields ); + m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) ); + m_grid->SetSelectionMode( wxGrid::wxGridSelectRows ); + + // Show/hide columns according to user's preference + auto cfg = dynamic_cast( Kiface().KifaceSettings() ); + wxASSERT( cfg ); + + if( cfg ) + { + m_shownColumns = cfg->m_Appearance.edit_label_visible_columns; + m_grid->ShowHideColumns( m_shownColumns ); + } + + // Configure button logos + m_bpAdd->SetBitmap( KiBitmap( BITMAPS::small_plus ) ); + m_bpDelete->SetBitmap( KiBitmap( BITMAPS::small_trash ) ); + m_bpMoveUp->SetBitmap( KiBitmap( BITMAPS::small_up ) ); + m_bpMoveDown->SetBitmap( KiBitmap( BITMAPS::small_down ) ); + + m_separator1->SetIsSeparator(); + + m_bold->SetIsCheckButton(); + m_bold->SetBitmap( KiBitmap( BITMAPS::text_bold ) ); + m_italic->SetIsCheckButton(); + m_italic->SetBitmap( KiBitmap( BITMAPS::text_italic ) ); + + m_separator2->SetIsSeparator(); + + m_spin0->SetIsCheckButton(); + m_spin1->SetIsCheckButton(); + m_spin2->SetIsCheckButton(); + m_spin3->SetIsCheckButton(); + + m_separator3->SetIsSeparator(); + + // Show/hide relevant controls + if( m_currentLabel->Type() == SCH_GLOBAL_LABEL_T || m_currentLabel->Type() == SCH_HIER_LABEL_T ) + { + m_dot->Hide(); + m_circle->Hide(); + m_diamond->Hide(); + m_rectangle->Hide(); + + m_spin0->SetBitmap( KiBitmap( BITMAPS::label_align_left ) ); + m_spin1->SetBitmap( KiBitmap( BITMAPS::label_align_right ) ); + m_spin2->SetBitmap( KiBitmap( BITMAPS::label_align_bottom ) ); + m_spin3->SetBitmap( KiBitmap( BITMAPS::label_align_top ) ); + } + else if( m_currentLabel->Type() == SCH_NETCLASS_FLAG_T ) + { + m_input->Hide(); + m_output->Hide(); + m_bidirectional->Hide(); + m_triState->Hide(); + m_passive->Hide(); + + m_spin0->SetBitmap( KiBitmap( BITMAPS::pinorient_down ) ); + m_spin1->SetBitmap( KiBitmap( BITMAPS::pinorient_up ) ); + m_spin2->SetBitmap( KiBitmap( BITMAPS::pinorient_right ) ); + m_spin3->SetBitmap( KiBitmap( BITMAPS::pinorient_left ) ); + } + else + { + m_shapeSizer->Show( false ); + + m_spin0->SetBitmap( KiBitmap( BITMAPS::text_align_left ) ); + m_spin1->SetBitmap( KiBitmap( BITMAPS::text_align_right ) ); + m_spin2->SetBitmap( KiBitmap( BITMAPS::text_align_bottom ) ); + m_spin3->SetBitmap( KiBitmap( BITMAPS::text_align_top ) ); + } + + m_sdbSizer1OK->SetDefault(); + + // DIALOG_SHIM needs a unique hash_key because classname is not sufficient because the + // various versions have different controls so we want to store sizes for each version. + m_hash_key = TO_UTF8( GetTitle() ); + + m_spin0->Bind( wxEVT_BUTTON, &DIALOG_LABEL_PROPERTIES::onSpinButton, this ); + m_spin1->Bind( wxEVT_BUTTON, &DIALOG_LABEL_PROPERTIES::onSpinButton, this ); + m_spin2->Bind( wxEVT_BUTTON, &DIALOG_LABEL_PROPERTIES::onSpinButton, this ); + m_spin3->Bind( wxEVT_BUTTON, &DIALOG_LABEL_PROPERTIES::onSpinButton, this ); + + // Now all widgets have the size fixed, call FinishDialogSettings + finishDialogSettings(); +} + + +DIALOG_LABEL_PROPERTIES::~DIALOG_LABEL_PROPERTIES() +{ + auto cfg = dynamic_cast( Kiface().KifaceSettings() ); + wxASSERT( cfg ); + + if( cfg ) + cfg->m_Appearance.edit_sheet_visible_columns = m_grid->GetShownColumns(); + + // Prevents crash bug in wxGrid's d'tor + m_grid->DestroyTable( m_fields ); + + // Delete the GRID_TRICKS. + m_grid->PopEventHandler( true ); + + if( m_helpWindow ) + m_helpWindow->Destroy(); +} + + +bool DIALOG_LABEL_PROPERTIES::TransferDataToWindow() +{ + if( !wxDialog::TransferDataToWindow() ) + return false; + + if( m_activeTextEntry ) + { + // show control characters in a human-readable format + m_activeTextEntry->SetValue( UnescapeString( m_currentLabel->GetText() ) ); + } + + if( m_currentLabel->Type() == SCH_GLOBAL_LABEL_T || m_currentLabel->Type() == SCH_LABEL_T ) + { + // Load the combobox with the existing labels of the same type + std::set existingLabels; + SCH_SCREENS allScreens( m_Parent->Schematic().Root() ); + + for( SCH_SCREEN* screen = allScreens.GetFirst(); screen; screen = allScreens.GetNext() ) + { + for( SCH_ITEM* item : screen->Items().OfType( m_currentLabel->Type() ) ) + { + const SCH_TEXT* textItem = static_cast( item ); + existingLabels.insert( UnescapeString( textItem->GetText() ) ); + } + } + + wxArrayString existingLabelArray; + + for( const wxString& label : existingLabels ) + existingLabelArray.push_back( label ); + + m_valueCombo->Append( existingLabelArray ); + } + else if( m_currentLabel->Type() == SCH_NETCLASS_FLAG_T ) + { + // Load the combobox with existing existingNetclassNames + NET_SETTINGS& netSettings = m_Parent->Schematic().Prj().GetProjectFile().NetSettings(); + wxArrayString existingNetclassNames; + + existingNetclassNames.push_back( netSettings.m_NetClasses.GetDefault()->GetName() ); + + for( const std::pair& pair : netSettings.m_NetClasses ) + existingNetclassNames.push_back( pair.second->GetName() ); + + m_valueCombo->Append( existingNetclassNames ); + } + + // Push a copy of each field into m_updateFields + for( SCH_FIELD& field : m_currentLabel->GetFields() ) + { + SCH_FIELD field_copy( field ); + + // change offset to be symbol-relative + field_copy.Offset( -m_currentLabel->GetPosition() ); + + m_fields->push_back( field_copy ); + } + + // notify the grid + wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->size() ); + m_grid->ProcessTableMessage( msg ); + AdjustGridColumns( m_grid->GetRect().GetWidth() ); + + if( m_shapeSizer->AreAnyItemsShown() ) + { + switch( m_currentLabel->GetShape() ) + { + case LABEL_FLAG_SHAPE::L_INPUT: m_input->SetValue( true ); break; + case LABEL_FLAG_SHAPE::L_OUTPUT: m_output->SetValue( true ); break; + case LABEL_FLAG_SHAPE::L_BIDI: m_bidirectional->SetValue( true ); break; + case LABEL_FLAG_SHAPE::L_TRISTATE: m_triState->SetValue( true ); break; + case LABEL_FLAG_SHAPE::L_UNSPECIFIED: m_passive->SetValue( true ); break; + case LABEL_FLAG_SHAPE::F_DOT: m_dot->SetValue( true ); break; + case LABEL_FLAG_SHAPE::F_ROUND: m_circle->SetValue( true ); break; + case LABEL_FLAG_SHAPE::F_DIAMOND: m_diamond->SetValue( true ); break; + case LABEL_FLAG_SHAPE::F_RECTANGLE: m_rectangle->SetValue( true ); break; + } + } + + if( m_currentLabel->Type() == SCH_NETCLASS_FLAG_T ) + m_textSize.SetValue( static_cast( m_currentLabel )->GetPinLength() ); + else + m_textSize.SetValue( m_currentLabel->GetTextWidth() ); + + m_bold->Check( m_currentLabel->IsBold() ); + m_italic->Check( m_currentLabel->IsItalic() ); + + switch( m_currentLabel->GetLabelSpinStyle() ) + { + case LABEL_SPIN_STYLE::RIGHT: m_spin0->Check( true ); break; + case LABEL_SPIN_STYLE::LEFT: m_spin1->Check( true ); break; + case LABEL_SPIN_STYLE::UP: m_spin2->Check( true ); break; + case LABEL_SPIN_STYLE::BOTTOM: m_spin3->Check( true ); break; + } + + return true; +} + + +/*! + * wxEVT_COMMAND_ENTER event handler for single-line control + */ +void DIALOG_LABEL_PROPERTIES::OnEnterKey( wxCommandEvent& aEvent ) +{ + wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); +} + + +static bool positioningChanged( const SCH_FIELD& a, const SCH_FIELD& b ) +{ + if( a.GetPosition() != b.GetPosition() ) + return true; + + if( a.GetHorizJustify() != b.GetHorizJustify() ) + return true; + + if( a.GetVertJustify() != b.GetVertJustify() ) + return true; + + if( a.GetTextAngle() != b.GetTextAngle() ) + return true; + + return false; +} + + +static bool positioningChanged( FIELDS_GRID_TABLE* a, std::vector& b ) +{ + for( size_t i = 0; i < a->size() && i < b.size(); ++i ) + { + if( positioningChanged( a->at( i ), b.at( i ) ) ) + return true; + } + + return false; +} + + +bool DIALOG_LABEL_PROPERTIES::TransferDataFromWindow() +{ + if( !m_grid->CommitPendingChanges() ) + return false; + + if( !wxDialog::TransferDataFromWindow() ) + return false; + + // Don't allow text to disappear; it can be difficult to correct if you can't select it + if( !m_textSize.Validate( 0.01, 1000.0, EDA_UNITS::MILLIMETRES ) ) + return false; + + wxString text; + + /* save old text in undo list if not already in edit */ + if( m_currentLabel->GetEditFlags() == 0 ) + { + m_Parent->SaveCopyInUndoList( m_Parent->GetScreen(), m_currentLabel, UNDO_REDO::CHANGED, + false ); + } + + m_Parent->GetCanvas()->Refresh(); + + if( m_activeTextEntry ) + { + // labels need escaping + text = EscapeString( m_activeTextEntry->GetValue(), CTX_NETNAME ); + +#ifdef __WXMAC__ + // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting + text.Replace( "\r", "\n" ); +#endif + + if( text.IsEmpty() && !m_currentLabel->IsNew() ) + { + DisplayError( this, _( "Label can not be empty." ) ); + return false; + } + + m_currentLabel->SetText( text ); + } + + bool doAutoplace = false; + + // change all field positions from relative to absolute + for( SCH_FIELD& field : *m_fields ) + { + field.Offset( m_currentLabel->GetPosition() ); + + if( field.GetCanonicalName() == wxT( "Netclass" ) ) + field.SetLayer( LAYER_NETCLASS_REFS ); + else if( field.GetCanonicalName() == wxT( "Intersheetrefs" ) ) + field.SetLayer( LAYER_INTERSHEET_REFS ); + else + field.SetLayer( LAYER_FIELDS ); + } + + if( positioningChanged( m_fields, m_currentLabel->GetFields() ) ) + m_currentLabel->ClearFieldsAutoplaced(); + else + doAutoplace = true; + + m_currentLabel->SetFields( *m_fields ); + + if( m_shapeSizer->AreAnyItemsShown() ) + { + if( m_input->GetValue() ) + m_currentLabel->SetShape( LABEL_FLAG_SHAPE::L_INPUT ); + else if( m_output->GetValue() ) + m_currentLabel->SetShape( LABEL_FLAG_SHAPE::L_OUTPUT ); + else if( m_bidirectional->GetValue() ) + m_currentLabel->SetShape( LABEL_FLAG_SHAPE::L_BIDI ); + else if( m_triState->GetValue() ) + m_currentLabel->SetShape( LABEL_FLAG_SHAPE::L_TRISTATE ); + else if( m_passive->GetValue() ) + m_currentLabel->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED ); + else if( m_dot->GetValue() ) + m_currentLabel->SetShape( LABEL_FLAG_SHAPE::F_DOT ); + else if( m_circle->GetValue() ) + m_currentLabel->SetShape( LABEL_FLAG_SHAPE::F_ROUND ); + else if( m_diamond->GetValue() ) + m_currentLabel->SetShape( LABEL_FLAG_SHAPE::F_DIAMOND ); + else if( m_rectangle->GetValue() ) + m_currentLabel->SetShape( LABEL_FLAG_SHAPE::F_RECTANGLE ); + } + + if( m_currentLabel->Type() == SCH_NETCLASS_FLAG_T ) + static_cast( m_currentLabel )->SetPinLength( m_textSize.GetValue() ); + else if( m_currentLabel->GetTextWidth() != m_textSize.GetValue() ) + m_currentLabel->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) ); + + if( m_bold->IsChecked() != m_currentLabel->IsBold() ) + { + if( m_bold->IsChecked() ) + { + m_currentLabel->SetBold( true ); + m_currentLabel->SetTextThickness( GetPenSizeForBold( m_currentLabel->GetTextWidth() ) ); + } + else + { + m_currentLabel->SetBold( false ); + m_currentLabel->SetTextThickness( 0 ); // Use default pen width + } + } + + m_currentLabel->SetItalic( m_italic->IsChecked() ); + + LABEL_SPIN_STYLE selectedSpinStyle= LABEL_SPIN_STYLE::LEFT; + + if( m_spin0->IsChecked() ) + selectedSpinStyle = LABEL_SPIN_STYLE::RIGHT; + else if( m_spin1->IsChecked() ) + selectedSpinStyle = LABEL_SPIN_STYLE::LEFT; + else if( m_spin2->IsChecked() ) + selectedSpinStyle = LABEL_SPIN_STYLE::UP; + else if( m_spin3->IsChecked() ) + selectedSpinStyle = LABEL_SPIN_STYLE::BOTTOM; + + if( m_currentLabel->GetLabelSpinStyle() != selectedSpinStyle ) + m_currentLabel->SetLabelSpinStyle( selectedSpinStyle ); + + if( doAutoplace ) + m_currentLabel->AutoAutoplaceFields( m_Parent->GetScreen() ); + + m_Parent->UpdateItem( m_currentLabel ); + m_Parent->GetCanvas()->Refresh(); + m_Parent->OnModify(); + + return true; +} + + +void DIALOG_LABEL_PROPERTIES::onSpinButton( wxCommandEvent& aEvent ) +{ + for( BITMAP_BUTTON* btn : { m_spin0, m_spin1, m_spin2, m_spin3 } ) + { + if( btn->IsChecked() && btn != aEvent.GetEventObject() ) + btn->Check( false ); + } +} + + +void DIALOG_LABEL_PROPERTIES::OnFormattingHelp( wxHyperlinkEvent& aEvent ) +{ + m_helpWindow = SCH_TEXT::ShowSyntaxHelp( this ); +} + + +void DIALOG_LABEL_PROPERTIES::OnAddField( wxCommandEvent& event ) +{ + if( !m_grid->CommitPendingChanges() ) + return; + + int fieldID = m_fields->size(); + wxString fieldName; + + if( (int) fieldID == m_currentLabel->GetMandatoryFieldCount() + || m_fields->at( m_fields->size()-1 ).GetCanonicalName() == wxT( "Netclass" ) ) + { + fieldName = wxT( "Netclass" ); + } + else + { + fieldName = SCH_LABEL_BASE::GetDefaultFieldName( fieldName, true ); + } + + SCH_FIELD newField( wxPoint( 0, 0 ), fieldID, m_currentLabel, fieldName ); + + if( m_fields->size() > 0 ) + { + newField.SetVisible( m_fields->at( m_fields->size() - 1 ).IsVisible() ); + newField.SetTextAngle( m_fields->at( m_fields->size() - 1 ).GetTextAngle() ); + newField.SetItalic( m_fields->at( m_fields->size() - 1 ).IsItalic() ); + newField.SetBold( m_fields->at( m_fields->size() - 1 ).IsBold() ); + } + else + { + newField.SetVisible( true ); + newField.SetItalic( true ); + } + + m_fields->push_back( newField ); + + // notify the grid + wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 ); + m_grid->ProcessTableMessage( msg ); + + m_grid->MakeCellVisible( m_fields->size() - 1, 0 ); + m_grid->SetGridCursor( m_fields->size() - 1, fieldName == wxT( "Netclass" ) ? 1 : 0 ); + + m_grid->EnableCellEditControl(); + m_grid->ShowCellEditControl(); +} + + +void DIALOG_LABEL_PROPERTIES::OnDeleteField( wxCommandEvent& event ) +{ + wxArrayInt selectedRows = m_grid->GetSelectedRows(); + + if( selectedRows.empty() && m_grid->GetGridCursorRow() >= 0 ) + selectedRows.push_back( m_grid->GetGridCursorRow() ); + + if( selectedRows.empty() ) + return; + + for( int row : selectedRows ) + { + if( row < m_currentLabel->GetMandatoryFieldCount() ) + { + DisplayError( this, _( "The first field is mandatory." ) ); + return; + } + } + + m_grid->CommitPendingChanges( true /* quiet mode */ ); + + // Reverse sort so deleting a row doesn't change the indexes of the other rows. + selectedRows.Sort( []( int* first, int* second ) { return *second - *first; } ); + + for( int row : selectedRows ) + { + m_fields->erase( m_fields->begin() + row ); + + // notify the grid + wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 ); + m_grid->ProcessTableMessage( msg ); + + if( m_grid->GetNumberRows() > 0 ) + { + m_grid->MakeCellVisible( std::max( 0, row-1 ), m_grid->GetGridCursorCol() ); + m_grid->SetGridCursor( std::max( 0, row-1 ), m_grid->GetGridCursorCol() ); + } + } +} + + +void DIALOG_LABEL_PROPERTIES::OnMoveUp( wxCommandEvent& event ) +{ + if( !m_grid->CommitPendingChanges() ) + return; + + int i = m_grid->GetGridCursorRow(); + + if( i > m_currentLabel->GetMandatoryFieldCount() ) + { + SCH_FIELD tmp = m_fields->at( (unsigned) i ); + m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 ); + m_fields->insert( m_fields->begin() + i - 1, tmp ); + m_grid->ForceRefresh(); + + m_grid->SetGridCursor( i - 1, m_grid->GetGridCursorCol() ); + m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() ); + } + else + { + wxBell(); + } +} + + +void DIALOG_LABEL_PROPERTIES::OnMoveDown( wxCommandEvent& event ) +{ + if( !m_grid->CommitPendingChanges() ) + return; + + int i = m_grid->GetGridCursorRow(); + + if( i >= m_currentLabel->GetMandatoryFieldCount() && i < m_grid->GetNumberRows() - 1 ) + { + SCH_FIELD tmp = m_fields->at( (unsigned) i ); + m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 ); + m_fields->insert( m_fields->begin() + i + 1, tmp ); + m_grid->ForceRefresh(); + + m_grid->SetGridCursor( i + 1, m_grid->GetGridCursorCol() ); + m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() ); + } + else + { + wxBell(); + } +} + + +void DIALOG_LABEL_PROPERTIES::AdjustGridColumns( int aWidth ) +{ + m_width = aWidth; + // Account for scroll bars + aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x ); + + m_grid->AutoSizeColumn( 0 ); + m_grid->SetColSize( 0, std::max( m_grid->GetColSize( 0 ), 72 ) ); + + int fixedColsWidth = m_grid->GetColSize( 0 ); + + for( int i = 2; i < m_grid->GetNumberCols(); i++ ) + fixedColsWidth += m_grid->GetColSize( i ); + + m_grid->SetColSize( 1, std::max( aWidth - fixedColsWidth, 120 ) ); +} + + +void DIALOG_LABEL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event ) +{ + wxString shownColumns = m_grid->GetShownColumns(); + + if( shownColumns != m_shownColumns ) + { + m_shownColumns = shownColumns; + + if( !m_grid->IsCellEditControlShown() ) + AdjustGridColumns( m_grid->GetRect().GetWidth() ); + } + + // Handle a delayed focus + if( m_delayedFocusRow >= 0 && m_delayedFocusRow < m_grid->GetNumberRows() ) + { + m_grid->SetFocus(); + m_grid->MakeCellVisible( m_delayedFocusRow, m_delayedFocusColumn ); + m_grid->SetGridCursor( m_delayedFocusRow, m_delayedFocusColumn ); + + m_grid->EnableCellEditControl( true ); + m_grid->ShowCellEditControl(); + } + + m_delayedFocusRow = -1; + m_delayedFocusColumn = -1; +} + + +void DIALOG_LABEL_PROPERTIES::OnSizeGrid( wxSizeEvent& event ) +{ + int new_size = event.GetSize().GetX(); + + if( m_width != new_size ) + AdjustGridColumns( new_size ); + + // Always propagate for a grid repaint (needed if the height changes, as well as width) + event.Skip(); +} + + diff --git a/eeschema/dialogs/dialog_label_properties.h b/eeschema/dialogs/dialog_label_properties.h new file mode 100644 index 0000000000..b45b2477a7 --- /dev/null +++ b/eeschema/dialogs/dialog_label_properties.h @@ -0,0 +1,84 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. + * + * 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; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef DIALOG_LABEL_PROPERTIES_H +#define DIALOG_LABEL_PROPERTIES_H + +#include +#include +#include +#include +#include + + +class SCH_EDIT_FRAME; +class SCH_TEXT; +class HTML_MESSAGE_BOX; + + +class DIALOG_LABEL_PROPERTIES : public DIALOG_LABEL_PROPERTIES_BASE +{ +public: + DIALOG_LABEL_PROPERTIES( SCH_EDIT_FRAME* parent, SCH_LABEL_BASE* aLabel ); + ~DIALOG_LABEL_PROPERTIES(); + +private: + void OnEnterKey( wxCommandEvent& aEvent ) override; + void OnFormattingHelp( wxHyperlinkEvent& aEvent ) override; + + void onSpinButton( wxCommandEvent &aEvent ); + + // event handlers + void OnAddField( wxCommandEvent& event ) override; + void OnDeleteField( wxCommandEvent& event ) override; + void OnMoveUp( wxCommandEvent& event ) override; + void OnMoveDown( wxCommandEvent& event ) override; + void OnSizeGrid( wxSizeEvent& event ) override; + void OnUpdateUI( wxUpdateUIEvent& event ) override; + + void AdjustGridColumns( int aWidth ); + + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; + +private: + SCH_EDIT_FRAME* m_Parent; + int m_width; + int m_delayedFocusRow; + int m_delayedFocusColumn; + + SCH_LABEL_BASE* m_currentLabel; + wxTextEntry* m_activeTextEntry; + SCH_NETNAME_VALIDATOR m_netNameValidator; + + FIELDS_GRID_TABLE* m_fields; + wxString m_shownColumns; + + UNIT_BINDER m_textSize; + + HTML_MESSAGE_BOX* m_helpWindow; +}; + + + +#endif // DIALOG_LABEL_PROPERTIES_H diff --git a/eeschema/dialogs/dialog_label_properties_base.cpp b/eeschema/dialogs/dialog_label_properties_base.cpp new file mode 100644 index 0000000000..5470d2aeaf --- /dev/null +++ b/eeschema/dialogs/dialog_label_properties_base.cpp @@ -0,0 +1,283 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "widgets/bitmap_button.h" +#include "widgets/wx_grid.h" + +#include "dialog_label_properties_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_LABEL_PROPERTIES_BASE::DIALOG_LABEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bMainSizer; + bMainSizer = new wxBoxSizer( wxVERTICAL ); + + m_textEntrySizer = new wxFlexGridSizer( 5, 2, 1, 3 ); + m_textEntrySizer->AddGrowableCol( 1 ); + m_textEntrySizer->AddGrowableRow( 1 ); + m_textEntrySizer->SetFlexibleDirection( wxBOTH ); + m_textEntrySizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_labelSingleLine = new wxStaticText( this, wxID_ANY, _("Label:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_labelSingleLine->Wrap( -1 ); + m_labelSingleLine->SetToolTip( _("Enter the text to be used within the schematic") ); + + m_textEntrySizer->Add( m_labelSingleLine, 0, wxALIGN_CENTER_VERTICAL, 2 ); + + m_valueSingleLine = new wxTextCtrl( this, wxID_VALUESINGLE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RICH ); + m_textEntrySizer->Add( m_valueSingleLine, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 2 ); + + m_labelCombo = new wxStaticText( this, wxID_ANY, _("Label:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_labelCombo->Wrap( -1 ); + m_textEntrySizer->Add( m_labelCombo, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + m_valueCombo = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER ); + m_textEntrySizer->Add( m_valueCombo, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + + + m_textEntrySizer->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_syntaxHelp = new wxHyperlinkCtrl( this, wxID_ANY, _("Syntax help"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE ); + m_syntaxHelp->SetToolTip( _("Show syntax help window") ); + + m_textEntrySizer->Add( m_syntaxHelp, 1, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxRIGHT|wxLEFT, 5 ); + + + bMainSizer->Add( m_textEntrySizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 12 ); + + wxStaticBoxSizer* sbFields; + sbFields = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fields") ), wxVERTICAL ); + + m_grid = new WX_GRID( sbFields->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + + // Grid + m_grid->CreateGrid( 4, 11 ); + m_grid->EnableEditing( true ); + m_grid->EnableGridLines( true ); + m_grid->EnableDragGridSize( false ); + m_grid->SetMargins( 0, 0 ); + + // Columns + m_grid->SetColSize( 0, 72 ); + m_grid->SetColSize( 1, 84 ); + m_grid->SetColSize( 2, 48 ); + m_grid->SetColSize( 3, 72 ); + m_grid->SetColSize( 4, 72 ); + m_grid->SetColSize( 5, 48 ); + m_grid->SetColSize( 6, 48 ); + m_grid->SetColSize( 7, 84 ); + m_grid->SetColSize( 8, 48 ); + m_grid->SetColSize( 9, 84 ); + m_grid->SetColSize( 10, 84 ); + m_grid->EnableDragColMove( false ); + m_grid->EnableDragColSize( true ); + m_grid->SetColLabelSize( 22 ); + m_grid->SetColLabelValue( 0, _("Name") ); + m_grid->SetColLabelValue( 1, _("Value") ); + m_grid->SetColLabelValue( 2, _("Show") ); + m_grid->SetColLabelValue( 3, _("H Align") ); + m_grid->SetColLabelValue( 4, _("V Align") ); + m_grid->SetColLabelValue( 5, _("Italic") ); + m_grid->SetColLabelValue( 6, _("Bold") ); + m_grid->SetColLabelValue( 7, _("Text Size") ); + m_grid->SetColLabelValue( 8, _("Orientation") ); + m_grid->SetColLabelValue( 9, _("X Position") ); + m_grid->SetColLabelValue( 10, _("Y Position") ); + m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + + // Rows + m_grid->EnableDragRowSize( true ); + m_grid->SetRowLabelSize( 0 ); + m_grid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + + // Label Appearance + + // Cell Defaults + m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + m_grid->SetMinSize( wxSize( -1,100 ) ); + + sbFields->Add( m_grid, 1, wxALL|wxEXPAND, 5 ); + + wxBoxSizer* bButtonSize; + bButtonSize = new wxBoxSizer( wxHORIZONTAL ); + + m_bpAdd = new wxBitmapButton( sbFields->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + m_bpAdd->SetToolTip( _("Add field") ); + + bButtonSize->Add( m_bpAdd, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + m_bpMoveUp = new wxBitmapButton( sbFields->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + m_bpMoveUp->SetToolTip( _("Move up") ); + + bButtonSize->Add( m_bpMoveUp, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + m_bpMoveDown = new wxBitmapButton( sbFields->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + m_bpMoveDown->SetToolTip( _("Move down") ); + + bButtonSize->Add( m_bpMoveDown, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + + bButtonSize->Add( 20, 0, 0, wxEXPAND, 10 ); + + m_bpDelete = new wxBitmapButton( sbFields->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + m_bpDelete->SetToolTip( _("Delete field") ); + + bButtonSize->Add( m_bpDelete, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + + + sbFields->Add( bButtonSize, 0, wxALL|wxEXPAND, 5 ); + + + bMainSizer->Add( sbFields, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + + wxBoxSizer* optionsSizer; + optionsSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_shapeSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Shape") ), wxVERTICAL ); + + m_input = new wxRadioButton( m_shapeSizer->GetStaticBox(), wxID_ANY, _("Input"), wxDefaultPosition, wxDefaultSize, 0 ); + m_shapeSizer->Add( m_input, 0, wxBOTTOM|wxRIGHT, 2 ); + + m_output = new wxRadioButton( m_shapeSizer->GetStaticBox(), wxID_ANY, _("Output"), wxDefaultPosition, wxDefaultSize, 0 ); + m_shapeSizer->Add( m_output, 0, wxBOTTOM|wxRIGHT, 3 ); + + m_bidirectional = new wxRadioButton( m_shapeSizer->GetStaticBox(), wxID_ANY, _("Bidirectional"), wxDefaultPosition, wxDefaultSize, 0 ); + m_shapeSizer->Add( m_bidirectional, 0, wxBOTTOM|wxRIGHT, 3 ); + + m_triState = new wxRadioButton( m_shapeSizer->GetStaticBox(), wxID_ANY, _("Tri-state"), wxDefaultPosition, wxDefaultSize, 0 ); + m_shapeSizer->Add( m_triState, 0, wxBOTTOM|wxRIGHT, 3 ); + + m_passive = new wxRadioButton( m_shapeSizer->GetStaticBox(), wxID_ANY, _("Passive"), wxDefaultPosition, wxDefaultSize, 0 ); + m_shapeSizer->Add( m_passive, 0, wxBOTTOM|wxRIGHT, 3 ); + + m_dot = new wxRadioButton( m_shapeSizer->GetStaticBox(), wxID_ANY, _("Dot"), wxDefaultPosition, wxDefaultSize, 0 ); + m_shapeSizer->Add( m_dot, 0, wxBOTTOM|wxRIGHT, 3 ); + + m_circle = new wxRadioButton( m_shapeSizer->GetStaticBox(), wxID_ANY, _("Circle"), wxDefaultPosition, wxDefaultSize, 0 ); + m_shapeSizer->Add( m_circle, 0, wxBOTTOM|wxRIGHT, 3 ); + + m_diamond = new wxRadioButton( m_shapeSizer->GetStaticBox(), wxID_ANY, _("Diamond"), wxDefaultPosition, wxDefaultSize, 0 ); + m_shapeSizer->Add( m_diamond, 0, wxBOTTOM|wxRIGHT, 3 ); + + m_rectangle = new wxRadioButton( m_shapeSizer->GetStaticBox(), wxID_ANY, _("Rectangle"), wxDefaultPosition, wxDefaultSize, 0 ); + m_shapeSizer->Add( m_rectangle, 0, wxBOTTOM|wxRIGHT, 3 ); + + + optionsSizer->Add( m_shapeSizer, 0, wxEXPAND|wxTOP|wxRIGHT, 5 ); + + wxStaticBoxSizer* formatting; + formatting = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Formatting") ), wxVERTICAL ); + + wxBoxSizer* formattingSizer; + formattingSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_textSizeLabel = new wxStaticText( formatting->GetStaticBox(), wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textSizeLabel->Wrap( -1 ); + formattingSizer->Add( m_textSizeLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + m_textSizeCtrl = new wxTextCtrl( formatting->GetStaticBox(), wxID_SIZE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + formattingSizer->Add( m_textSizeCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_textSizeUnits = new wxStaticText( formatting->GetStaticBox(), wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textSizeUnits->Wrap( -1 ); + formattingSizer->Add( m_textSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 2 ); + + m_separator1 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator1->Enable( false ); + + formattingSizer->Add( m_separator1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + + m_bold = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_bold->SetToolTip( _("Bold") ); + + formattingSizer->Add( m_bold, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_italic = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_italic->SetToolTip( _("Italic") ); + + formattingSizer->Add( m_italic, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_separator2 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator2->Enable( false ); + + formattingSizer->Add( m_separator2, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_spin0 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + formattingSizer->Add( m_spin0, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_spin1 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + formattingSizer->Add( m_spin1, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_spin2 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + formattingSizer->Add( m_spin2, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_spin3 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + formattingSizer->Add( m_spin3, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_separator3 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator3->Enable( false ); + + formattingSizer->Add( m_separator3, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + + formatting->Add( formattingSizer, 0, wxEXPAND|wxBOTTOM, 5 ); + + + optionsSizer->Add( formatting, 1, wxEXPAND|wxTOP, 5 ); + + + bMainSizer->Add( optionsSizer, 0, wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + wxBoxSizer* bSizer4; + bSizer4 = new wxBoxSizer( wxHORIZONTAL ); + + m_sdbSizer1 = new wxStdDialogButtonSizer(); + m_sdbSizer1OK = new wxButton( this, wxID_OK ); + m_sdbSizer1->AddButton( m_sdbSizer1OK ); + m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL ); + m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); + m_sdbSizer1->Realize(); + + bSizer4->Add( m_sdbSizer1, 1, wxALL|wxEXPAND, 5 ); + + + bMainSizer->Add( bSizer4, 0, wxEXPAND, 5 ); + + + this->SetSizer( bMainSizer ); + this->Layout(); + bMainSizer->Fit( this ); + + // Connect Events + this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnUpdateUI ) ); + m_valueSingleLine->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnEnterKey ), NULL, this ); + m_valueCombo->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnEnterKey ), NULL, this ); + m_syntaxHelp->Connect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnFormattingHelp ), NULL, this ); + m_grid->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnSizeGrid ), NULL, this ); + m_bpAdd->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnAddField ), NULL, this ); + m_bpMoveUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnMoveUp ), NULL, this ); + m_bpMoveDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnMoveDown ), NULL, this ); + m_bpDelete->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnDeleteField ), NULL, this ); +} + +DIALOG_LABEL_PROPERTIES_BASE::~DIALOG_LABEL_PROPERTIES_BASE() +{ + // Disconnect Events + this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnUpdateUI ) ); + m_valueSingleLine->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnEnterKey ), NULL, this ); + m_valueCombo->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnEnterKey ), NULL, this ); + m_syntaxHelp->Disconnect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnFormattingHelp ), NULL, this ); + m_grid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnSizeGrid ), NULL, this ); + m_bpAdd->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnAddField ), NULL, this ); + m_bpMoveUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnMoveUp ), NULL, this ); + m_bpMoveDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnMoveDown ), NULL, this ); + m_bpDelete->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnDeleteField ), NULL, this ); + +} diff --git a/eeschema/dialogs/dialog_label_properties_base.fbp b/eeschema/dialogs/dialog_label_properties_base.fbp new file mode 100644 index 0000000000..b36cf5d125 --- /dev/null +++ b/eeschema/dialogs/dialog_label_properties_base.fbp @@ -0,0 +1,2315 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dialog_label_properties_base + 1000 + none + + 1 + dialog_label_properties_base + + . + + 1 + 1 + 1 + 1 + UI + 1 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DIALOG_LABEL_PROPERTIES_BASE + + -1,-1 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + Label Properties + + + + + OnUpdateUI + + + bMainSizer + wxVERTICAL + none + + 12 + wxEXPAND|wxLEFT|wxRIGHT|wxTOP + 0 + + 2 + wxBOTH + 1 + 1 + 3 + -1,-1 + m_textEntrySizer + wxFLEX_GROWMODE_SPECIFIED + protected + 5 + 1 + + 2 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Label: + 0 + + 0 + + + 0 + + 1 + m_labelSingleLine + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Enter the text to be used within the schematic + + + + -1 + + + + 2 + wxEXPAND|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_VALUESINGLE + + 0 + + + + 0 + -1,-1 + 1 + m_valueSingleLine + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_PROCESS_ENTER|wxTE_RICH + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + OnEnterKey + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Label: + 0 + + 0 + + + 0 + + 1 + m_labelCombo + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + 5 + wxEXPAND|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + -1,-1 + 1 + m_valueCombo + 1 + + + protected + 1 + + Resizable + -1 + 1 + + wxTE_PROCESS_ENTER + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + OnEnterKey + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxRIGHT|wxLEFT + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + + wxID_ANY + Syntax help + + 0 + + + 0 + + 1 + m_syntaxHelp + + 1 + + + protected + 1 + + Resizable + 1 + + wxHL_DEFAULT_STYLE + ; ; forward_declare + 0 + Show syntax help window + + + + + + OnFormattingHelp + + + + + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 1 + + wxID_ANY + Fields + + sbFields + wxVERTICAL + 1 + none + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + 0 + 0 + + + + 1 + + + wxALIGN_LEFT + + wxALIGN_TOP + 0 + 1 + wxALIGN_CENTER + 22 + "Name" "Value" "Show" "H Align" "V Align" "Italic" "Bold" "Text Size" "Orientation" "X Position" "Y Position" + wxALIGN_CENTER + 11 + 72,84,48,72,72,48,48,84,48,84,84 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + 0 + 1 + 1 + 1 + + 1 + + + 1 + 0 + 0 + wxID_ANY + + + + 0 + 0 + + 0 + + + 0 + -1,100 + 1 + m_grid + 1 + + + protected + 1 + + Resizable + wxALIGN_CENTER + 0 + + wxALIGN_CENTER + + 4 + 1 + + WX_GRID; widgets/wx_grid.h; forward_declare + 0 + + + + + OnSizeGrid + + + + 5 + wxALL|wxEXPAND + 0 + + + bButtonSize + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Add Field + + 0 + + 0 + + + 0 + -1,-1 + 1 + m_bpAdd + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; forward_declare + 0 + Add field + + wxFILTER_NONE + wxDefaultValidator + + + + + OnAddField + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Move Up + + 0 + + 0 + + + 0 + -1,-1 + 1 + m_bpMoveUp + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; forward_declare + 0 + Move up + + wxFILTER_NONE + wxDefaultValidator + + + + + OnMoveUp + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Move Down + + 0 + + 0 + + + 0 + -1,-1 + 1 + m_bpMoveDown + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; forward_declare + 0 + Move down + + wxFILTER_NONE + wxDefaultValidator + + + + + OnMoveDown + + + + 10 + wxEXPAND + 0 + + 0 + protected + 20 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Delete Field + + 0 + + 0 + + + 0 + -1,-1 + 1 + m_bpDelete + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; forward_declare + 0 + Delete field + + wxFILTER_NONE + wxDefaultValidator + + + + + OnDeleteField + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + optionsSizer + wxHORIZONTAL + none + + 5 + wxEXPAND|wxTOP|wxRIGHT + 0 + + wxID_ANY + Shape + + m_shapeSizer + wxVERTICAL + 1 + protected + + 2 + wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Input + + 0 + + + 0 + + 1 + m_input + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + 3 + wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Output + + 0 + + + 0 + + 1 + m_output + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + 3 + wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Bidirectional + + 0 + + + 0 + + 1 + m_bidirectional + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + 3 + wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Tri-state + + 0 + + + 0 + + 1 + m_triState + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + 3 + wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Passive + + 0 + + + 0 + + 1 + m_passive + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + 3 + wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Dot + + 0 + + + 0 + + 1 + m_dot + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + 3 + wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Circle + + 0 + + + 0 + + 1 + m_circle + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + 3 + wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Diamond + + 0 + + + 0 + + 1 + m_diamond + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + 3 + wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Rectangle + + 0 + + + 0 + + 1 + m_rectangle + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + 5 + wxEXPAND|wxTOP + 1 + + wxID_ANY + Formatting + + formatting + wxVERTICAL + 1 + none + + 5 + wxEXPAND|wxBOTTOM + 0 + + + formattingSizer + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Text size: + 0 + + 0 + + + 0 + + 1 + m_textSizeLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_SIZE + + 0 + -1,-1 + + + 0 + -1,-1 + 1 + m_textSizeCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 2 + wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + + 1 + m_textSizeUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_separator1 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Bold + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_bold + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Bold + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Italic + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_italic + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Italic + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_separator2 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_spin0 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_spin1 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_spin2 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_spin3 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_separator3 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + bSizer4 + wxHORIZONTAL + none + + 5 + wxALL|wxEXPAND + 1 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer1 + protected + + + + + + + + diff --git a/eeschema/dialogs/dialog_label_properties_base.h b/eeschema/dialogs/dialog_label_properties_base.h new file mode 100644 index 0000000000..3a0d557a69 --- /dev/null +++ b/eeschema/dialogs/dialog_label_properties_base.h @@ -0,0 +1,107 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +class BITMAP_BUTTON; +class WX_GRID; + +#include "dialog_shim.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_LABEL_PROPERTIES_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_LABEL_PROPERTIES_BASE : public DIALOG_SHIM +{ + private: + + protected: + enum + { + wxID_VALUESINGLE = 1000, + wxID_SIZE + }; + + wxFlexGridSizer* m_textEntrySizer; + wxStaticText* m_labelSingleLine; + wxTextCtrl* m_valueSingleLine; + wxStaticText* m_labelCombo; + wxComboBox* m_valueCombo; + wxHyperlinkCtrl* m_syntaxHelp; + WX_GRID* m_grid; + wxBitmapButton* m_bpAdd; + wxBitmapButton* m_bpMoveUp; + wxBitmapButton* m_bpMoveDown; + wxBitmapButton* m_bpDelete; + wxStaticBoxSizer* m_shapeSizer; + wxRadioButton* m_input; + wxRadioButton* m_output; + wxRadioButton* m_bidirectional; + wxRadioButton* m_triState; + wxRadioButton* m_passive; + wxRadioButton* m_dot; + wxRadioButton* m_circle; + wxRadioButton* m_diamond; + wxRadioButton* m_rectangle; + wxStaticText* m_textSizeLabel; + wxTextCtrl* m_textSizeCtrl; + wxStaticText* m_textSizeUnits; + BITMAP_BUTTON* m_separator1; + BITMAP_BUTTON* m_bold; + BITMAP_BUTTON* m_italic; + BITMAP_BUTTON* m_separator2; + BITMAP_BUTTON* m_spin0; + BITMAP_BUTTON* m_spin1; + BITMAP_BUTTON* m_spin2; + BITMAP_BUTTON* m_spin3; + BITMAP_BUTTON* m_separator3; + wxStdDialogButtonSizer* m_sdbSizer1; + wxButton* m_sdbSizer1OK; + wxButton* m_sdbSizer1Cancel; + + // Virtual event handlers, overide them in your derived class + virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } + virtual void OnEnterKey( wxCommandEvent& event ) { event.Skip(); } + virtual void OnFormattingHelp( wxHyperlinkEvent& event ) { event.Skip(); } + virtual void OnSizeGrid( wxSizeEvent& event ) { event.Skip(); } + virtual void OnAddField( wxCommandEvent& event ) { event.Skip(); } + virtual void OnMoveUp( wxCommandEvent& event ) { event.Skip(); } + virtual void OnMoveDown( wxCommandEvent& event ) { event.Skip(); } + virtual void OnDeleteField( wxCommandEvent& event ) { event.Skip(); } + + + public: + + DIALOG_LABEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Label Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_LABEL_PROPERTIES_BASE(); + +}; + diff --git a/eeschema/dialogs/dialog_lib_text_properties.cpp b/eeschema/dialogs/dialog_lib_text_properties.cpp index 039c551a05..6065731fea 100644 --- a/eeschema/dialogs/dialog_lib_text_properties.cpp +++ b/eeschema/dialogs/dialog_lib_text_properties.cpp @@ -22,12 +22,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include #include #include #include #include #include +#include DIALOG_LIB_TEXT_PROPERTIES::DIALOG_LIB_TEXT_PROPERTIES( SYMBOL_EDIT_FRAME* aParent, @@ -40,6 +42,12 @@ DIALOG_LIB_TEXT_PROPERTIES::DIALOG_LIB_TEXT_PROPERTIES( SYMBOL_EDIT_FRAME* aPare m_parent = aParent; m_graphicText = aText; + m_scintillaTricks = new SCINTILLA_TRICKS( m_StyledTextCtrl, wxT( "{}" ), false, + [this]() + { + wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); + } ); + // Disable options for fieldedit, not existing in graphic text m_visible->Show( false ); m_TextValueSelectButton->Hide(); @@ -61,11 +69,62 @@ DIALOG_LIB_TEXT_PROPERTIES::DIALOG_LIB_TEXT_PROPERTIES( SYMBOL_EDIT_FRAME* aPare m_sdbSizerButtonsOK->SetDefault(); } + m_separator1->SetIsSeparator(); + + m_horizontal->SetIsCheckButton(); + m_horizontal->SetBitmap( KiBitmap( BITMAPS::text_horizontal ) ); + m_vertical->SetIsCheckButton(); + m_vertical->SetBitmap( KiBitmap( BITMAPS::text_vertical ) ); + + m_separator2->SetIsSeparator(); + + m_bold->SetIsCheckButton(); + m_bold->SetBitmap( KiBitmap( BITMAPS::text_bold ) ); + m_italic->SetIsCheckButton(); + m_italic->SetBitmap( KiBitmap( BITMAPS::text_italic ) ); + + m_separator3->SetIsSeparator(); + + m_hAlignLeft->SetIsCheckButton(); + m_hAlignLeft->SetBitmap( KiBitmap( BITMAPS::text_align_left ) ); + m_hAlignCenter->SetIsCheckButton(); + m_hAlignCenter->SetBitmap( KiBitmap( BITMAPS::text_align_center ) ); + m_hAlignRight->SetIsCheckButton(); + m_hAlignRight->SetBitmap( KiBitmap( BITMAPS::text_align_right ) ); + + m_separator4->SetIsSeparator(); + + m_vAlignTop->SetIsCheckButton(); + m_vAlignTop->SetBitmap( KiBitmap( BITMAPS::text_valign_top ) ); + m_vAlignCenter->SetIsCheckButton(); + m_vAlignCenter->SetBitmap( KiBitmap( BITMAPS::text_valign_center ) ); + m_vAlignBottom->SetIsCheckButton(); + m_vAlignBottom->SetBitmap( KiBitmap( BITMAPS::text_valign_bottom ) ); + + m_separator5->SetIsSeparator(); + + m_horizontal->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onOrientButton, this ); + m_vertical->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onOrientButton, this ); + + m_hAlignLeft->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onHAlignButton, this ); + m_hAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onHAlignButton, this ); + m_hAlignRight->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onHAlignButton, this ); + + m_vAlignTop->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onVAlignButton, this ); + m_vAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onVAlignButton, this ); + m_vAlignBottom->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onVAlignButton, this ); + // Now all widgets have the size fixed, call FinishDialogSettings finishDialogSettings(); } +DIALOG_LIB_TEXT_PROPERTIES::~DIALOG_LIB_TEXT_PROPERTIES() +{ + delete m_scintillaTricks; +}; + + bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow() { if( m_graphicText ) @@ -75,24 +134,28 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow() m_textSize.SetValue( m_graphicText->GetTextWidth() ); m_TextCtrl->SetValue( m_graphicText->GetText() ); - m_italic->SetValue( m_graphicText->IsItalic() ); - m_bold->SetValue( m_graphicText->IsBold() ); + m_italic->Check( m_graphicText->IsItalic() ); + m_bold->Check( m_graphicText->IsBold() ); m_CommonUnit->SetValue( m_graphicText->GetUnit() == 0 ); m_CommonConvert->SetValue( m_graphicText->GetConvert() == 0 ); - m_orientChoice->SetSelection( m_graphicText->GetTextAngle() == TEXT_ANGLE_HORIZ ? 0 : 1 ); + + if( m_graphicText->GetTextAngle() == TEXT_ANGLE_HORIZ ) + m_horizontal->Check(); + else + m_vertical->Check(); switch ( m_graphicText->GetHorizJustify() ) { - case GR_TEXT_HJUSTIFY_LEFT: m_hAlignChoice->SetSelection( 0 ); break; - case GR_TEXT_HJUSTIFY_CENTER: m_hAlignChoice->SetSelection( 1 ); break; - case GR_TEXT_HJUSTIFY_RIGHT: m_hAlignChoice->SetSelection( 2 ); break; + case GR_TEXT_HJUSTIFY_LEFT: m_hAlignLeft->Check( true ); break; + case GR_TEXT_HJUSTIFY_CENTER: m_hAlignCenter->Check( true ); break; + case GR_TEXT_HJUSTIFY_RIGHT: m_hAlignRight->Check( true ); break; } switch ( m_graphicText->GetVertJustify() ) { - case GR_TEXT_VJUSTIFY_TOP: m_vAlignChoice->SetSelection( 0 ); break; - case GR_TEXT_VJUSTIFY_CENTER: m_vAlignChoice->SetSelection( 1 ); break; - case GR_TEXT_VJUSTIFY_BOTTOM: m_vAlignChoice->SetSelection( 2 ); break; + case GR_TEXT_VJUSTIFY_TOP: m_vAlignTop->Check( true ); break; + case GR_TEXT_VJUSTIFY_CENTER: m_vAlignCenter->Check( true ); break; + case GR_TEXT_VJUSTIFY_BOTTOM: m_vAlignBottom->Check( true ); break; } } else @@ -104,13 +167,47 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow() m_CommonUnit->SetValue( !tools->GetDrawSpecificUnit() ); m_CommonConvert->SetValue( !tools->GetDrawSpecificConvert() ); - m_orientChoice->SetSelection( tools->GetLastTextAngle() == TEXT_ANGLE_HORIZ ? 0 : 1 ); + + if( tools->GetLastTextAngle() == TEXT_ANGLE_HORIZ ) + m_horizontal->Check(); + else + m_vertical->Check(); } return true; } +void DIALOG_LIB_TEXT_PROPERTIES::onOrientButton( wxCommandEvent& aEvent ) +{ + for( BITMAP_BUTTON* btn : { m_horizontal, m_vertical } ) + { + if( btn->IsChecked() && btn != aEvent.GetEventObject() ) + btn->Check( false ); + } +} + + +void DIALOG_LIB_TEXT_PROPERTIES::onHAlignButton( wxCommandEvent& aEvent ) +{ + for( BITMAP_BUTTON* btn : { m_hAlignLeft, m_hAlignCenter, m_hAlignRight } ) + { + if( btn->IsChecked() && btn != aEvent.GetEventObject() ) + btn->Check( false ); + } +} + + +void DIALOG_LIB_TEXT_PROPERTIES::onVAlignButton( wxCommandEvent& aEvent ) +{ + for( BITMAP_BUTTON* btn : { m_vAlignTop, m_vAlignTop, m_vAlignBottom } ) + { + if( btn->IsChecked() && btn != aEvent.GetEventObject() ) + btn->Check( false ); + } +} + + bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow() { if( m_graphicText ) @@ -125,8 +222,10 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow() if( m_textSize.GetValue() != m_graphicText->GetTextWidth() ) m_graphicText->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) ); - m_graphicText->SetTextAngle( m_orientChoice->GetSelection() ? TEXT_ANGLE_VERT - : TEXT_ANGLE_HORIZ ); + if( m_horizontal->IsChecked() ) + m_graphicText->SetTextAngle( TEXT_ANGLE_HORIZ ); + else + m_graphicText->SetTextAngle( TEXT_ANGLE_VERT ); if( !m_CommonUnit->GetValue() ) m_graphicText->SetUnit( m_parent->GetUnit() ); @@ -138,22 +237,22 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow() else m_graphicText->SetConvert( 0 ); - m_graphicText->SetItalic( m_italic->GetValue() ); - m_graphicText->SetBold( m_bold->GetValue() ); + m_graphicText->SetItalic( m_italic->IsChecked() ); + m_graphicText->SetBold( m_bold->IsChecked() ); - switch( m_hAlignChoice->GetSelection() ) - { - case 0: m_graphicText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); break; - case 1: m_graphicText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); break; - case 2: m_graphicText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); break; - } + if( m_hAlignLeft->IsChecked() ) + m_graphicText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + else if( m_hAlignCenter->IsChecked() ) + m_graphicText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + else + m_graphicText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - switch( m_vAlignChoice->GetSelection() ) - { - case 0: m_graphicText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); break; - case 1: m_graphicText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); break; - case 2: m_graphicText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break; - } + if( m_vAlignTop->IsChecked() ) + m_graphicText->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + else if( m_vAlignCenter->IsChecked() ) + m_graphicText->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + else + m_graphicText->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); // Record settings used for next time: auto* tools = m_parent->GetToolManager()->GetTool(); @@ -166,3 +265,12 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow() return true; } + + +void DIALOG_LIB_TEXT_PROPERTIES::onMultiLineTCLostFocus( wxFocusEvent& event ) +{ + if( m_scintillaTricks ) + m_scintillaTricks->CancelAutocomplete(); + + event.Skip(); +} diff --git a/eeschema/dialogs/dialog_lib_text_properties.h b/eeschema/dialogs/dialog_lib_text_properties.h index c8b2551f38..f268446352 100644 --- a/eeschema/dialogs/dialog_lib_text_properties.h +++ b/eeschema/dialogs/dialog_lib_text_properties.h @@ -30,6 +30,7 @@ #include class SYMBOL_EDIT_FRAME; +class SCINTILLA_TRICKS; class LIB_TEXT; @@ -37,9 +38,14 @@ class DIALOG_LIB_TEXT_PROPERTIES : public DIALOG_LIB_TEXT_PROPERTIES_BASE { public: DIALOG_LIB_TEXT_PROPERTIES( SYMBOL_EDIT_FRAME* aParent, LIB_TEXT* aText ); - ~DIALOG_LIB_TEXT_PROPERTIES() override {}; + ~DIALOG_LIB_TEXT_PROPERTIES() override; private: + void onOrientButton( wxCommandEvent &aEvent ); + void onHAlignButton( wxCommandEvent &aEvent ); + void onVAlignButton( wxCommandEvent &aEvent ); + void onMultiLineTCLostFocus( wxFocusEvent& event ) override; + bool TransferDataToWindow() override; bool TransferDataFromWindow() override; @@ -49,6 +55,7 @@ private: UNIT_BINDER m_posX; UNIT_BINDER m_posY; UNIT_BINDER m_textSize; + SCINTILLA_TRICKS* m_scintillaTricks; }; diff --git a/eeschema/dialogs/dialog_lib_text_properties_base.cpp b/eeschema/dialogs/dialog_lib_text_properties_base.cpp index a975ee735d..e4fce157ec 100644 --- a/eeschema/dialogs/dialog_lib_text_properties_base.cpp +++ b/eeschema/dialogs/dialog_lib_text_properties_base.cpp @@ -5,6 +5,8 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// +#include "widgets/bitmap_button.h" + #include "dialog_lib_text_properties_base.h" /////////////////////////////////////////////////////////////////////////// @@ -86,99 +88,141 @@ DIALOG_LIB_TEXT_PROPERTIES_BASE::DIALOG_LIB_TEXT_PROPERTIES_BASE( wxWindow* pare bPropertiesSizer->Add( bSizer9, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); wxFlexGridSizer* fgSizer3; - fgSizer3 = new wxFlexGridSizer( 0, 8, 3, 3 ); + fgSizer3 = new wxFlexGridSizer( 0, 4, 3, 3 ); fgSizer3->SetFlexibleDirection( wxBOTH ); fgSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_xPosLabel = new wxStaticText( this, wxID_ANY, _("Position X:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_xPosLabel->Wrap( -1 ); - fgSizer3->Add( m_xPosLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - - m_xPosCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer3->Add( m_xPosCtrl, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxEXPAND, 5 ); - - m_xPosUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); - m_xPosUnits->Wrap( -1 ); - fgSizer3->Add( m_xPosUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - - fgSizer3->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - - m_italic = new wxCheckBox( this, wxID_ANY, _("Italic"), wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer3->Add( m_italic, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 8 ); - - - fgSizer3->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - - m_orientLabel = new wxStaticText( this, wxID_ANY, _("Orientation:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_orientLabel->Wrap( -1 ); - fgSizer3->Add( m_orientLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 10 ); - - wxString m_orientChoiceChoices[] = { _("Horizontal"), _("Vertical") }; - int m_orientChoiceNChoices = sizeof( m_orientChoiceChoices ) / sizeof( wxString ); - m_orientChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_orientChoiceNChoices, m_orientChoiceChoices, 0 ); - m_orientChoice->SetSelection( 0 ); - fgSizer3->Add( m_orientChoice, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - - m_yPosLabel = new wxStaticText( this, wxID_ANY, _("Position Y:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_yPosLabel->Wrap( -1 ); - fgSizer3->Add( m_yPosLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - - m_yPosCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer3->Add( m_yPosCtrl, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxEXPAND, 5 ); - - m_yPosUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); - m_yPosUnits->Wrap( -1 ); - fgSizer3->Add( m_yPosUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - - fgSizer3->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - - m_bold = new wxCheckBox( this, wxID_ANY, _("Bold"), wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer3->Add( m_bold, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 8 ); - - - fgSizer3->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - - m_hAlignLabel = new wxStaticText( this, wxID_ANY, _("H Align:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_hAlignLabel->Wrap( -1 ); - fgSizer3->Add( m_hAlignLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 10 ); - - wxString m_hAlignChoiceChoices[] = { _("Left"), _("Center"), _("Right") }; - int m_hAlignChoiceNChoices = sizeof( m_hAlignChoiceChoices ) / sizeof( wxString ); - m_hAlignChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_hAlignChoiceNChoices, m_hAlignChoiceChoices, 0 ); - m_hAlignChoice->SetSelection( 0 ); - fgSizer3->Add( m_hAlignChoice, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - m_textSizeLabel = new wxStaticText( this, wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 ); m_textSizeLabel->Wrap( -1 ); fgSizer3->Add( m_textSizeLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); m_textSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer3->Add( m_textSizeCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + fgSizer3->Add( m_textSizeCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); m_textSizeUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_textSizeUnits->Wrap( -1 ); - fgSizer3->Add( m_textSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + fgSizer3->Add( m_textSizeUnits, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + wxBoxSizer* formattingSizer; + formattingSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_separator1 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator1->Enable( false ); + + formattingSizer->Add( m_separator1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + + m_horizontal = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_horizontal->SetToolTip( _("Horizontal text") ); + + formattingSizer->Add( m_horizontal, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_vertical = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_vertical->SetToolTip( _("Vertical text") ); + + formattingSizer->Add( m_vertical, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_separator2 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator2->Enable( false ); + + formattingSizer->Add( m_separator2, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_bold = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_bold->SetToolTip( _("Bold") ); + + formattingSizer->Add( m_bold, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_italic = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_italic->SetToolTip( _("Italic") ); + + formattingSizer->Add( m_italic, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_separator3 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator3->Enable( false ); + + formattingSizer->Add( m_separator3, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_hAlignLeft = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_hAlignLeft->SetToolTip( _("Align left") ); + + formattingSizer->Add( m_hAlignLeft, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_hAlignCenter = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_hAlignCenter->SetToolTip( _("Align horizontal center") ); + + formattingSizer->Add( m_hAlignCenter, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_hAlignRight = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_hAlignRight->SetToolTip( _("Align right") ); + + formattingSizer->Add( m_hAlignRight, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_separator4 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator4->Enable( false ); + + formattingSizer->Add( m_separator4, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_vAlignTop = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_vAlignTop->SetToolTip( _("Align top") ); + + formattingSizer->Add( m_vAlignTop, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_vAlignCenter = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_vAlignCenter->SetToolTip( _("Align vertical center") ); + + formattingSizer->Add( m_vAlignCenter, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_vAlignBottom = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_vAlignBottom->SetToolTip( _("Align bottom") ); + + formattingSizer->Add( m_vAlignBottom, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_separator5 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator5->Enable( false ); + + formattingSizer->Add( m_separator5, 0, wxALIGN_CENTER_VERTICAL, 5 ); - fgSizer3->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); + fgSizer3->Add( formattingSizer, 1, wxEXPAND|wxRIGHT, 5 ); - fgSizer3->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); + fgSizer3->Add( 0, 10, 1, wxEXPAND, 5 ); fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); - m_vAlignLabel = new wxStaticText( this, wxID_ANY, _("V Align:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_vAlignLabel->Wrap( -1 ); - fgSizer3->Add( m_vAlignLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 10 ); - wxString m_vAlignChoiceChoices[] = { _("Top"), _("Center"), _("Bottom") }; - int m_vAlignChoiceNChoices = sizeof( m_vAlignChoiceChoices ) / sizeof( wxString ); - m_vAlignChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_vAlignChoiceNChoices, m_vAlignChoiceChoices, 0 ); - m_vAlignChoice->SetSelection( 0 ); - fgSizer3->Add( m_vAlignChoice, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); + + + fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_xPosLabel = new wxStaticText( this, wxID_ANY, _("Position X:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_xPosLabel->Wrap( -1 ); + fgSizer3->Add( m_xPosLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + + m_xPosCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer3->Add( m_xPosCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + m_xPosUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_xPosUnits->Wrap( -1 ); + fgSizer3->Add( m_xPosUnits, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_CommonUnit = new wxCheckBox( this, wxID_ANY, _("Common to all units"), wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer3->Add( m_CommonUnit, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 80 ); + + m_yPosLabel = new wxStaticText( this, wxID_ANY, _("Position Y:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_yPosLabel->Wrap( -1 ); + fgSizer3->Add( m_yPosLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + + m_yPosCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer3->Add( m_yPosCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + m_yPosUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_yPosUnits->Wrap( -1 ); + fgSizer3->Add( m_yPosUnits, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_CommonConvert = new wxCheckBox( this, wxID_ANY, _("Common to all body styles"), wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer3->Add( m_CommonConvert, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 80 ); bPropertiesSizer->Add( fgSizer3, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); @@ -186,12 +230,6 @@ DIALOG_LIB_TEXT_PROPERTIES_BASE::DIALOG_LIB_TEXT_PROPERTIES_BASE( wxWindow* pare wxBoxSizer* bBottomtBoxSizer; bBottomtBoxSizer = new wxBoxSizer( wxVERTICAL ); - m_CommonUnit = new wxCheckBox( this, wxID_ANY, _("Common to all units"), wxDefaultPosition, wxDefaultSize, 0 ); - bBottomtBoxSizer->Add( m_CommonUnit, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_CommonConvert = new wxCheckBox( this, wxID_ANY, _("Common to all body styles"), wxDefaultPosition, wxDefaultSize, 0 ); - bBottomtBoxSizer->Add( m_CommonConvert, 0, wxLEFT|wxRIGHT, 5 ); - bPropertiesSizer->Add( bBottomtBoxSizer, 0, wxEXPAND|wxTOP|wxLEFT, 5 ); @@ -218,6 +256,7 @@ DIALOG_LIB_TEXT_PROPERTIES_BASE::DIALOG_LIB_TEXT_PROPERTIES_BASE( wxWindow* pare // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnCloseDialog ) ); m_TextCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnSetFocusText ), NULL, this ); + m_StyledTextCtrl->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); m_StyledTextCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnSetFocusText ), NULL, this ); m_TextValueSelectButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnTextValueSelectButtonClick ), NULL, this ); } @@ -227,6 +266,7 @@ DIALOG_LIB_TEXT_PROPERTIES_BASE::~DIALOG_LIB_TEXT_PROPERTIES_BASE() // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnCloseDialog ) ); m_TextCtrl->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnSetFocusText ), NULL, this ); + m_StyledTextCtrl->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); m_StyledTextCtrl->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnSetFocusText ), NULL, this ); m_TextValueSelectButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnTextValueSelectButtonClick ), NULL, this ); diff --git a/eeschema/dialogs/dialog_lib_text_properties_base.fbp b/eeschema/dialogs/dialog_lib_text_properties_base.fbp index 5fcd5cdeff..f071c225f9 100644 --- a/eeschema/dialogs/dialog_lib_text_properties_base.fbp +++ b/eeschema/dialogs/dialog_lib_text_properties_base.fbp @@ -276,6 +276,7 @@ wxBORDER_SUNKEN + onMultiLineTCLostFocus OnSetFocusText @@ -497,7 +498,7 @@ wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 - 8 + 4 wxBOTH @@ -508,6 +509,1323 @@ none 0 3 + + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Text size: + 0 + + 0 + + + 0 + + 1 + m_textSizeLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxEXPAND|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_textSizeCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + unit + 0 + + 0 + + + 0 + + 1 + m_textSizeUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + 5 + wxEXPAND|wxRIGHT + 1 + + + formattingSizer + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_separator1 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Horizontal text + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_horizontal + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Horizontal text + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Vertical text + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_vertical + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Vertical text + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_separator2 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Bold + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_bold + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Bold + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Italic + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_italic + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Italic + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_separator3 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align left + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_hAlignLeft + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align left + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align center + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_hAlignCenter + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align horizontal center + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align right + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_hAlignRight + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align right + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_separator4 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align top + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_vAlignTop + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align top + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align vertical center + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_vAlignCenter + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align vertical center + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align bottom + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_vAlignBottom + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align bottom + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_separator5 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + 5 + wxEXPAND + 1 + + 10 + protected + 0 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + 5 wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT @@ -571,7 +1889,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxLEFT|wxEXPAND + wxALIGN_CENTER_VERTICAL|wxEXPAND 0 1 @@ -635,7 +1953,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT + wxALIGN_CENTER_VERTICAL 0 1 @@ -694,21 +2012,11 @@ -1 - - 5 - wxEXPAND|wxRIGHT|wxLEFT + + 80 + wxALIGN_CENTER_VERTICAL|wxLEFT 0 - - 0 - protected - 0 - - - - 8 - wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL - 0 - + 1 1 1 @@ -737,7 +2045,7 @@ 0 0 wxID_ANY - Italic + Common to all units 0 @@ -745,7 +2053,7 @@ 0 1 - m_italic + m_CommonUnit 1 @@ -756,142 +2064,7 @@ 1 - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxEXPAND|wxRIGHT|wxLEFT - 0 - - 0 - protected - 0 - - - - 10 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Orientation: - 0 - - 0 - - - 0 - - 1 - m_orientLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 - - - - 5 - wxEXPAND|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Horizontal" "Vertical" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_orientChoice - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - ; forward_declare + 0 @@ -966,7 +2139,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxLEFT|wxEXPAND + wxALIGN_CENTER_VERTICAL|wxEXPAND 0 1 @@ -1030,7 +2203,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT + wxALIGN_CENTER_VERTICAL 0 1 @@ -1089,635 +2262,10 @@ -1 - - 5 - wxEXPAND|wxRIGHT|wxLEFT - 0 - - 0 - protected - 0 - - - - 8 - wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Bold - - 0 - - - 0 - - 1 - m_bold - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxEXPAND|wxRIGHT|wxLEFT - 0 - - 0 - protected - 0 - - - - 10 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - H Align: - 0 - - 0 - - - 0 - - 1 - m_hAlignLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 - - - - 5 - wxEXPAND|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Left" "Center" "Right" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_hAlignChoice - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - 5 + 80 wxALIGN_CENTER_VERTICAL|wxLEFT 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Text size: - 0 - - 0 - - - 0 - - 1 - m_textSizeLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxEXPAND|wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_textSizeCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - unit - 0 - - 0 - - - 0 - - 1 - m_textSizeUnits - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 - - - - 10 - wxEXPAND|wxRIGHT|wxLEFT - 0 - - 0 - protected - 0 - - - - 10 - wxEXPAND|wxRIGHT|wxLEFT - 0 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 10 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - V Align: - 0 - - 0 - - - 0 - - 1 - m_vAlignLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 - - - - 5 - wxEXPAND|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Top" "Center" "Bottom" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_vAlignChoice - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - 5 - wxEXPAND|wxTOP|wxLEFT - 0 - - - bBottomtBoxSizer - wxVERTICAL - none - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Common to all units - - 0 - - - 0 - - 1 - m_CommonUnit - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxLEFT|wxRIGHT - 0 1 1 @@ -1780,6 +2328,17 @@ + + 5 + wxEXPAND|wxTOP|wxLEFT + 0 + + + bBottomtBoxSizer + wxVERTICAL + none + + diff --git a/eeschema/dialogs/dialog_lib_text_properties_base.h b/eeschema/dialogs/dialog_lib_text_properties_base.h index 8ed3f4b36c..c1da0d989d 100644 --- a/eeschema/dialogs/dialog_lib_text_properties_base.h +++ b/eeschema/dialogs/dialog_lib_text_properties_base.h @@ -10,6 +10,8 @@ #include #include #include +class BITMAP_BUTTON; + #include "dialog_shim.h" #include #include @@ -26,7 +28,6 @@ #include #include #include -#include #include #include @@ -46,24 +47,31 @@ class DIALOG_LIB_TEXT_PROPERTIES_BASE : public DIALOG_SHIM wxBitmapButton* m_TextValueSelectButton; wxStaticText* m_note; wxCheckBox* m_visible; - wxStaticText* m_xPosLabel; - wxTextCtrl* m_xPosCtrl; - wxStaticText* m_xPosUnits; - wxCheckBox* m_italic; - wxStaticText* m_orientLabel; - wxChoice* m_orientChoice; - wxStaticText* m_yPosLabel; - wxTextCtrl* m_yPosCtrl; - wxStaticText* m_yPosUnits; - wxCheckBox* m_bold; - wxStaticText* m_hAlignLabel; - wxChoice* m_hAlignChoice; wxStaticText* m_textSizeLabel; wxTextCtrl* m_textSizeCtrl; wxStaticText* m_textSizeUnits; - wxStaticText* m_vAlignLabel; - wxChoice* m_vAlignChoice; + BITMAP_BUTTON* m_separator1; + BITMAP_BUTTON* m_horizontal; + BITMAP_BUTTON* m_vertical; + BITMAP_BUTTON* m_separator2; + BITMAP_BUTTON* m_bold; + BITMAP_BUTTON* m_italic; + BITMAP_BUTTON* m_separator3; + BITMAP_BUTTON* m_hAlignLeft; + BITMAP_BUTTON* m_hAlignCenter; + BITMAP_BUTTON* m_hAlignRight; + BITMAP_BUTTON* m_separator4; + BITMAP_BUTTON* m_vAlignTop; + BITMAP_BUTTON* m_vAlignCenter; + BITMAP_BUTTON* m_vAlignBottom; + BITMAP_BUTTON* m_separator5; + wxStaticText* m_xPosLabel; + wxTextCtrl* m_xPosCtrl; + wxStaticText* m_xPosUnits; wxCheckBox* m_CommonUnit; + wxStaticText* m_yPosLabel; + wxTextCtrl* m_yPosCtrl; + wxStaticText* m_yPosUnits; wxCheckBox* m_CommonConvert; wxStaticLine* m_staticline2; wxStdDialogButtonSizer* m_sdbSizerButtons; @@ -73,6 +81,7 @@ class DIALOG_LIB_TEXT_PROPERTIES_BASE : public DIALOG_SHIM // Virtual event handlers, overide them in your derived class virtual void OnCloseDialog( wxCloseEvent& event ) { event.Skip(); } virtual void OnSetFocusText( wxFocusEvent& event ) { event.Skip(); } + virtual void onMultiLineTCLostFocus( wxFocusEvent& event ) { event.Skip(); } virtual void OnTextValueSelectButtonClick( wxCommandEvent& event ) { event.Skip(); } diff --git a/eeschema/dialogs/dialog_sheet_pin_properties.cpp b/eeschema/dialogs/dialog_sheet_pin_properties.cpp index c2d8672525..fa2634d347 100644 --- a/eeschema/dialogs/dialog_sheet_pin_properties.cpp +++ b/eeschema/dialogs/dialog_sheet_pin_properties.cpp @@ -122,7 +122,7 @@ bool DIALOG_SHEET_PIN_PROPERTIES::TransferDataFromWindow() // and expects text width = text height m_sheetPin->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) ); - auto shape = static_cast( m_choiceConnectionType->GetCurrentSelection() ); + auto shape = static_cast( m_choiceConnectionType->GetCurrentSelection() ); m_sheetPin->SetShape( shape ); m_frame->UpdateItem( m_sheetPin, false, true ); diff --git a/eeschema/dialogs/dialog_sheet_properties.cpp b/eeschema/dialogs/dialog_sheet_properties.cpp index 70bf11ab0f..76ab261a4e 100644 --- a/eeschema/dialogs/dialog_sheet_properties.cpp +++ b/eeschema/dialogs/dialog_sheet_properties.cpp @@ -774,7 +774,9 @@ void DIALOG_SHEET_PROPERTIES::OnMoveUp( wxCommandEvent& event ) m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() ); } else + { wxBell(); + } } @@ -796,7 +798,9 @@ void DIALOG_SHEET_PROPERTIES::OnMoveDown( wxCommandEvent& event ) m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() ); } else + { wxBell(); + } } @@ -866,7 +870,6 @@ void DIALOG_SHEET_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event ) m_grid->MakeCellVisible( m_delayedFocusRow, m_delayedFocusColumn ); m_grid->SetGridCursor( m_delayedFocusRow, m_delayedFocusColumn ); - m_grid->EnableCellEditControl( true ); m_grid->ShowCellEditControl(); @@ -878,12 +881,10 @@ void DIALOG_SHEET_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event ) void DIALOG_SHEET_PROPERTIES::OnSizeGrid( wxSizeEvent& event ) { - auto new_size = event.GetSize().GetX(); + int new_size = event.GetSize().GetX(); if( m_width != new_size ) - { AdjustGridColumns( new_size ); - } // Always propagate for a grid repaint (needed if the height changes, as well as width) event.Skip(); diff --git a/eeschema/dialogs/dialog_sheet_properties.h b/eeschema/dialogs/dialog_sheet_properties.h index c59056285c..441e3f6e34 100644 --- a/eeschema/dialogs/dialog_sheet_properties.h +++ b/eeschema/dialogs/dialog_sheet_properties.h @@ -43,21 +43,6 @@ public: ~DIALOG_SHEET_PROPERTIES() override; private: - SCH_EDIT_FRAME* m_frame; - SCH_SHEET* m_sheet; - bool* m_clearAnnotationNewItems; - - int m_width; - int m_delayedFocusRow; - int m_delayedFocusColumn; - wxString m_shownColumns; - - FIELDS_GRID_TABLE* m_fields; - UNIT_BINDER m_borderWidth; - - SCH_SHEET m_dummySheet; - SCH_FIELD m_dummySheetNameField; - bool onSheetFilenameChanged( const wxString& aNewFilename ); bool TransferDataToWindow() override; @@ -76,6 +61,22 @@ private: void OnInitDlg( wxInitDialogEvent& event ) override; void AdjustGridColumns( int aWidth ); + +private: + SCH_EDIT_FRAME* m_frame; + SCH_SHEET* m_sheet; + bool* m_clearAnnotationNewItems; + + int m_width; + int m_delayedFocusRow; + int m_delayedFocusColumn; + wxString m_shownColumns; + + FIELDS_GRID_TABLE* m_fields; + UNIT_BINDER m_borderWidth; + + SCH_SHEET m_dummySheet; + SCH_FIELD m_dummySheetNameField; }; #endif // DIALOG_SHEET_PROPERTIES_H diff --git a/eeschema/dialogs/dialog_sheet_properties_base.cpp b/eeschema/dialogs/dialog_sheet_properties_base.cpp index c49c484c55..81f7dac74c 100644 --- a/eeschema/dialogs/dialog_sheet_properties_base.cpp +++ b/eeschema/dialogs/dialog_sheet_properties_base.cpp @@ -69,7 +69,7 @@ DIALOG_SHEET_PROPERTIES_BASE::DIALOG_SHEET_PROPERTIES_BASE( wxWindow* parent, wx // Cell Defaults m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - m_grid->SetMinSize( wxSize( -1,180 ) ); + m_grid->SetMinSize( wxSize( -1,120 ) ); sbFields->Add( m_grid, 1, wxALL|wxEXPAND, 5 ); @@ -173,7 +173,7 @@ DIALOG_SHEET_PROPERTIES_BASE::DIALOG_SHEET_PROPERTIES_BASE( wxWindow* parent, wx bSizer6->Add( 0, 0, 3, wxEXPAND, 5 ); - mainSizer->Add( bSizer6, 0, wxALL|wxEXPAND, 5 ); + mainSizer->Add( bSizer6, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); mainSizer->Add( m_staticline1, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); diff --git a/eeschema/dialogs/dialog_sheet_properties_base.fbp b/eeschema/dialogs/dialog_sheet_properties_base.fbp index 332816990d..5b2e5cacc4 100644 --- a/eeschema/dialogs/dialog_sheet_properties_base.fbp +++ b/eeschema/dialogs/dialog_sheet_properties_base.fbp @@ -143,7 +143,7 @@ 0 - -1,180 + -1,120 1 m_grid 1 @@ -975,8 +975,8 @@ - 5 - wxALL|wxEXPAND + 10 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp index 1d93632bf3..e94d127c46 100644 --- a/eeschema/dialogs/dialog_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_symbol_properties.cpp @@ -322,7 +322,7 @@ DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES( SCH_EDIT_FRAME* aParent, if( cfg ) { - m_shownColumns = cfg->m_Appearance.edit_component_visible_columns; + m_shownColumns = cfg->m_Appearance.edit_symbol_visible_columns; m_fieldsGrid->ShowHideColumns( m_shownColumns ); } @@ -379,7 +379,7 @@ DIALOG_SYMBOL_PROPERTIES::~DIALOG_SYMBOL_PROPERTIES() EESCHEMA_SETTINGS* cfg = dynamic_cast( Kiface().KifaceSettings() ); if( cfg ) - cfg->m_Appearance.edit_component_visible_columns = m_fieldsGrid->GetShownColumns(); + cfg->m_Appearance.edit_symbol_visible_columns = m_fieldsGrid->GetShownColumns(); // Prevents crash bug in wxGrid's d'tor m_fieldsGrid->DestroyTable( m_fields ); diff --git a/eeschema/dialogs/dialog_text_and_label_properties.cpp b/eeschema/dialogs/dialog_text_and_label_properties.cpp deleted file mode 100644 index 6064f103bb..0000000000 --- a/eeschema/dialogs/dialog_text_and_label_properties.cpp +++ /dev/null @@ -1,409 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2013 Wayne Stambaugh - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. - * - * 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; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class SCH_EDIT_FRAME; -class SCH_TEXT; - - -DIALOG_TEXT_AND_LABEL_PROPERTIES::DIALOG_TEXT_AND_LABEL_PROPERTIES( SCH_EDIT_FRAME* aParent, - SCH_TEXT* aTextItem ) : - DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE( aParent ), - m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, false ), - m_netNameValidator( true ), - m_scintillaTricks( nullptr ), - m_helpWindow( nullptr ) -{ - m_Parent = aParent; - m_CurrentText = aTextItem; - - m_valueMultiLine->SetEOLMode( wxSTC_EOL_LF ); - - m_scintillaTricks = new SCINTILLA_TRICKS( m_valueMultiLine, wxT( "{}" ), false, - [this]() - { - wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); - } ); - - if( m_CurrentText->IsMultilineAllowed() ) - { - m_activeTextCtrl = m_valueMultiLine; - m_activeTextEntry = nullptr; - - m_labelSingleLine->Show( false ); - m_valueSingleLine->Show( false ); - m_labelCombo->Show( false ); - m_valueCombo->Show( false ); - - m_textEntrySizer->AddGrowableRow( 0 ); - } - else if( m_CurrentText->Type() == SCH_GLOBAL_LABEL_T || m_CurrentText->Type() == SCH_LABEL_T ) - { - m_activeTextCtrl = m_valueCombo; - m_activeTextEntry = m_valueCombo; - - m_labelSingleLine->Show( false ); m_valueSingleLine->Show( false ); - m_labelMultiLine->Show( false ); m_valueMultiLine->Show( false ); - - m_valueCombo->SetValidator( m_netNameValidator ); - } - else - { - m_activeTextCtrl = m_valueSingleLine; - m_activeTextEntry = m_valueSingleLine; - - m_labelCombo->Show( false ); - m_valueCombo->Show( false ); - m_labelMultiLine->Show( false ); - m_valueMultiLine->Show( false ); - - if( m_CurrentText->Type() != SCH_TEXT_T ) - m_valueSingleLine->SetValidator( m_netNameValidator ); - - m_valueCombo->SetValidator( m_netNameValidator ); - } - - switch( m_CurrentText->Type() ) - { - case SCH_GLOBAL_LABEL_T: SetTitle( _( "Global Label Properties" ) ); break; - case SCH_HIER_LABEL_T: SetTitle( _( "Hierarchical Label Properties" ) ); break; - case SCH_LABEL_T: SetTitle( _( "Label Properties" ) ); break; - case SCH_SHEET_PIN_T: SetTitle( _( "Hierarchical Sheet Pin Properties" ) ); break; - default: SetTitle( _( "Text Properties" ) ); break; - } - - SetInitialFocus( m_activeTextCtrl ); - - m_TextShape->Show( m_CurrentText->Type() == SCH_GLOBAL_LABEL_T || - m_CurrentText->Type() == SCH_HIER_LABEL_T ); - - if( m_CurrentText->Type() == SCH_GLOBAL_LABEL_T ) - { - m_note1->SetFont( KIUI::GetInfoFont( this ).Italic() ); - m_note2->SetFont( KIUI::GetInfoFont( this ).Italic() ); - } - else - { - m_note1->Show( false ); - m_note2->Show( false ); - } - - m_sdbSizer1OK->SetDefault(); - Layout(); - - m_valueMultiLine->Bind( wxEVT_STC_CHARADDED, &DIALOG_TEXT_AND_LABEL_PROPERTIES::onScintillaCharAdded, this ); - - // DIALOG_SHIM needs a unique hash_key because classname is not sufficient because the - // various versions have different controls so we want to store sizes for each version. - m_hash_key = TO_UTF8( GetTitle() ); - - - // Now all widgets have the size fixed, call FinishDialogSettings - finishDialogSettings(); -} - - -DIALOG_TEXT_AND_LABEL_PROPERTIES::~DIALOG_TEXT_AND_LABEL_PROPERTIES() -{ - delete m_scintillaTricks; - - if( m_helpWindow ) - m_helpWindow->Destroy(); -} - - -void DIALOG_TEXT_AND_LABEL_PROPERTIES::SetTitle( const wxString& aTitle ) -{ - // This class is shared for numerous tasks: a couple of single line labels and - // multi-line text fields. Since the desired size of the multi-line text field editor - // is often larger, we retain separate sizes based on the dialog titles. - switch( m_CurrentText->Type() ) - { - case SCH_GLOBAL_LABEL_T: - case SCH_HIER_LABEL_T: - case SCH_LABEL_T: - // labels can share retained settings probably. - break; - - default: - m_hash_key = TO_UTF8( aTitle ); - m_hash_key += typeid(*this).name(); - } - - DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::SetTitle( aTitle ); -} - - -bool DIALOG_TEXT_AND_LABEL_PROPERTIES::TransferDataToWindow() -{ - if( !wxDialog::TransferDataToWindow() ) - return false; - - if( m_CurrentText->Type() == SCH_TEXT_T ) - { - SCHEMATIC& schematic = m_Parent->Schematic(); - - // show text variable cross-references in a human-readable format - m_valueMultiLine->SetValue( schematic.ConvertKIIDsToRefs( m_CurrentText->GetText() ) ); - } - else - { - // show control characters in a human-readable format - m_activeTextEntry->SetValue( UnescapeString( m_CurrentText->GetText() ) ); - } - - if( m_valueCombo->IsShown() ) - { - // Load the combobox with the existing labels of the same type - std::set existingLabels; - SCH_SCREENS allScreens( m_Parent->Schematic().Root() ); - - for( SCH_SCREEN* screen = allScreens.GetFirst(); screen; screen = allScreens.GetNext() ) - { - for( SCH_ITEM* item : screen->Items().OfType( m_CurrentText->Type() ) ) - { - auto textItem = static_cast( item ); - existingLabels.insert( UnescapeString( textItem->GetText() ) ); - } - } - - wxArrayString existingLabelArray; - - for( const wxString& label : existingLabels ) - existingLabelArray.push_back( label ); - - // existingLabelArray.Sort(); - m_valueCombo->Append( existingLabelArray ); - } - - // Set text options: - m_TextOrient->SetSelection( static_cast( m_CurrentText->GetLabelSpinStyle() ) ); - - m_TextShape->SetSelection( static_cast( m_CurrentText->GetShape() ) ); - - int style = 0; - - if( m_CurrentText->IsItalic() ) - style = 1; - - if( m_CurrentText->IsBold() ) - style += 2; - - m_TextStyle->SetSelection( style ); - - m_textSize.SetValue( m_CurrentText->GetTextWidth() ); - - return true; -} - - -/*! - * wxEVT_COMMAND_ENTER event handler for single-line control - */ -void DIALOG_TEXT_AND_LABEL_PROPERTIES::OnEnterKey( wxCommandEvent& aEvent ) -{ - wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); -} - - -void DIALOG_TEXT_AND_LABEL_PROPERTIES::onScintillaCharAdded( wxStyledTextEvent &aEvent ) -{ - wxStyledTextCtrl* te = m_valueMultiLine; - wxArrayString autocompleteTokens; - int text_pos = te->GetCurrentPos(); - int start = te->WordStartPosition( text_pos, true ); - wxString partial; - - auto textVarRef = - [&]( int pos ) - { - return pos >= 2 && te->GetCharAt( pos-2 ) == '$' && te->GetCharAt( pos-1 ) == '{'; - }; - - // Check for cross-reference - if( start > 1 && te->GetCharAt( start-1 ) == ':' ) - { - int refStart = te->WordStartPosition( start-1, true ); - - if( textVarRef( refStart ) ) - { - partial = te->GetRange( start+1, text_pos ); - - wxString ref = te->GetRange( refStart, start-1 ); - SCH_SHEET_LIST sheets = m_Parent->Schematic().GetSheets(); - SCH_REFERENCE_LIST refs; - SCH_SYMBOL* refSymbol = nullptr; - - sheets.GetSymbols( refs ); - - for( size_t jj = 0; jj < refs.GetCount(); jj++ ) - { - if( refs[ jj ].GetSymbol()->GetRef( &refs[ jj ].GetSheetPath(), true ) == ref ) - { - refSymbol = refs[ jj ].GetSymbol(); - break; - } - } - - if( refSymbol ) - refSymbol->GetContextualTextVars( &autocompleteTokens ); - } - } - else if( textVarRef( start ) ) - { - partial = te->GetTextRange( start, text_pos ); - - m_CurrentText->GetContextualTextVars( &autocompleteTokens ); - - SCHEMATIC* schematic = m_CurrentText->Schematic(); - - if( schematic && schematic->CurrentSheet().Last() ) - schematic->CurrentSheet().Last()->GetContextualTextVars( &autocompleteTokens ); - - for( std::pair entry : Prj().GetTextVars() ) - autocompleteTokens.push_back( entry.first ); - } - - m_scintillaTricks->DoAutocomplete( partial, autocompleteTokens ); - m_valueMultiLine->SetFocus(); -} - - -bool DIALOG_TEXT_AND_LABEL_PROPERTIES::TransferDataFromWindow() -{ - if( !wxDialog::TransferDataFromWindow() ) - return false; - - // Don't allow text to disappear; it can be difficult to correct if you can't select it - if( !m_textSize.Validate( 0.01, 1000.0, EDA_UNITS::MILLIMETRES ) ) - return false; - - wxString text; - - /* save old text in undo list if not already in edit */ - if( m_CurrentText->GetEditFlags() == 0 ) - m_Parent->SaveCopyInUndoList( m_Parent->GetScreen(), m_CurrentText, UNDO_REDO::CHANGED, false ); - - m_Parent->GetCanvas()->Refresh(); - - if( m_CurrentText->Type() == SCH_TEXT_T ) - { - // convert any text variable cross-references to their UUIDs - text = m_Parent->Schematic().ConvertRefsToKIIDs( m_valueMultiLine->GetValue() ); - } - else - { - // labels need escaping - text = EscapeString( m_activeTextEntry->GetValue(), CTX_NETNAME ); - } - - if( !text.IsEmpty() ) - { -#ifdef __WXMAC__ - // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting - text.Replace( "\r", "\n" ); -#endif - m_CurrentText->SetText( text ); - } - else if( !m_CurrentText->IsNew() ) - { - DisplayError( this, _( "Label requires non-empty text." ) ); - return false; - } - - LABEL_SPIN_STYLE selectedSpinStyle( - static_cast( m_TextOrient->GetSelection() ) ); - - if( m_CurrentText->GetLabelSpinStyle() != selectedSpinStyle ) - m_CurrentText->SetLabelSpinStyle( selectedSpinStyle ); - - if( m_CurrentText->GetTextWidth() != m_textSize.GetValue() ) - m_CurrentText->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) ); - - if( m_TextShape ) - m_CurrentText->SetShape( (PINSHEETLABEL_SHAPE) m_TextShape->GetSelection() ); - - int style = m_TextStyle->GetSelection(); - bool wantItalic = ( style & 1 ) > 0; - bool wantBold = (style & 2 ) > 0; - - m_CurrentText->SetItalic( wantItalic ); - - if( wantBold != m_CurrentText->IsBold() ) - { - if( wantBold ) - { - m_CurrentText->SetBold( true ); - m_CurrentText->SetTextThickness( GetPenSizeForBold( m_CurrentText->GetTextWidth() ) ); - } - else - { - m_CurrentText->SetBold( false ); - m_CurrentText->SetTextThickness( 0 ); // Use default pen width - } - } - - m_Parent->UpdateItem( m_CurrentText, false, true ); - m_Parent->GetCanvas()->Refresh(); - m_Parent->OnModify(); - - if( m_CurrentText->Type() == SCH_GLOBAL_LABEL_T ) - { - SCH_GLOBALLABEL* label = static_cast( m_CurrentText ); - label->UpdateIntersheetRefProps(); - } - - return true; -} - - -void DIALOG_TEXT_AND_LABEL_PROPERTIES::onMultiLineTCLostFocus( wxFocusEvent& event ) -{ - if( m_scintillaTricks ) - m_scintillaTricks->CancelAutocomplete(); - - event.Skip(); -} - - -void DIALOG_TEXT_AND_LABEL_PROPERTIES::OnFormattingHelp( wxHyperlinkEvent& aEvent ) -{ - m_helpWindow = SCH_TEXT::ShowSyntaxHelp( this ); -} diff --git a/eeschema/dialogs/dialog_text_and_label_properties_base.cpp b/eeschema/dialogs/dialog_text_and_label_properties_base.cpp deleted file mode 100644 index 25c36f7f6e..0000000000 --- a/eeschema/dialogs/dialog_text_and_label_properties_base.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "dialog_text_and_label_properties_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) -{ - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - - wxBoxSizer* bMainSizer; - bMainSizer = new wxBoxSizer( wxVERTICAL ); - - m_textEntrySizer = new wxFlexGridSizer( 5, 2, 1, 3 ); - m_textEntrySizer->AddGrowableCol( 1 ); - m_textEntrySizer->AddGrowableRow( 1 ); - m_textEntrySizer->SetFlexibleDirection( wxBOTH ); - m_textEntrySizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_textEntrySizer->SetMinSize( wxSize( 500,-1 ) ); - m_labelSingleLine = new wxStaticText( this, wxID_ANY, _("Label:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_labelSingleLine->Wrap( -1 ); - m_labelSingleLine->SetToolTip( _("Enter the text to be used within the schematic") ); - - m_textEntrySizer->Add( m_labelSingleLine, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 2 ); - - m_valueSingleLine = new wxTextCtrl( this, wxID_VALUESINGLE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RICH ); - m_valueSingleLine->SetMinSize( wxSize( 360,-1 ) ); - - m_textEntrySizer->Add( m_valueSingleLine, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM, 2 ); - - m_labelMultiLine = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_labelMultiLine->Wrap( -1 ); - m_textEntrySizer->Add( m_labelMultiLine, 0, wxTOP|wxRIGHT, 2 ); - - m_valueMultiLine = new wxStyledTextCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN, wxEmptyString ); - m_valueMultiLine->SetUseTabs( true ); - m_valueMultiLine->SetTabWidth( 4 ); - m_valueMultiLine->SetIndent( 4 ); - m_valueMultiLine->SetTabIndents( false ); - m_valueMultiLine->SetBackSpaceUnIndents( false ); - m_valueMultiLine->SetViewEOL( false ); - m_valueMultiLine->SetViewWhiteSpace( false ); - m_valueMultiLine->SetMarginWidth( 2, 0 ); - m_valueMultiLine->SetIndentationGuides( false ); - m_valueMultiLine->SetReadOnly( false ); - m_valueMultiLine->SetMarginWidth( 1, 0 ); - m_valueMultiLine->SetMarginWidth( 0, 0 ); - m_valueMultiLine->MarkerDefine( wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS ); - m_valueMultiLine->MarkerSetBackground( wxSTC_MARKNUM_FOLDER, wxColour( wxT("BLACK") ) ); - m_valueMultiLine->MarkerSetForeground( wxSTC_MARKNUM_FOLDER, wxColour( wxT("WHITE") ) ); - m_valueMultiLine->MarkerDefine( wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS ); - m_valueMultiLine->MarkerSetBackground( wxSTC_MARKNUM_FOLDEROPEN, wxColour( wxT("BLACK") ) ); - m_valueMultiLine->MarkerSetForeground( wxSTC_MARKNUM_FOLDEROPEN, wxColour( wxT("WHITE") ) ); - m_valueMultiLine->MarkerDefine( wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY ); - m_valueMultiLine->MarkerDefine( wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUS ); - m_valueMultiLine->MarkerSetBackground( wxSTC_MARKNUM_FOLDEREND, wxColour( wxT("BLACK") ) ); - m_valueMultiLine->MarkerSetForeground( wxSTC_MARKNUM_FOLDEREND, wxColour( wxT("WHITE") ) ); - m_valueMultiLine->MarkerDefine( wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUS ); - m_valueMultiLine->MarkerSetBackground( wxSTC_MARKNUM_FOLDEROPENMID, wxColour( wxT("BLACK") ) ); - m_valueMultiLine->MarkerSetForeground( wxSTC_MARKNUM_FOLDEROPENMID, wxColour( wxT("WHITE") ) ); - m_valueMultiLine->MarkerDefine( wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY ); - m_valueMultiLine->MarkerDefine( wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY ); - m_valueMultiLine->SetSelBackground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); - m_valueMultiLine->SetSelForeground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) ); - m_textEntrySizer->Add( m_valueMultiLine, 1, wxEXPAND|wxBOTTOM, 2 ); - - m_labelCombo = new wxStaticText( this, wxID_ANY, _("Label:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_labelCombo->Wrap( -1 ); - m_textEntrySizer->Add( m_labelCombo, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - m_valueCombo = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER ); - m_valueCombo->SetMinSize( wxSize( 360,-1 ) ); - - m_textEntrySizer->Add( m_valueCombo, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); - - m_textSizeLabel = new wxStaticText( this, wxID_ANY, _("Text Size:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textSizeLabel->Wrap( -1 ); - m_textEntrySizer->Add( m_textSizeLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 6 ); - - wxBoxSizer* bSizeCtrlSizer; - bSizeCtrlSizer = new wxBoxSizer( wxHORIZONTAL ); - - m_textSizeCtrl = new wxTextCtrl( this, wxID_SIZE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - bSizeCtrlSizer->Add( m_textSizeCtrl, 0, wxBOTTOM|wxRIGHT|wxTOP, 6 ); - - m_textSizeUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textSizeUnits->Wrap( -1 ); - bSizeCtrlSizer->Add( m_textSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 6 ); - - - bSizeCtrlSizer->Add( 0, 0, 1, wxEXPAND, 15 ); - - m_formattingHelp = new wxHyperlinkCtrl( this, wxID_ANY, _("Syntax help"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE ); - m_formattingHelp->SetToolTip( _("Show syntax help window") ); - - bSizeCtrlSizer->Add( m_formattingHelp, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 ); - - - m_textEntrySizer->Add( bSizeCtrlSizer, 1, wxEXPAND, 6 ); - - m_note1 = new wxStaticText( this, wxID_ANY, _("Note:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_note1->Wrap( -1 ); - m_textEntrySizer->Add( m_note1, 0, wxTOP|wxRIGHT, 2 ); - - m_note2 = new wxStaticText( this, wxID_ANY, _("The margins around the text are controlled by the text offset ratio\nin Schematic Setup > General > Formatting."), wxDefaultPosition, wxDefaultSize, 0 ); - m_note2->Wrap( -1 ); - m_textEntrySizer->Add( m_note2, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 2 ); - - - bMainSizer->Add( m_textEntrySizer, 1, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 12 ); - - wxBoxSizer* m_OptionsSizer; - m_OptionsSizer = new wxBoxSizer( wxHORIZONTAL ); - - wxString m_TextOrientChoices[] = { _("Align right"), _("Align bottom"), _("Align left"), _("Align top") }; - int m_TextOrientNChoices = sizeof( m_TextOrientChoices ) / sizeof( wxString ); - m_TextOrient = new wxRadioBox( this, wxID_ANY, _("Justification"), wxDefaultPosition, wxDefaultSize, m_TextOrientNChoices, m_TextOrientChoices, 1, wxRA_SPECIFY_COLS ); - m_TextOrient->SetSelection( 2 ); - m_OptionsSizer->Add( m_TextOrient, 1, wxRIGHT|wxTOP|wxEXPAND, 3 ); - - wxString m_TextStyleChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold and italic") }; - int m_TextStyleNChoices = sizeof( m_TextStyleChoices ) / sizeof( wxString ); - m_TextStyle = new wxRadioBox( this, wxID_ANY, _("Style"), wxDefaultPosition, wxDefaultSize, m_TextStyleNChoices, m_TextStyleChoices, 1, wxRA_SPECIFY_COLS ); - m_TextStyle->SetSelection( 0 ); - m_OptionsSizer->Add( m_TextStyle, 1, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 3 ); - - wxString m_TextShapeChoices[] = { _("Input"), _("Output"), _("Bidirectional"), _("Tri-state"), _("Passive") }; - int m_TextShapeNChoices = sizeof( m_TextShapeChoices ) / sizeof( wxString ); - m_TextShape = new wxRadioBox( this, wxID_ANY, _("Shape"), wxDefaultPosition, wxDefaultSize, m_TextShapeNChoices, m_TextShapeChoices, 1, wxRA_SPECIFY_COLS ); - m_TextShape->SetSelection( 0 ); - m_OptionsSizer->Add( m_TextShape, 1, wxEXPAND|wxTOP|wxLEFT, 3 ); - - - bMainSizer->Add( m_OptionsSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 10 ); - - wxBoxSizer* bSizer4; - bSizer4 = new wxBoxSizer( wxHORIZONTAL ); - - m_sdbSizer1 = new wxStdDialogButtonSizer(); - m_sdbSizer1OK = new wxButton( this, wxID_OK ); - m_sdbSizer1->AddButton( m_sdbSizer1OK ); - m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL ); - m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); - m_sdbSizer1->Realize(); - - bSizer4->Add( m_sdbSizer1, 1, wxALL|wxEXPAND, 5 ); - - - bMainSizer->Add( bSizer4, 0, wxEXPAND|wxALL, 5 ); - - - this->SetSizer( bMainSizer ); - this->Layout(); - bMainSizer->Fit( this ); - - // Connect Events - m_valueSingleLine->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::OnEnterKey ), NULL, this ); - m_valueMultiLine->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); - m_valueCombo->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::OnEnterKey ), NULL, this ); - m_formattingHelp->Connect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::OnFormattingHelp ), NULL, this ); -} - -DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::~DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE() -{ - // Disconnect Events - m_valueSingleLine->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::OnEnterKey ), NULL, this ); - m_valueMultiLine->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); - m_valueCombo->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::OnEnterKey ), NULL, this ); - m_formattingHelp->Disconnect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::OnFormattingHelp ), NULL, this ); - -} diff --git a/eeschema/dialogs/dialog_text_and_label_properties_base.fbp b/eeschema/dialogs/dialog_text_and_label_properties_base.fbp deleted file mode 100644 index d9be83b1db..0000000000 --- a/eeschema/dialogs/dialog_text_and_label_properties_base.fbp +++ /dev/null @@ -1,1098 +0,0 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - dialog_text_and_label_properties_base - 1000 - none - - - 1 - dialog_text_and_label_properties_base - - . - - 1 - 1 - 1 - 1 - UI - 0 - 1 - 0 - - 0 - wxAUI_MGR_DEFAULT - - - - 1 - 1 - impl_virtual - - - - 0 - wxID_ANY - - - DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE - - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - Text Properties - - 0 - - - - - - bMainSizer - wxVERTICAL - none - - 12 - wxEXPAND|wxLEFT|wxRIGHT|wxTOP - 1 - - 2 - wxBOTH - 1 - 1 - 3 - 500,-1 - m_textEntrySizer - wxFLEX_GROWMODE_SPECIFIED - protected - 5 - 1 - - 2 - wxALIGN_CENTER_VERTICAL|wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Label: - 0 - - 0 - - - 0 - - 1 - m_labelSingleLine - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Enter the text to be used within the schematic - - - - -1 - - - - 2 - wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_VALUESINGLE - - 0 - - - - 0 - 360,-1 - 1 - m_valueSingleLine - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_PROCESS_ENTER|wxTE_RICH - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - OnEnterKey - - - - 2 - wxTOP|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Text: - 0 - - 0 - - - 0 - - 1 - m_labelMultiLine - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 - - - - 2 - wxEXPAND|wxBOTTOM - 1 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - 0 - - 0 - 0 - wxID_ANY - 0 - 0 - - 0 - - - 0 - -1,-1 - 1 - m_valueMultiLine - 1 - - - protected - 1 - - 0 - Resizable - 1 - - ; forward_declare - 0 - 4 - 0 - - 1 - 0 - 0 - - - wxBORDER_SUNKEN - onMultiLineTCLostFocus - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Label: - 0 - - 0 - - - 0 - - 1 - m_labelCombo - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 - - - - 5 - wxEXPAND|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - 360,-1 - 1 - m_valueCombo - 1 - - - protected - 1 - - Resizable - -1 - 1 - - wxTE_PROCESS_ENTER - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - OnEnterKey - - - - 6 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Text Size: - 0 - - 0 - - - 0 - - 1 - m_textSizeLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 6 - wxEXPAND - 1 - - - bSizeCtrlSizer - wxHORIZONTAL - none - - 6 - wxBOTTOM|wxRIGHT|wxTOP - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_SIZE - - 0 - - - - 0 - - 1 - m_textSizeCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 6 - wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - 0 - - 0 - - - 0 - - 1 - m_textSizeUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 15 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - - wxID_ANY - Syntax help - - 0 - - - 0 - - 1 - m_formattingHelp - - 1 - - - protected - 1 - - Resizable - 1 - - wxHL_DEFAULT_STYLE - ; ; forward_declare - 0 - Show syntax help window - - - - - - OnFormattingHelp - - - - - - 2 - wxTOP|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Note: - 0 - - 0 - - - 0 - - 1 - m_note1 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 2 - wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - The margins around the text are controlled by the text offset ratio in Schematic Setup > General > Formatting. - 0 - - 0 - - - 0 - - 1 - m_note2 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - - - 10 - wxEXPAND|wxLEFT|wxRIGHT|wxTOP - 0 - - - m_OptionsSizer - wxHORIZONTAL - none - - 3 - wxRIGHT|wxTOP|wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Align right" "Align bottom" "Align left" "Align top" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Justification - 1 - - 0 - - - 0 - - 1 - m_TextOrient - 1 - - - protected - 1 - - Resizable - 2 - 1 - - wxRA_SPECIFY_COLS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 3 - wxLEFT|wxRIGHT|wxTOP|wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Normal" "Italic" "Bold" "Bold and italic" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Style - 1 - - 0 - - - 0 - - 1 - m_TextStyle - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 3 - wxEXPAND|wxTOP|wxLEFT - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Input" "Output" "Bidirectional" "Tri-state" "Passive" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Shape - 1 - - 0 - - - 0 - - 1 - m_TextShape - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - 5 - wxEXPAND|wxALL - 0 - - - bSizer4 - wxHORIZONTAL - none - - 5 - wxALL|wxEXPAND - 1 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer1 - protected - - - - - - - - diff --git a/eeschema/dialogs/dialog_text_properties.cpp b/eeschema/dialogs/dialog_text_properties.cpp new file mode 100644 index 0000000000..a294615aff --- /dev/null +++ b/eeschema/dialogs/dialog_text_properties.cpp @@ -0,0 +1,296 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2013 Wayne Stambaugh + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * + * 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; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class SCH_EDIT_FRAME; +class SCH_TEXT; + + +DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTextItem ) : + DIALOG_TEXT_PROPERTIES_BASE( aParent ), + m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, false ), + m_scintillaTricks( nullptr ), + m_helpWindow( nullptr ) +{ + m_Parent = aParent; + m_currentText = aTextItem; + + m_textCtrl->SetEOLMode( wxSTC_EOL_LF ); + + m_scintillaTricks = new SCINTILLA_TRICKS( m_textCtrl, wxT( "{}" ), false, + [this]() + { + wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); + } ); + + m_textEntrySizer->AddGrowableRow( 0 ); + + SetInitialFocus( m_textCtrl ); + + m_separator1->SetIsSeparator(); + + m_bold->SetIsCheckButton(); + m_bold->SetBitmap( KiBitmap( BITMAPS::text_bold ) ); + m_italic->SetIsCheckButton(); + m_italic->SetBitmap( KiBitmap( BITMAPS::text_italic ) ); + + m_separator2->SetIsSeparator(); + + m_spin0->SetIsCheckButton(); + m_spin0->SetBitmap( KiBitmap( BITMAPS::text_align_left ) ); + m_spin1->SetIsCheckButton(); + m_spin1->SetBitmap( KiBitmap( BITMAPS::text_align_right ) ); + m_spin2->SetIsCheckButton(); + m_spin2->SetBitmap( KiBitmap( BITMAPS::text_align_bottom ) ); + m_spin3->SetIsCheckButton(); + m_spin3->SetBitmap( KiBitmap( BITMAPS::text_align_top ) ); + + m_separator3->SetIsSeparator(); + + m_sdbSizer1OK->SetDefault(); + Layout(); + + m_textCtrl->Bind( wxEVT_STC_CHARADDED, &DIALOG_TEXT_PROPERTIES::onScintillaCharAdded, this ); + m_spin0->Bind( wxEVT_BUTTON, &DIALOG_TEXT_PROPERTIES::onSpinButton, this ); + m_spin1->Bind( wxEVT_BUTTON, &DIALOG_TEXT_PROPERTIES::onSpinButton, this ); + m_spin2->Bind( wxEVT_BUTTON, &DIALOG_TEXT_PROPERTIES::onSpinButton, this ); + m_spin3->Bind( wxEVT_BUTTON, &DIALOG_TEXT_PROPERTIES::onSpinButton, this ); + + // Now all widgets have the size fixed, call FinishDialogSettings + finishDialogSettings(); +} + + +DIALOG_TEXT_PROPERTIES::~DIALOG_TEXT_PROPERTIES() +{ + delete m_scintillaTricks; + + if( m_helpWindow ) + m_helpWindow->Destroy(); +} + + +bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow() +{ + if( !wxDialog::TransferDataToWindow() ) + return false; + + SCHEMATIC& schematic = m_Parent->Schematic(); + + // show text variable cross-references in a human-readable format + m_textCtrl->SetValue( schematic.ConvertKIIDsToRefs( m_currentText->GetText() ) ); + + m_textSize.SetValue( m_currentText->GetTextWidth() ); + + m_bold->Check( m_currentText->IsBold() ); + m_italic->Check( m_currentText->IsItalic() ); + + switch( m_currentText->GetLabelSpinStyle() ) + { + case LABEL_SPIN_STYLE::RIGHT: m_spin0->Check( true ); break; + case LABEL_SPIN_STYLE::LEFT: m_spin1->Check( true ); break; + case LABEL_SPIN_STYLE::UP: m_spin2->Check( true ); break; + case LABEL_SPIN_STYLE::BOTTOM: m_spin3->Check( true ); break; + } + + return true; +} + + +void DIALOG_TEXT_PROPERTIES::onScintillaCharAdded( wxStyledTextEvent &aEvent ) +{ + wxStyledTextCtrl* te = m_textCtrl; + wxArrayString autocompleteTokens; + int text_pos = te->GetCurrentPos(); + int start = te->WordStartPosition( text_pos, true ); + wxString partial; + + auto textVarRef = + [&]( int pos ) + { + return pos >= 2 && te->GetCharAt( pos-2 ) == '$' && te->GetCharAt( pos-1 ) == '{'; + }; + + // Check for cross-reference + if( start > 1 && te->GetCharAt( start-1 ) == ':' ) + { + int refStart = te->WordStartPosition( start-1, true ); + + if( textVarRef( refStart ) ) + { + partial = te->GetRange( start+1, text_pos ); + + wxString ref = te->GetRange( refStart, start-1 ); + SCH_SHEET_LIST sheets = m_Parent->Schematic().GetSheets(); + SCH_REFERENCE_LIST refs; + SCH_SYMBOL* refSymbol = nullptr; + + sheets.GetSymbols( refs ); + + for( size_t jj = 0; jj < refs.GetCount(); jj++ ) + { + if( refs[ jj ].GetSymbol()->GetRef( &refs[ jj ].GetSheetPath(), true ) == ref ) + { + refSymbol = refs[ jj ].GetSymbol(); + break; + } + } + + if( refSymbol ) + refSymbol->GetContextualTextVars( &autocompleteTokens ); + } + } + else if( textVarRef( start ) ) + { + partial = te->GetTextRange( start, text_pos ); + + SCHEMATIC* schematic = m_currentText->Schematic(); + + if( schematic && schematic->CurrentSheet().Last() ) + schematic->CurrentSheet().Last()->GetContextualTextVars( &autocompleteTokens ); + + for( std::pair entry : Prj().GetTextVars() ) + autocompleteTokens.push_back( entry.first ); + } + + m_scintillaTricks->DoAutocomplete( partial, autocompleteTokens ); + m_textCtrl->SetFocus(); +} + + +void DIALOG_TEXT_PROPERTIES::onSpinButton( wxCommandEvent& aEvent ) +{ + for( BITMAP_BUTTON* btn : { m_spin0, m_spin1, m_spin2, m_spin3 } ) + { + if( btn->IsChecked() && btn != aEvent.GetEventObject() ) + btn->Check( false ); + } +} + + +bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() +{ + if( !wxDialog::TransferDataFromWindow() ) + return false; + + // Don't allow text to disappear; it can be difficult to correct if you can't select it + if( !m_textSize.Validate( 0.01, 1000.0, EDA_UNITS::MILLIMETRES ) ) + return false; + + wxString text; + + /* save old text in undo list if not already in edit */ + if( m_currentText->GetEditFlags() == 0 ) + { + m_Parent->SaveCopyInUndoList( m_Parent->GetScreen(), m_currentText, UNDO_REDO::CHANGED, + false ); + } + + m_Parent->GetCanvas()->Refresh(); + + // convert any text variable cross-references to their UUIDs + text = m_Parent->Schematic().ConvertRefsToKIIDs( m_textCtrl->GetValue() ); + + if( !text.IsEmpty() ) + { +#ifdef __WXMAC__ + // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting + text.Replace( "\r", "\n" ); +#endif + + m_currentText->SetText( text ); + } + else if( !m_currentText->IsNew() ) + { + DisplayError( this, _( "Text can not be empty." ) ); + return false; + } + + if( m_currentText->GetTextWidth() != m_textSize.GetValue() ) + m_currentText->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) ); + + if( m_bold->IsChecked() != m_currentText->IsBold() ) + { + if( m_bold->IsChecked() ) + { + m_currentText->SetBold( true ); + m_currentText->SetTextThickness( GetPenSizeForBold( m_currentText->GetTextWidth() ) ); + } + else + { + m_currentText->SetBold( false ); + m_currentText->SetTextThickness( 0 ); // Use default pen width + } + } + + m_currentText->SetItalic( m_italic->IsChecked() ); + + LABEL_SPIN_STYLE selectedSpinStyle= LABEL_SPIN_STYLE::LEFT; + + if( m_spin0->IsChecked() ) + selectedSpinStyle = LABEL_SPIN_STYLE::RIGHT; + else if( m_spin1->IsChecked() ) + selectedSpinStyle = LABEL_SPIN_STYLE::LEFT; + else if( m_spin2->IsChecked() ) + selectedSpinStyle = LABEL_SPIN_STYLE::UP; + else if( m_spin3->IsChecked() ) + selectedSpinStyle = LABEL_SPIN_STYLE::BOTTOM; + + if( m_currentText->GetLabelSpinStyle() != selectedSpinStyle ) + m_currentText->SetLabelSpinStyle( selectedSpinStyle ); + + m_Parent->UpdateItem( m_currentText, false, true ); + m_Parent->GetCanvas()->Refresh(); + m_Parent->OnModify(); + + return true; +} + + +void DIALOG_TEXT_PROPERTIES::OnFormattingHelp( wxHyperlinkEvent& aEvent ) +{ + m_helpWindow = SCH_TEXT::ShowSyntaxHelp( this ); +} + + +void DIALOG_TEXT_PROPERTIES::onMultiLineTCLostFocus( wxFocusEvent& event ) +{ + if( m_scintillaTricks ) + m_scintillaTricks->CancelAutocomplete(); + + event.Skip(); +} diff --git a/eeschema/dialogs/dialog_text_and_label_properties.h b/eeschema/dialogs/dialog_text_properties.h similarity index 63% rename from eeschema/dialogs/dialog_text_and_label_properties.h rename to eeschema/dialogs/dialog_text_properties.h index 76c686702e..f5767611c0 100644 --- a/eeschema/dialogs/dialog_text_and_label_properties.h +++ b/eeschema/dialogs/dialog_text_properties.h @@ -21,13 +21,12 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef DIALOG_TEXT_AND_LABEL_PROPERTIES_H -#define DIALOG_TEXT_AND_LABEL_PROPERTIES_H +#ifndef DIALOG_TEXT_PROPERTIES_H +#define DIALOG_TEXT_PROPERTIES_H #include #include -#include -#include +#include class SCH_EDIT_FRAME; @@ -36,21 +35,16 @@ class SCINTILLA_TRICKS; class HTML_MESSAGE_BOX; -class DIALOG_TEXT_AND_LABEL_PROPERTIES : public DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE +class DIALOG_TEXT_PROPERTIES : public DIALOG_TEXT_PROPERTIES_BASE { public: - DIALOG_TEXT_AND_LABEL_PROPERTIES( SCH_EDIT_FRAME* parent, SCH_TEXT* aTextItem ); - ~DIALOG_TEXT_AND_LABEL_PROPERTIES(); - - // This class is shared for numerous tasks: a couple of single line labels and - // multi-line text fields. Since the desired size of the multi-line text field editor - // is often larger, we retain separate sizes based on the dialog titles. - void SetTitle( const wxString& aTitle ) override; + DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* parent, SCH_TEXT* aTextItem ); + ~DIALOG_TEXT_PROPERTIES(); private: void onScintillaCharAdded( wxStyledTextEvent &aEvent ); + void onSpinButton( wxCommandEvent &aEvent ); - void OnEnterKey( wxCommandEvent& aEvent ) override; void OnFormattingHelp( wxHyperlinkEvent& aEvent ) override; void onMultiLineTCLostFocus( wxFocusEvent& event ) override; @@ -58,11 +52,8 @@ private: bool TransferDataFromWindow() override; SCH_EDIT_FRAME* m_Parent; - SCH_TEXT* m_CurrentText; - wxWindow* m_activeTextCtrl; - wxTextEntry* m_activeTextEntry; + SCH_TEXT* m_currentText; UNIT_BINDER m_textSize; - SCH_NETNAME_VALIDATOR m_netNameValidator; SCINTILLA_TRICKS* m_scintillaTricks; HTML_MESSAGE_BOX* m_helpWindow; @@ -70,4 +61,4 @@ private: -#endif // DIALOG_TEXT_AND_LABEL_PROPERTIES_H +#endif // DIALOG_TEXT_PROPERTIES_H diff --git a/eeschema/dialogs/dialog_text_properties_base.cpp b/eeschema/dialogs/dialog_text_properties_base.cpp new file mode 100644 index 0000000000..6653967501 --- /dev/null +++ b/eeschema/dialogs/dialog_text_properties_base.cpp @@ -0,0 +1,171 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "widgets/bitmap_button.h" + +#include "dialog_text_properties_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bMainSizer; + bMainSizer = new wxBoxSizer( wxVERTICAL ); + + m_textEntrySizer = new wxFlexGridSizer( 5, 2, 1, 5 ); + m_textEntrySizer->AddGrowableCol( 1 ); + m_textEntrySizer->AddGrowableRow( 1 ); + m_textEntrySizer->SetFlexibleDirection( wxBOTH ); + m_textEntrySizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_textLabel = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textLabel->Wrap( -1 ); + m_textEntrySizer->Add( m_textLabel, 0, wxTOP|wxRIGHT, 2 ); + + m_textCtrl = new wxStyledTextCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN, wxEmptyString ); + m_textCtrl->SetUseTabs( true ); + m_textCtrl->SetTabWidth( 4 ); + m_textCtrl->SetIndent( 4 ); + m_textCtrl->SetTabIndents( false ); + m_textCtrl->SetBackSpaceUnIndents( false ); + m_textCtrl->SetViewEOL( false ); + m_textCtrl->SetViewWhiteSpace( false ); + m_textCtrl->SetMarginWidth( 2, 0 ); + m_textCtrl->SetIndentationGuides( false ); + m_textCtrl->SetMarginWidth( 1, 0 ); + m_textCtrl->SetMarginWidth( 0, 0 ); + m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS ); + m_textCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDER, wxColour( wxT("BLACK") ) ); + m_textCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDER, wxColour( wxT("WHITE") ) ); + m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS ); + m_textCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDEROPEN, wxColour( wxT("BLACK") ) ); + m_textCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDEROPEN, wxColour( wxT("WHITE") ) ); + m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY ); + m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUS ); + m_textCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDEREND, wxColour( wxT("BLACK") ) ); + m_textCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDEREND, wxColour( wxT("WHITE") ) ); + m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUS ); + m_textCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDEROPENMID, wxColour( wxT("BLACK") ) ); + m_textCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDEROPENMID, wxColour( wxT("WHITE") ) ); + m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY ); + m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY ); + m_textCtrl->SetSelBackground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); + m_textCtrl->SetSelForeground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) ); + m_textCtrl->SetMinSize( wxSize( 500,140 ) ); + + m_textEntrySizer->Add( m_textCtrl, 1, wxEXPAND|wxBOTTOM, 2 ); + + m_textSizeLabel = new wxStaticText( this, wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textSizeLabel->Wrap( -1 ); + m_textEntrySizer->Add( m_textSizeLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 6 ); + + wxBoxSizer* bSizeCtrlSizer; + bSizeCtrlSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_textSizeCtrl = new wxTextCtrl( this, wxID_SIZE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizeCtrlSizer->Add( m_textSizeCtrl, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5 ); + + m_textSizeUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textSizeUnits->Wrap( -1 ); + bSizeCtrlSizer->Add( m_textSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 2 ); + + m_separator1 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator1->Enable( false ); + + bSizeCtrlSizer->Add( m_separator1, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 ); + + m_bold = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_bold->SetToolTip( _("Bold") ); + + bSizeCtrlSizer->Add( m_bold, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 ); + + m_italic = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_italic->SetToolTip( _("Italic") ); + + bSizeCtrlSizer->Add( m_italic, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 ); + + m_separator2 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator2->Enable( false ); + + bSizeCtrlSizer->Add( m_separator2, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 ); + + m_spin0 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_spin0->SetToolTip( _("Align right") ); + + bSizeCtrlSizer->Add( m_spin0, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 ); + + m_spin1 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_spin1->SetToolTip( _("Align bottom") ); + + bSizeCtrlSizer->Add( m_spin1, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 ); + + m_spin2 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_spin2->SetToolTip( _("Align left") ); + + bSizeCtrlSizer->Add( m_spin2, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 ); + + m_spin3 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_spin3->SetToolTip( _("Align top") ); + + bSizeCtrlSizer->Add( m_spin3, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 ); + + m_separator3 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator3->Enable( false ); + + bSizeCtrlSizer->Add( m_separator3, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5 ); + + + bSizeCtrlSizer->Add( 0, 0, 1, wxEXPAND, 15 ); + + m_syntaxHelp = new wxHyperlinkCtrl( this, wxID_ANY, _("Syntax help"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE ); + m_syntaxHelp->SetToolTip( _("Show syntax help window") ); + + bSizeCtrlSizer->Add( m_syntaxHelp, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 ); + + + m_textEntrySizer->Add( bSizeCtrlSizer, 1, wxEXPAND, 6 ); + + + bMainSizer->Add( m_textEntrySizer, 1, wxEXPAND|wxALL, 12 ); + + m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bMainSizer->Add( m_staticline, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + + wxBoxSizer* bSizer4; + bSizer4 = new wxBoxSizer( wxHORIZONTAL ); + + m_sdbSizer1 = new wxStdDialogButtonSizer(); + m_sdbSizer1OK = new wxButton( this, wxID_OK ); + m_sdbSizer1->AddButton( m_sdbSizer1OK ); + m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL ); + m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); + m_sdbSizer1->Realize(); + + bSizer4->Add( m_sdbSizer1, 1, wxALL|wxEXPAND, 5 ); + + + bMainSizer->Add( bSizer4, 0, wxEXPAND|wxALL, 5 ); + + + this->SetSizer( bMainSizer ); + this->Layout(); + bMainSizer->Fit( this ); + + // Connect Events + m_textCtrl->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); + m_syntaxHelp->Connect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnFormattingHelp ), NULL, this ); +} + +DIALOG_TEXT_PROPERTIES_BASE::~DIALOG_TEXT_PROPERTIES_BASE() +{ + // Disconnect Events + m_textCtrl->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); + m_syntaxHelp->Disconnect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnFormattingHelp ), NULL, this ); + +} diff --git a/eeschema/dialogs/dialog_text_properties_base.fbp b/eeschema/dialogs/dialog_text_properties_base.fbp new file mode 100644 index 0000000000..b97e44cd68 --- /dev/null +++ b/eeschema/dialogs/dialog_text_properties_base.fbp @@ -0,0 +1,1216 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dialog_text_properties_base + 1000 + none + + 1 + dialog_text_properties_base + + . + + 1 + 1 + 1 + 1 + UI + 1 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DIALOG_TEXT_PROPERTIES_BASE + + -1,-1 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + Text Properties + + + + + + + bMainSizer + wxVERTICAL + none + + 12 + wxEXPAND|wxALL + 1 + + 2 + wxBOTH + 1 + 1 + 5 + -1,-1 + m_textEntrySizer + wxFLEX_GROWMODE_SPECIFIED + protected + 5 + 1 + + 2 + wxTOP|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Text: + 0 + + 0 + + + 0 + + 1 + m_textLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + 2 + wxEXPAND|wxBOTTOM + 1 + + 1 + 1 + 1 + 1 + + + + + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + 0 + + 0 + 0 + wxID_ANY + 0 + 0 + + 0 + + + 0 + 500,140 + 1 + m_textCtrl + 1 + + + protected + 1 + + Resizable + 1 + + ; forward_declare + 0 + 4 + 0 + + 1 + 0 + 0 + + + wxBORDER_SUNKEN + onMultiLineTCLostFocus + + + + 6 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Text size: + 0 + + 0 + + + 0 + + 1 + m_textSizeLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 6 + wxEXPAND + 1 + + + bSizeCtrlSizer + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_SIZE + + 0 + + + + 0 + + 1 + m_textSizeCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 2 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + + 1 + m_textSizeUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + + + 0 + + 1 + m_separator1 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Bold + + 0 + + 0 + + + 0 + + 1 + m_bold + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Bold + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Italic + + 0 + + 0 + + + 0 + + 1 + m_italic + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Italic + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + + + 0 + + 1 + m_separator2 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align right + + 0 + + 0 + + + 0 + + 1 + m_spin0 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align right + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align bottom + + 0 + + 0 + + + 0 + + 1 + m_spin1 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align bottom + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align left + + 0 + + 0 + + + 0 + + 1 + m_spin2 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align left + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align top + + 0 + + 0 + + + 0 + + 1 + m_spin3 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align top + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + + + 0 + + 1 + m_separator3 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 15 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + + wxID_ANY + Syntax help + + 0 + + + 0 + + 1 + m_syntaxHelp + + 1 + + + protected + 1 + + Resizable + 1 + + wxHL_DEFAULT_STYLE + ; ; forward_declare + 0 + Show syntax help window + + + + + + OnFormattingHelp + + + + + + + + 5 + wxEXPAND|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + ; ; forward_declare + 0 + + + + + + + + 5 + wxEXPAND|wxALL + 0 + + + bSizer4 + wxHORIZONTAL + none + + 5 + wxALL|wxEXPAND + 1 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer1 + protected + + + + + + + + diff --git a/eeschema/dialogs/dialog_text_and_label_properties_base.h b/eeschema/dialogs/dialog_text_properties_base.h similarity index 54% rename from eeschema/dialogs/dialog_text_and_label_properties_base.h rename to eeschema/dialogs/dialog_text_properties_base.h index 01888ccaa0..9510f80a13 100644 --- a/eeschema/dialogs/dialog_text_and_label_properties_base.h +++ b/eeschema/dialogs/dialog_text_properties_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -10,6 +10,8 @@ #include #include #include +class BITMAP_BUTTON; + #include "dialog_shim.h" #include #include @@ -17,62 +19,63 @@ #include #include #include -#include #include -#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include +#include #include /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE +/// Class DIALOG_TEXT_PROPERTIES_BASE /////////////////////////////////////////////////////////////////////////////// -class DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE : public DIALOG_SHIM +class DIALOG_TEXT_PROPERTIES_BASE : public DIALOG_SHIM { private: protected: enum { - wxID_VALUESINGLE = 1000, - wxID_SIZE + wxID_SIZE = 1000 }; wxFlexGridSizer* m_textEntrySizer; - wxStaticText* m_labelSingleLine; - wxTextCtrl* m_valueSingleLine; - wxStaticText* m_labelMultiLine; - wxStyledTextCtrl* m_valueMultiLine; - wxStaticText* m_labelCombo; - wxComboBox* m_valueCombo; + wxStaticText* m_textLabel; + wxStyledTextCtrl* m_textCtrl; wxStaticText* m_textSizeLabel; wxTextCtrl* m_textSizeCtrl; wxStaticText* m_textSizeUnits; - wxHyperlinkCtrl* m_formattingHelp; - wxStaticText* m_note1; - wxStaticText* m_note2; - wxRadioBox* m_TextOrient; - wxRadioBox* m_TextStyle; - wxRadioBox* m_TextShape; + BITMAP_BUTTON* m_separator1; + BITMAP_BUTTON* m_bold; + BITMAP_BUTTON* m_italic; + BITMAP_BUTTON* m_separator2; + BITMAP_BUTTON* m_spin0; + BITMAP_BUTTON* m_spin1; + BITMAP_BUTTON* m_spin2; + BITMAP_BUTTON* m_spin3; + BITMAP_BUTTON* m_separator3; + wxHyperlinkCtrl* m_syntaxHelp; + wxStaticLine* m_staticline; wxStdDialogButtonSizer* m_sdbSizer1; wxButton* m_sdbSizer1OK; wxButton* m_sdbSizer1Cancel; - // Virtual event handlers, override them in your derived class - virtual void OnEnterKey( wxCommandEvent& event ) { event.Skip(); } + // Virtual event handlers, overide them in your derived class virtual void onMultiLineTCLostFocus( wxFocusEvent& event ) { event.Skip(); } virtual void OnFormattingHelp( wxHyperlinkEvent& event ) { event.Skip(); } public: - DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - - ~DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE(); + DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_TEXT_PROPERTIES_BASE(); }; diff --git a/eeschema/ee_collectors.cpp b/eeschema/ee_collectors.cpp index d532aac321..7d6f345a5c 100644 --- a/eeschema/ee_collectors.cpp +++ b/eeschema/ee_collectors.cpp @@ -48,6 +48,7 @@ const KICAD_T EE_COLLECTOR::EditableItems[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, + SCH_NETCLASS_FLAG_T, SCH_FIELD_T, SCH_SYMBOL_T, SCH_SHEET_PIN_T, @@ -86,6 +87,7 @@ const KICAD_T EE_COLLECTOR::MovableItems[] = SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, + SCH_NETCLASS_FLAG_T, SCH_FIELD_T, SCH_SYMBOL_T, SCH_SHEET_PIN_T, @@ -103,7 +105,10 @@ const KICAD_T EE_COLLECTOR::WiresOnly[] = { const KICAD_T EE_COLLECTOR::FieldOwners[] = { SCH_SYMBOL_T, SCH_SHEET_T, + SCH_LABEL_T, SCH_GLOBAL_LABEL_T, + SCH_HIER_LABEL_T, + SCH_NETCLASS_FLAG_T, EOT }; @@ -148,48 +153,8 @@ void EE_COLLECTOR::Collect( SCH_SCREEN* aScreen, const KICAD_T aFilterList[], co if( aScreen ) { - // Symbols and sheets own their own children so have to be visited even if - // they're not in the filter list - bool symbolsVisited = false; - bool sheetsVisited = false; - bool globalLabelsVisited = false; - - EE_RTREE& items = aScreen->Items(); - - for( const KICAD_T *filter = aFilterList; *filter != EOT; ++filter ) - { - for( SCH_ITEM *item : items.Overlapping( *filter, aPos, m_Threshold ) ) - { - if( *filter == SCH_SYMBOL_T || *filter == SCH_LOCATE_ANY_T ) - symbolsVisited = true; - - if( *filter == SCH_SHEET_T || *filter == SCH_LOCATE_ANY_T ) - sheetsVisited = true; - - if( *filter == SCH_GLOBAL_LABEL_T || *filter == SCH_LOCATE_ANY_T ) - globalLabelsVisited = true; - - item->Visit( m_inspector, nullptr, m_scanTypes ); - } - } - - if( !symbolsVisited ) - { - for( SCH_ITEM *item : items.Overlapping( SCH_SYMBOL_T, aPos, m_Threshold ) ) - item->Visit( m_inspector, nullptr, m_scanTypes ); - } - - if( !sheetsVisited ) - { - for( SCH_ITEM *item : items.Overlapping( SCH_SHEET_T, aPos, m_Threshold ) ) - item->Visit( m_inspector, nullptr, m_scanTypes ); - } - - if( !globalLabelsVisited ) - { - for( SCH_ITEM *item : items.Overlapping( SCH_GLOBAL_LABEL_T, aPos, m_Threshold ) ) - item->Visit( m_inspector, nullptr, m_scanTypes ); - } + for( SCH_ITEM *item : aScreen->Items().Overlapping( SCH_LOCATE_ANY_T, aPos, m_Threshold ) ) + item->Visit( m_inspector, nullptr, m_scanTypes ); } } @@ -245,9 +210,12 @@ void CollectOtherUnits( const wxString& aRef, int aUnit, const LIB_ID& aLibId, { SCH_REFERENCE symbol = symbols[i]; - if( symbol.GetRef() == aRef && symbol.GetSymbol()->GetLibId() == aLibId - && symbol.GetUnit() != aUnit ) + if( symbol.GetRef() == aRef + && symbol.GetSymbol()->GetLibId() == aLibId + && symbol.GetUnit() != aUnit ) + { otherUnits->push_back( symbol.GetSymbol() ); + } } } diff --git a/eeschema/eeschema_settings.cpp b/eeschema/eeschema_settings.cpp index 539450ce32..be303edc1c 100644 --- a/eeschema/eeschema_settings.cpp +++ b/eeschema/eeschema_settings.cpp @@ -73,12 +73,15 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() : m_Simulator(), m_RescueNeverShow( false ) { - m_params.emplace_back( new PARAM( "appearance.edit_component_visible_columns", - &m_Appearance.edit_component_visible_columns, "0 1 2 3 4 5 6 7" ) ); + m_params.emplace_back( new PARAM( "appearance.edit_symbol_visible_columns", + &m_Appearance.edit_symbol_visible_columns, "0 1 2 3 4 5 6 7" ) ); m_params.emplace_back( new PARAM( "appearance.edit_sheet_visible_columns", &m_Appearance.edit_sheet_visible_columns, "0 1 2 3 4 5 6 7" ) ); + m_params.emplace_back( new PARAM( "appearance.edit_label_visible_columns", + &m_Appearance.edit_label_visible_columns, "0 1 2 3 4 5 6 7" ) ); + m_params.emplace_back( new PARAM( "appearance.erc_severities", &m_Appearance.erc_severities, RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING ) ); diff --git a/eeschema/eeschema_settings.h b/eeschema/eeschema_settings.h index 5fed482710..f53136bced 100644 --- a/eeschema/eeschema_settings.h +++ b/eeschema/eeschema_settings.h @@ -35,8 +35,9 @@ class EESCHEMA_SETTINGS : public APP_SETTINGS_BASE public: struct APPEARANCE { - wxString edit_component_visible_columns; + wxString edit_symbol_visible_columns; wxString edit_sheet_visible_columns; + wxString edit_label_visible_columns; int erc_severities; bool footprint_preview; bool navigator_stays_open; diff --git a/eeschema/fields_grid_table.cpp b/eeschema/fields_grid_table.cpp index 9f437c7ed4..c9a57988e2 100644 --- a/eeschema/fields_grid_table.cpp +++ b/eeschema/fields_grid_table.cpp @@ -27,17 +27,22 @@ #include #include #include +#include #include #include +#include +#include #include +#include #include #include #include #include +#include #include "eda_doc.h" #include #include - +#include enum { @@ -88,6 +93,28 @@ FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* a } +template +FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, + WX_GRID* aGrid, SCH_LABEL_BASE* aLabel ) : + m_frame( aFrame ), + m_dialog( aDialog ), + m_userUnits( aDialog->GetUserUnits() ), + m_grid( aGrid ), + m_parentType( SCH_LABEL_LOCATE_ANY_T ), + m_mandatoryFieldCount( aLabel->GetMandatoryFieldCount() ), + m_part( nullptr ), + m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ), + m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), 0 ), + m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), 0 ), + m_libIdValidator(), + m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ), + m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ), + m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), 0 ) +{ + initGrid( aGrid ); +} + + template void FIELDS_GRID_TABLE::initGrid( WX_GRID* aGrid ) { @@ -169,6 +196,23 @@ void FIELDS_GRID_TABLE::initGrid( WX_GRID* aGrid ) m_orientationAttr->SetEditor( new wxGridCellChoiceEditor( orientationNames ) ); m_orientationAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM ); + SCH_EDIT_FRAME* editFrame = dynamic_cast( m_frame ); + wxArrayString existingNetclasses; + + if( editFrame ) + { + // Load the combobox with existing existingNetclassNames + NET_SETTINGS& netSettings = editFrame->Schematic().Prj().GetProjectFile().NetSettings(); + + existingNetclasses.push_back( netSettings.m_NetClasses.GetDefault()->GetName() ); + + for( const std::pair& pair : netSettings.m_NetClasses ) + existingNetclasses.push_back( pair.second->GetName() ); + } + + m_netclassAttr = new wxGridCellAttr; + m_netclassAttr->SetEditor( new GRID_CELL_COMBOBOX( existingNetclasses ) ); + m_frame->Bind( UNITS_CHANGED, &FIELDS_GRID_TABLE::onUnitsChanged, this ); } @@ -188,6 +232,7 @@ FIELDS_GRID_TABLE::~FIELDS_GRID_TABLE() m_vAlignAttr->DecRef(); m_hAlignAttr->DecRef(); m_orientationAttr->DecRef(); + m_netclassAttr->DecRef(); m_frame->Unbind( UNITS_CHANGED, &FIELDS_GRID_TABLE::onUnitsChanged, this ); } @@ -321,6 +366,12 @@ wxGridCellAttr* FIELDS_GRID_TABLE::GetAttr( int aRow, int aCol, wxGridCellAtt m_filepathAttr->IncRef(); return m_filepathAttr; } + else if( ( m_parentType == SCH_LABEL_LOCATE_ANY_T ) + && this->at( (size_t) aRow ).GetCanonicalName() == wxT( "Netclass" ) ) + { + m_netclassAttr->IncRef(); + return m_netclassAttr; + } else { wxString fn = GetValue( aRow, FDC_NAME ); @@ -342,8 +393,6 @@ wxGridCellAttr* FIELDS_GRID_TABLE::GetAttr( int aRow, int aCol, wxGridCellAtt } } - return nullptr; - case FDC_TEXT_SIZE: case FDC_POSX: case FDC_POSY: @@ -383,17 +432,31 @@ wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol ) switch( aCol ) { case FDC_NAME: - // Use default field name for mandatory fields, because they are translated + // Use default field names for mandatory and system fields because they are translated // according to the current locale - if( aRow < m_mandatoryFieldCount ) + if( m_parentType == SCH_SYMBOL_T ) { - if( m_parentType == SCH_SYMBOL_T ) + if( aRow < m_mandatoryFieldCount ) return TEMPLATE_FIELDNAME::GetDefaultFieldName( aRow ); - else if( m_parentType == SCH_SHEET_T ) - return SCH_SHEET::GetDefaultFieldName( aRow ); + else + return field.GetName( false ); + } + else if( m_parentType == SCH_SHEET_T ) + { + if( aRow < m_mandatoryFieldCount ) + return SCH_SHEET::GetDefaultFieldName( aRow ); + else + return field.GetName( false ); + } + else if( m_parentType == SCH_LABEL_LOCATE_ANY_T ) + { + return SCH_LABEL_BASE::GetDefaultFieldName( field.GetCanonicalName(), false ); + } + else + { + wxFAIL_MSG( "Unhandled field owner type." ); + return field.GetName( false ); } - - return field.GetName( false ); case FDC_VALUE: return UnescapeString( field.GetText() ); @@ -679,8 +742,8 @@ bool FIELDS_GRID_TABLE::BoolFromString( wxString aValue ) const } else { - wxFAIL_MSG( wxString::Format( "string '%s' can't be converted to boolean " - "correctly, it will have been perceived as FALSE", aValue ) ); + wxFAIL_MSG( wxString::Format( "string '%s' can't be converted to boolean correctly and " + "will be perceived as FALSE", aValue ) ); return false; } } diff --git a/eeschema/fields_grid_table.h b/eeschema/fields_grid_table.h index c01b321956..936627d5c4 100644 --- a/eeschema/fields_grid_table.h +++ b/eeschema/fields_grid_table.h @@ -33,6 +33,7 @@ class SCH_BASE_FRAME; class DIALOG_SHIM; +class SCH_LABEL_BASE; class FIELDS_GRID_TRICKS : public GRID_TRICKS @@ -76,6 +77,8 @@ public: LIB_SYMBOL* aSymbol ); FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, WX_GRID* aGrid, SCH_SHEET* aSheet ); + FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, WX_GRID* aGrid, + SCH_LABEL_BASE* aLabel ); ~FIELDS_GRID_TABLE(); int GetNumberRows() override { return (int) this->size(); } @@ -135,6 +138,7 @@ private: wxGridCellAttr* m_vAlignAttr; wxGridCellAttr* m_hAlignAttr; wxGridCellAttr* m_orientationAttr; + wxGridCellAttr* m_netclassAttr; }; diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index 53859d3194..ba4f406e6a 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -207,6 +207,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() placeMenu->Add( EE_ACTIONS::placeNoConnect ); placeMenu->Add( EE_ACTIONS::placeJunction ); placeMenu->Add( EE_ACTIONS::placeLabel ); + placeMenu->Add( EE_ACTIONS::placeClassLabel ); placeMenu->Add( EE_ACTIONS::placeGlobalLabel ); placeMenu->AppendSeparator(); diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 162cd5eff8..54ef9def88 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -316,7 +316,13 @@ void SCH_BASE_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aUpda GetCanvas()->GetView()->Update( aItem ); // Some children are drawn from their parents. Mark them for re-paint. - static KICAD_T parentTypes[] = { SCH_SYMBOL_T, SCH_SHEET_T, SCH_GLOBAL_LABEL_T, EOT }; + static KICAD_T parentTypes[] = { SCH_SYMBOL_T, + SCH_SHEET_T, + SCH_LABEL_T, + SCH_GLOBAL_LABEL_T, + SCH_HIER_LABEL_T, + SCH_NETCLASS_FLAG_T, + EOT }; if( parent && parent->IsType( parentTypes ) ) GetCanvas()->GetView()->Update( parent, KIGFX::REPAINT ); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 3eeb6f772b..e6f8ef27b5 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -479,6 +479,7 @@ void SCH_EDIT_FRAME::setupUIConditions() CURRENT_TOOL( EE_ACTIONS::placeNoConnect ); CURRENT_TOOL( EE_ACTIONS::placeJunction ); CURRENT_TOOL( EE_ACTIONS::placeLabel ); + CURRENT_TOOL( EE_ACTIONS::placeClassLabel ); CURRENT_TOOL( EE_ACTIONS::placeGlobalLabel ); CURRENT_TOOL( EE_ACTIONS::placeHierLabel ); CURRENT_TOOL( EE_ACTIONS::drawSheet ); @@ -1135,6 +1136,9 @@ bool SCH_EDIT_FRAME::isAutoSaveRequired() const static void inheritNetclass( const SCH_SHEET_PATH& aSheetPath, SCH_TEXT* aItem ) { + if( CONNECTION_SUBGRAPH::GetDriverPriority( aItem ) == CONNECTION_SUBGRAPH::PRIORITY::NONE ) + return; + // Netclasses are assigned to subgraphs by association with their netname. However, when // a new label is attached to an existing subgraph (with an existing netclass association), // the association will be lost as the label will drive its name on to the graph. @@ -1434,7 +1438,7 @@ void SCH_EDIT_FRAME::RecomputeIntersheetRefs() for( SCH_GLOBALLABEL* globalLabel : globalLabels ) { - globalLabel->GetIntersheetRefs()->SetVisible( show ); + globalLabel->GetFields()[0].SetVisible( show ); if( show ) { @@ -1450,19 +1454,7 @@ void SCH_EDIT_FRAME::ShowAllIntersheetRefs( bool aShow ) if( aShow ) RecomputeIntersheetRefs(); - SCH_SCREENS screens( Schematic().Root() ); - - for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() ) - { - for( SCH_ITEM* item : screen->Items().OfType( SCH_GLOBAL_LABEL_T ) ) - { - SCH_GLOBALLABEL* gLabel = (SCH_GLOBALLABEL*)( item ); - SCH_FIELD* intersheetRef = gLabel->GetIntersheetRefs(); - - intersheetRef->SetVisible( aShow ); - UpdateItem( intersheetRef, true ); - } - } + GetCanvas()->GetView()->SetLayerVisible( LAYER_INTERSHEET_REFS, aShow ); } diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 37dee4b8b2..c5960b4053 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -40,7 +40,6 @@ #include #include #include -#include // enum PINSHEETLABEL_SHAPE #include class STATUS_TEXT_POPUP; diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index e753284924..a03adb6898 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -90,7 +90,7 @@ void SCH_FIELD::SetId( int aId ) default: SetLayer( LAYER_SHEETFIELDS ); break; } } - else + else if( m_parent && m_parent->Type() == SCH_SYMBOL_T ) { switch( m_id ) { @@ -99,11 +99,25 @@ void SCH_FIELD::SetId( int aId ) default: SetLayer( LAYER_FIELDS ); break; } } + else + { + // We can't use defined IDs for labels because there can be multiple net class + // assignments. + + if( GetCanonicalName() == wxT( "Netclass" ) ) + SetLayer( LAYER_NETCLASS_REFS ); + else if( GetCanonicalName() == wxT( "Intersheetrefs" ) ) + SetLayer( LAYER_INTERSHEET_REFS ); + else + SetLayer( LAYER_FIELDS ); + } } wxString SCH_FIELD::GetShownText( int aDepth ) const { + KICAD_T labelTypes[] = { SCH_LABEL_LOCATE_ANY_T, EOT }; + std::function symbolResolver = [&]( wxString* token ) -> bool { @@ -136,11 +150,11 @@ wxString SCH_FIELD::GetShownText( int aDepth ) const return sheet->ResolveTextVar( token, aDepth + 1 ); }; - std::function globalLabelResolver = + std::function labelResolver = [&]( wxString* token ) -> bool { - SCH_GLOBALLABEL* globalLabel = static_cast( m_parent ); - return globalLabel->ResolveTextVar( token, aDepth + 1 ); + SCH_LABEL_BASE* label = static_cast( m_parent ); + return label->ResolveTextVar( token, aDepth + 1 ); }; PROJECT* project = nullptr; @@ -161,8 +175,8 @@ wxString SCH_FIELD::GetShownText( int aDepth ) const text = ExpandTextVars( text, &symbolResolver, nullptr, project ); else if( m_parent && m_parent->Type() == SCH_SHEET_T ) text = ExpandTextVars( text, &sheetResolver, nullptr, project ); - else if( m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T ) - text = ExpandTextVars( text, &globalLabelResolver, nullptr, project ); + else if( m_parent && m_parent->IsType( labelTypes ) ) + text = ExpandTextVars( text, &labelResolver, nullptr, project ); else text = ExpandTextVars( text, project ); } @@ -484,7 +498,8 @@ bool SCH_FIELD::IsReplaceable() const } else if( m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T ) { - return false; + if( m_id == 0 /* IntersheetRefs */ ) + return false; } return true; @@ -554,6 +569,10 @@ bool SCH_FIELD::Replace( const wxFindReplaceData& aSearchData, void* aAuxData ) // sheets, etc. See DIALOG_SHEET_PROPERTIES::TransferDataFromWindow(). } } + else + { + isReplaced = EDA_TEXT::Replace( aSearchData ); + } return isReplaced; } @@ -677,24 +696,42 @@ void SCH_FIELD::DoHypertextMenu( EDA_DRAW_FRAME* aFrame ) wxString SCH_FIELD::GetName( bool aUseDefaultName ) const { - if( !m_name.IsEmpty() ) - return m_name; - else if( aUseDefaultName ) - { - if( m_parent && m_parent->Type() == SCH_SYMBOL_T ) - return TEMPLATE_FIELDNAME::GetDefaultFieldName( m_id ); - else if( m_parent && m_parent->Type() == SCH_SHEET_T ) - return SCH_SHEET::GetDefaultFieldName( m_id ); - else if( m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T ) - return _( "Intersheet References" ); - } + KICAD_T labelTypes[] = { SCH_LABEL_LOCATE_ANY_T, EOT }; - return wxEmptyString; + if( m_parent && m_parent->Type() == SCH_SYMBOL_T ) + { + if( m_id < MANDATORY_FIELDS ) + return TEMPLATE_FIELDNAME::GetDefaultFieldName( m_id ); + else if( m_name.IsEmpty() && aUseDefaultName ) + return TEMPLATE_FIELDNAME::GetDefaultFieldName( m_id ); + else + return m_name; + } + else if( m_parent && m_parent->Type() == SCH_SHEET_T ) + { + if( m_id < SHEET_MANDATORY_FIELDS ) + return SCH_SHEET::GetDefaultFieldName( m_id ); + else if( m_name.IsEmpty() && aUseDefaultName ) + return SCH_SHEET::GetDefaultFieldName( m_id ); + else + return m_name; + } + else if( m_parent && m_parent->IsType( labelTypes ) ) + { + return SCH_LABEL_BASE::GetDefaultFieldName( m_name, aUseDefaultName ); + } + else + { + wxFAIL_MSG( "Unhandled field owner type." ); + return m_name; + } } wxString SCH_FIELD::GetCanonicalName() const { + KICAD_T labelTypes[] = { SCH_LABEL_LOCATE_ANY_T, EOT }; + if( m_parent && m_parent->Type() == SCH_SYMBOL_T ) { switch( m_id ) @@ -703,6 +740,7 @@ wxString SCH_FIELD::GetCanonicalName() const case VALUE_FIELD: return wxT( "Value" ); case FOOTPRINT_FIELD: return wxT( "Footprint" ); case DATASHEET_FIELD: return wxT( "Datasheet" ); + default: return m_name; } } else if( m_parent && m_parent->Type() == SCH_SHEET_T ) @@ -711,14 +749,24 @@ wxString SCH_FIELD::GetCanonicalName() const { case SHEETNAME: return wxT( "Sheetname" ); case SHEETFILENAME: return wxT( "Sheetfile" ); + default: return m_name; } } - else if( m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T ) + else if( m_parent && m_parent->IsType( labelTypes ) ) { - return wxT( "Intersheet References" ); + // These should be stored in canonical format, but just in case: + if( m_name == _( "Net Class" ) ) + return wxT( "Netclass" ); + else if (m_name == _( "Sheet References" ) ) + return wxT( "Intersheetrefs" ); + else + return m_name; + } + else + { + wxFAIL_MSG( "Unhandled field owner type." ); + return m_name; } - - return m_name; } diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index 46f7e7db06..0f6d7b964a 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -88,7 +88,7 @@ public: bool IsHypertext() const override { - return m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T; + return m_id == 0 && m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T; } void DoHypertextMenu( EDA_DRAW_FRAME* aFrame ) override; diff --git a/eeschema/sch_file_versions.h b/eeschema/sch_file_versions.h index 7ed2abf6d5..66f7d45430 100644 --- a/eeschema/sch_file_versions.h +++ b/eeschema/sch_file_versions.h @@ -39,8 +39,9 @@ //#define SEXPR_SYMBOL_LIB_FILE_VERSION 20200827 // Remove host tag. //#define SEXPR_SYMBOL_LIB_FILE_VERSION 20200908 // Add include in BOM and on board support. //#define SEXPR_SYMBOL_LIB_FILE_VERSION 20201005 // Separate ki_fp_filters by spaces. -//#define SEXPR_SYMBOL_LIB_FILE_VERSION 20210619 // Change pin overbar syntax from `~...~` to `~{...}`. -#define SEXPR_SYMBOL_LIB_FILE_VERSION 20211014 // Arc formatting. +//#define SEXPR_SYMBOL_LIB_FILE_VERSION 20210619 // Change pin overbar syntax from `~...~` to `~{...}`. +//#define SEXPR_SYMBOL_LIB_FILE_VERSION 20211014 // Arc formatting. +#define SEXPR_SYMBOL_LIB_FILE_VERSION 20220101 // Class flags. /** @@ -68,4 +69,5 @@ //#define SEXPR_SCHEMATIC_FILE_VERSION 20210621 // Update overbar syntax in bus aliases. //#define SEXPR_SCHEMATIC_FILE_VERSION 20211123 // R/W uuids for junctions. //#define SEXPR_SCHEMATIC_FILE_VERSION 20220101 // Circles, arcs, rects, polys & beziers -#define SEXPR_SCHEMATIC_FILE_VERSION 20220102 // Dash-dot-dot +//#define SEXPR_SCHEMATIC_FILE_VERSION 20220102 // Dash-dot-dot +#define SEXPR_SCHEMATIC_FILE_VERSION 20220103 // Label fields diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index 22efeabe56..934deb1296 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -165,10 +165,15 @@ public: { if( *p == SCH_ITEM_LOCATE_WIRE_T && m_layer == LAYER_WIRE ) return true; - else if ( *p == SCH_ITEM_LOCATE_BUS_T && m_layer == LAYER_BUS ) + + if ( *p == SCH_ITEM_LOCATE_BUS_T && m_layer == LAYER_BUS ) return true; - else if ( *p == SCH_ITEM_LOCATE_GRAPHIC_LINE_T && m_layer == LAYER_NOTES ) + + if ( *p == SCH_ITEM_LOCATE_GRAPHIC_LINE_T + && Type() == SCH_LINE_T && m_layer == LAYER_NOTES ) + { return true; + } } return false; diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index eff76343f6..623da0f82b 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -668,6 +668,7 @@ bool SCH_LINE::CanConnect( const SCH_ITEM* aItem ) const case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIER_LABEL_T: + case SCH_NETCLASS_FLAG_T: case SCH_BUS_WIRE_ENTRY_T: case SCH_SYMBOL_T: case SCH_SHEET_T: @@ -685,6 +686,7 @@ bool SCH_LINE::CanConnect( const SCH_ITEM* aItem ) const case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIER_LABEL_T: + case SCH_NETCLASS_FLAG_T: case SCH_BUS_WIRE_ENTRY_T: case SCH_SHEET_T: case SCH_SHEET_PIN_T: diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index ad7a27075d..2464e6c337 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -59,6 +59,26 @@ public: return wxT( "SCH_LINE" ); } + bool IsType( const KICAD_T aScanTypes[] ) const override + { + if( SCH_ITEM::IsType( aScanTypes ) ) + return true; + + for( const KICAD_T* p = aScanTypes; *p != EOT; ++p ) + { + if( *p == SCH_ITEM_LOCATE_WIRE_T && m_layer == LAYER_WIRE ) + return true; + + if ( *p == SCH_ITEM_LOCATE_BUS_T && m_layer == LAYER_BUS ) + return true; + + if ( *p == SCH_ITEM_LOCATE_GRAPHIC_LINE_T && m_layer == LAYER_NOTES ) + return true; + } + + return false; + } + bool IsEndPoint( const wxPoint& aPoint ) const { return aPoint == m_start || aPoint == m_end; diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index a5015ebe04..6bbb1b1cb7 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -224,7 +224,8 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer ) HANDLE_ITEM( SCH_LINE_T, SCH_LINE ); HANDLE_ITEM( SCH_SHAPE_T, SCH_SHAPE ); HANDLE_ITEM( SCH_TEXT_T, SCH_TEXT ); - HANDLE_ITEM( SCH_LABEL_T, SCH_TEXT ); + HANDLE_ITEM( SCH_LABEL_T, SCH_LABEL ); + HANDLE_ITEM( SCH_NETCLASS_FLAG_T, SCH_NETCLASS_FLAG ); HANDLE_ITEM( SCH_FIELD_T, SCH_FIELD ); HANDLE_ITEM( SCH_HIER_LABEL_T, SCH_HIERLABEL ); HANDLE_ITEM( SCH_GLOBAL_LABEL_T, SCH_GLOBALLABEL ); @@ -278,6 +279,10 @@ float SCH_PAINTER::getShadowWidth( bool aForHighlight ) const COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows ) const { + // We don't (yet?) have a separate color for intersheet refs + if( aLayer == LAYER_INTERSHEET_REFS ) + aLayer = LAYER_GLOBLABEL; + COLOR4D color = m_schSettings.GetLayerColor( aLayer ); if( aItem->Type() == SCH_LINE_T ) @@ -417,6 +422,19 @@ static VECTOR2D mapCoords( const wxPoint& aCoord ) } +static bool isFieldsLayer( int aLayer ) +{ + return aLayer == LAYER_REFERENCEPART + || aLayer == LAYER_VALUEPART + || aLayer == LAYER_INTERSHEET_REFS + || aLayer == LAYER_NETCLASS_REFS + || aLayer == LAYER_FIELDS + || aLayer == LAYER_SHEETNAME + || aLayer == LAYER_SHEETFILENAME + || aLayer == LAYER_SHEETFIELDS; +} + + void SCH_PAINTER::strokeText( const wxString& aText, const VECTOR2D& aPosition, double aAngle ) { m_gal->StrokeText( aText, VECTOR2D( aPosition.x, aPosition.y ), aAngle ); @@ -1416,11 +1434,12 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer ) switch( aText->Type() ) { - case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break; - case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break; - case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break; - case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break; - default: aLayer = LAYER_NOTES; break; + case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break; + case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break; + case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break; + case SCH_NETCLASS_FLAG_T: aLayer = LAYER_NETCLASS_REFS; break; + case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break; + default: aLayer = LAYER_NOTES; break; } COLOR4D color = getRenderColor( aText, aLayer, drawingShadows ); @@ -1547,6 +1566,20 @@ static void orientSymbol( LIB_SYMBOL* symbol, int orientation ) void SCH_PAINTER::draw( SCH_SYMBOL* aSymbol, int aLayer ) { + bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; + + if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children ) + { + for( const SCH_FIELD& field : aSymbol->GetFields() ) + draw( &field, aLayer ); + } + + if( isFieldsLayer( aLayer ) ) + return; + + if( drawingShadows && !( aSymbol->IsBrightened() || aSymbol->IsSelected() ) ) + return; + int unit = aSymbol->GetUnitSelection( &m_schematic->CurrentSheet() ); int convert = aSymbol->GetConvert(); @@ -1589,10 +1622,6 @@ void SCH_PAINTER::draw( SCH_SYMBOL* aSymbol, int aLayer ) } draw( &tempSymbol, aLayer, false, aSymbol->GetUnit(), aSymbol->GetConvert() ); - - // The fields are SCH_SYMBOL-specific so don't need to be copied/oriented/translated - for( const SCH_FIELD& field : aSymbol->GetFields() ) - draw( &field, aLayer ); } @@ -1603,6 +1632,9 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer ) if( drawingShadows && !( aField->IsBrightened() || aField->IsSelected() ) ) return; + if( !drawingShadows && aField->GetLayer() != aLayer ) + return; + aLayer = aField->GetLayer(); COLOR4D color = getRenderColor( aField, aLayer, drawingShadows ); @@ -1656,6 +1688,13 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer ) * GetBoundingBox to know the text coordinate considered as centered */ EDA_RECT bbox = aField->GetBoundingBox(); + + if( aField->GetParent() && aField->GetParent()->Type() == SCH_GLOBAL_LABEL_T ) + { + SCH_GLOBALLABEL* label = static_cast( aField->GetParent() ); + bbox.Offset( label->GetSchematicTextOffset( &m_schSettings ) ); + } + wxPoint textpos = bbox.Centre(); m_gal->SetIsStroke( true ); @@ -1696,12 +1735,18 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer ) } -void SCH_PAINTER::draw( SCH_GLOBALLABEL *aLabel, int aLayer ) +void SCH_PAINTER::draw( const SCH_GLOBALLABEL *aLabel, int aLayer ) { bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children ) - draw( aLabel->GetIntersheetRefs(), aLayer ); + { + for( const SCH_FIELD& field : aLabel->GetFields() ) + draw( &field, aLayer ); + } + + if( isFieldsLayer( aLayer ) ) + return; if( drawingShadows && !( aLabel->IsBrightened() || aLabel->IsSelected() ) ) return; @@ -1729,14 +1774,43 @@ void SCH_PAINTER::draw( SCH_GLOBALLABEL *aLabel, int aLayer ) m_gal->SetStrokeColor( color ); m_gal->DrawPolyline( pts2 ); - draw( static_cast( aLabel ), aLayer ); + draw( static_cast( aLabel ), aLayer ); } -void SCH_PAINTER::draw( SCH_HIERLABEL *aLabel, int aLayer ) +void SCH_PAINTER::draw( const SCH_LABEL *aLabel, int aLayer ) { bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; + if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children ) + { + for( const SCH_FIELD& field : aLabel->GetFields() ) + draw( &field, aLayer ); + } + + if( isFieldsLayer( aLayer ) ) + return; + + if( drawingShadows && !( aLabel->IsBrightened() || aLabel->IsSelected() ) ) + return; + + draw( static_cast( aLabel ), aLayer ); +} + + +void SCH_PAINTER::draw( const SCH_HIERLABEL *aLabel, int aLayer ) +{ + bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; + + if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children ) + { + for( const SCH_FIELD& field : aLabel->GetFields() ) + draw( &field, aLayer ); + } + + if( isFieldsLayer( aLayer ) ) + return; + if( drawingShadows && !( aLabel->IsBrightened() || aLabel->IsSelected() ) ) return; @@ -1772,10 +1846,77 @@ void SCH_PAINTER::draw( SCH_HIERLABEL *aLabel, int aLayer ) } +void SCH_PAINTER::draw( const SCH_NETCLASS_FLAG *aLabel, int aLayer ) +{ + bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; + + if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children ) + { + for( const SCH_FIELD& field : aLabel->GetFields() ) + draw( &field, aLayer ); + } + + if( isFieldsLayer( aLayer ) ) + return; + + if( drawingShadows && !( aLabel->IsBrightened() || aLabel->IsSelected() ) ) + return; + + COLOR4D color = getRenderColor( aLabel, LAYER_NETCLASS_REFS, drawingShadows ); + + if( aLayer == LAYER_DANGLING ) + { + if( aLabel->IsDangling() ) + { + drawDanglingSymbol( aLabel->GetTextPos(), color, Mils2iu( DANGLING_SYMBOL_SIZE / 2 ), + drawingShadows, aLabel->IsBrightened() ); + } + + return; + } + + std::vector pts; + std::deque pts2; + + aLabel->CreateGraphicShape( &m_schSettings, pts, aLabel->GetTextPos() ); + + for( const wxPoint& p : pts ) + pts2.emplace_back( VECTOR2D( p.x, p.y ) ); + + m_gal->SetIsFill( false ); + m_gal->SetFillColor( color ); + m_gal->SetIsStroke( true ); + m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) ); + m_gal->SetStrokeColor( color ); + + if( aLabel->GetShape() == LABEL_FLAG_SHAPE::F_DOT ) + { + m_gal->DrawLine( pts2[0], pts2[1] ); + m_gal->SetIsFill( true ); + m_gal->DrawCircle( pts2[2], ( pts2[2] - pts2[1] ).EuclideanNorm() ); + } + else if( aLabel->GetShape() == LABEL_FLAG_SHAPE::F_ROUND ) + { + m_gal->DrawLine( pts2[0], pts2[1] ); + m_gal->DrawCircle( pts2[2], ( pts2[2] - pts2[1] ).EuclideanNorm() ); + } + else + { + m_gal->DrawPolyline( pts2 ); + } +} + + void SCH_PAINTER::draw( const SCH_SHEET *aSheet, int aLayer ) { bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; + if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children ) + { + for( const SCH_FIELD& field : aSheet->GetFields() ) + draw( &field, aLayer ); + } + if( aLayer == LAYER_HIERLABEL || aLayer == LAYER_SELECTION_SHADOWS ) { for( SCH_SHEET_PIN* sheetPin : aSheet->GetPins() ) @@ -1838,12 +1979,6 @@ void SCH_PAINTER::draw( const SCH_SHEET *aSheet, int aLayer ) m_gal->SetIsFill( false ); m_gal->DrawRectangle( pos, pos + size ); - - if( drawingShadows && !eeconfig()->m_Selection.draw_selected_children ) - return; - - for( const SCH_FIELD& field : aSheet->GetFields() ) - draw( &field, aLayer ); } } diff --git a/eeschema/sch_painter.h b/eeschema/sch_painter.h index 5ab21b33ab..11d806af25 100644 --- a/eeschema/sch_painter.h +++ b/eeschema/sch_painter.h @@ -44,6 +44,7 @@ class SCH_JUNCTION; class SCH_LABEL; class SCH_TEXT; class SCH_HIERLABEL; +class SCH_NETCLASS_FLAG; class SCH_GLOBALLABEL; class SCH_SHEET; class SCH_SHEET_PIN; @@ -159,8 +160,10 @@ private: void draw( const SCH_FIELD* aField, int aLayer ); void draw( const SCH_SHAPE* shape, int aLayer ); void draw( const SCH_TEXT* aText, int aLayer ); - void draw( SCH_HIERLABEL* aLabel, int aLayer ); - void draw( SCH_GLOBALLABEL* aLabel, int aLayer ); + void draw( const SCH_LABEL* aText, int aLayer ); + void draw( const SCH_NETCLASS_FLAG* aLabel, int aLayer ); + void draw( const SCH_HIERLABEL* aLabel, int aLayer ); + void draw( const SCH_GLOBALLABEL* aLabel, int aLayer ); void draw( const SCH_SHEET* aSheet, int aLayer ); void draw( const SCH_NO_CONNECT* aNC, int aLayer ); void draw( const SCH_MARKER* aMarker, int aLayer ); diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index 6b8ea6133b..8229200794 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -1548,7 +1548,7 @@ void SCH_ALTIUM_PLUGIN::ParseSheetEntry( const std::map& aPr sheetIt->second->AddPin( sheetPin ); sheetPin->SetText( elem.name ); - sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_UNSPECIFIED ); + sheetPin->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED ); //sheetPin->SetLabelSpinStyle( getSpinStyle( term.OrientAngle, false ) ); //sheetPin->SetPosition( getKiCadPoint( term.Position ) ); @@ -1584,16 +1584,16 @@ void SCH_ALTIUM_PLUGIN::ParseSheetEntry( const std::map& aPr { default: case ASCH_PORT_IOTYPE::UNSPECIFIED: - sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_UNSPECIFIED ); + sheetPin->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED ); break; case ASCH_PORT_IOTYPE::OUTPUT: - sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_OUTPUT ); + sheetPin->SetShape( LABEL_FLAG_SHAPE::L_OUTPUT ); break; case ASCH_PORT_IOTYPE::INPUT: - sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_INPUT ); + sheetPin->SetShape( LABEL_FLAG_SHAPE::L_INPUT ); break; case ASCH_PORT_IOTYPE::BIDI: - sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_BIDI ); + sheetPin->SetShape( LABEL_FLAG_SHAPE::L_BIDI ); break; } } @@ -1972,16 +1972,16 @@ void SCH_ALTIUM_PLUGIN::ParsePort( const ASCH_PORT& aElem ) { default: case ASCH_PORT_IOTYPE::UNSPECIFIED: - label->SetShape( PINSHEETLABEL_SHAPE::PS_UNSPECIFIED ); + label->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED ); break; case ASCH_PORT_IOTYPE::OUTPUT: - label->SetShape( PINSHEETLABEL_SHAPE::PS_OUTPUT ); + label->SetShape( LABEL_FLAG_SHAPE::L_OUTPUT ); break; case ASCH_PORT_IOTYPE::INPUT: - label->SetShape( PINSHEETLABEL_SHAPE::PS_INPUT ); + label->SetShape( LABEL_FLAG_SHAPE::L_INPUT ); break; case ASCH_PORT_IOTYPE::BIDI: - label->SetShape( PINSHEETLABEL_SHAPE::PS_BIDI ); + label->SetShape( LABEL_FLAG_SHAPE::L_BIDI ); break; } diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp index 8d0e466390..8c63003b0c 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp @@ -345,7 +345,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadHierarchicalSheetPins() sheetPin = new SCH_SHEET_PIN( sheet ); sheetPin->SetText( name ); - sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_UNSPECIFIED ); + sheetPin->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED ); sheetPin->SetLabelSpinStyle( getSpinStyle( term.OrientAngle, false ) ); sheetPin->SetPosition( getKiCadPoint( term.Position ) ); @@ -665,13 +665,13 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances() netLabel->SetLabelSpinStyle( getSpinStyle( sym.OrientAngle, sym.Mirror ) ); if( libSymDef.Alternate.Lower().Contains( "in" ) ) - netLabel->SetShape( PINSHEETLABEL_SHAPE::PS_INPUT ); + netLabel->SetShape( LABEL_FLAG_SHAPE::L_INPUT ); else if( libSymDef.Alternate.Lower().Contains( "bi" ) ) - netLabel->SetShape( PINSHEETLABEL_SHAPE::PS_BIDI ); + netLabel->SetShape( LABEL_FLAG_SHAPE::L_BIDI ); else if( libSymDef.Alternate.Lower().Contains( "out" ) ) - netLabel->SetShape( PINSHEETLABEL_SHAPE::PS_OUTPUT ); + netLabel->SetShape( LABEL_FLAG_SHAPE::L_OUTPUT ); else - netLabel->SetShape( PINSHEETLABEL_SHAPE::PS_UNSPECIFIED ); + netLabel->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED ); SCH_SCREEN* screen = m_sheetMap.at( sym.LayerID )->GetScreen(); diff --git a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp index 689ec8694e..0399b42e8e 100644 --- a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp +++ b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp @@ -2318,16 +2318,16 @@ bool SCH_EAGLE_PLUGIN::CheckHeader( const wxString& aFileName ) void SCH_EAGLE_PLUGIN::moveLabels( SCH_LINE* aWire, const wxPoint& aNewEndPoint ) { - for( SCH_ITEM* item : m_currentSheet->GetScreen()->Items().Overlapping( aWire->GetBoundingBox() ) ) + static KICAD_T labelTypes[] = { SCH_LABEL_LOCATE_ANY_T, EOT }; + SCH_SCREEN* screen = m_currentSheet->GetScreen(); + + for( SCH_ITEM* item : screen->Items().Overlapping( aWire->GetBoundingBox() ) ) { - if( item->Type() == SCH_LABEL_T || item->Type() == SCH_GLOBAL_LABEL_T ) - { - if( TestSegmentHit( item->GetPosition(), aWire->GetStartPoint(), aWire->GetEndPoint(), - 0 ) ) - { - item->SetPosition( aNewEndPoint ); - } - } + if( !item->IsType( labelTypes ) ) + continue; + + if( TestSegmentHit( item->GetPosition(), aWire->GetStartPoint(), aWire->GetEndPoint(), 0 ) ) + item->SetPosition( aNewEndPoint ); } } diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index 52a139774e..c6708f40d2 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -1752,11 +1752,11 @@ SCH_SHEET_PIN* SCH_SEXPR_PARSER::parseSchSheetPin( SCH_SHEET* aSheet ) switch( token ) { - case T_input: sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_INPUT ); break; - case T_output: sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_OUTPUT ); break; - case T_bidirectional: sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_BIDI ); break; - case T_tri_state: sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_TRISTATE ); break; - case T_passive: sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_UNSPECIFIED ); break; + case T_input: sheetPin->SetShape( LABEL_FLAG_SHAPE::L_INPUT ); break; + case T_output: sheetPin->SetShape( LABEL_FLAG_SHAPE::L_OUTPUT ); break; + case T_bidirectional: sheetPin->SetShape( LABEL_FLAG_SHAPE::L_BIDI ); break; + case T_tri_state: sheetPin->SetShape( LABEL_FLAG_SHAPE::L_TRISTATE ); break; + case T_passive: sheetPin->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED ); break; default: Expecting( "input, output, bidirectional, tri_state, or passive" ); } @@ -2135,6 +2135,7 @@ void SCH_SEXPR_PARSER::ParseSchematic( SCH_SHEET* aSheet, bool aIsCopyableOnly, case T_label: case T_global_label: case T_hierarchical_label: + case T_netclass_flag: screen->Append( static_cast( parseSchText() ) ); break; @@ -2155,8 +2156,8 @@ void SCH_SEXPR_PARSER::ParseSchematic( SCH_SHEET* aSheet, bool aIsCopyableOnly, default: Expecting( "symbol, paper, page, title_block, bitmap, sheet, junction, no_connect, " - "bus_entry, line, bus, text, label, global_label, hierarchical_label, " - "symbol_instances, or bus_alias" ); + "bus_entry, line, bus, text, label, class_label, global_label, " + "hierarchical_label, symbol_instances, or bus_alias" ); } } @@ -3123,10 +3124,15 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText() case T_label: text = std::make_unique(); break; case T_global_label: text = std::make_unique(); break; case T_hierarchical_label: text = std::make_unique(); break; + case T_netclass_flag: text = std::make_unique(); break; default: wxCHECK_MSG( false, nullptr, "Cannot parse " + GetTokenString( CurTok() ) + " as text." ); } + // Clear any auto-created fields; we want what's in the file and only what's in the file + if( text->Type() != SCH_TEXT_T ) + static_cast( text.get() )->GetFields().clear(); + // We'll reset this if we find a fields_autoplaced token text->ClearFieldsAutoplaced(); @@ -3169,18 +3175,35 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText() switch( token ) { - case T_input: text->SetShape( PINSHEETLABEL_SHAPE::PS_INPUT ); break; - case T_output: text->SetShape( PINSHEETLABEL_SHAPE::PS_OUTPUT ); break; - case T_bidirectional: text->SetShape( PINSHEETLABEL_SHAPE::PS_BIDI ); break; - case T_tri_state: text->SetShape( PINSHEETLABEL_SHAPE::PS_TRISTATE ); break; - case T_passive: text->SetShape( PINSHEETLABEL_SHAPE::PS_UNSPECIFIED ); break; + case T_input: text->SetShape( LABEL_FLAG_SHAPE::L_INPUT ); break; + case T_output: text->SetShape( LABEL_FLAG_SHAPE::L_OUTPUT ); break; + case T_bidirectional: text->SetShape( LABEL_FLAG_SHAPE::L_BIDI ); break; + case T_tri_state: text->SetShape( LABEL_FLAG_SHAPE::L_TRISTATE ); break; + case T_passive: text->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED ); break; + case T_dot: text->SetShape( LABEL_FLAG_SHAPE::F_DOT ); break; + case T_round: text->SetShape( LABEL_FLAG_SHAPE::F_ROUND ); break; + case T_diamond: text->SetShape( LABEL_FLAG_SHAPE::F_DIAMOND ); break; + case T_rectangle: text->SetShape( LABEL_FLAG_SHAPE::F_RECTANGLE ); break; default: - Expecting( "input, output, bidirectional, tri_state, or passive" ); + Expecting( "input, output, bidirectional, tri_state, passive, dot, round, diamond" + "or rectangle" ); } NeedRIGHT(); break; + case T_length: + { + if( text->Type() != SCH_NETCLASS_FLAG_T ) + Unexpected( T_length ); + + SCH_NETCLASS_FLAG* label = static_cast( text.get() ); + + label->SetPinLength( parseInternalUnits( "pin length" ) ); + NeedRIGHT(); + } + break; + case T_fields_autoplaced: text->SetFieldsAutoplaced(); NeedRIGHT(); @@ -3214,7 +3237,7 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText() if( text->Type() == SCH_GLOBAL_LABEL_T ) { SCH_GLOBALLABEL* label = static_cast( text.get() ); - SCH_FIELD* field = label->GetIntersheetRefs(); + SCH_FIELD* field = &label->GetFields()[0]; field->SetTextPos( parseXY() ); NeedRIGHT(); @@ -3230,23 +3253,28 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText() break; case T_property: - if( text->Type() == SCH_GLOBAL_LABEL_T ) - { - SCH_GLOBALLABEL* label = static_cast( text.get() ); - SCH_FIELD* field = parseSchField( label ); + { + if( text->Type() == SCH_TEXT_T ) + Unexpected( T_property ); - field->SetLayer( LAYER_GLOBLABEL ); - label->SetIntersheetRefs( *field ); + SCH_FIELD* field = parseSchField( text.get() ); - delete field; - } + static_cast( text.get() )->GetFields().emplace_back( *field ); + + delete field; break; + } default: Expecting( "at, shape, iref, uuid or effects" ); } } + SCH_LABEL_BASE* label = dynamic_cast( text.get() ); + + if( label && label->GetFields().empty() ) + label->SetFieldsAutoplaced(); + return text.release(); } diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index cfa24bc9b3..9ff4837bb6 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -203,16 +203,20 @@ static float getPinAngle( int aOrientation ) } -static const char* getSheetPinShapeToken( PINSHEETLABEL_SHAPE aShape ) +static const char* getSheetPinShapeToken( LABEL_FLAG_SHAPE aShape ) { switch( aShape ) { - case PINSHEETLABEL_SHAPE::PS_INPUT: return SCHEMATIC_LEXER::TokenName( T_input ); - case PINSHEETLABEL_SHAPE::PS_OUTPUT: return SCHEMATIC_LEXER::TokenName( T_output ); - case PINSHEETLABEL_SHAPE::PS_BIDI: return SCHEMATIC_LEXER::TokenName( T_bidirectional ); - case PINSHEETLABEL_SHAPE::PS_TRISTATE: return SCHEMATIC_LEXER::TokenName( T_tri_state ); - case PINSHEETLABEL_SHAPE::PS_UNSPECIFIED: return SCHEMATIC_LEXER::TokenName( T_passive ); - default: wxFAIL; return SCHEMATIC_LEXER::TokenName( T_passive ); + case LABEL_FLAG_SHAPE::L_INPUT: return SCHEMATIC_LEXER::TokenName( T_input ); + case LABEL_FLAG_SHAPE::L_OUTPUT: return SCHEMATIC_LEXER::TokenName( T_output ); + case LABEL_FLAG_SHAPE::L_BIDI: return SCHEMATIC_LEXER::TokenName( T_bidirectional ); + case LABEL_FLAG_SHAPE::L_TRISTATE: return SCHEMATIC_LEXER::TokenName( T_tri_state ); + case LABEL_FLAG_SHAPE::L_UNSPECIFIED: return SCHEMATIC_LEXER::TokenName( T_passive ); + case LABEL_FLAG_SHAPE::F_DOT: return SCHEMATIC_LEXER::TokenName( T_dot ); + case LABEL_FLAG_SHAPE::F_ROUND: return SCHEMATIC_LEXER::TokenName( T_round ); + case LABEL_FLAG_SHAPE::F_DIAMOND: return SCHEMATIC_LEXER::TokenName( T_diamond ); + case LABEL_FLAG_SHAPE::F_RECTANGLE: return SCHEMATIC_LEXER::TokenName( T_rectangle ); + default: wxFAIL; return SCHEMATIC_LEXER::TokenName( T_passive ); } } @@ -243,6 +247,7 @@ static const char* getTextTypeToken( KICAD_T aType ) case SCH_LABEL_T: return SCHEMATIC_LEXER::TokenName( T_label ); case SCH_GLOBAL_LABEL_T: return SCHEMATIC_LEXER::TokenName( T_global_label ); case SCH_HIER_LABEL_T: return SCHEMATIC_LEXER::TokenName( T_hierarchical_label ); + case SCH_NETCLASS_FLAG_T: return SCHEMATIC_LEXER::TokenName( T_netclass_flag ); default: wxFAIL; return SCHEMATIC_LEXER::TokenName( T_text ); } } @@ -822,6 +827,7 @@ void SCH_SEXPR_PLUGIN::Format( SCH_SHEET* aSheet ) case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIER_LABEL_T: + case SCH_NETCLASS_FLAG_T: saveText( static_cast( item ), 1 ); break; @@ -967,6 +973,7 @@ void SCH_SEXPR_PLUGIN::Format( EE_SELECTION* aSelection, SCH_SHEET_PATH* aSelect case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIER_LABEL_T: + case SCH_NETCLASS_FLAG_T: saveText( static_cast< SCH_TEXT* >( item ), 0 ); break; @@ -1120,20 +1127,10 @@ void SCH_SEXPR_PLUGIN::saveField( SCH_FIELD* aField, int aNestLevel ) { wxCHECK_RET( aField != nullptr && m_out != nullptr, "" ); - wxString fieldName = aField->GetName(); + wxString fieldName = aField->GetCanonicalName(); // For some reason (bug in legacy parser?) the field ID for non-mandatory fields is -1 so // check for this in order to correctly use the field name. - if( aField->GetParent()->Type() == SCH_SYMBOL_T ) - { - if( aField->GetId() >= 0 && aField->GetId() < MANDATORY_FIELDS ) - fieldName = TEMPLATE_FIELDNAME::GetDefaultFieldName( aField->GetId(), false ); - } - else if( aField->GetParent()->Type() == SCH_SHEET_T ) - { - if( aField->GetId() >= 0 && aField->GetId() < SHEET_MANDATORY_FIELDS ) - fieldName = SCH_SHEET::GetDefaultFieldName( aField->GetId(), false ); - } if( aField->GetId() == -1 /* undefined ID */ ) { @@ -1430,8 +1427,20 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel ) getTextTypeToken( aText->Type() ), m_out->Quotew( aText->GetText() ).c_str() ); - if( ( aText->Type() == SCH_GLOBAL_LABEL_T ) || ( aText->Type() == SCH_HIER_LABEL_T ) ) + if( aText->Type() == SCH_NETCLASS_FLAG_T ) + { + SCH_NETCLASS_FLAG* label = static_cast( aText ); + + m_out->Print( 0, " (length %s)", + FormatInternalUnits( label->GetPinLength() ).c_str() ); + } + + if( aText->Type() == SCH_GLOBAL_LABEL_T + || aText->Type() == SCH_HIER_LABEL_T + || aText->Type() == SCH_NETCLASS_FLAG_T ) + { m_out->Print( 0, " (shape %s)", getSheetPinShapeToken( aText->GetShape() ) ); + } if( aText->GetText().Length() < 50 ) { @@ -1457,10 +1466,12 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel ) m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aText->m_Uuid.AsString() ) ); - if( ( aText->Type() == SCH_GLOBAL_LABEL_T ) ) + SCH_LABEL_BASE* label = dynamic_cast( aText ); + + if( label ) { - SCH_GLOBALLABEL* label = static_cast( aText ); - saveField( label->GetIntersheetRefs(), aNestLevel + 1 ); + for( SCH_FIELD& field : label->GetFields() ) + saveField( &field, aNestLevel + 1 ); } m_out->Print( aNestLevel, ")\n" ); // Closes text token. diff --git a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp index bd423cd306..ff1513a7f3 100644 --- a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp +++ b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp @@ -1082,20 +1082,20 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::loadSheet( LINE_READER& aReader ) switch( parseChar( aReader, line, &line ) ) { - case 'I': sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_INPUT ); break; - case 'O': sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_OUTPUT ); break; - case 'B': sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_BIDI ); break; - case 'T': sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_TRISTATE ); break; - case 'U': sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_UNSPECIFIED ); break; + case 'I': sheetPin->SetShape( LABEL_FLAG_SHAPE::L_INPUT ); break; + case 'O': sheetPin->SetShape( LABEL_FLAG_SHAPE::L_OUTPUT ); break; + case 'B': sheetPin->SetShape( LABEL_FLAG_SHAPE::L_BIDI ); break; + case 'T': sheetPin->SetShape( LABEL_FLAG_SHAPE::L_TRISTATE ); break; + case 'U': sheetPin->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED ); break; default: SCH_PARSE_ERROR( "invalid sheet pin type", aReader, line ); } switch( parseChar( aReader, line, &line ) ) { - case 'R': sheetPin->SetSide( SHEET_SIDE::RIGHT ); break; - case 'T': sheetPin->SetSide( SHEET_SIDE::TOP ); break; + case 'R': sheetPin->SetSide( SHEET_SIDE::RIGHT ); break; + case 'T': sheetPin->SetSide( SHEET_SIDE::TOP ); break; case 'B': sheetPin->SetSide( SHEET_SIDE::BOTTOM ); break; - case 'L': sheetPin->SetSide( SHEET_SIDE::LEFT ); break; + case 'L': sheetPin->SetSide( SHEET_SIDE::LEFT ); break; default: SCH_PARSE_ERROR( "invalid sheet pin side", aReader, line ); } @@ -1404,13 +1404,13 @@ SCH_BUS_ENTRY_BASE* SCH_LEGACY_PLUGIN::loadBusEntry( LINE_READER& aReader ) } // clang-format off -const std::map sheetLabelNames +const std::map sheetLabelNames { - { PINSHEETLABEL_SHAPE::PS_INPUT, "Input" }, - { PINSHEETLABEL_SHAPE::PS_OUTPUT, "Output" }, - { PINSHEETLABEL_SHAPE::PS_BIDI, "BiDi" }, - { PINSHEETLABEL_SHAPE::PS_TRISTATE, "3State" }, - { PINSHEETLABEL_SHAPE::PS_UNSPECIFIED, "UnSpc" }, + { LABEL_FLAG_SHAPE::L_INPUT, "Input" }, + { LABEL_FLAG_SHAPE::L_OUTPUT, "Output" }, + { LABEL_FLAG_SHAPE::L_BIDI, "BiDi" }, + { LABEL_FLAG_SHAPE::L_TRISTATE, "3State" }, + { LABEL_FLAG_SHAPE::L_UNSPECIFIED, "UnSpc" }, }; // clang-format on @@ -2272,11 +2272,11 @@ void SCH_LEGACY_PLUGIN::saveSheet( SCH_SHEET* aSheet ) switch( pin->GetShape() ) { default: - case PINSHEETLABEL_SHAPE::PS_UNSPECIFIED: type = 'U'; break; - case PINSHEETLABEL_SHAPE::PS_INPUT: type = 'I'; break; - case PINSHEETLABEL_SHAPE::PS_OUTPUT: type = 'O'; break; - case PINSHEETLABEL_SHAPE::PS_BIDI: type = 'B'; break; - case PINSHEETLABEL_SHAPE::PS_TRISTATE: type = 'T'; break; + case LABEL_FLAG_SHAPE::L_UNSPECIFIED: type = 'U'; break; + case LABEL_FLAG_SHAPE::L_INPUT: type = 'I'; break; + case LABEL_FLAG_SHAPE::L_OUTPUT: type = 'O'; break; + case LABEL_FLAG_SHAPE::L_BIDI: type = 'B'; break; + case LABEL_FLAG_SHAPE::L_TRISTATE: type = 'T'; break; } m_out->Print( 0, "F%d %s %c %c %-3d %-3d %-3d\n", diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 1d67265f12..4ea4289414 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -1011,7 +1011,13 @@ void SCH_SCREEN::EnsureAlternateReferencesExist() void SCH_SCREEN::GetHierarchicalItems( std::vector* aItems ) const { - static KICAD_T hierarchicalTypes[] = { SCH_SYMBOL_T, SCH_SHEET_T, SCH_GLOBAL_LABEL_T, EOT }; + static KICAD_T hierarchicalTypes[] = { SCH_SYMBOL_T, + SCH_SHEET_T, + SCH_LABEL_T, + SCH_HIER_LABEL_T, + SCH_NETCLASS_FLAG_T, + SCH_GLOBAL_LABEL_T, + EOT }; for( SCH_ITEM* item : Items() ) { @@ -1113,6 +1119,7 @@ SCH_TEXT* SCH_SCREEN::GetLabel( const wxPoint& aPosition, int aAccuracy ) const case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIER_LABEL_T: + case SCH_NETCLASS_FLAG_T: if( item->HitTest( aPosition, aAccuracy ) ) return static_cast( item ); diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 4ab821ac57..5697963690 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -594,11 +594,14 @@ void SCH_SHEET::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) void SCH_SHEET::ViewGetLayers( int aLayers[], int& aCount ) const { - aCount = 4; - aLayers[0] = LAYER_HIERLABEL; - aLayers[1] = LAYER_SHEET; - aLayers[2] = LAYER_SHEET_BACKGROUND; - aLayers[3] = LAYER_SELECTION_SHADOWS; + aCount = 7; + aLayers[0] = LAYER_HIERLABEL; + aLayers[1] = LAYER_SHEETNAME; + aLayers[2] = LAYER_SHEETFILENAME; + aLayers[3] = LAYER_SHEETFIELDS; + aLayers[4] = LAYER_SHEET; + aLayers[5] = LAYER_SHEET_BACKGROUND; + aLayers[6] = LAYER_SELECTION_SHADOWS; } diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index ce1ec4f5c0..9baa3d0f4f 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -53,7 +53,7 @@ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxStr else SetSide( SHEET_SIDE::LEFT ); - m_shape = PINSHEETLABEL_SHAPE::PS_INPUT; + m_shape = LABEL_FLAG_SHAPE::L_INPUT; m_isDangling = true; m_number = 2; } @@ -308,13 +308,13 @@ void SCH_SHEET_PIN::CreateGraphicShape( const RENDER_SETTINGS* aSettings, * for INPUT type the icon is the OUTPUT shape of SCH_HIERLABEL * for OUTPUT type the icon is the INPUT shape of SCH_HIERLABEL */ - PINSHEETLABEL_SHAPE shape = m_shape; + LABEL_FLAG_SHAPE shape = m_shape; switch( shape ) { - case PINSHEETLABEL_SHAPE::PS_INPUT: shape = PINSHEETLABEL_SHAPE::PS_OUTPUT; break; - case PINSHEETLABEL_SHAPE::PS_OUTPUT: shape = PINSHEETLABEL_SHAPE::PS_INPUT; break; - default: break; + case LABEL_FLAG_SHAPE::L_INPUT: shape = LABEL_FLAG_SHAPE::L_OUTPUT; break; + case LABEL_FLAG_SHAPE::L_OUTPUT: shape = LABEL_FLAG_SHAPE::L_INPUT; break; + default: break; } SCH_HIERLABEL::CreateGraphicShape( aSettings, aPoints, aPos, shape ); diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 7591639ef5..17bb31d4c8 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -228,12 +228,15 @@ EDA_ITEM* SCH_SYMBOL::Clone() const void SCH_SYMBOL::ViewGetLayers( int aLayers[], int& aCount ) const { - aCount = 4; + aCount = 7; aLayers[0] = LAYER_DANGLING; // Pins are drawn by their parent symbol, so the parent // symbol needs to draw to LAYER_DANGLING - aLayers[1] = LAYER_DEVICE; - aLayers[2] = LAYER_DEVICE_BACKGROUND; - aLayers[3] = LAYER_SELECTION_SHADOWS; + aLayers[1] = LAYER_DEVICE; + aLayers[2] = LAYER_REFERENCEPART; + aLayers[3] = LAYER_VALUEPART; + aLayers[4] = LAYER_FIELDS; + aLayers[5] = LAYER_DEVICE_BACKGROUND; + aLayers[6] = LAYER_SELECTION_SHADOWS; } diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index 4afb65aac0..b00aece106 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -602,12 +602,13 @@ public: bool CanConnect( const SCH_ITEM* aItem ) const override { return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE ) || - ( aItem->Type() == SCH_NO_CONNECT_T ) || - ( aItem->Type() == SCH_JUNCTION_T ) || - ( aItem->Type() == SCH_SYMBOL_T ) || - ( aItem->Type() == SCH_LABEL_T ) || - ( aItem->Type() == SCH_HIER_LABEL_T ) || - ( aItem->Type() == SCH_GLOBAL_LABEL_T ); + ( aItem->Type() == SCH_NO_CONNECT_T ) || + ( aItem->Type() == SCH_JUNCTION_T ) || + ( aItem->Type() == SCH_SYMBOL_T ) || + ( aItem->Type() == SCH_NETCLASS_FLAG_T ) || + ( aItem->Type() == SCH_LABEL_T ) || + ( aItem->Type() == SCH_HIER_LABEL_T ) || + ( aItem->Type() == SCH_GLOBAL_LABEL_T ); } /** diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index aa2f5ff1a1..70e8cbe094 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -28,7 +28,7 @@ * @brief Code for handling schematic texts (texts, labels, hlabels and global labels). */ -#include +#include #include #include #include @@ -214,10 +214,7 @@ LABEL_SPIN_STYLE LABEL_SPIN_STYLE::MirrorY() SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) : SCH_ITEM( nullptr, aType ), - EDA_TEXT( text ), - m_shape( PINSHEETLABEL_SHAPE::PS_INPUT ), - m_isDangling( false ), - m_connectionType( CONNECTION_TYPE::NONE ) + EDA_TEXT( text ) { m_layer = LAYER_NOTES; @@ -230,19 +227,10 @@ SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) : SCH_TEXT::SCH_TEXT( const SCH_TEXT& aText ) : SCH_ITEM( aText ), EDA_TEXT( aText ), - m_shape( aText.m_shape ), - m_isDangling( aText.m_isDangling ), - m_connectionType( aText.m_connectionType ), m_spin_style( aText.m_spin_style ) { } -EDA_ITEM* SCH_TEXT::Clone() const -{ - return new SCH_TEXT( *this ); -} - - bool SCH_TEXT::IncrementLabel( int aIncrement ) { wxString text = GetText(); @@ -265,14 +253,10 @@ wxPoint SCH_TEXT::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) con switch( GetLabelSpinStyle() ) { case LABEL_SPIN_STYLE::UP: - case LABEL_SPIN_STYLE::BOTTOM: - text_offset.x = -dist; - break; // Vert Orientation + case LABEL_SPIN_STYLE::BOTTOM: text_offset.x = -dist; break; // Vert Orientation default: case LABEL_SPIN_STYLE::LEFT: - case LABEL_SPIN_STYLE::RIGHT: - text_offset.y = -dist; - break; // Horiz Orientation + case LABEL_SPIN_STYLE::RIGHT: text_offset.y = -dist; break; // Horiz Orientation } return text_offset; @@ -336,46 +320,40 @@ void SCH_TEXT::SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle ) switch( aSpinStyle ) { default: - wxASSERT_MSG( 1, "Bad spin style" ); - break; + wxFAIL_MSG( "Bad spin style" ); + m_spin_style = LABEL_SPIN_STYLE::RIGHT; // Handle the error spin style by resetting + KI_FALLTHROUGH; case LABEL_SPIN_STYLE::RIGHT: // Horiz Normal Orientation - // - m_spin_style = LABEL_SPIN_STYLE::RIGHT; // Handle the error spin style by resetting SetTextAngle( TEXT_ANGLE_HORIZ ); SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break; case LABEL_SPIN_STYLE::UP: // Vert Orientation UP SetTextAngle( TEXT_ANGLE_VERT ); SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break; case LABEL_SPIN_STYLE::LEFT: // Horiz Orientation - Right justified SetTextAngle( TEXT_ANGLE_HORIZ ); SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break; case LABEL_SPIN_STYLE::BOTTOM: // Vert Orientation BOTTOM SetTextAngle( TEXT_ANGLE_VERT ); SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); break; } + + SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); } void SCH_TEXT::SwapData( SCH_ITEM* aItem ) { - SCH_TEXT* item = (SCH_TEXT*) aItem; + SCH_TEXT* item = static_cast( aItem ); std::swap( m_layer, item->m_layer ); - - std::swap( m_shape, item->m_shape ); - std::swap( m_isDangling, item->m_isDangling ); std::swap( m_spin_style, item->m_spin_style ); SwapText( *item ); @@ -420,7 +398,595 @@ int SCH_TEXT::GetTextOffset( const RENDER_SETTINGS* aSettings ) const } -int SCH_TEXT::GetLabelBoxExpansion( const RENDER_SETTINGS* aSettings ) const +int SCH_TEXT::GetPenWidth() const +{ + return GetEffectiveTextPenWidth(); +} + + +void SCH_TEXT::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) +{ + COLOR4D color = aSettings->GetLayerColor( m_layer ); + wxPoint text_offset = aOffset + GetSchematicTextOffset( aSettings ); + + EDA_TEXT::Print( aSettings, text_offset, color ); +} + + +const EDA_RECT SCH_TEXT::GetBoundingBox() const +{ + EDA_RECT rect = GetTextBox(); + + if( GetTextAngle() != 0 ) // Rotate rect. + { + wxPoint pos = rect.GetOrigin(); + wxPoint end = rect.GetEnd(); + + RotatePoint( &pos, GetTextPos(), GetTextAngle() ); + RotatePoint( &end, GetTextPos(), GetTextAngle() ); + + rect.SetOrigin( pos ); + rect.SetEnd( end ); + } + + rect.Normalize(); + return rect; +} + + +wxString getElectricalTypeLabel( LABEL_FLAG_SHAPE aType ) +{ + switch( aType ) + { + case LABEL_FLAG_SHAPE::L_INPUT: return _( "Input" ); + case LABEL_FLAG_SHAPE::L_OUTPUT: return _( "Output" ); + case LABEL_FLAG_SHAPE::L_BIDI: return _( "Bidirectional" ); + case LABEL_FLAG_SHAPE::L_TRISTATE: return _( "Tri-State" ); + case LABEL_FLAG_SHAPE::L_UNSPECIFIED: return _( "Passive" ); + default: return wxT( "???" ); + } +} + + +wxString SCH_TEXT::GetShownText( int aDepth ) const +{ + std::function textResolver = + [&]( wxString* token ) -> bool + { + if( token->Contains( ':' ) ) + { + if( Schematic()->ResolveCrossReference( token, aDepth ) ) + return true; + } + else + { + SCHEMATIC* schematic = Schematic(); + SCH_SHEET* sheet = schematic ? schematic->CurrentSheet().Last() : nullptr; + + if( sheet && sheet->ResolveTextVar( token, aDepth + 1 ) ) + return true; + } + + return false; + }; + + std::function schematicTextResolver = + [&]( wxString* token ) -> bool + { + return Schematic()->ResolveTextVar( token, aDepth + 1 ); + }; + + wxString text = EDA_TEXT::GetShownText(); + + if( text == "~" ) // Legacy placeholder for empty string + { + text = ""; + } + else if( HasTextVars() ) + { + PROJECT* project = nullptr; + + if( Schematic() ) + project = &Schematic()->Prj(); + + if( aDepth < 10 ) + text = ExpandTextVars( text, &textResolver, &schematicTextResolver, project ); + } + + return text; +} + + +wxString SCH_TEXT::GetSelectMenuText( EDA_UNITS aUnits ) const +{ + return wxString::Format( _( "Graphic Text '%s'" ), ShortenedShownText() ); +} + + +BITMAPS SCH_TEXT::GetMenuImage() const +{ + return BITMAPS::text; +} + + +bool SCH_TEXT::HitTest( const wxPoint& aPosition, int aAccuracy ) const +{ + EDA_RECT bBox = GetBoundingBox(); + bBox.Inflate( aAccuracy ); + return bBox.Contains( aPosition ); +} + + +bool SCH_TEXT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const +{ + EDA_RECT bBox = GetBoundingBox(); + bBox.Inflate( aAccuracy ); + + if( aContained ) + return aRect.Contains( bBox ); + + return aRect.Intersects( bBox ); +} + + +void SCH_TEXT::ViewGetLayers( int aLayers[], int& aCount ) const +{ + aCount = 2; + aLayers[0] = m_layer; + aLayers[1] = LAYER_SELECTION_SHADOWS; +} + + +void SCH_TEXT::Plot( PLOTTER* aPlotter ) const +{ + static std::vector s_poly; + + RENDER_SETTINGS* settings = aPlotter->RenderSettings(); + SCH_CONNECTION* connection = Connection(); + int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer; + COLOR4D color = settings->GetLayerColor( layer ); + int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() ); + + penWidth = std::max( penWidth, settings->GetMinPenWidth() ); + aPlotter->SetCurrentLineWidth( penWidth ); + + std::vector positions; + wxArrayString strings_list; + wxStringSplit( GetShownText(), strings_list, '\n' ); + positions.reserve( strings_list.Count() ); + + GetLinePositions( positions, (int) strings_list.Count() ); + + for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) + { + wxPoint textpos = positions[ii] + GetSchematicTextOffset( aPlotter->RenderSettings() ); + wxString& txt = strings_list.Item( ii ); + aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(), GetHorizJustify(), + GetVertJustify(), penWidth, IsItalic(), IsBold() ); + } +} + + +void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) +{ + wxString msg; + + // Don't use GetShownText() here; we want to show the user the variable references + aList.emplace_back( _( "Graphic Text" ), UnescapeString( GetText() ) ); + + wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) }; + int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0; + aList.emplace_back( _( "Style" ), textStyle[style] ); + + aList.emplace_back( _( "Text Size" ), MessageTextFromValue( aFrame->GetUserUnits(), + GetTextWidth() ) ); + + switch( GetLabelSpinStyle() ) + { + case LABEL_SPIN_STYLE::LEFT: msg = _( "Align right" ); break; + case LABEL_SPIN_STYLE::UP: msg = _( "Align bottom" ); break; + case LABEL_SPIN_STYLE::RIGHT: msg = _( "Align left" ); break; + case LABEL_SPIN_STYLE::BOTTOM: msg = _( "Align top" ); break; + default: msg = wxT( "???" ); break; + } + + aList.emplace_back( _( "Justification" ), msg ); +} + + +#if defined(DEBUG) + +void SCH_TEXT::Show( int nestLevel, std::ostream& os ) const +{ + // XML output: + wxString s = GetClass(); + + NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() + << " layer=\"" << m_layer << '"' + << '>' + << TO_UTF8( GetText() ) + << "\n"; +} + +#endif + + +SCH_LABEL_BASE::SCH_LABEL_BASE( const wxPoint& aPos, const wxString& aText, KICAD_T aType ) : + SCH_TEXT( aPos, aText, aType ) +{ + SetMultilineAllowed( false ); + SetFieldsAutoplaced(); +} + + +SCH_LABEL_BASE::SCH_LABEL_BASE( const SCH_LABEL_BASE& aLabel ) : + SCH_TEXT( aLabel ), + m_shape( aLabel.m_shape ), + m_connectionType( aLabel.m_connectionType ), + m_isDangling( aLabel.m_isDangling ) +{ + SetMultilineAllowed( false ); + + m_fields = aLabel.m_fields; + + for( SCH_FIELD& field : m_fields ) + field.SetParent( this ); +} + + +const wxString SCH_LABEL_BASE::GetDefaultFieldName( const wxString& aName, bool aUseDefaultName ) +{ + static void* locale = nullptr; + static wxString intersheetRefsDefault; + static wxString netclassRefDefault; + static wxString userFieldDefault; + + // Fetching translations can take a surprising amount of time when loading libraries, + // so only do it when necessary. + if( Pgm().GetLocale() != locale ) + { + intersheetRefsDefault = _( "Sheet References" ); + netclassRefDefault = _( "Net Class" ); + userFieldDefault = _( "Field" ); + locale = Pgm().GetLocale(); + } + + if( aName == wxT( "Intersheetrefs" ) ) + return intersheetRefsDefault; + else if( aName == wxT( "Netclass" ) ) + return netclassRefDefault; + else if( aName.IsEmpty() && aUseDefaultName ) + return userFieldDefault; + else + return aName; +} + + +bool SCH_LABEL_BASE::IsType( const KICAD_T aScanTypes[] ) const +{ + static KICAD_T wireTypes[] = { SCH_ITEM_LOCATE_WIRE_T, SCH_PIN_T, EOT }; + static KICAD_T busTypes[] = { SCH_ITEM_LOCATE_BUS_T, EOT }; + + if( SCH_TEXT::IsType( aScanTypes ) ) + return true; + + for( const KICAD_T* p = aScanTypes; *p != EOT; ++p ) + { + if( *p == SCH_LABEL_LOCATE_ANY_T ) + return true; + + if( *p == SCH_LABEL_LOCATE_WIRE_T ) + { + wxCHECK_MSG( Schematic(), false, "No parent SCHEMATIC set for SCH_LABEL!" ); + + for( SCH_ITEM* connection : m_connected_items.at( Schematic()->CurrentSheet() ) ) + { + if( connection->IsType( wireTypes ) ) + return true; + } + } + + if ( *p == SCH_LABEL_LOCATE_BUS_T ) + { + wxCHECK_MSG( Schematic(), false, "No parent SCHEMATIC set for SCH_LABEL!" ); + + for( SCH_ITEM* connection : m_connected_items.at( Schematic()->CurrentSheet() ) ) + { + if( connection->IsType( busTypes ) ) + return true; + } + } + } + + return false; +} + + +void SCH_LABEL_BASE::SwapData( SCH_ITEM* aItem ) +{ + SCH_TEXT::SwapData( aItem ); + + SCH_LABEL_BASE* label = static_cast( aItem ); + + m_fields.swap( label->m_fields ); + std::swap( m_fieldsAutoplaced, label->m_fieldsAutoplaced ); + + for( SCH_FIELD& field : m_fields ) + field.SetParent( this ); + + for( SCH_FIELD& field : label->m_fields ) + field.SetParent( label ); + + std::swap( m_shape, label->m_shape ); + std::swap( m_connectionType, label->m_connectionType ); + std::swap( m_isDangling, label->m_isDangling ); +} + + +void SCH_LABEL_BASE::Rotate( const wxPoint& aCenter ) +{ + wxPoint pt = GetTextPos(); + RotatePoint( &pt, aCenter, 900 ); + wxPoint offset = pt - GetTextPos(); + + Rotate90( false ); + + SetTextPos( GetTextPos() + offset ); + + for( SCH_FIELD& field : m_fields ) + field.SetTextPos( field.GetTextPos() + offset ); +} + + +void SCH_LABEL_BASE::Rotate90( bool aClockwise ) +{ + SCH_TEXT::Rotate90( aClockwise ); + + if( m_fieldsAutoplaced == FIELDS_AUTOPLACED_AUTO ) + { + AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false ); + } + else + { + for( SCH_FIELD& field : m_fields ) + { + if( field.GetTextAngle() == TEXT_ANGLE_VERT + && field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) + { + if( !aClockwise ) + field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + + field.SetTextAngle( TEXT_ANGLE_HORIZ ); + } + else if( field.GetTextAngle() == TEXT_ANGLE_VERT + && field.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) + { + if( !aClockwise ) + field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + + field.SetTextAngle( TEXT_ANGLE_HORIZ ); + } + else if( field.GetTextAngle() == TEXT_ANGLE_HORIZ + && field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) + { + if( aClockwise ) + field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + + field.SetTextAngle( TEXT_ANGLE_VERT ); + } + else if( field.GetTextAngle() == TEXT_ANGLE_HORIZ + && field.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) + { + if( aClockwise ) + field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + + field.SetTextAngle( TEXT_ANGLE_VERT ); + } + + wxPoint pos = field.GetTextPos(); + RotatePoint( &pos, GetPosition(), aClockwise ? -900 : 900 ); + field.SetTextPos( pos ); + } + } +} + + +void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) +{ + int margin = GetTextOffset() * 2; + int labelLen = GetBodyBoundingBox().GetSizeMax(); + int accumulated = GetTextHeight() / 2; + + if( Type() == SCH_GLOBAL_LABEL_T ) + accumulated += margin + GetPenWidth() + margin; + + for( SCH_FIELD& field : m_fields ) + { + wxPoint offset( 0, 0 ); + + switch( GetLabelSpinStyle() ) + { + default: + case LABEL_SPIN_STYLE::LEFT: + field.SetTextAngle( TEXT_ANGLE_HORIZ ); + field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + + if( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 ) + offset.x = - ( labelLen + margin ); + else + offset.y = accumulated + field.GetTextHeight() / 2; + + break; + + case LABEL_SPIN_STYLE::UP: + field.SetTextAngle( TEXT_ANGLE_VERT ); + field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + + if( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 ) + offset.y = - ( labelLen + margin ); + else + offset.x = accumulated + field.GetTextHeight() / 2; + + break; + + case LABEL_SPIN_STYLE::RIGHT: + field.SetTextAngle( TEXT_ANGLE_HORIZ ); + field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + + if( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 ) + offset.x = labelLen + margin; + else + offset.y = accumulated + field.GetTextHeight() / 2; + + break; + + case LABEL_SPIN_STYLE::BOTTOM: + field.SetTextAngle( TEXT_ANGLE_VERT ); + field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + + if( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 ) + offset.y = labelLen + margin; + else + offset.x = accumulated + field.GetTextHeight() / 2; + + break; + } + + field.SetTextPos( GetTextPos() + offset ); + + if( Type() != SCH_GLOBAL_LABEL_T || field.GetId() > 0 ) + accumulated += field.GetTextHeight() + margin; + } + + m_fieldsAutoplaced = FIELDS_AUTOPLACED_AUTO; +} + + +bool SCH_LABEL_BASE::ResolveTextVar( wxString* token, int aDepth ) const +{ + if( ( Type() == SCH_GLOBAL_LABEL_T || Type() == SCH_HIER_LABEL_T || Type() == SCH_SHEET_PIN_T ) + && token->IsSameAs( wxT( "CONNECTION_TYPE" ) ) ) + { + const SCH_LABEL_BASE* label = static_cast( this ); + *token = getElectricalTypeLabel( label->GetShape() ); + return true; + } + + for( size_t i = 0; i < m_fields.size(); ++i ) + { + if( token->IsSameAs( m_fields[i].GetName() ) ) + { + *token = m_fields[i].GetShownText( aDepth + 1 ); + return true; + } + } + + if( Type() == SCH_SHEET_PIN_T && m_parent ) + { + SCH_SHEET* sheet = static_cast( m_parent ); + + if( sheet->ResolveTextVar( token, aDepth ) ) + return true; + } + + return false; +} + + +wxString SCH_LABEL_BASE::GetShownText( int aDepth ) const +{ + std::function textResolver = + [&]( wxString* token ) -> bool + { + return ResolveTextVar( token, aDepth ); + }; + + std::function schematicTextResolver = + [&]( wxString* token ) -> bool + { + return Schematic()->ResolveTextVar( token, aDepth + 1 ); + }; + + wxString text = EDA_TEXT::GetShownText(); + + if( text == "~" ) // Legacy placeholder for empty string + { + text = ""; + } + else if( HasTextVars() ) + { + PROJECT* project = nullptr; + + if( Schematic() ) + project = &Schematic()->Prj(); + + if( aDepth < 10 ) + text = ExpandTextVars( text, &textResolver, &schematicTextResolver, project ); + } + + return text; +} + + +void SCH_LABEL_BASE::RunOnChildren( const std::function& aFunction ) +{ + for( SCH_FIELD& field : m_fields ) + aFunction( &field ); +} + + +SEARCH_RESULT SCH_LABEL_BASE::Visit( INSPECTOR aInspector, void* testData, + const KICAD_T aFilterTypes[] ) +{ + KICAD_T stype; + + if( IsType( aFilterTypes ) ) + { + if( SEARCH_RESULT::QUIT == aInspector( this, nullptr ) ) + return SEARCH_RESULT::QUIT; + } + + for( const KICAD_T* p = aFilterTypes; (stype = *p) != EOT; ++p ) + { + if( stype == SCH_LOCATE_ANY_T || stype == SCH_FIELD_T ) + { + for( SCH_FIELD& field : m_fields ) + { + if( SEARCH_RESULT::QUIT == aInspector( &field, this ) ) + return SEARCH_RESULT::QUIT; + } + } + } + + return SEARCH_RESULT::CONTINUE; +} + + +void SCH_LABEL_BASE::GetEndPoints( std::vector& aItemList ) +{ + DANGLING_END_ITEM item( LABEL_END, this, GetTextPos() ); + aItemList.push_back( item ); +} + + +std::vector SCH_LABEL_BASE::GetConnectionPoints() const +{ + return { GetTextPos() }; +} + + +void SCH_LABEL_BASE::ViewGetLayers( int aLayers[], int& aCount ) const +{ + aCount = 5; + aLayers[0] = LAYER_DANGLING; + aLayers[1] = LAYER_DEVICE; + aLayers[2] = LAYER_NETCLASS_REFS; + aLayers[3] = LAYER_FIELDS; + aLayers[4] = LAYER_SELECTION_SHADOWS; +} + + +int SCH_LABEL_BASE::GetLabelBoxExpansion( const RENDER_SETTINGS* aSettings ) const { double ratio; @@ -437,39 +1003,93 @@ int SCH_TEXT::GetLabelBoxExpansion( const RENDER_SETTINGS* aSettings ) const } -int SCH_TEXT::GetPenWidth() const +const EDA_RECT SCH_LABEL_BASE::GetBodyBoundingBox() const { - return GetEffectiveTextPenWidth(); + // build the bounding box of the label only, without taking into account its fields + + EDA_RECT box; + std::vector pts; + + CreateGraphicShape( nullptr, pts, GetTextPos() ); + + for( const wxPoint& pt : pts ) + box.Merge( pt ); + + box.Inflate( GetEffectiveTextPenWidth() / 2 ); + box.Normalize(); + return box; } -void SCH_TEXT::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) +const EDA_RECT SCH_LABEL_BASE::GetBoundingBox() const { - COLOR4D color = aSettings->GetLayerColor( m_layer ); - wxPoint text_offset = aOffset + GetSchematicTextOffset( aSettings ); + // build the bounding box of the entire net class flag, including both the symbol and the + // net class reference text - EDA_TEXT::Print( aSettings, text_offset, color ); + EDA_RECT box( GetBodyBoundingBox() ); + + for( const SCH_FIELD& field : m_fields ) + box.Merge( field.GetBoundingBox() ); + + box.Normalize(); + + return box; } -void SCH_TEXT::GetEndPoints( std::vector & aItemList ) +bool SCH_LABEL_BASE::HitTest( const wxPoint& aPosition, int aAccuracy ) const { - // Normal text labels cannot be tested for dangling ends. - if( Type() == SCH_TEXT_T ) - return; + EDA_RECT bbox = GetBodyBoundingBox(); + bbox.Inflate( aAccuracy ); - DANGLING_END_ITEM item( LABEL_END, this, GetTextPos() ); - aItemList.push_back( item ); + if( bbox.Contains( aPosition ) ) + return true; + + for( const SCH_FIELD& field : m_fields ) + { + if( field.IsVisible() ) + { + bbox = field.GetBoundingBox(); + bbox.Inflate( aAccuracy ); + + if( bbox.Contains( aPosition ) ) + return bbox.Contains( aPosition ); + } + } + + return false; } -bool SCH_TEXT::UpdateDanglingState( std::vector& aItemList, - const SCH_SHEET_PATH* aPath ) +bool SCH_LABEL_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const { - // Normal text labels cannot be tested for dangling ends. - if( Type() == SCH_TEXT_T ) + EDA_RECT rect = aRect; + + rect.Inflate( aAccuracy ); + + if( aContained ) + { + return rect.Contains( GetBoundingBox() ); + } + else + { + if( rect.Intersects( GetBodyBoundingBox() ) ) + return true; + + for( const SCH_FIELD& field : m_fields ) + { + if( field.IsVisible() && rect.Intersects( field.GetBoundingBox() ) ) + return true; + } + return false; + } +} + +bool SCH_LABEL_BASE::UpdateDanglingState( std::vector& aItemList, + const SCH_SHEET_PATH* aPath ) +{ bool previousState = m_isDangling; m_isDangling = true; m_connectionType = CONNECTION_TYPE::NONE; @@ -542,218 +1162,14 @@ bool SCH_TEXT::UpdateDanglingState( std::vector& aItemList, } -std::vector SCH_TEXT::GetConnectionPoints() const -{ - // Normal text labels do not have connection points. All others do. - if( Type() == SCH_TEXT_T ) - return {}; - - return { GetTextPos() }; -} - - -const EDA_RECT SCH_TEXT::GetBoundingBox() const -{ - EDA_RECT rect = GetTextBox(); - - if( GetTextAngle() != 0 ) // Rotate rect. - { - wxPoint pos = rect.GetOrigin(); - wxPoint end = rect.GetEnd(); - - RotatePoint( &pos, GetTextPos(), GetTextAngle() ); - RotatePoint( &end, GetTextPos(), GetTextAngle() ); - - rect.SetOrigin( pos ); - rect.SetEnd( end ); - } - - rect.Normalize(); - return rect; -} - - -wxString getElectricalTypeLabel( PINSHEETLABEL_SHAPE aType ) -{ - switch( aType ) - { - case PINSHEETLABEL_SHAPE::PS_INPUT: return _( "Input" ); - case PINSHEETLABEL_SHAPE::PS_OUTPUT: return _( "Output" ); - case PINSHEETLABEL_SHAPE::PS_BIDI: return _( "Bidirectional" ); - case PINSHEETLABEL_SHAPE::PS_TRISTATE: return _( "Tri-State" ); - case PINSHEETLABEL_SHAPE::PS_UNSPECIFIED: return _( "Passive" ); - default: return wxT( "???" ); - } -} - - -void SCH_TEXT::GetContextualTextVars( wxArrayString* aVars ) const -{ - if( Type() == SCH_GLOBAL_LABEL_T || Type() == SCH_HIER_LABEL_T || Type() == SCH_SHEET_PIN_T ) - aVars->push_back( wxT( "CONNECTION_TYPE" ) ); - - if( Type() == SCH_SHEET_PIN_T && m_parent ) - static_cast( m_parent )->GetContextualTextVars( aVars ); -} - - -wxString SCH_TEXT::GetShownText( int aDepth ) const -{ - std::function textResolver = - [&]( wxString* token ) -> bool - { - if( ( Type() == SCH_GLOBAL_LABEL_T - || Type() == SCH_HIER_LABEL_T - || Type() == SCH_SHEET_PIN_T ) - && token->IsSameAs( wxT( "CONNECTION_TYPE" ) ) ) - { - *token = getElectricalTypeLabel( GetShape() ); - return true; - } - - if( Type() == SCH_SHEET_PIN_T && m_parent ) - { - SCH_SHEET* sheet = static_cast( m_parent ); - - if( sheet->ResolveTextVar( token, aDepth ) ) - return true; - } - - if( Type() == SCH_TEXT_T ) - { - if( token->Contains( ':' ) ) - { - if( Schematic()->ResolveCrossReference( token, aDepth ) ) - return true; - } - else - { - SCHEMATIC* schematic = Schematic(); - SCH_SHEET* sheet = schematic ? schematic->CurrentSheet().Last() : nullptr; - - if( sheet && sheet->ResolveTextVar( token, aDepth + 1 ) ) - return true; - } - } - - return false; - }; - - std::function schematicTextResolver = - [&]( wxString* token ) -> bool - { - return Schematic()->ResolveTextVar( token, aDepth + 1 ); - }; - - wxString text = EDA_TEXT::GetShownText(); - - if( text == "~" ) // Legacy placeholder for empty string - { - text = ""; - } - else if( HasTextVars() ) - { - wxCHECK_MSG( Schematic(), wxEmptyString, "No parent SCHEMATIC set for SCH_TEXT!" ); - - PROJECT* project = nullptr; - - if( Schematic() ) - project = &Schematic()->Prj(); - - if( aDepth < 10 ) - text = ExpandTextVars( text, &textResolver, &schematicTextResolver, project ); - } - - return text; -} - - -wxString SCH_TEXT::GetSelectMenuText( EDA_UNITS aUnits ) const -{ - return wxString::Format( _( "Graphic Text '%s'" ), ShortenedShownText() ); -} - - -BITMAPS SCH_TEXT::GetMenuImage() const -{ - return BITMAPS::text; -} - - -bool SCH_TEXT::HitTest( const wxPoint& aPosition, int aAccuracy ) const -{ - EDA_RECT bBox = GetBoundingBox(); - bBox.Inflate( aAccuracy ); - return bBox.Contains( aPosition ); -} - - -bool SCH_TEXT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const -{ - EDA_RECT bBox = GetBoundingBox(); - bBox.Inflate( aAccuracy ); - - if( aContained ) - return aRect.Contains( bBox ); - - return aRect.Intersects( bBox ); -} - - -void SCH_TEXT::Plot( PLOTTER* aPlotter ) const -{ - static std::vector s_poly; - - RENDER_SETTINGS* settings = aPlotter->RenderSettings(); - SCH_CONNECTION* connection = Connection(); - int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer; - COLOR4D color = settings->GetLayerColor( layer ); - int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() ); - - penWidth = std::max( penWidth, settings->GetMinPenWidth() ); - aPlotter->SetCurrentLineWidth( penWidth ); - - if( IsMultilineAllowed() ) - { - std::vector positions; - wxArrayString strings_list; - wxStringSplit( GetShownText(), strings_list, '\n' ); - positions.reserve( strings_list.Count() ); - - GetLinePositions( positions, (int) strings_list.Count() ); - - for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) - { - wxPoint textpos = positions[ii] + GetSchematicTextOffset( aPlotter->RenderSettings() ); - wxString& txt = strings_list.Item( ii ); - aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(), GetHorizJustify(), - GetVertJustify(), penWidth, IsItalic(), IsBold() ); - } - } - else - { - wxPoint textpos = GetTextPos() + GetSchematicTextOffset( aPlotter->RenderSettings() ); - - aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(), - GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), IsBold() ); - } - - // Draw graphic symbol for global or hierarchical labels - CreateGraphicShape( aPlotter->RenderSettings(), s_poly, GetTextPos() ); - - if( s_poly.size() ) - aPlotter->PlotPoly( s_poly, FILL_T::NO_FILL, penWidth ); -} - - -void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) +void SCH_LABEL_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { wxString msg; switch( Type() ) { - case SCH_TEXT_T: msg = _( "Graphic Text" ); break; case SCH_LABEL_T: msg = _( "Label" ); break; + case SCH_NETCLASS_FLAG_T: msg = _( "Net Class Flag" ); break; case SCH_GLOBAL_LABEL_T: msg = _( "Global Label" ); break; case SCH_HIER_LABEL_T: msg = _( "Hierarchical Label" ); break; case SCH_SHEET_PIN_T: msg = _( "Hierarchical Sheet Pin" ); break; @@ -768,14 +1184,7 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), @@ -816,82 +1225,64 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector s_poly; - NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() - << " layer=\"" << m_layer << '"' - << " shape=\"" << static_cast( m_shape ) << '"' - << " dangling=\"" << m_isDangling << '"' - << '>' - << TO_UTF8( GetText() ) - << "\n"; + RENDER_SETTINGS* settings = aPlotter->RenderSettings(); + SCH_CONNECTION* connection = Connection(); + int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer; + COLOR4D color = settings->GetLayerColor( layer ); + int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() ); + + penWidth = std::max( penWidth, settings->GetMinPenWidth() ); + aPlotter->SetCurrentLineWidth( penWidth ); + + wxPoint textpos = GetTextPos() + GetSchematicTextOffset( aPlotter->RenderSettings() ); + + aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(), + GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), IsBold() ); + + CreateGraphicShape( aPlotter->RenderSettings(), s_poly, GetTextPos() ); + + if( s_poly.size() ) + aPlotter->PlotPoly( s_poly, FILL_T::NO_FILL, penWidth ); } -#endif + +void SCH_LABEL_BASE::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) +{ + static std::vector s_poly; + + SCH_CONNECTION* connection = Connection(); + int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer; + wxDC* DC = aSettings->GetPrintDC(); + COLOR4D color = aSettings->GetLayerColor( layer ); + int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() ); + wxPoint text_offset = aOffset + GetSchematicTextOffset( aSettings ); + + EDA_TEXT::Print( aSettings, text_offset, color ); + + CreateGraphicShape( aSettings, s_poly, GetTextPos() + aOffset ); + + if( !s_poly.empty() ) + GRPoly( nullptr, DC, s_poly.size(), &s_poly[0], false, penWidth, color, color ); + + for( SCH_FIELD& field : m_fields ) + field.Print( aSettings, aOffset ); +} -SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) - : SCH_TEXT( pos, text, SCH_LABEL_T ) +SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) : + SCH_LABEL_BASE( pos, text, SCH_LABEL_T ) { m_layer = LAYER_LOCLABEL; - m_shape = PINSHEETLABEL_SHAPE::PS_INPUT; + m_shape = LABEL_FLAG_SHAPE::L_INPUT; m_isDangling = true; - SetMultilineAllowed( false ); } -EDA_ITEM* SCH_LABEL::Clone() const -{ - return new SCH_LABEL( *this ); -} - - -bool SCH_LABEL::IsType( const KICAD_T aScanTypes[] ) const -{ - static KICAD_T wireTypes[] = { SCH_ITEM_LOCATE_WIRE_T, SCH_PIN_T, EOT }; - static KICAD_T busTypes[] = { SCH_ITEM_LOCATE_BUS_T, EOT }; - - if( SCH_ITEM::IsType( aScanTypes ) ) - return true; - - wxCHECK_MSG( Schematic(), false, "No parent SCHEMATIC set for SCH_LABEL!" ); - - SCH_SHEET_PATH current = Schematic()->CurrentSheet(); - - for( const KICAD_T* p = aScanTypes; *p != EOT; ++p ) - { - if( *p == SCH_LABEL_LOCATE_WIRE_T ) - { - wxASSERT( m_connected_items.count( current ) ); - - for( SCH_ITEM* connection : m_connected_items.at( current ) ) - { - if( connection->IsType( wireTypes ) ) - return true; - } - } - else if ( *p == SCH_LABEL_LOCATE_BUS_T ) - { - wxASSERT( m_connected_items.count( current ) ); - - for( SCH_ITEM* connection : m_connected_items.at( current ) ) - { - if( connection->IsType( busTypes ) ) - return true; - } - } - } - - return false; -} - - -const EDA_RECT SCH_LABEL::GetBoundingBox() const +const EDA_RECT SCH_LABEL::GetBodyBoundingBox() const { EDA_RECT rect = GetTextBox(); @@ -919,18 +1310,6 @@ const EDA_RECT SCH_LABEL::GetBoundingBox() const } -void SCH_TEXT::ViewGetLayers( int aLayers[], int& aCount ) const -{ - aCount = 0; - - if( m_layer != LAYER_NOTES ) - aLayers[ aCount++ ] = LAYER_DANGLING; - - aLayers[ aCount++ ] = m_layer; - aLayers[ aCount++ ] = LAYER_SELECTION_SHADOWS; -} - - wxString SCH_LABEL::GetSelectMenuText( EDA_UNITS aUnits ) const { return wxString::Format( _( "Label '%s'" ), ShortenedShownText() ); @@ -943,86 +1322,176 @@ BITMAPS SCH_LABEL::GetMenuImage() const } -SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) : - SCH_TEXT( pos, text, SCH_GLOBAL_LABEL_T ), - m_intersheetRefsField( { 0, 0 }, 0, this ) +SCH_NETCLASS_FLAG::SCH_NETCLASS_FLAG( const wxPoint& pos ) : + SCH_LABEL_BASE( pos, wxEmptyString, SCH_NETCLASS_FLAG_T ) { - m_layer = LAYER_GLOBLABEL; - m_shape = PINSHEETLABEL_SHAPE::PS_BIDI; + m_layer = LAYER_NETCLASS_REFS; + m_shape = LABEL_FLAG_SHAPE::F_ROUND; + m_pinLength = Mils2iu( 100 ); + m_symbolSize = Mils2iu( 20 ); m_isDangling = true; - SetMultilineAllowed( false ); - SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + m_fields.emplace_back( SCH_FIELD( { 0, 0 }, 0, this, _( "Net Class" ) ) ); + m_fields[0].SetLayer( LAYER_NETCLASS_REFS ); + m_fields[0].SetVisible( true ); + m_fields[0].SetItalic( true ); + m_fields[0].SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); +} + + +SCH_NETCLASS_FLAG::SCH_NETCLASS_FLAG( const SCH_NETCLASS_FLAG& aClassLabel ) : + SCH_LABEL_BASE( aClassLabel ) +{ + m_pinLength = aClassLabel.m_pinLength; + m_symbolSize = aClassLabel.m_symbolSize; +} + + +void SCH_NETCLASS_FLAG::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings, + std::vector& aPoints, + const wxPoint& aPos ) const +{ + int symbolSize = m_symbolSize; + + aPoints.clear(); + + switch( m_shape ) + { + case LABEL_FLAG_SHAPE::F_DOT: + symbolSize = KiROUND( symbolSize * 0.7 ); + KI_FALLTHROUGH; + + case LABEL_FLAG_SHAPE::F_ROUND: + // First 3 points are used for generating shape + aPoints.emplace_back( wxPoint( 0, 0 ) ); + aPoints.emplace_back( wxPoint( 0, m_pinLength - symbolSize ) ); + aPoints.emplace_back( wxPoint( 0, m_pinLength ) ); + // These points are just used to bulk out the bounding box + aPoints.emplace_back( wxPoint( -m_symbolSize, m_pinLength ) ); + aPoints.emplace_back( wxPoint( 0, m_pinLength ) ); + aPoints.emplace_back( wxPoint( m_symbolSize, m_pinLength + symbolSize ) ); + break; + + case LABEL_FLAG_SHAPE::F_DIAMOND: + aPoints.emplace_back( wxPoint( 0, 0 ) ); + aPoints.emplace_back( wxPoint( 0, m_pinLength - symbolSize ) ); + aPoints.emplace_back( wxPoint( -2 * m_symbolSize, m_pinLength ) ); + aPoints.emplace_back( wxPoint( 0, m_pinLength + symbolSize ) ); + aPoints.emplace_back( wxPoint( 2 * m_symbolSize, m_pinLength ) ); + aPoints.emplace_back( wxPoint( 0, m_pinLength - symbolSize ) ); + aPoints.emplace_back( wxPoint( 0, 0 ) ); + break; + + case LABEL_FLAG_SHAPE::F_RECTANGLE: + symbolSize = KiROUND( symbolSize * 0.8 ); + + aPoints.emplace_back( wxPoint( 0, 0 ) ); + aPoints.emplace_back( wxPoint( 0, m_pinLength - symbolSize ) ); + aPoints.emplace_back( wxPoint( -2 * symbolSize, m_pinLength - symbolSize ) ); + aPoints.emplace_back( wxPoint( -2 * symbolSize, m_pinLength + symbolSize ) ); + aPoints.emplace_back( wxPoint( 2 * symbolSize, m_pinLength + symbolSize ) ); + aPoints.emplace_back( wxPoint( 2 * symbolSize, m_pinLength - symbolSize ) ); + aPoints.emplace_back( wxPoint( 0, m_pinLength - symbolSize ) ); + aPoints.emplace_back( wxPoint( 0, 0 ) ); + break; + + default: + break; + } + + // Rotate outlines and move corners to real position + for( wxPoint& aPoint : aPoints ) + { + switch( GetLabelSpinStyle() ) + { + default: + case LABEL_SPIN_STYLE::LEFT: break; + case LABEL_SPIN_STYLE::UP: RotatePoint( &aPoint, -900 ); break; + case LABEL_SPIN_STYLE::RIGHT: RotatePoint( &aPoint, 1800 ); break; + case LABEL_SPIN_STYLE::BOTTOM: RotatePoint( &aPoint, 900 ); break; + } + + aPoint += aPos; + } +} + + +void SCH_NETCLASS_FLAG::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) +{ + int margin = GetTextOffset(); + int symbolWidth = m_symbolSize; + int origin = m_pinLength; + + if( m_shape == LABEL_FLAG_SHAPE::F_DIAMOND || m_shape == LABEL_FLAG_SHAPE::F_RECTANGLE ) + symbolWidth *= 2; + + if( IsItalic() ) + margin = KiROUND( margin * 1.5 ); + + wxPoint offset; + + for( SCH_FIELD& field : m_fields ) + { + switch( GetLabelSpinStyle() ) + { + default: + case LABEL_SPIN_STYLE::LEFT: + field.SetTextAngle( TEXT_ANGLE_HORIZ ); + offset = { symbolWidth + margin, origin }; + break; + + case LABEL_SPIN_STYLE::UP: + field.SetTextAngle( TEXT_ANGLE_VERT ); + offset = { -origin, -( symbolWidth + margin ) }; + break; + + case LABEL_SPIN_STYLE::RIGHT: + field.SetTextAngle( TEXT_ANGLE_HORIZ ); + offset = { symbolWidth + margin, -origin }; + break; + + case LABEL_SPIN_STYLE::BOTTOM: + field.SetTextAngle( TEXT_ANGLE_VERT ); + offset = { origin, -( symbolWidth + margin ) }; + break; + } + + field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + field.SetTextPos( GetPosition() + offset ); + + origin -= field.GetTextHeight() + margin; + } - m_intersheetRefsField.SetText( wxT( "${INTERSHEET_REFS}" ) ); - m_intersheetRefsField.SetLayer( LAYER_GLOBLABEL ); - m_intersheetRefsField.SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); m_fieldsAutoplaced = FIELDS_AUTOPLACED_AUTO; } +wxString SCH_NETCLASS_FLAG::GetSelectMenuText( EDA_UNITS aUnits ) const +{ + return wxString::Format( _( "Net Class Flag" ), ShortenedShownText() ); +} + + +SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) : + SCH_LABEL_BASE( pos, text, SCH_GLOBAL_LABEL_T ) +{ + m_layer = LAYER_GLOBLABEL; + m_shape = LABEL_FLAG_SHAPE::L_BIDI; + m_isDangling = true; + + SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + + m_fields.emplace_back( SCH_FIELD( { 0, 0 }, 0, this, _( "Sheet References" ) ) ); + m_fields[0].SetText( wxT( "${INTERSHEET_REFS}" ) ); + m_fields[0].SetVisible( true ); + m_fields[0].SetLayer( LAYER_INTERSHEET_REFS ); + m_fields[0].SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); +} + + SCH_GLOBALLABEL::SCH_GLOBALLABEL( const SCH_GLOBALLABEL& aGlobalLabel ) : - SCH_TEXT( aGlobalLabel ), - m_intersheetRefsField( { 0, 0 }, 0, this ) + SCH_LABEL_BASE( aGlobalLabel ) { - m_intersheetRefsField = aGlobalLabel.m_intersheetRefsField; - - // Re-parent the fields, which before this had aGlobalLabel as parent - m_intersheetRefsField.SetParent( this ); - - m_fieldsAutoplaced = aGlobalLabel.m_fieldsAutoplaced; -} - - -EDA_ITEM* SCH_GLOBALLABEL::Clone() const -{ - return new SCH_GLOBALLABEL( *this ); -} - - -void SCH_GLOBALLABEL::SwapData( SCH_ITEM* aItem ) -{ - SCH_TEXT::SwapData( aItem ); - - SCH_GLOBALLABEL* globalLabel = static_cast( aItem ); - - // Swap field data wholesale... - std::swap( m_intersheetRefsField, globalLabel->m_intersheetRefsField ); - - // ...and then reset parent pointers. - globalLabel->m_intersheetRefsField.SetParent( globalLabel ); - m_intersheetRefsField.SetParent( this ); -} - - -SEARCH_RESULT SCH_GLOBALLABEL::Visit( INSPECTOR aInspector, void* testData, - const KICAD_T aFilterTypes[] ) -{ - KICAD_T stype; - - for( const KICAD_T* p = aFilterTypes; (stype = *p) != EOT; ++p ) - { - // If caller wants to inspect my type - if( stype == SCH_LOCATE_ANY_T || stype == Type() ) - { - if( SEARCH_RESULT::QUIT == aInspector( this, nullptr ) ) - return SEARCH_RESULT::QUIT; - } - - if( stype == SCH_LOCATE_ANY_T || stype == SCH_FIELD_T ) - { - if( SEARCH_RESULT::QUIT == aInspector( GetIntersheetRefs(), this ) ) - return SEARCH_RESULT::QUIT; - } - } - - return SEARCH_RESULT::CONTINUE; -} - - -void SCH_GLOBALLABEL::RunOnChildren( const std::function& aFunction ) -{ - aFunction( &m_intersheetRefsField ); } @@ -1035,14 +1504,14 @@ wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset( const RENDER_SETTINGS* aSetting switch( m_shape ) { - case PINSHEETLABEL_SHAPE::PS_INPUT: - case PINSHEETLABEL_SHAPE::PS_BIDI: - case PINSHEETLABEL_SHAPE::PS_TRISTATE: + case LABEL_FLAG_SHAPE::L_INPUT: + case LABEL_FLAG_SHAPE::L_BIDI: + case LABEL_FLAG_SHAPE::L_TRISTATE: horiz += GetTextHeight() * 3 / 4; // Use three-quarters-height as proxy for triangle size break; - case PINSHEETLABEL_SHAPE::PS_OUTPUT: - case PINSHEETLABEL_SHAPE::PS_UNSPECIFIED: + case LABEL_FLAG_SHAPE::L_OUTPUT: + case LABEL_FLAG_SHAPE::L_UNSPECIFIED: default: break; } @@ -1060,91 +1529,8 @@ wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset( const RENDER_SETTINGS* aSetting void SCH_GLOBALLABEL::SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle ) { - m_spin_style = aSpinStyle; - - switch( aSpinStyle ) - { - default: - wxASSERT_MSG( 1, "Bad spin style" ); - m_spin_style = LABEL_SPIN_STYLE::RIGHT; - KI_FALLTHROUGH; - - case LABEL_SPIN_STYLE::RIGHT: // Horiz Normal Orientation - SetTextAngle( TEXT_ANGLE_HORIZ ); - SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - break; - - case LABEL_SPIN_STYLE::UP: // Vert Orientation UP - SetTextAngle( TEXT_ANGLE_VERT ); - SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - break; - - case LABEL_SPIN_STYLE::LEFT: // Horiz Orientation - SetTextAngle( TEXT_ANGLE_HORIZ ); - SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - break; - - case LABEL_SPIN_STYLE::BOTTOM: // Vert Orientation BOTTOM - SetTextAngle( TEXT_ANGLE_VERT ); - SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - break; - } -} - - -void SCH_GLOBALLABEL::Rotate( const wxPoint& aCenter ) -{ - wxPoint pt = GetTextPos(); - RotatePoint( &pt, aCenter, 900 ); - wxPoint offset = pt - GetTextPos(); - - Rotate90( false ); - - SetTextPos( GetTextPos() + offset ); - m_intersheetRefsField.SetTextPos( m_intersheetRefsField.GetTextPos() + offset ); -} - - -void SCH_GLOBALLABEL::Rotate90( bool aClockwise ) -{ - SCH_TEXT::Rotate90( aClockwise ); - - if( m_intersheetRefsField.GetTextAngle() == TEXT_ANGLE_VERT - && m_intersheetRefsField.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) - { - if( !aClockwise ) - m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - - m_intersheetRefsField.SetTextAngle( TEXT_ANGLE_HORIZ ); - } - else if( m_intersheetRefsField.GetTextAngle() == TEXT_ANGLE_VERT - && m_intersheetRefsField.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) - { - if( !aClockwise ) - m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - - m_intersheetRefsField.SetTextAngle( TEXT_ANGLE_HORIZ ); - } - else if( m_intersheetRefsField.GetTextAngle() == TEXT_ANGLE_HORIZ - && m_intersheetRefsField.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) - { - if( aClockwise ) - m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - - m_intersheetRefsField.SetTextAngle( TEXT_ANGLE_VERT ); - } - else if( m_intersheetRefsField.GetTextAngle() == TEXT_ANGLE_HORIZ - && m_intersheetRefsField.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) - { - if( aClockwise ) - m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - - m_intersheetRefsField.SetTextAngle( TEXT_ANGLE_VERT ); - } - - wxPoint pos = m_intersheetRefsField.GetTextPos(); - RotatePoint( &pos, GetPosition(), aClockwise ? -900 : 900 ); - m_intersheetRefsField.SetTextPos( pos ); + SCH_TEXT::SetLabelSpinStyle( aSpinStyle ); + SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); } @@ -1152,24 +1538,27 @@ void SCH_GLOBALLABEL::MirrorSpinStyle( bool aLeftRight ) { SCH_TEXT::MirrorSpinStyle( aLeftRight ); - if( ( aLeftRight && m_intersheetRefsField.GetTextAngle() == TEXT_ANGLE_HORIZ ) - || ( !aLeftRight && m_intersheetRefsField.GetTextAngle() == TEXT_ANGLE_VERT ) ) + for( SCH_FIELD& field : m_fields ) { - if( m_intersheetRefsField.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) - m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + if( ( aLeftRight && field.GetTextAngle() == TEXT_ANGLE_HORIZ ) + || ( !aLeftRight && field.GetTextAngle() == TEXT_ANGLE_VERT ) ) + { + if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) + field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + else + field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + } + + wxPoint pos = field.GetTextPos(); + wxPoint delta = GetPosition() - pos; + + if( aLeftRight ) + pos.x = GetPosition().x + delta.x; else - m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + pos.y = GetPosition().y + delta.y; + + field.SetTextPos( pos ); } - - wxPoint pos = m_intersheetRefsField.GetTextPos(); - wxPoint delta = GetPosition() - pos; - - if( aLeftRight ) - pos.x = GetPosition().x + delta.x; - else - pos.y = GetPosition().y + delta.y; - - m_intersheetRefsField.SetTextPos( pos ); } @@ -1178,16 +1567,19 @@ void SCH_GLOBALLABEL::MirrorHorizontally( int aCenter ) wxPoint old_pos = GetPosition(); SCH_TEXT::MirrorHorizontally( aCenter ); - if( m_intersheetRefsField.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) - m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - else - m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + for( SCH_FIELD& field : m_fields ) + { + if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) + field.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + else + field.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - wxPoint pos = m_intersheetRefsField.GetTextPos(); - wxPoint delta = old_pos - pos; - pos.x = GetPosition().x + delta.x; + wxPoint pos = field.GetTextPos(); + wxPoint delta = old_pos - pos; + pos.x = GetPosition().x + delta.x; - m_intersheetRefsField.SetPosition( pos ); + field.SetPosition( pos ); + } } @@ -1195,66 +1587,15 @@ void SCH_GLOBALLABEL::MirrorVertically( int aCenter ) { wxPoint old_pos = GetPosition(); SCH_TEXT::MirrorVertically( aCenter ); - wxPoint pos = m_intersheetRefsField.GetTextPos(); - wxPoint delta = old_pos - pos; - pos.y = GetPosition().y + delta.y; - m_intersheetRefsField.SetPosition( pos ); -} - - -void SCH_GLOBALLABEL::UpdateIntersheetRefProps() -{ - m_intersheetRefsField.SetTextSize( GetTextSize() ); - m_intersheetRefsField.SetItalic( IsItalic() ); - m_intersheetRefsField.SetBold( IsBold() ); - m_intersheetRefsField.SetTextThickness( GetTextThickness() ); - - if( m_fieldsAutoplaced == FIELDS_AUTOPLACED_AUTO ) - AutoplaceFields( nullptr, false ); -} - - -void SCH_GLOBALLABEL::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) -{ - int margin = GetTextOffset() * 2; - int labelLen = GetBoundingBoxBase().GetSizeMax(); - int penOffset = GetPenWidth() / 2; - - // Set both axes to penOffset; we're going to overwrite the text axis below - wxPoint offset( -penOffset, -penOffset ); - - switch( GetLabelSpinStyle() ) + for( SCH_FIELD& field : m_fields ) { - default: - case LABEL_SPIN_STYLE::LEFT: - m_intersheetRefsField.SetTextAngle( TEXT_ANGLE_HORIZ ); - m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - offset.x = - ( labelLen + margin / 2 ); - break; + wxPoint pos = field.GetTextPos(); + wxPoint delta = old_pos - pos; + pos.y = GetPosition().y + delta.y; - case LABEL_SPIN_STYLE::UP: - m_intersheetRefsField.SetTextAngle( TEXT_ANGLE_VERT ); - m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - offset.y = - ( labelLen + margin / 2 ); - break; - - case LABEL_SPIN_STYLE::RIGHT: - m_intersheetRefsField.SetTextAngle( TEXT_ANGLE_HORIZ ); - m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - offset.x = labelLen + margin /2 ; - break; - - case LABEL_SPIN_STYLE::BOTTOM: - m_intersheetRefsField.SetTextAngle( TEXT_ANGLE_VERT ); - m_intersheetRefsField.SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - offset.y = labelLen + margin / 2; - break; + field.SetPosition( pos ); } - - m_intersheetRefsField.SetTextPos( GetPosition() + offset ); - - m_fieldsAutoplaced = FIELDS_AUTOPLACED_AUTO; } @@ -1307,44 +1648,24 @@ bool SCH_GLOBALLABEL::ResolveTextVar( wxString* token, int aDepth ) const return true; } - return false; + return SCH_LABEL_BASE::ResolveTextVar( token, aDepth ); } -void SCH_GLOBALLABEL::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) +void SCH_GLOBALLABEL::ViewGetLayers( int aLayers[], int& aCount ) const { - static std::vector s_poly; - - SCH_CONNECTION* connection = Connection(); - int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer; - wxDC* DC = aSettings->GetPrintDC(); - COLOR4D color = aSettings->GetLayerColor( layer ); - int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() ); - wxPoint text_offset = aOffset + GetSchematicTextOffset( aSettings ); - - EDA_TEXT::Print( aSettings, text_offset, color ); - - CreateGraphicShape( aSettings, s_poly, GetTextPos() + aOffset ); - GRPoly( nullptr, DC, s_poly.size(), &s_poly[0], false, penWidth, color, color ); - - if( Schematic()->Settings().m_IntersheetRefsShow ) - m_intersheetRefsField.Print( aSettings, aOffset ); -} - - -void SCH_GLOBALLABEL::Plot( PLOTTER* aPlotter ) const -{ - SCH_TEXT::Plot( aPlotter ); - - bool show = Schematic()->Settings().m_IntersheetRefsShow; - - if ( show ) - m_intersheetRefsField.Plot( aPlotter ); + aCount = 5; + aLayers[0] = LAYER_DEVICE; + aLayers[1] = LAYER_INTERSHEET_REFS; + aLayers[2] = LAYER_NETCLASS_REFS; + aLayers[3] = LAYER_FIELDS; + aLayers[4] = LAYER_SELECTION_SHADOWS; } void SCH_GLOBALLABEL::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings, - std::vector& aPoints, const wxPoint& Pos ) const + std::vector& aPoints, + const wxPoint& aPos ) const { int margin = GetLabelBoxExpansion( aRenderSettings ); int halfSize = ( GetTextHeight() / 2 ) + margin; @@ -1368,121 +1689,48 @@ void SCH_GLOBALLABEL::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings switch( m_shape ) { - case PINSHEETLABEL_SHAPE::PS_INPUT: + case LABEL_FLAG_SHAPE::L_INPUT: x_offset = -halfSize; aPoints[0].x += halfSize; break; - case PINSHEETLABEL_SHAPE::PS_OUTPUT: + case LABEL_FLAG_SHAPE::L_OUTPUT: aPoints[3].x -= halfSize; break; - case PINSHEETLABEL_SHAPE::PS_BIDI: - case PINSHEETLABEL_SHAPE::PS_TRISTATE: + case LABEL_FLAG_SHAPE::L_BIDI: + case LABEL_FLAG_SHAPE::L_TRISTATE: x_offset = -halfSize; aPoints[0].x += halfSize; aPoints[3].x -= halfSize; break; - case PINSHEETLABEL_SHAPE::PS_UNSPECIFIED: + case LABEL_FLAG_SHAPE::L_UNSPECIFIED: default: break; } - int angle = 0; - - switch( GetLabelSpinStyle() ) - { - default: - case LABEL_SPIN_STYLE::LEFT: break; - case LABEL_SPIN_STYLE::UP: angle = -900; break; - case LABEL_SPIN_STYLE::RIGHT: angle = 1800; break; - case LABEL_SPIN_STYLE::BOTTOM: angle = 900; break; - } - // Rotate outlines and move corners in real position for( wxPoint& aPoint : aPoints ) { aPoint.x += x_offset; - if( angle ) - RotatePoint( &aPoint, angle ); + switch( GetLabelSpinStyle() ) + { + default: + case LABEL_SPIN_STYLE::LEFT: break; + case LABEL_SPIN_STYLE::UP: RotatePoint( &aPoint, -900 ); break; + case LABEL_SPIN_STYLE::RIGHT: RotatePoint( &aPoint, 1800 ); break; + case LABEL_SPIN_STYLE::BOTTOM: RotatePoint( &aPoint, 900 ); break; + } - aPoint += Pos; + aPoint += aPos; } aPoints.push_back( aPoints[0] ); // closing } -const EDA_RECT SCH_GLOBALLABEL::GetBoundingBoxBase() const -{ - // build the bounding box on the global label only, without taking in account - // the intersheets references, just the bounding box of the graphic shape - int x = GetTextPos().x; - int y = GetTextPos().y; - int penWidth = GetEffectiveTextPenWidth(); - int margin = GetTextOffset(); - int height = ( ( GetTextHeight() * 15 ) / 10 ) + penWidth + margin; - int length = LenSize( GetShownText(), penWidth ) - + height // add height for triangular shapes - - margin; // margin added to height not needed here - - int dx, dy; - - switch( GetLabelSpinStyle() ) // respect orientation - { - default: - case LABEL_SPIN_STYLE::LEFT: - dx = -length; - dy = height; - y -= height / 2; - break; - - case LABEL_SPIN_STYLE::UP: - dx = height; - dy = -length; - x -= height / 2; - break; - - case LABEL_SPIN_STYLE::RIGHT: - dx = length; - dy = height; - y -= height / 2; - break; - - case LABEL_SPIN_STYLE::BOTTOM: - dx = height; - dy = length; - x -= height / 2; - break; - } - - EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) ); - - box.Normalize(); - return box; -} - - -const EDA_RECT SCH_GLOBALLABEL::GetBoundingBox() const -{ - // build the bounding box on the global label only, including the intersheets references - // full bounding box if they are shown - - EDA_RECT box( GetBoundingBoxBase() ); - - // Note: Schematic() can be null in preference preview panel - if( Schematic() && Schematic()->Settings().m_IntersheetRefsShow ) - { - box.Merge( m_intersheetRefsField.GetBoundingBox() ); - box.Normalize(); - } - - return box; -} - - wxString SCH_GLOBALLABEL::GetSelectMenuText( EDA_UNITS aUnits ) const { return wxString::Format( _( "Global Label '%s'" ), ShortenedShownText() ); @@ -1495,132 +1743,19 @@ BITMAPS SCH_GLOBALLABEL::GetMenuImage() const } -bool SCH_GLOBALLABEL::HitTest( const wxPoint& aPosition, int aAccuracy ) const -{ - EDA_RECT bbox = GetBoundingBoxBase(); - bbox.Inflate( aAccuracy ); - - if( !bbox.Contains( aPosition ) ) - { - if( Schematic() && Schematic()->Settings().m_IntersheetRefsShow ) - { - bbox = m_intersheetRefsField.GetBoundingBox(); - bbox.Inflate( aAccuracy ); - - return bbox.Contains( aPosition ); - } - - return false; - } - - return true; -} - - -bool SCH_GLOBALLABEL::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const -{ - EDA_RECT bbox = GetBoundingBoxBase(); - - if( aContained ) - { - if( Schematic() && Schematic()->Settings().m_IntersheetRefsShow ) - bbox.Merge( m_intersheetRefsField.GetBoundingBox() ); - - bbox.Inflate( aAccuracy ); - return aRect.Contains( bbox ); - } - - bbox.Inflate( aAccuracy ); - - if( aRect.Intersects( bbox ) ) - return true; - - if( Schematic() && Schematic()->Settings().m_IntersheetRefsShow ) - { - bbox = m_intersheetRefsField.GetBoundingBox(); - bbox.Inflate( aAccuracy ); - - return aRect.Intersects( bbox ); - } - - return false; -} - - -SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType ) - : SCH_TEXT( pos, text, aType ) +SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType ) : + SCH_LABEL_BASE( pos, text, aType ) { m_layer = LAYER_HIERLABEL; - m_shape = PINSHEETLABEL_SHAPE::PS_INPUT; + m_shape = LABEL_FLAG_SHAPE::L_INPUT; m_isDangling = true; - SetMultilineAllowed( false ); -} - - -EDA_ITEM* SCH_HIERLABEL::Clone() const -{ - return new SCH_HIERLABEL( *this ); } void SCH_HIERLABEL::SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle ) { - m_spin_style = aSpinStyle; - - // Assume "Right" and Left" mean which side of the port symbol the text will be on - // If we are left of the symbol, we want to right justify to line up with the symbol - switch( aSpinStyle ) - { - default: - wxLogWarning( "SetLabelSpinStyle bad spin style" ); - break; - - case LABEL_SPIN_STYLE::LEFT: - // - m_spin_style = LABEL_SPIN_STYLE::LEFT; // Handle the error spin style by resetting - SetTextAngle( TEXT_ANGLE_HORIZ ); - SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - break; - - case LABEL_SPIN_STYLE::UP: - SetTextAngle( TEXT_ANGLE_VERT ); - SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - break; - - case LABEL_SPIN_STYLE::RIGHT: - SetTextAngle( TEXT_ANGLE_HORIZ ); - SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - break; - - case LABEL_SPIN_STYLE::BOTTOM: - SetTextAngle( TEXT_ANGLE_VERT ); - SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - break; - } -} - - -void SCH_HIERLABEL::Print( const RENDER_SETTINGS* aSettings, const wxPoint& offset ) -{ - wxCHECK_RET( Schematic(), "No parent SCHEMATIC set for SCH_LABEL!" ); - - static std::vector Poly; - - wxDC* DC = aSettings->GetPrintDC(); - SCH_CONNECTION* conn = Connection(); - bool isBus = conn && conn->IsBus(); - COLOR4D color = aSettings->GetLayerColor( isBus ? LAYER_BUS : m_layer ); - int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() ); - wxPoint textOffset = offset + GetSchematicTextOffset( aSettings ); - - EDA_TEXT::Print( aSettings, textOffset, color ); - - CreateGraphicShape( aSettings, Poly, GetTextPos() + offset ); - GRPoly( nullptr, DC, Poly.size(), &Poly[0], false, penWidth, color, color ); + SCH_TEXT::SetLabelSpinStyle( aSpinStyle ); + SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); } @@ -1633,7 +1768,7 @@ void SCH_HIERLABEL::CreateGraphicShape( const RENDER_SETTINGS* aSettings, void SCH_HIERLABEL::CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector& aPoints, const wxPoint& aPos, - PINSHEETLABEL_SHAPE aShape ) const + LABEL_FLAG_SHAPE aShape ) const { int* Template = TemplateShape[static_cast( aShape )][static_cast( m_spin_style )]; int halfSize = GetTextHeight() / 2; @@ -1656,7 +1791,7 @@ void SCH_HIERLABEL::CreateGraphicShape( const RENDER_SETTINGS* aSettings, } -const EDA_RECT SCH_HIERLABEL::GetBoundingBox() const +const EDA_RECT SCH_HIERLABEL::GetBodyBoundingBox() const { int penWidth = GetEffectiveTextPenWidth(); int margin = GetTextOffset(); diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index 8dde35ebdb..a4ff049aa9 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -90,16 +90,21 @@ private: }; /* - * Shape/Type of #SCH_HIERLABEL and #SCH_GLOBALLABEL. + * Shape/Type of #SCH_HIERLABEL, #SCH_GLOBALLABEL and #SCH_NETCLASS_FLAG. */ -enum class PINSHEETLABEL_SHAPE +enum LABEL_FLAG_SHAPE { - PS_INPUT, // use "PS_INPUT" instead of "INPUT" to avoid colliding - // with a Windows header on msys2 - PS_OUTPUT, - PS_BIDI, - PS_TRISTATE, - PS_UNSPECIFIED + L_INPUT, + L_OUTPUT, + L_BIDI, + L_TRISTATE, + L_UNSPECIFIED, + + F_FIRST, + F_DOT = F_FIRST, + F_ROUND, + F_DIAMOND, + F_RECTANGLE }; @@ -112,12 +117,6 @@ public: SCH_TEXT( const wxPoint& aPos = wxPoint( 0, 0 ), const wxString& aText = wxEmptyString, KICAD_T aType = SCH_TEXT_T ); - /** - * Clone \a aText into a new object. All members are copied as is except - * for the #m_isDangling member which is set to false. This prevents newly - * copied objects derived from #SCH_TEXT from having their connection state - * improperly set. - */ SCH_TEXT( const SCH_TEXT& aText ); ~SCH_TEXT() { } @@ -132,13 +131,6 @@ public: return wxT( "SCH_TEXT" ); } - /** - * Return the set of contextual text variable tokens for this text item. - * - * @param[out] aVars - */ - void GetContextualTextVars( wxArrayString* aVars ) const; - wxString GetShownText( int aDepth = 0 ) const override; /** @@ -158,9 +150,8 @@ public: virtual void SetLabelSpinStyle( LABEL_SPIN_STYLE aSpinStyle ); LABEL_SPIN_STYLE GetLabelSpinStyle() const { return m_spin_style; } - PINSHEETLABEL_SHAPE GetShape() const { return m_shape; } - - void SetShape( PINSHEETLABEL_SHAPE aShape ) { m_shape = aShape; } + virtual LABEL_FLAG_SHAPE GetShape() const { return L_UNSPECIFIED; } + virtual void SetShape( LABEL_FLAG_SHAPE aShape ) { } /** * This offset depends on the orientation, the type of text, and the area required to @@ -172,18 +163,6 @@ public: void Print( const RENDER_SETTINGS* aSettings, const wxPoint& offset ) override; - /** - * Calculate the graphic shape (a polygon) associated to the text. - * - * @param aPoints A buffer to fill with polygon corners coordinates - * @param Pos Position of the shape, for texts and labels: do nothing - */ - virtual void CreateGraphicShape( const RENDER_SETTINGS* aSettings, - std::vector& aPoints, const wxPoint& Pos ) const - { - aPoints.clear(); - } - void SwapData( SCH_ITEM* aItem ) override; const EDA_RECT GetBoundingBox() const override; @@ -192,12 +171,8 @@ public: int GetTextOffset( const RENDER_SETTINGS* aSettings = nullptr ) const; - int GetLabelBoxExpansion( const RENDER_SETTINGS* aSettings = nullptr ) const; - int GetPenWidth() const override; - // Geometric transforms (used in block operations): - void Move( const wxPoint& aMoveVector ) override { EDA_TEXT::Offset( aMoveVector ); @@ -222,16 +197,6 @@ public: virtual bool IsReplaceable() const override { return true; } - void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override; - - bool UpdateDanglingState( std::vector& aItemList, - const SCH_SHEET_PATH* aPath = nullptr ) override; - - bool IsDangling() const override { return m_isDangling; } - void SetIsDangling( bool aIsDangling ) { m_isDangling = aIsDangling; } - - std::vector GetConnectionPoints() const override; - void ViewGetLayers( int aLayers[], int& aCount ) const override; wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; @@ -246,7 +211,10 @@ public: void Plot( PLOTTER* aPlotter ) const override; - EDA_ITEM* Clone() const override; + EDA_ITEM* Clone() const override + { + return new SCH_TEXT( *this ); + } void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; @@ -257,14 +225,6 @@ public: static HTML_MESSAGE_BOX* ShowSyntaxHelp( wxWindow* aParentWindow ); protected: - PINSHEETLABEL_SHAPE m_shape; - - /// True if not connected to another object if the object derive from SCH_TEXT - /// supports connections. - bool m_isDangling; - - CONNECTION_TYPE m_connectionType; - /** * The orientation of text and any associated drawing elements of derived objects. * - 0 is the horizontal and left justified. @@ -279,7 +239,117 @@ protected: }; -class SCH_LABEL : public SCH_TEXT +class SCH_LABEL_BASE : public SCH_TEXT +{ +public: + SCH_LABEL_BASE( const wxPoint& aPos, const wxString& aText, KICAD_T aType ); + + SCH_LABEL_BASE( const SCH_LABEL_BASE& aLabel ); + + // Abstract class + virtual wxString GetClass() const override = 0; + + bool IsType( const KICAD_T aScanTypes[] ) const override; + + void SwapData( SCH_ITEM* aItem ) override; + + LABEL_FLAG_SHAPE GetShape() const override { return m_shape; } + void SetShape( LABEL_FLAG_SHAPE aShape ) override { m_shape = aShape; } + + static const wxString GetDefaultFieldName( const wxString& aName, bool aUseDefaultName ); + + virtual int GetMandatoryFieldCount() { return 0; } + + std::vector& GetFields() { return m_fields; } + const std::vector& GetFields() const { return m_fields; } + + /** + * Set multiple schematic fields. + * + * @param aFields are the fields to set in this symbol. + */ + void SetFields( const std::vector& aFields ) + { + m_fields = aFields; // vector copying, length is changed possibly + } + + void Move( const wxPoint& aMoveVector ) override + { + SCH_TEXT::Move( aMoveVector ); + + for( SCH_FIELD& field : m_fields ) + field.Offset( aMoveVector ); + } + + void Rotate( const wxPoint& aCenter ) override; + void Rotate90( bool aClockwise ) override; + + void AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) override; + + virtual bool ResolveTextVar( wxString* token, int aDepth ) const; + + wxString GetShownText( int aDepth = 0 ) const override; + + void RunOnChildren( const std::function& aFunction ) override; + + SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override; + + /** + * Calculate the graphic shape (a polygon) associated to the text. + * + * @param aPoints A buffer to fill with polygon corners coordinates + * @param Pos Position of the shape, for texts and labels: do nothing + */ + virtual void CreateGraphicShape( const RENDER_SETTINGS* aSettings, + std::vector& aPoints, const wxPoint& Pos ) const + { + aPoints.clear(); + } + + int GetLabelBoxExpansion( const RENDER_SETTINGS* aSettings = nullptr ) const; + + /** + * Return the bounding box of the label only, without taking in account its fields. + */ + virtual const EDA_RECT GetBodyBoundingBox() const; + + /** + * Return the bounding box of the label including its fields. + */ + const EDA_RECT GetBoundingBox() const override; + + bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; + bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; + + std::vector GetConnectionPoints() const override; + + void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override; + + bool UpdateDanglingState( std::vector& aItemList, + const SCH_SHEET_PATH* aPath = nullptr ) override; + + bool IsDangling() const override { return m_isDangling; } + void SetIsDangling( bool aIsDangling ) { m_isDangling = aIsDangling; } + + void ViewGetLayers( int aLayers[], int& aCount ) const override; + + void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; + + void Plot( PLOTTER* aPlotter ) const override; + + void Print( const RENDER_SETTINGS* aSettings, const wxPoint& offset ) override; + +protected: + std::vector m_fields; + + LABEL_FLAG_SHAPE m_shape; + + CONNECTION_TYPE m_connectionType; + bool m_isDangling; +}; + + +class SCH_LABEL : public SCH_LABEL_BASE { public: SCH_LABEL( const wxPoint& aPos = wxPoint( 0, 0 ), const wxString& aText = wxEmptyString ); @@ -298,9 +368,7 @@ public: return wxT( "SCH_LABEL" ); } - bool IsType( const KICAD_T aScanTypes[] ) const override; - - const EDA_RECT GetBoundingBox() const override; + const EDA_RECT GetBodyBoundingBox() const override; bool IsConnectable() const override { return true; } @@ -316,7 +384,10 @@ public: bool IsReplaceable() const override { return true; } - EDA_ITEM* Clone() const override; + EDA_ITEM* Clone() const override + { + return new SCH_LABEL( *this ); + } bool IsPointClickableAnchor( const wxPoint& aPos ) const override { @@ -331,7 +402,55 @@ private: }; -class SCH_GLOBALLABEL : public SCH_TEXT +class SCH_NETCLASS_FLAG : public SCH_LABEL_BASE +{ +public: + SCH_NETCLASS_FLAG( const wxPoint& aPos = wxPoint( 0, 0 ) ); + + SCH_NETCLASS_FLAG( const SCH_NETCLASS_FLAG& aClassLabel ); + + ~SCH_NETCLASS_FLAG() { } + + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_NETCLASS_FLAG_T == aItem->Type(); + } + + wxString GetClass() const override + { + return wxT( "SCH_NETCLASS_FLAG" ); + } + + EDA_ITEM* Clone() const override + { + return new SCH_NETCLASS_FLAG( *this ); + } + + int GetPinLength() const { return m_pinLength; } + void SetPinLength( int aLength ) { m_pinLength = aLength; } + + void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector& aPoints, + const wxPoint& aPos ) const override; + + void AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) override; + + wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + + bool IsConnectable() const override { return true; } + + bool CanConnect( const SCH_ITEM* aItem ) const override + { + return aItem->Type() == SCH_LINE_T && + ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS ); + } + +private: + int m_pinLength; + int m_symbolSize; +}; + + +class SCH_GLOBALLABEL : public SCH_LABEL_BASE { public: SCH_GLOBALLABEL( const wxPoint& aPos = wxPoint( 0, 0 ), const wxString& aText = wxEmptyString ); @@ -350,16 +469,13 @@ public: return wxT( "SCH_GLOBALLABEL" ); } - EDA_ITEM* Clone() const override; + EDA_ITEM* Clone() const override + { + return new SCH_GLOBALLABEL( *this ); + } - void SwapData( SCH_ITEM* aItem ) override; + int GetMandatoryFieldCount() override { return 1; } - SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override; - - void RunOnChildren( const std::function& aFunction ) override; - - void Rotate( const wxPoint& aCenter ) override; - void Rotate90( bool aClockwise ) override; void MirrorSpinStyle( bool aLeftRight ) override; void MirrorHorizontally( int aCenter ) override; @@ -369,32 +485,10 @@ public: wxPoint GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override; - /** - * Return the bounding box on the global label only, without taking in account - * the intersheet references. - */ - const EDA_RECT GetBoundingBoxBase() const; - - /** - * Return the bounding box on the global label only, including the intersheet references. - */ - const EDA_RECT GetBoundingBox() const override; - - /** - * Override basic hit test to allow testing separately for label and intersheet refs - * which can move independently - * @return True if hit in either label or associated intersheet ref - */ - bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; - bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings, std::vector& aPoints, const wxPoint& aPos ) const override; - void UpdateIntersheetRefProps(); - void AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) override; - - bool ResolveTextVar( wxString* token, int aDepth ) const; + bool ResolveTextVar( wxString* token, int aDepth ) const override; bool IsConnectable() const override { return true; } @@ -404,39 +498,26 @@ public: ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS ); } + void ViewGetLayers( int aLayers[], int& aCount ) const override; + wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; BITMAPS GetMenuImage() const override; - void Print( const RENDER_SETTINGS* aSettings, const wxPoint& offset ) override; - - void Plot( PLOTTER* aPlotter ) const override; - - SCH_FIELD* GetIntersheetRefs() { return &m_intersheetRefsField; } - void SetIntersheetRefs( const SCH_FIELD& aField ) { m_intersheetRefsField = aField; } - bool IsPointClickableAnchor( const wxPoint& aPos ) const override { return m_isDangling && GetPosition() == aPos; } - void Move( const wxPoint& aMoveVector ) override - { - SCH_TEXT::Move( aMoveVector ); - m_intersheetRefsField.Move( aMoveVector ); - } - private: bool doIsConnected( const wxPoint& aPosition ) const override { return EDA_TEXT::GetTextPos() == aPosition; } - - SCH_FIELD m_intersheetRefsField; }; -class SCH_HIERLABEL : public SCH_TEXT +class SCH_HIERLABEL : public SCH_LABEL_BASE { public: SCH_HIERLABEL( const wxPoint& aPos = wxPoint( 0, 0 ), const wxString& aText = wxEmptyString, @@ -446,8 +527,6 @@ public: ~SCH_HIERLABEL() { } - void Print( const RENDER_SETTINGS* aSettings, const wxPoint& offset ) override; - static inline bool ClassOf( const EDA_ITEM* aItem ) { return aItem && SCH_HIER_LABEL_T == aItem->Type(); @@ -465,9 +544,9 @@ public: void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector& aPoints, const wxPoint& aPos ) const override; void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector& aPoints, - const wxPoint& aPos, PINSHEETLABEL_SHAPE aShape ) const; + const wxPoint& aPos, LABEL_FLAG_SHAPE aShape ) const; - const EDA_RECT GetBoundingBox() const override; + const EDA_RECT GetBodyBoundingBox() const override; bool IsConnectable() const override { return true; } @@ -481,7 +560,10 @@ public: BITMAPS GetMenuImage() const override; - EDA_ITEM* Clone() const override; + EDA_ITEM* Clone() const override + { + return new SCH_HIERLABEL( *this ); + } bool IsPointClickableAnchor( const wxPoint& aPos ) const override { diff --git a/eeschema/sch_view.h b/eeschema/sch_view.h index e1dfa3379e..8e6bcf322d 100644 --- a/eeschema/sch_view.h +++ b/eeschema/sch_view.h @@ -47,6 +47,7 @@ static const int SCH_LAYER_ORDER[] = LAYER_GP_OVERLAY, LAYER_SELECT_OVERLAY, LAYER_ERC_ERR, LAYER_ERC_WARN, LAYER_DANGLING, LAYER_REFERENCEPART, LAYER_VALUEPART, LAYER_FIELDS, + LAYER_INTERSHEET_REFS, LAYER_NETCLASS_REFS, LAYER_BUS_JUNCTION, LAYER_JUNCTION, LAYER_NOCONNECT, LAYER_HIERLABEL, LAYER_WIRE, LAYER_BUS, diff --git a/eeschema/schematic.keywords b/eeschema/schematic.keywords index 072085038f..e4e43105d1 100644 --- a/eeschema/schematic.keywords +++ b/eeschema/schematic.keywords @@ -25,6 +25,8 @@ data date default diameter +diamond +dot edge_clock_high effects end @@ -63,6 +65,7 @@ members mid mirror name +netclass_flag no no_connect non_logic @@ -100,6 +103,7 @@ reference required rev right +round scale shape sheet diff --git a/eeschema/symbol_editor/symbol_editor_settings.cpp b/eeschema/symbol_editor/symbol_editor_settings.cpp index f75696b814..43937bc372 100644 --- a/eeschema/symbol_editor/symbol_editor_settings.cpp +++ b/eeschema/symbol_editor/symbol_editor_settings.cpp @@ -61,9 +61,11 @@ SYMBOL_EDITOR_SETTINGS::SYMBOL_EDITOR_SETTINGS() : m_params.emplace_back( new PARAM( "defaults.pin_num_size", &m_Defaults.pin_num_size, DEFAULT_PINNUM_SIZE ) ); - m_params.emplace_back( new PARAM( "repeat.label_delta", &m_Repeat.label_delta, 1 ) ); + m_params.emplace_back( new PARAM( "repeat.label_delta", + &m_Repeat.label_delta, 1 ) ); - m_params.emplace_back( new PARAM( "repeat.pin_step", &m_Repeat.pin_step, 100 ) ); + m_params.emplace_back( new PARAM( "repeat.pin_step", + &m_Repeat.pin_step, 100 ) ); m_params.emplace_back( new PARAM( "show_pin_electrical_type", &m_ShowPinElectricalType, true ) ); @@ -71,7 +73,7 @@ SYMBOL_EDITOR_SETTINGS::SYMBOL_EDITOR_SETTINGS() : m_params.emplace_back( new PARAM( "lib_table_width", &m_LibWidth, 250 ) ); - m_params.emplace_back( new PARAM( "edit_component_visible_columns", + m_params.emplace_back( new PARAM( "edit_symbol_visible_columns", &m_EditSymbolVisibleColumns, "0 1 2 3 4 5 6 7" ) ); m_params.emplace_back( new PARAM( "pin_table_visible_columns", @@ -101,21 +103,22 @@ bool SYMBOL_EDITOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) Set( gridSizePtr, 1 ); } - ret &= fromLegacy( aCfg, "DefaultWireWidth", "defaults.line_width" ); - ret &= fromLegacy( aCfg, "DefaultPinLength", "defaults.pin_length" ); - ret &= fromLegacy( aCfg, "LibeditPinNameSize", "defaults.pin_name_size" ); - ret &= fromLegacy( aCfg, "LibeditPinNumSize", "defaults.pin_num_size" ); + ret &= fromLegacy( aCfg, "DefaultWireWidth", "defaults.line_width" ); + ret &= fromLegacy( aCfg, "DefaultPinLength", "defaults.pin_length" ); + ret &= fromLegacy( aCfg, "LibeditPinNameSize", "defaults.pin_name_size" ); + ret &= fromLegacy( aCfg, "LibeditPinNumSize", "defaults.pin_num_size" ); - ret &= fromLegacy( aCfg, "LibeditRepeatLabelInc", "repeat.label_delta" ); - ret &= fromLegacy( aCfg, "LibeditPinRepeatStep", "repeat.pin_step" ); - ret &= fromLegacy( aCfg, "LibeditRepeatStepX", "repeat.x_step" ); - ret &= fromLegacy( aCfg, "LibeditRepeatStepY", "repeat.y_step" ); + ret &= fromLegacy( aCfg, "LibeditRepeatLabelInc", "repeat.label_delta" ); + ret &= fromLegacy( aCfg, "LibeditPinRepeatStep", "repeat.pin_step" ); + ret &= fromLegacy( aCfg, "LibeditRepeatStepX", "repeat.x_step" ); + ret &= fromLegacy( aCfg, "LibeditRepeatStepY", "repeat.y_step" ); ret &= fromLegacy( aCfg, "LibeditLibWidth", "lib_table_width" ); ret &= fromLegacy( aCfg, "LibeditShowPinElectricalType", "show_pin_electrical_type" ); - ret &= fromLegacyString( aCfg, "LibEditFieldsShownColumns", "edit_component_visible_columns" ); - ret &= fromLegacyString( aCfg, "PinTableShownColumns", "pin_table_visible_columns" ); + ret &= fromLegacyString( aCfg, "LibEditFieldsShownColumns", "edit_symbol_visible_columns" ); + + ret &= fromLegacyString( aCfg, "PinTableShownColumns", "pin_table_visible_columns" ); return ret; } diff --git a/eeschema/toolbars_sch_editor.cpp b/eeschema/toolbars_sch_editor.cpp index 4a2fdf87f6..257baa7bc0 100644 --- a/eeschema/toolbars_sch_editor.cpp +++ b/eeschema/toolbars_sch_editor.cpp @@ -152,6 +152,7 @@ void SCH_EDIT_FRAME::ReCreateVToolbar() m_drawToolBar->Add( EE_ACTIONS::placeNoConnect, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( EE_ACTIONS::placeJunction, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( EE_ACTIONS::placeLabel, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( EE_ACTIONS::placeClassLabel, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( EE_ACTIONS::placeGlobalLabel, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( EE_ACTIONS::placeHierLabel, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( EE_ACTIONS::drawSheet, ACTION_TOOLBAR::TOGGLE ); diff --git a/eeschema/tools/backannotate.cpp b/eeschema/tools/backannotate.cpp index 699a3e459b..800960b07f 100644 --- a/eeschema/tools/backannotate.cpp +++ b/eeschema/tools/backannotate.cpp @@ -403,6 +403,8 @@ void BACK_ANNOTATE::applyChangelist() } } } + + // JEY TODO: back-annotate netclass changes? } if( !m_dryRun ) diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index 33b9748d86..4052200db7 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -296,6 +296,11 @@ TOOL_ACTION EE_ACTIONS::placeLabel( "eeschema.InteractiveDrawing.placeLabel", _( "Add Label" ), _( "Add a net label" ), BITMAPS::add_label, AF_ACTIVATE ); +TOOL_ACTION EE_ACTIONS::placeClassLabel( "eeschema.InteractiveDrawing.placeClassLabel", + AS_GLOBAL, 0, "", + _( "Add Net Class Flag" ), _( "Add a net class flag" ), + BITMAPS::add_class_flag, AF_ACTIVATE ); + TOOL_ACTION EE_ACTIONS::placeHierLabel( "eeschema.InteractiveDrawing.placeHierarchicalLabel", AS_GLOBAL, 'H', LEGACY_HK_NAME( "Add Hierarchical Label" ), @@ -468,6 +473,11 @@ TOOL_ACTION EE_ACTIONS::toLabel( "eeschema.InteractiveEdit.toLabel", _( "Change to Label" ), _( "Change existing item to a label" ), BITMAPS::add_line_label, AF_NONE, (void*) SCH_LABEL_T ); +TOOL_ACTION EE_ACTIONS::toCLabel( "eeschema.InteractiveEdit.toCLabel", + AS_GLOBAL, 0, "", + _( "Change to Net Class Flag" ), _( "Change existing item to a net class flag" ), + BITMAPS::add_class_flag, AF_NONE, (void*) SCH_NETCLASS_FLAG_T ); + TOOL_ACTION EE_ACTIONS::toHLabel( "eeschema.InteractiveEdit.toHLabel", AS_GLOBAL, 0, "", _( "Change to Hierarchical Label" ), _( "Change existing item to a hierarchical label" ), diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index 5cb29d12fc..948adc012f 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -83,6 +83,7 @@ public: static TOOL_ACTION placeJunction; static TOOL_ACTION placeBusWireEntry; static TOOL_ACTION placeLabel; + static TOOL_ACTION placeClassLabel; static TOOL_ACTION placeGlobalLabel; static TOOL_ACTION placeHierLabel; static TOOL_ACTION drawSheet; @@ -127,6 +128,7 @@ public: static TOOL_ACTION showDeMorganAlternate; static TOOL_ACTION editSymbolUnit; static TOOL_ACTION toLabel; + static TOOL_ACTION toCLabel; static TOOL_ACTION toHLabel; static TOOL_ACTION toGLabel; static TOOL_ACTION toText; diff --git a/eeschema/tools/ee_grid_helper.cpp b/eeschema/tools/ee_grid_helper.cpp index b7a828d87e..e30e21a490 100644 --- a/eeschema/tools/ee_grid_helper.cpp +++ b/eeschema/tools/ee_grid_helper.cpp @@ -293,6 +293,7 @@ void EE_GRID_HELPER::computeAnchors( SCH_ITEM *aItem, const VECTOR2I &aRefPos, b case SCH_GLOBAL_LABEL_T: case SCH_HIER_LABEL_T: case SCH_LABEL_T: + case SCH_NETCLASS_FLAG_T: case SCH_BUS_WIRE_ENTRY_T: { std::vector pts = aItem->GetConnectionPoints(); diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 8431457acd..350717ef0f 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -151,9 +151,15 @@ bool EE_SELECTION_TOOL::Init() } static KICAD_T wireOrBusTypes[] = { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T, EOT }; - static KICAD_T connectedTypes[] = { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T, - SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, - SCH_SHEET_PIN_T, SCH_PIN_T, EOT }; + static KICAD_T connectedTypes[] = { SCH_ITEM_LOCATE_WIRE_T, + SCH_ITEM_LOCATE_BUS_T, + SCH_GLOBAL_LABEL_T, + SCH_HIER_LABEL_T, + SCH_LABEL_T, + SCH_NETCLASS_FLAG_T, + SCH_SHEET_PIN_T, + SCH_PIN_T, + EOT }; auto wireSelection = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_ITEM_LOCATE_WIRE_T ); auto busSelection = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_ITEM_LOCATE_BUS_T ); @@ -212,6 +218,7 @@ bool EE_SELECTION_TOOL::Init() menu.AddItem( EE_ACTIONS::selectConnection, wireOrBusSelection && EE_CONDITIONS::Idle, 250 ); menu.AddItem( EE_ACTIONS::placeJunction, wireOrBusSelection && EE_CONDITIONS::Idle, 250 ); menu.AddItem( EE_ACTIONS::placeLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 ); + menu.AddItem( EE_ACTIONS::placeClassLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 ); menu.AddItem( EE_ACTIONS::placeGlobalLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 ); menu.AddItem( EE_ACTIONS::placeHierLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 ); menu.AddItem( EE_ACTIONS::breakWire, wireSelection && EE_CONDITIONS::Idle, 250 ); @@ -284,31 +291,9 @@ int EE_SELECTION_TOOL::UpdateMenu( const TOOL_EVENT& aEvent ) } -const KICAD_T movableSchematicItems[] = -{ - SCH_MARKER_T, - SCH_JUNCTION_T, - SCH_NO_CONNECT_T, - SCH_BUS_BUS_ENTRY_T, - SCH_BUS_WIRE_ENTRY_T, - SCH_LINE_T, - SCH_BITMAP_T, - SCH_SHAPE_T, - SCH_TEXT_T, - SCH_LABEL_T, - SCH_GLOBAL_LABEL_T, - SCH_HIER_LABEL_T, - SCH_FIELD_T, - SCH_SYMBOL_T, - SCH_SHEET_PIN_T, - SCH_SHEET_T, - EOT -}; - - const KICAD_T movableSymbolItems[] = { - LIB_SHAPE_T, + LIB_SHAPE_T, LIB_TEXT_T, LIB_PIN_T, LIB_FIELD_T, @@ -554,7 +539,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) } else { - m_selection = RequestSelection( movableSchematicItems ); + m_selection = RequestSelection( EE_COLLECTOR::MovableItems ); } // Check if dragging has started within any of selected items bounding box @@ -1345,6 +1330,7 @@ static KICAD_T nodeTypes[] = SCH_HIER_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_SHEET_PIN_T, + SCH_NETCLASS_FLAG_T, SCH_JUNCTION_T, EOT }; @@ -1848,13 +1834,13 @@ void EE_SELECTION_TOOL::highlight( EDA_ITEM* aItem, int aMode, EE_SELECTION* aGr if( SCH_ITEM* sch_item = dynamic_cast( aItem ) ) { sch_item->RunOnChildren( - [&]( SCH_ITEM* aChild ) - { - if( aMode == SELECTED ) - aChild->SetSelected(); - else if( aMode == BRIGHTENED ) - aChild->SetBrightened(); - } ); + [&]( SCH_ITEM* aChild ) + { + if( aMode == SELECTED ) + aChild->SetSelected(); + else if( aMode == BRIGHTENED ) + aChild->SetBrightened(); + } ); } if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T ) diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 6802129a2d..25e4ac819b 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -46,7 +46,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -57,11 +58,13 @@ SCH_DRAWING_TOOLS::SCH_DRAWING_TOOLS() : EE_TOOL_BASE( "eeschema.InteractiveDrawing" ), - m_lastSheetPinType( PINSHEETLABEL_SHAPE::PS_INPUT ), - m_lastGlobalLabelShape( PINSHEETLABEL_SHAPE::PS_INPUT ), + m_lastSheetPinType( LABEL_FLAG_SHAPE::L_INPUT ), + m_lastGlobalLabelShape( LABEL_FLAG_SHAPE::L_INPUT ), + m_lastNetClassFlagShape( LABEL_FLAG_SHAPE::F_ROUND ), m_lastTextOrientation( LABEL_SPIN_STYLE::RIGHT ), m_lastTextBold( false ), m_lastTextItalic( false ), + m_lastNetClassFlagItalic( true ), m_lastFillStyle( FILL_T::NO_FILL ), m_inPlaceSymbol( false ), m_inDrawShape( false ), @@ -876,6 +879,11 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType textItem = new SCH_LABEL( (wxPoint) aPosition ); break; + case LAYER_NETCLASS_REFS: + textItem = new SCH_NETCLASS_FLAG( (wxPoint) aPosition ); + textItem->SetShape( m_lastNetClassFlagShape ); + break; + case LAYER_HIERLABEL: textItem = new SCH_HIERLABEL( (wxPoint) aPosition ); textItem->SetShape( m_lastGlobalLabelShape ); @@ -884,10 +892,7 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType case LAYER_GLOBLABEL: textItem = new SCH_GLOBALLABEL( (wxPoint) aPosition ); textItem->SetShape( m_lastGlobalLabelShape ); - - if( settings.m_IntersheetRefsShow ) - static_cast( textItem )->GetIntersheetRefs()->SetVisible( true ); - + static_cast( textItem )->GetFields()[0].SetVisible( true ); break; default: @@ -897,26 +902,60 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType textItem->SetParent( schematic ); textItem->SetBold( m_lastTextBold ); - textItem->SetItalic( m_lastTextItalic ); + + if( textItem->Type() == SCH_NETCLASS_FLAG_T ) + textItem->SetItalic( m_lastNetClassFlagItalic ); + else + textItem->SetItalic( m_lastTextItalic ); + textItem->SetLabelSpinStyle( m_lastTextOrientation ); textItem->SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) ); textItem->SetFlags( IS_NEW | IS_MOVING ); - DIALOG_TEXT_AND_LABEL_PROPERTIES dlg( m_frame, textItem ); + if( aType == LAYER_NOTES ) + { + DIALOG_TEXT_PROPERTIES dlg( m_frame, textItem ); - // Must be quasi modal for syntax help - if( dlg.ShowQuasiModal() != wxID_OK || NoPrintableChars( textItem->GetText() ) ) + // Must be quasi modal for syntax help + if( dlg.ShowQuasiModal() != wxID_OK ) + { + delete textItem; + return nullptr; + } + } + else + { + DIALOG_LABEL_PROPERTIES dlg( m_frame, static_cast( textItem ) ); + + // Must be quasi modal for syntax help + if( dlg.ShowQuasiModal() != wxID_OK ) + { + delete textItem; + return nullptr; + } + } + + wxString text = textItem->GetText(); + + if( textItem->Type() != SCH_NETCLASS_FLAG_T && NoPrintableChars( text ) ) { delete textItem; return nullptr; } m_lastTextBold = textItem->IsBold(); - m_lastTextItalic = textItem->IsItalic(); + + if( textItem->Type() == SCH_NETCLASS_FLAG_T ) + m_lastNetClassFlagItalic = textItem->IsItalic(); + else + m_lastTextItalic = textItem->IsItalic(); + m_lastTextOrientation = textItem->GetLabelSpinStyle(); if( textItem->Type() == SCH_GLOBAL_LABEL_T || textItem->Type() == SCH_HIER_LABEL_T ) m_lastGlobalLabelShape = textItem->GetShape(); + else if( textItem->Type() == SCH_NETCLASS_FLAG_T ) + m_lastNetClassFlagShape = textItem->GetShape(); return textItem; } @@ -990,6 +1029,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) bool isText = aEvent.IsAction( &EE_ACTIONS::placeSchematicText ); bool isGlobalLabel = aEvent.IsAction( &EE_ACTIONS::placeGlobalLabel ); bool isHierLabel = aEvent.IsAction( &EE_ACTIONS::placeHierLabel ); + bool isClassLabel = aEvent.IsAction( &EE_ACTIONS::placeClassLabel ); bool isNetLabel = aEvent.IsAction( &EE_ACTIONS::placeLabel ); bool isSheetPin = aEvent.IsAction( &EE_ACTIONS::importSheetPin ); int snapLayer = isText ? LAYER_GRAPHICS : LAYER_CONNECTABLE; @@ -1009,6 +1049,8 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::LABEL_GLOBAL ); else if( isNetLabel ) m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::LABEL_NET ); + else if( isClassLabel ) + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::LABEL_NET ); // JEY TODO: LABEL_CLASS cursor else if( isHierLabel ) m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::LABEL_HIER ); else @@ -1043,7 +1085,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) // Prime the pump if the tool isn't being re-activated if( aEvent.HasPosition() || ( !aEvent.IsReactivate() - && ( isText || isGlobalLabel || isHierLabel || isNetLabel ) ) ) + && ( isText || isGlobalLabel || isHierLabel || isClassLabel || isNetLabel ) ) ) { m_toolMgr->RunAction( ACTIONS::cursorClick ); } @@ -1124,6 +1166,10 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) { item = createNewText( cursorPos, LAYER_LOCLABEL ); } + else if( isClassLabel ) + { + item = createNewText( cursorPos, LAYER_NETCLASS_REFS ); + } else if( isSheetPin ) { EDA_ITEM* i; @@ -1601,6 +1647,7 @@ void SCH_DRAWING_TOOLS::setTransitions() Go( &SCH_DRAWING_TOOLS::SingleClickPlace, EE_ACTIONS::placeJunction.MakeEvent() ); Go( &SCH_DRAWING_TOOLS::SingleClickPlace, EE_ACTIONS::placeBusWireEntry.MakeEvent() ); Go( &SCH_DRAWING_TOOLS::TwoClickPlace, EE_ACTIONS::placeLabel.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::TwoClickPlace, EE_ACTIONS::placeClassLabel.MakeEvent() ); Go( &SCH_DRAWING_TOOLS::TwoClickPlace, EE_ACTIONS::placeHierLabel.MakeEvent() ); Go( &SCH_DRAWING_TOOLS::TwoClickPlace, EE_ACTIONS::placeGlobalLabel.MakeEvent() ); Go( &SCH_DRAWING_TOOLS::DrawSheet, EE_ACTIONS::drawSheet.MakeEvent() ); diff --git a/eeschema/tools/sch_drawing_tools.h b/eeschema/tools/sch_drawing_tools.h index 4a959c6d14..f947446dfa 100644 --- a/eeschema/tools/sch_drawing_tools.h +++ b/eeschema/tools/sch_drawing_tools.h @@ -84,11 +84,13 @@ private: std::vector m_symbolHistoryList; std::vector m_powerHistoryList; - PINSHEETLABEL_SHAPE m_lastSheetPinType; - PINSHEETLABEL_SHAPE m_lastGlobalLabelShape; + LABEL_FLAG_SHAPE m_lastSheetPinType; + LABEL_FLAG_SHAPE m_lastGlobalLabelShape; + LABEL_FLAG_SHAPE m_lastNetClassFlagShape; LABEL_SPIN_STYLE m_lastTextOrientation; bool m_lastTextBold; bool m_lastTextItalic; + bool m_lastNetClassFlagItalic; FILL_T m_lastFillStyle; ///< Re-entrancy guards diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 1f3fb454ad..93b6d568bd 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -61,7 +61,8 @@ #include #include #include -#include +#include +#include #include // for KiROUND #include #include @@ -177,6 +178,7 @@ bool SCH_EDIT_TOOL::Init() [this]( const SELECTION& aSel ) { return ( m_frame->IsCurrentTool( EE_ACTIONS::placeLabel ) + || m_frame->IsCurrentTool( EE_ACTIONS::placeClassLabel ) || m_frame->IsCurrentTool( EE_ACTIONS::placeGlobalLabel ) || m_frame->IsCurrentTool( EE_ACTIONS::placeHierLabel ) || m_frame->IsCurrentTool( EE_ACTIONS::placeSchematicText ) ); @@ -251,6 +253,7 @@ bool SCH_EDIT_TOOL::Init() case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIER_LABEL_T: + case SCH_NETCLASS_FLAG_T: case SCH_FIELD_T: case SCH_BITMAP_T: return aSel.GetSize() == 1; @@ -279,23 +282,32 @@ bool SCH_EDIT_TOOL::Init() return false; }; - static KICAD_T allLabelTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT }; + static KICAD_T allLabelTypes[] = { SCH_LABEL_T, + SCH_NETCLASS_FLAG_T, + SCH_GLOBAL_LABEL_T, + SCH_HIER_LABEL_T, + SCH_TEXT_T, + EOT }; - static KICAD_T toLabelTypes[] = { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT }; + static KICAD_T toLabelTypes[] = { SCH_NETCLASS_FLAG_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT }; auto toLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( toLabelTypes ) ) - || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allLabelTypes ) ); + || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allLabelTypes ) ); - static KICAD_T toHLableTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_TEXT_T, EOT }; - auto toHLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( toHLableTypes ) ) - || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allLabelTypes ) ); + static KICAD_T toCLabelTypes[] = { SCH_LABEL_T, SCH_HIER_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_TEXT_T, EOT }; + auto toCLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( toCLabelTypes ) ) + || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allLabelTypes ) ); - static KICAD_T toGLableTypes[] = { SCH_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT }; - auto toGLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( toGLableTypes ) ) - || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allLabelTypes ) ); + static KICAD_T toHLabelTypes[] = { SCH_LABEL_T, SCH_NETCLASS_FLAG_T, SCH_GLOBAL_LABEL_T, SCH_TEXT_T, EOT }; + auto toHLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( toHLabelTypes ) ) + || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allLabelTypes ) ); - static KICAD_T toTextTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, EOT }; - auto toTextlCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( toTextTypes ) ) - || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allLabelTypes ) ); + static KICAD_T toGLabelTypes[] = { SCH_LABEL_T, SCH_NETCLASS_FLAG_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT }; + auto toGLabelCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( toGLabelTypes ) ) + || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allLabelTypes ) ); + + static KICAD_T toTextTypes[] = { SCH_LABEL_T, SCH_NETCLASS_FLAG_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, EOT }; + auto toTextCondition = ( E_C::Count( 1 ) && E_C::OnlyTypes( toTextTypes ) ) + || ( E_C::MoreThan( 1 ) && E_C::OnlyTypes( allLabelTypes ) ); static KICAD_T entryTypes[] = { SCH_BUS_WIRE_ENTRY_T, SCH_BUS_BUS_ENTRY_T, EOT }; auto entryCondition = E_C::MoreThan( 0 ) && E_C::OnlyTypes( entryTypes ); @@ -392,9 +404,10 @@ bool SCH_EDIT_TOOL::Init() selToolMenu.AddItem( EE_ACTIONS::updateSymbol, E_C::SingleSymbolOrPower, 200 ); selToolMenu.AddItem( EE_ACTIONS::toLabel, toLabelCondition, 200 ); + selToolMenu.AddItem( EE_ACTIONS::toCLabel, toCLabelCondition, 200 ); selToolMenu.AddItem( EE_ACTIONS::toHLabel, toHLabelCondition, 200 ); selToolMenu.AddItem( EE_ACTIONS::toGLabel, toGLabelCondition, 200 ); - selToolMenu.AddItem( EE_ACTIONS::toText, toTextlCondition, 200 ); + selToolMenu.AddItem( EE_ACTIONS::toText, toTextCondition, 200 ); selToolMenu.AddItem( EE_ACTIONS::cleanupSheetPins, sheetHasUndefinedPins, 250 ); selToolMenu.AddSeparator( 300 ); @@ -419,6 +432,7 @@ const KICAD_T rotatableItems[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, + SCH_NETCLASS_FLAG_T, SCH_FIELD_T, SCH_SYMBOL_T, SCH_SHEET_PIN_T, @@ -492,6 +506,7 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIER_LABEL_T: + case SCH_NETCLASS_FLAG_T: { SCH_TEXT* textItem = static_cast( head ); textItem->Rotate90( clockwise ); @@ -708,6 +723,7 @@ int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent ) case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIER_LABEL_T: + case SCH_NETCLASS_FLAG_T: { SCH_TEXT* textItem = static_cast( item ); textItem->MirrorSpinStyle( !vertical ); @@ -935,6 +951,7 @@ static KICAD_T deletableItems[] = SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, + SCH_NETCLASS_FLAG_T, SCH_NO_CONNECT_T, SCH_SHEET_T, SCH_SHEET_PIN_T, @@ -1333,19 +1350,6 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) break; } - auto doTextAndLabelProps = - [&]( SCH_TEXT* aText ) - { - DIALOG_TEXT_AND_LABEL_PROPERTIES dlg( m_frame, aText ); - - // Must be quasi modal for syntax help - if( dlg.ShowQuasiModal() == wxID_OK ) - { - m_toolMgr->PostEvent( EVENTS::SelectedItemsModified ); - m_frame->OnModify(); - } - }; - switch( item->Type() ) { case SCH_SYMBOL_T: @@ -1453,21 +1457,39 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) break; case SCH_TEXT_T: + { + DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast( item ) ); + + // Must be quasi modal for syntax help + if( dlg.ShowQuasiModal() == wxID_OK ) + { + m_toolMgr->PostEvent( EVENTS::SelectedItemsModified ); + m_frame->OnModify(); + } + } + break; + case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIER_LABEL_T: - doTextAndLabelProps( static_cast( item ) ); + case SCH_NETCLASS_FLAG_T: + { + DIALOG_LABEL_PROPERTIES dlg( m_frame, static_cast( item ) ); + + // Must be quasi modal for syntax help + if( dlg.ShowQuasiModal() == wxID_OK ) + { + m_toolMgr->PostEvent( EVENTS::SelectedItemsModified ); + m_frame->OnModify(); + } + } break; case SCH_FIELD_T: { SCH_FIELD* field = static_cast( item ); - EDA_ITEM* parent = field->GetParent(); - if( parent->Type() == SCH_GLOBAL_LABEL_T ) - doTextAndLabelProps( static_cast( parent ) ); - else - editFieldText( field ); + editFieldText( field ); if( !field->IsVisible() ) clearSelection = true; @@ -1575,7 +1597,12 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent ) { KICAD_T convertTo = aEvent.Parameter(); - KICAD_T allTextTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT }; + KICAD_T allTextTypes[] = { SCH_LABEL_T, + SCH_GLOBAL_LABEL_T, + SCH_HIER_LABEL_T, + SCH_TEXT_T, + SCH_NETCLASS_FLAG_T, + EOT }; EE_SELECTION selection = m_selectionTool->RequestSelection( allTextTypes ); for( unsigned int i = 0; i < selection.GetSize(); ++i ) @@ -1604,16 +1631,19 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent ) if( convertTo != SCH_TEXT_T ) txt = EscapeString( txt, CTX_NETNAME ); + std::vector fields; + + if( text->Type() != SCH_TEXT_T ) + fields = static_cast( text )->GetFields(); + switch( convertTo ) { - case SCH_LABEL_T: newtext = new SCH_LABEL( position, txt ); break; - case SCH_GLOBAL_LABEL_T: newtext = new SCH_GLOBALLABEL( position, txt ); break; - case SCH_HIER_LABEL_T: newtext = new SCH_HIERLABEL( position, txt ); break; - case SCH_TEXT_T: newtext = new SCH_TEXT( position, txt ); break; - - default: - wxFAIL_MSG( wxString::Format( "Invalid text type: %d.", convertTo ) ); - return 0; + case SCH_LABEL_T: newtext = new SCH_LABEL( position, txt ); break; + case SCH_GLOBAL_LABEL_T: newtext = new SCH_GLOBALLABEL( position, txt ); break; + case SCH_HIER_LABEL_T: newtext = new SCH_HIERLABEL( position, txt ); break; + case SCH_TEXT_T: newtext = new SCH_TEXT( position, txt ); break; + case SCH_NETCLASS_FLAG_T: newtext = new SCH_NETCLASS_FLAG( position ); break; + default: UNIMPLEMENTED_FOR( wxString::Format( "%d.", convertTo ) ); break; } // Copy the old text item settings to the new one. Justifications are not copied @@ -1627,7 +1657,6 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent ) newtext->SetTextThickness( text->GetTextThickness() ); newtext->SetItalic( text->IsItalic() ); newtext->SetBold( text->IsBold() ); - newtext->SetIsDangling( text->IsDangling() ); if( selected ) m_toolMgr->RunAction( EE_ACTIONS::removeItemFromSel, true, text ); @@ -1639,9 +1668,6 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent ) m_frame->RemoveFromScreen( text, m_frame->GetScreen() ); m_frame->AddToScreen( newtext, m_frame->GetScreen() ); - - if( convertTo == SCH_GLOBAL_LABEL_T ) - static_cast( newtext )->UpdateIntersheetRefProps(); } if( selected ) @@ -1654,10 +1680,7 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent ) if( convertTo == SCH_TEXT_T ) { if( newtext->IsDangling() ) - { - newtext->SetIsDangling( false ); getView()->Update( newtext, KIGFX::REPAINT ); - } } else { diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index ae9091d2d7..b045bd50de 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -224,6 +224,7 @@ bool SCH_LINE_WIRE_BUS_TOOL::Init() ctxMenu.AddSeparator( 100 ); ctxMenu.AddItem( EE_ACTIONS::placeJunction, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); ctxMenu.AddItem( EE_ACTIONS::placeLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); + ctxMenu.AddItem( EE_ACTIONS::placeClassLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); ctxMenu.AddItem( EE_ACTIONS::placeGlobalLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); ctxMenu.AddItem( EE_ACTIONS::placeHierLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); ctxMenu.AddItem( EE_ACTIONS::breakWire, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index bc994e1cee..0270991199 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -583,7 +583,7 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, const wxPoin // end. for( SCH_ITEM* item : itemsOverlapping ) { - if( item->Type() == SCH_LABEL_T ) + if( item->Type() == SCH_LABEL_T || item->Type() == SCH_NETCLASS_FLAG_T ) { SCH_TEXT* label = static_cast( item ); @@ -647,6 +647,7 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, const wxPoin case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIER_LABEL_T: + case SCH_NETCLASS_FLAG_T: // Performance optimization: if( test->HasFlag( TEMP_SELECTED ) ) break; @@ -773,6 +774,7 @@ void SCH_MOVE_TOOL::moveItem( EDA_ITEM* aItem, const VECTOR2I& aDelta ) break; } case SCH_LABEL_T: + case SCH_NETCLASS_FLAG_T: { SCH_TEXT* label = static_cast( aItem ); diff --git a/include/bitmaps/bitmap_info.h b/include/bitmaps/bitmap_info.h index 70d731efa4..caa093b45f 100644 --- a/include/bitmaps/bitmap_info.h +++ b/include/bitmaps/bitmap_info.h @@ -49,6 +49,10 @@ const std::vector g_BitmapInfo = { { BITMAPS::icon_pagelayout_editor_16, wxT( "icon_pagelayout_editor_16_16.png" ), 16, wxT( "light" ) }, { BITMAPS::icon_pcbcalculator_16, wxT( "icon_pcbcalculator_16_16.png" ), 16, wxT( "light" ) }, { BITMAPS::icon_pcbnew_16, wxT( "icon_pcbnew_16_16.png" ), 16, wxT( "light" ) }, + { BITMAPS::label_align_left, wxT( "label_align_left_16.png" ), 16, wxT( "light" ) }, + { BITMAPS::label_align_right, wxT( "label_align_right_16.png" ), 16, wxT( "light" ) }, + { BITMAPS::label_align_top, wxT( "label_align_top_16.png" ), 16, wxT( "light" ) }, + { BITMAPS::label_align_bottom, wxT( "label_align_bottom_16.png" ), 16, wxT( "light" ) }, { BITMAPS::list_nets_16, wxT( "list_nets_16_16.png" ), 16, wxT( "light" ) }, { BITMAPS::options_generic_16, wxT( "options_generic_16_16.png" ), 16, wxT( "light" ) }, { BITMAPS::pinorient_right, wxT( "pinorient_right_16.png" ), 16, wxT( "light" ) }, @@ -85,6 +89,18 @@ const std::vector g_BitmapInfo = { { BITMAPS::small_trash, wxT( "small_trash_16.png" ), 16, wxT( "light" ) }, { BITMAPS::small_up, wxT( "small_up_16.png" ), 16, wxT( "light" ) }, { BITMAPS::small_warning, wxT( "small_warning_16.png" ), 16, wxT( "light" ) }, + { BITMAPS::text_horizontal, wxT( "text_horizontal_16.png" ), 16, wxT( "light" ) }, + { BITMAPS::text_vertical, wxT( "text_vertical_16.png" ), 16, wxT( "light" ) }, + { BITMAPS::text_align_left, wxT( "text_align_left_16.png" ), 16, wxT( "light" ) }, + { BITMAPS::text_align_center, wxT( "text_align_center_16.png" ), 16, wxT( "light" ) }, + { BITMAPS::text_align_right, wxT( "text_align_right_16.png" ), 16, wxT( "light" ) }, + { BITMAPS::text_align_bottom, wxT( "text_align_bottom_16.png" ), 16, wxT( "light" ) }, + { BITMAPS::text_align_top, wxT( "text_align_top_16.png" ), 16, wxT( "light" ) }, + { BITMAPS::text_valign_top, wxT( "text_valign_top_16.png" ), 16, wxT( "light" ) }, + { BITMAPS::text_valign_center, wxT( "text_valign_center_16.png" ), 16, wxT( "light" ) }, + { BITMAPS::text_valign_bottom, wxT( "text_valign_bottom_16.png" ), 16, wxT( "light" ) }, + { BITMAPS::text_bold, wxT( "text_bold_16.png" ), 16, wxT( "light" ) }, + { BITMAPS::text_italic, wxT( "text_italic_16.png" ), 16, wxT( "light" ) }, { BITMAPS::tree_nosel, wxT( "tree_nosel_16.png" ), 16, wxT( "light" ) }, { BITMAPS::tree_sel, wxT( "tree_sel_16.png" ), 16, wxT( "light" ) }, { BITMAPS::visibility, wxT( "visibility_16.png" ), 16, wxT( "light" ) }, @@ -147,6 +163,7 @@ const std::vector g_BitmapInfo = { { BITMAPS::add_bus2bus, wxT( "add_bus2bus_24.png" ), 24, wxT( "light" ) }, { BITMAPS::add_bus, wxT( "add_bus_24.png" ), 24, wxT( "light" ) }, { BITMAPS::add_center_dimension, wxT( "add_center_dimension_24.png" ), 24, wxT( "light" ) }, + { BITMAPS::add_class_flag, wxT( "add_class_flag_24.png" ), 24, wxT( "light" ) }, { BITMAPS::add_circle, wxT( "add_circle_24.png" ), 24, wxT( "light" ) }, { BITMAPS::add_component, wxT( "add_component_24.png" ), 24, wxT( "light" ) }, { BITMAPS::add_corner, wxT( "add_corner_24.png" ), 24, wxT( "light" ) }, @@ -515,6 +532,7 @@ const std::vector g_BitmapInfo = { { BITMAPS::add_bus2bus, wxT( "add_bus2bus_dark_24.png" ), 24, wxT( "dark" ) }, { BITMAPS::add_bus, wxT( "add_bus_dark_24.png" ), 24, wxT( "dark" ) }, { BITMAPS::add_center_dimension, wxT( "add_center_dimension_dark_24.png" ), 24, wxT( "dark" ) }, + { BITMAPS::add_class_flag, wxT( "add_class_flag_dark_24.png" ), 24, wxT( "dark" ) }, { BITMAPS::add_circle, wxT( "add_circle_dark_24.png" ), 24, wxT( "dark" ) }, { BITMAPS::add_component, wxT( "add_component_dark_24.png" ), 24, wxT( "dark" ) }, { BITMAPS::add_corner, wxT( "add_corner_dark_24.png" ), 24, wxT( "dark" ) }, diff --git a/include/bitmaps/bitmaps_list.h b/include/bitmaps/bitmaps_list.h index 8718012f10..b34aee22e9 100644 --- a/include/bitmaps/bitmaps_list.h +++ b/include/bitmaps/bitmaps_list.h @@ -45,6 +45,7 @@ enum class BITMAPS : unsigned int add_bus, add_bus2bus, add_center_dimension, + add_class_flag, add_circle, add_component, add_corner, @@ -284,6 +285,10 @@ enum class BITMAPS : unsigned int insert_module_board, invisible_text, kicad_icon_small, + label_align_left, + label_align_right, + label_align_top, + label_align_bottom, language, layers_manager, leave_sheet, @@ -525,6 +530,18 @@ enum class BITMAPS : unsigned int swap_layer, switch_corner_rounding_shape, text, + text_align_left, + text_align_center, + text_align_right, + text_align_top, + text_align_bottom, + text_valign_top, + text_valign_center, + text_valign_bottom, + text_horizontal, + text_vertical, + text_bold, + text_italic, text_sketch, thermal_spokes, three_d, diff --git a/include/core/typeinfo.h b/include/core/typeinfo.h index 8e6fbe0ad0..4b36c1d59e 100644 --- a/include/core/typeinfo.h +++ b/include/core/typeinfo.h @@ -133,6 +133,7 @@ enum KICAD_T SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, + SCH_NETCLASS_FLAG_T, SCH_FIELD_T, SCH_SYMBOL_T, SCH_SHEET_PIN_T, @@ -152,7 +153,8 @@ enum KICAD_T SCH_ITEM_LOCATE_BUS_T, SCH_ITEM_LOCATE_GRAPHIC_LINE_T, - // Same for picking labels attached to wires and/or buses + // Same for picking labels, or labels attached to wires and/or buses + SCH_LABEL_LOCATE_ANY_T, SCH_LABEL_LOCATE_WIRE_T, SCH_LABEL_LOCATE_BUS_T, diff --git a/include/layer_ids.h b/include/layer_ids.h index b51da59aa5..f20066339c 100644 --- a/include/layer_ids.h +++ b/include/layer_ids.h @@ -329,6 +329,8 @@ enum SCH_LAYER_ID: int LAYER_REFERENCEPART, LAYER_VALUEPART, LAYER_FIELDS, + LAYER_INTERSHEET_REFS, + LAYER_NETCLASS_REFS, LAYER_DEVICE, LAYER_NOTES, LAYER_NOTES_BACKGROUND, diff --git a/include/widgets/bitmap_button.h b/include/widgets/bitmap_button.h index 95bb665608..85a6d39349 100644 --- a/include/widgets/bitmap_button.h +++ b/include/widgets/bitmap_button.h @@ -43,6 +43,11 @@ public: const wxSize& aSize = wxDefaultSize, int aStyles = wxBORDER_NONE | wxTAB_TRAVERSAL ); + // For use with wxFormBuilder on a sub-classed wxBitmapButton + BITMAP_BUTTON( wxWindow* aParent, wxWindowID aId, const wxBitmap& aDummyBitmap, + const wxPoint& aPos = wxDefaultPosition, const wxSize& aSize = wxDefaultSize, + int aStyles = wxBORDER_NONE | wxTAB_TRAVERSAL ); + ~BITMAP_BUTTON(); /** @@ -68,18 +73,28 @@ public: /** * Enable the button. - * - * @param aEnable is true to enable, false to disable. */ bool Enable( bool aEnable = true ) override; + /** + * Setup the control as a two-state button (checked or unchecked). + */ + void SetIsCheckButton(); + /** * Check the control. This is the equivalent to toggling a toolbar button. - * - * @param aCheck is true to check, false to uncheck. */ void Check( bool aCheck = true ); + bool IsChecked() const; + + /** + * Render button as a toolbar separator. + * + * Also disables the button. Bitmap, if set, is ignored. + */ + void SetIsSeparator(); + /** * Accept mouse-up as click even if mouse-down happened outside of the control * @@ -88,6 +103,8 @@ public: void AcceptDragInAsClick( bool aAcceptDragIn = true ); protected: + void setupEvents(); + void OnMouseLeave( wxEvent& aEvent ); void OnMouseEnter( wxEvent& aEvent ); void OnKillFocus( wxEvent& aEvent ); @@ -106,25 +123,17 @@ protected: m_buttonState &= ~aFlag; } - bool hasFlag( int aFlag ) + bool hasFlag( int aFlag ) const { return m_buttonState & aFlag; } private: - ///< Bitmap shown when button is enabled wxBitmap m_normalBitmap; - - ///< Bitmap shown when button is disabled wxBitmap m_disabledBitmap; - ///< Current state of the button int m_buttonState; - - ///< Padding on each side of the bitmap int m_padding; - - ///< Size without the padding wxSize m_unadjustedMinSize; ///< Accept mouse-up as click even if mouse-down happened outside of the control