App-Music-ChordPro

 view release on metacpan or  search on metacpan

lib/ChordPro/Wx/Utils.pm  view on Meta::CPAN

use ChordPro::Files;

################ Constants ################

# Constants not (yet) in this version of Wx, and constants specific to us.

my %const =
  ( wxID_FULLSCREEN	=> Wx::NewId(),	# for menu
    wxICON_NONE         => 0x00040000,	# unused for now

    $Wx::VERSION < 3.006 ?
    ( wxSTC_MARGIN_COLOUR		=> 6,
    ) : (),

    $Wx::VERSION < 3.004 ?
    ( wxEVT_COMMAND_FILEPICKER_CHANGED	=> 0x000027b8,
      wxEVT_COMMAND_DIRPICKER_CHANGED	=> 0x000027b9,
    ) : (),

    $Wx::VERSION < 3.003 ?
    ( wxELLIPSIZE_FLAGS_DEFAULT		=> 3,
      wxELLIPSIZE_NONE			=> 0,
      wxELLIPSIZE_START			=> 1,
      wxELLIPSIZE_MIDDLE		=> 2,
      wxELLIPSIZE_END			=> 3,
    ) : (),

    $Wx::VERSION < 3.000 ?
    ( wxEXEC_HIDE_CONSOLE		=> 0x00000020,
      # wxID_EXECUTE
      # wxDIRP_SMALL
      # wxFLP_SMALL
      # wxPB_SMALL
      # wxRESERVE_SPACE_EVEN_IF_HIDDEN
    ) : (),

  );

no strict 'refs';

while ( my ( $sub, $value ) = each %const ) {
    *$sub = sub () { $value };
    push( @EXPORT, $sub );
}

use strict 'refs';

{ no feature 'signatures';
  sub Wx::Event::EVT_STC_CLIPBOARD_PASTE($$$) {
    $_[0]->Connect( $_[1], -1, Wx::wxEVT_STC_AUTOCOMP_CHAR_DELETED()+3, $_[2] );
  }
}

################ ################

# Create / update menu bar.
#
# setup_menubar is called by main ctor, update_menubar by the refresh
# methods of main and panels.
# This is intended to be called by a panel, but the actual menu bar is
# attached to the top level frame. The callbacks are routed to the
# methods in the panel, if possible.

use constant
  { M_ALL	=> 0xff,
    M_MAIN	=> 0x01,
    M_EDITOR	=> 0x02,
    M_SONGBOOK	=> 0x04,
  };

push( @EXPORT, qw( M_MAIN M_EDITOR M_SONGBOOK ) );

my @swingers;

sub update_menubar( $self, $sel ) {
    die unless @swingers;

    for ( @swingers ) {
	my ( $mi, $mask ) = @$_;
	$mi->Enable( $mask & $sel );
    }
}

sub setup_menubar( $self ) {

    state $expert   = $ChordPro::Wx::Config::state{preferences}{expert};
    state $advanced = $ChordPro::Wx::Config::state{preferences}{advanced};

    state $ctl =
      [ [ wxID_FILE,
	  [ [ wxID_HOME, M_EDITOR|M_SONGBOOK, "Start Screen",
	      "Return to the Start Screen.", "OnStart" ],
	    [],
	    [ wxID_NEW, M_ALL, "",
	      "Create another ChordPro document", "OnNew" ],
	    [ wxID_OPEN, M_ALL, "",
	      "Open an existing ChordPro document", "OnOpen" ],
	    [],
	    [ wxID_SAVE, M_EDITOR, "",
	      "Save the current ChordPro file", "OnSave" ],
	    [ wxID_SAVEAS, M_EDITOR, "Save &As...\tShift-Ctrl-S",
	      "Save under a different name", "OnSaveAs" ],
	    [],
	    [ wxID_ANY, M_EDITOR|M_SONGBOOK, "Export to PDF...",
	      "Save the preview to a PDF", "OnPreviewSave" ],
	    [],
	    [ wxID_EXIT, M_ALL, "",
	      "Close Window and Exit", "OnClose" ],
	  ]
	],
	[ wxID_EDIT,
	  [ [ wxID_UNDO,   M_EDITOR, "",
	      "Undo edits", "OnUndo" ],
	    [ wxID_REDO,   M_EDITOR, "",
	      "Redo edits", "OnRedo" ],
	    [],
	    [ wxID_CUT,    M_EDITOR|M_SONGBOOK, "", "OnCut" ],
	    [ wxID_COPY,   M_EDITOR|M_SONGBOOK, "", "OnCopy" ],
	    [ wxID_PASTE,  M_EDITOR|M_SONGBOOK, "", "OnPaste" ],
	    [ wxID_DELETE, M_EDITOR|M_SONGBOOK, "", "OnDelete" ],
	    [],



( run in 0.892 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )