use crate::*;
use crate::{
cmd::append_opts,
error::{
NotList,
TkButtonNoError,
TkEventTypeError,
TkNotifyModeParseError,
TkPlaceOnParseError,
TkValidationSetParseError,
TkValidationOpParseError,
TkValidatingActionError,
},
opt::{
OptPair,
TkEventOpt,
},
};
use num_enum::{IntoPrimitive, TryFromPrimitive};
use tcl::Obj;
use tuplex::*;
pub struct TkEvent( String );
pub struct TkEventSeq( String );
pub struct TkModifier( String );
pub struct TkEventModifier( String );
pub fn control () -> TkModifier { TkModifier( "<Control" .to_owned() )}
pub fn alt () -> TkModifier { TkModifier( "<Alt" .to_owned() )}
pub fn shift () -> TkModifier { TkModifier( "<Shift" .to_owned() )}
pub fn lock () -> TkModifier { TkModifier( "<Lock" .to_owned() )}
pub fn extended () -> TkModifier { TkModifier( "<Extended" .to_owned() )}
pub fn button_1 () -> TkModifier { TkModifier( "<Button1" .to_owned() )}
pub fn button_2 () -> TkModifier { TkModifier( "<Button2" .to_owned() )}
pub fn button_3 () -> TkModifier { TkModifier( "<Button3" .to_owned() )}
pub fn button_4 () -> TkModifier { TkModifier( "<Button4" .to_owned() )}
pub fn button_5 () -> TkModifier { TkModifier( "<Button5" .to_owned() )}
pub fn mod_1 () -> TkModifier { TkModifier( "<Mod1" .to_owned() )}
pub fn mod_2 () -> TkModifier { TkModifier( "<Mod2" .to_owned() )}
pub fn mod_3 () -> TkModifier { TkModifier( "<Mod3" .to_owned() )}
pub fn mod_4 () -> TkModifier { TkModifier( "<Mod4" .to_owned() )}
pub fn mod_5 () -> TkModifier { TkModifier( "<Mod5" .to_owned() )}
pub fn command () -> TkModifier { TkModifier( "<Command" .to_owned() )}
pub fn option () -> TkModifier { TkModifier( "<option" .to_owned() )}
pub fn meta () -> TkModifier { TkModifier( "<Meta" .to_owned() )}
pub fn double () -> TkModifier { TkModifier( "<Double" .to_owned() )}
pub fn triple () -> TkModifier { TkModifier( "<Triple" .to_owned() )}
pub fn quadruple() -> TkModifier { TkModifier( "<Quadruple".to_owned() )}
impl TkModifier {
pub fn control ( mut self ) -> Self { self.0.push_str( "-Control" ); self }
pub fn alt ( mut self ) -> Self { self.0.push_str( "-Alt" ); self }
pub fn shift ( mut self ) -> Self { self.0.push_str( "-Shift" ); self }
pub fn lock ( mut self ) -> Self { self.0.push_str( "-Lock" ); self }
pub fn extended ( mut self ) -> Self { self.0.push_str( "-Extended" ); self }
pub fn button_1 ( mut self ) -> Self { self.0.push_str( "-Button1" ); self }
pub fn button_2 ( mut self ) -> Self { self.0.push_str( "-Button2" ); self }
pub fn button_3 ( mut self ) -> Self { self.0.push_str( "-Button3" ); self }
pub fn button_4 ( mut self ) -> Self { self.0.push_str( "-Button4" ); self }
pub fn button_5 ( mut self ) -> Self { self.0.push_str( "-Button5" ); self }
pub fn mod_1 ( mut self ) -> Self { self.0.push_str( "-Mod1" ); self }
pub fn mod_2 ( mut self ) -> Self { self.0.push_str( "-Mod2" ); self }
pub fn mod_3 ( mut self ) -> Self { self.0.push_str( "-Mod3" ); self }
pub fn mod_4 ( mut self ) -> Self { self.0.push_str( "-Mod4" ); self }
pub fn mod_5 ( mut self ) -> Self { self.0.push_str( "-Mod5" ); self }
pub fn command ( mut self ) -> Self { self.0.push_str( "-Command" ); self }
pub fn option ( mut self ) -> Self { self.0.push_str( "-option" ); self }
pub fn meta ( mut self ) -> Self { self.0.push_str( "-Meta" ); self }
pub fn double ( mut self ) -> Self { self.0.push_str( "-Double" ); self }
pub fn triple ( mut self ) -> Self { self.0.push_str( "-Triple" ); self }
pub fn quadruple( mut self ) -> Self { self.0.push_str( "-Quadruple" ); self }
}
pub fn activate () -> TkEvent { TkEvent( "<activate>" .to_owned() )}
pub fn button_press () -> TkEvent { TkEvent( "<ButtonPress" .to_owned() )}
pub fn button_press_1 () -> TkEvent { TkEvent( "<ButtonPress-1>" .to_owned() )}
pub fn button_press_2 () -> TkEvent { TkEvent( "<ButtonPress-2>" .to_owned() )}
pub fn button_press_3 () -> TkEvent { TkEvent( "<ButtonPress-3>" .to_owned() )}
pub fn button_press_4 () -> TkEvent { TkEvent( "<ButtonPress-4>" .to_owned() )}
pub fn button_press_5 () -> TkEvent { TkEvent( "<ButtonPress-5>" .to_owned() )}
pub fn button_release () -> TkEvent { TkEvent( "<ButtonRelease>" .to_owned() )}
pub fn button_release_1 () -> TkEvent { TkEvent( "<ButtonRelease-1>" .to_owned() )}
pub fn button_release_2 () -> TkEvent { TkEvent( "<ButtonRelease-2>" .to_owned() )}
pub fn button_release_3 () -> TkEvent { TkEvent( "<ButtonRelease-3>" .to_owned() )}
pub fn button_release_4 () -> TkEvent { TkEvent( "<ButtonRelease-4>" .to_owned() )}
pub fn button_release_5 () -> TkEvent { TkEvent( "<ButtonRelease-5>" .to_owned() )}
pub fn circulate () -> TkEvent { TkEvent( "<Circulate>" .to_owned() )}
pub fn circulate_request() -> TkEvent { TkEvent( "<CirculateRequest>".to_owned() )}
pub fn colormap () -> TkEvent { TkEvent( "<Colormap>" .to_owned() )}
pub fn configure () -> TkEvent { TkEvent( "<Configure>" .to_owned() )}
pub fn configure_request() -> TkEvent { TkEvent( "<ConfigureRequest>".to_owned() )}
pub fn create () -> TkEvent { TkEvent( "<Create>" .to_owned() )}
pub fn deactivate () -> TkEvent { TkEvent( "<Deactivate>" .to_owned() )}
pub fn destroy () -> TkEvent { TkEvent( "<Destroy>" .to_owned() )}
pub fn enter () -> TkEvent { TkEvent( "<Enter>" .to_owned() )}
pub fn expose () -> TkEvent { TkEvent( "<Expose>" .to_owned() )}
pub fn focus_in () -> TkEvent { TkEvent( "<FocusIn>" .to_owned() )}
pub fn focus_out () -> TkEvent { TkEvent( "<FocusOut>" .to_owned() )}
pub fn gravity () -> TkEvent { TkEvent( "<Gravity>" .to_owned() )}
pub fn map () -> TkEvent { TkEvent( "<Map>" .to_owned() )}
pub fn map_request () -> TkEvent { TkEvent( "<MapRequest>" .to_owned() )}
pub fn motion () -> TkEvent { TkEvent( "<Motion>" .to_owned() )}
pub fn mouse_wheel () -> TkEvent { TkEvent( "<MouseWheel>" .to_owned() )}
pub fn leave () -> TkEvent { TkEvent( "<Leave>" .to_owned() )}
pub fn property () -> TkEvent { TkEvent( "<Property>" .to_owned() )}
pub fn reparent () -> TkEvent { TkEvent( "<Reparent>" .to_owned() )}
pub fn resize_request () -> TkEvent { TkEvent( "<ResizeRequest>" .to_owned() )}
pub fn unmap () -> TkEvent { TkEvent( "<Unmap>" .to_owned() )}
pub fn visibility () -> TkEvent { TkEvent( "<Visibility>" .to_owned() )}
pub fn key_press ( key: impl Into<TkKey> ) -> TkEvent { TkEvent( format!( "<KeyPress-{}>" , key.into().to_string() ))}
pub fn key_release( key: impl Into<TkKey> ) -> TkEvent { TkEvent( format!( "<KeyRelease-{}>", key.into().to_string() ))}
pub fn any_key_press () -> TkEvent { TkEvent( "<KeyPress>" .to_owned() )}
pub fn any_key_release() -> TkEvent { TkEvent( "<KeyRelease>".to_owned() )}
pub fn virtual_event( name: &str ) -> TkEvent { TkEvent( format!( "<<{}>>", name ))}
impl TkModifier {
pub fn activate ( mut self ) -> TkEvent { self.0.push_str( "-activate>" ); TkEvent( self.0 )}
pub fn button_press ( mut self ) -> TkEvent { self.0.push_str( "-ButtonPress" ); TkEvent( self.0 )}
pub fn button_press_1 ( mut self ) -> TkEvent { self.0.push_str( "-ButtonPress-1>" ); TkEvent( self.0 )}
pub fn button_press_2 ( mut self ) -> TkEvent { self.0.push_str( "-ButtonPress-2>" ); TkEvent( self.0 )}
pub fn button_press_3 ( mut self ) -> TkEvent { self.0.push_str( "-ButtonPress-3>" ); TkEvent( self.0 )}
pub fn button_press_4 ( mut self ) -> TkEvent { self.0.push_str( "-ButtonPress-4>" ); TkEvent( self.0 )}
pub fn button_press_5 ( mut self ) -> TkEvent { self.0.push_str( "-ButtonPress-5>" ); TkEvent( self.0 )}
pub fn button_release ( mut self ) -> TkEvent { self.0.push_str( "-ButtonRelease>" ); TkEvent( self.0 )}
pub fn button_release_1 ( mut self ) -> TkEvent { self.0.push_str( "-ButtonRelease-1>" ); TkEvent( self.0 )}
pub fn button_release_2 ( mut self ) -> TkEvent { self.0.push_str( "-ButtonRelease-2>" ); TkEvent( self.0 )}
pub fn button_release_3 ( mut self ) -> TkEvent { self.0.push_str( "-ButtonRelease-3>" ); TkEvent( self.0 )}
pub fn button_release_4 ( mut self ) -> TkEvent { self.0.push_str( "-ButtonRelease-4>" ); TkEvent( self.0 )}
pub fn button_release_5 ( mut self ) -> TkEvent { self.0.push_str( "-ButtonRelease-5>" ); TkEvent( self.0 )}
pub fn circulate ( mut self ) -> TkEvent { self.0.push_str( "-Circulate>" ); TkEvent( self.0 )}
pub fn circulate_request( mut self ) -> TkEvent { self.0.push_str( "-CirculateRequest>" ); TkEvent( self.0 )}
pub fn colormap ( mut self ) -> TkEvent { self.0.push_str( "-Colormap>" ); TkEvent( self.0 )}
pub fn configure ( mut self ) -> TkEvent { self.0.push_str( "-Configure>" ); TkEvent( self.0 )}
pub fn configure_request( mut self ) -> TkEvent { self.0.push_str( "-ConfigureRequest>" ); TkEvent( self.0 )}
pub fn create ( mut self ) -> TkEvent { self.0.push_str( "-Create>" ); TkEvent( self.0 )}
pub fn deactivate ( mut self ) -> TkEvent { self.0.push_str( "-Deactivate>" ); TkEvent( self.0 )}
pub fn destroy ( mut self ) -> TkEvent { self.0.push_str( "-Destroy>" ); TkEvent( self.0 )}
pub fn enter ( mut self ) -> TkEvent { self.0.push_str( "-Enter>" ); TkEvent( self.0 )}
pub fn expose ( mut self ) -> TkEvent { self.0.push_str( "-Expose>" ); TkEvent( self.0 )}
pub fn focus_in ( mut self ) -> TkEvent { self.0.push_str( "-FocusIn>" ); TkEvent( self.0 )}
pub fn focus_out ( mut self ) -> TkEvent { self.0.push_str( "-FocusOut>" ); TkEvent( self.0 )}
pub fn gravity ( mut self ) -> TkEvent { self.0.push_str( "-Gravity>" ); TkEvent( self.0 )}
pub fn map ( mut self ) -> TkEvent { self.0.push_str( "-Map>" ); TkEvent( self.0 )}
pub fn map_request ( mut self ) -> TkEvent { self.0.push_str( "-MapRequest>" ); TkEvent( self.0 )}
pub fn motion ( mut self ) -> TkEvent { self.0.push_str( "-Motion>" ); TkEvent( self.0 )}
pub fn mouse_wheel ( mut self ) -> TkEvent { self.0.push_str( "-MouseWheel>" ); TkEvent( self.0 )}
pub fn leave ( mut self ) -> TkEvent { self.0.push_str( "-Leave>" ); TkEvent( self.0 )}
pub fn property ( mut self ) -> TkEvent { self.0.push_str( "-Property>" ); TkEvent( self.0 )}
pub fn reparent ( mut self ) -> TkEvent { self.0.push_str( "-Reparent>" ); TkEvent( self.0 )}
pub fn resize_request ( mut self ) -> TkEvent { self.0.push_str( "-ResizeRequest>" ); TkEvent( self.0 )}
pub fn unmap ( mut self ) -> TkEvent { self.0.push_str( "-Unmap>" ); TkEvent( self.0 )}
pub fn visibility ( mut self ) -> TkEvent { self.0.push_str( "-Visibility>" ); TkEvent( self.0 )}
pub fn key_press ( mut self, key: impl Into<TkKey> ) -> TkEvent { self.0.push_str( &format!( "-KeyPress-{}>" , key.into().to_string() )); TkEvent( self.0 )}
pub fn key_release( mut self, key: impl Into<TkKey> ) -> TkEvent { self.0.push_str( &format!( "-KeyRelease-{}>", key.into().to_string() )); TkEvent( self.0 )}
pub fn any_key_press ( mut self ) -> TkEvent { self.0.push_str( "-KeyPress>" ); TkEvent( self.0 )}
pub fn any_key_release( mut self ) -> TkEvent { self.0.push_str( "-KeyRelease>" ); TkEvent( self.0 )}
}
impl TkEvent {
pub fn control ( mut self ) -> TkEventModifier { self.0.push_str( "<Control" ); TkEventModifier( self.0 )}
pub fn alt ( mut self ) -> TkEventModifier { self.0.push_str( "<Alt" ); TkEventModifier( self.0 )}
pub fn shift ( mut self ) -> TkEventModifier { self.0.push_str( "<Shift" ); TkEventModifier( self.0 )}
pub fn lock ( mut self ) -> TkEventModifier { self.0.push_str( "<Lock" ); TkEventModifier( self.0 )}
pub fn extended ( mut self ) -> TkEventModifier { self.0.push_str( "<Extended" ); TkEventModifier( self.0 )}
pub fn button_1 ( mut self ) -> TkEventModifier { self.0.push_str( "<Button1" ); TkEventModifier( self.0 )}
pub fn button_2 ( mut self ) -> TkEventModifier { self.0.push_str( "<Button2" ); TkEventModifier( self.0 )}
pub fn button_3 ( mut self ) -> TkEventModifier { self.0.push_str( "<Button3" ); TkEventModifier( self.0 )}
pub fn button_4 ( mut self ) -> TkEventModifier { self.0.push_str( "<Button4" ); TkEventModifier( self.0 )}
pub fn button_5 ( mut self ) -> TkEventModifier { self.0.push_str( "<Button5" ); TkEventModifier( self.0 )}
pub fn mod_1 ( mut self ) -> TkEventModifier { self.0.push_str( "<Mod1" ); TkEventModifier( self.0 )}
pub fn mod_2 ( mut self ) -> TkEventModifier { self.0.push_str( "<Mod2" ); TkEventModifier( self.0 )}
pub fn mod_3 ( mut self ) -> TkEventModifier { self.0.push_str( "<Mod3" ); TkEventModifier( self.0 )}
pub fn mod_4 ( mut self ) -> TkEventModifier { self.0.push_str( "<Mod4" ); TkEventModifier( self.0 )}
pub fn mod_5 ( mut self ) -> TkEventModifier { self.0.push_str( "<Mod5" ); TkEventModifier( self.0 )}
pub fn command ( mut self ) -> TkEventModifier { self.0.push_str( "<Command" ); TkEventModifier( self.0 )}
pub fn option ( mut self ) -> TkEventModifier { self.0.push_str( "<option" ); TkEventModifier( self.0 )}
pub fn meta ( mut self ) -> TkEventModifier { self.0.push_str( "<Meta" ); TkEventModifier( self.0 )}
pub fn double ( mut self ) -> TkEventModifier { self.0.push_str( "<Double" ); TkEventModifier( self.0 )}
pub fn triple ( mut self ) -> TkEventModifier { self.0.push_str( "<Triple" ); TkEventModifier( self.0 )}
pub fn quadruple( mut self ) -> TkEventModifier { self.0.push_str( "<Quadruple" ); TkEventModifier( self.0 )}
}
impl TkEventSeq {
pub fn control ( mut self ) -> TkEventModifier { self.0.push_str( "<Control" ); TkEventModifier( self.0 )}
pub fn alt ( mut self ) -> TkEventModifier { self.0.push_str( "<Alt" ); TkEventModifier( self.0 )}
pub fn shift ( mut self ) -> TkEventModifier { self.0.push_str( "<Shift" ); TkEventModifier( self.0 )}
pub fn lock ( mut self ) -> TkEventModifier { self.0.push_str( "<Lock" ); TkEventModifier( self.0 )}
pub fn extended ( mut self ) -> TkEventModifier { self.0.push_str( "<Extended" ); TkEventModifier( self.0 )}
pub fn button_1 ( mut self ) -> TkEventModifier { self.0.push_str( "<Button1" ); TkEventModifier( self.0 )}
pub fn button_2 ( mut self ) -> TkEventModifier { self.0.push_str( "<Button2" ); TkEventModifier( self.0 )}
pub fn button_3 ( mut self ) -> TkEventModifier { self.0.push_str( "<Button3" ); TkEventModifier( self.0 )}
pub fn button_4 ( mut self ) -> TkEventModifier { self.0.push_str( "<Button4" ); TkEventModifier( self.0 )}
pub fn button_5 ( mut self ) -> TkEventModifier { self.0.push_str( "<Button5" ); TkEventModifier( self.0 )}
pub fn mod_1 ( mut self ) -> TkEventModifier { self.0.push_str( "<Mod1" ); TkEventModifier( self.0 )}
pub fn mod_2 ( mut self ) -> TkEventModifier { self.0.push_str( "<Mod2" ); TkEventModifier( self.0 )}
pub fn mod_3 ( mut self ) -> TkEventModifier { self.0.push_str( "<Mod3" ); TkEventModifier( self.0 )}
pub fn mod_4 ( mut self ) -> TkEventModifier { self.0.push_str( "<Mod4" ); TkEventModifier( self.0 )}
pub fn mod_5 ( mut self ) -> TkEventModifier { self.0.push_str( "<Mod5" ); TkEventModifier( self.0 )}
pub fn command ( mut self ) -> TkEventModifier { self.0.push_str( "<Command" ); TkEventModifier( self.0 )}
pub fn option ( mut self ) -> TkEventModifier { self.0.push_str( "<option" ); TkEventModifier( self.0 )}
pub fn meta ( mut self ) -> TkEventModifier { self.0.push_str( "<Meta" ); TkEventModifier( self.0 )}
pub fn double ( mut self ) -> TkEventModifier { self.0.push_str( "<Double" ); TkEventModifier( self.0 )}
pub fn triple ( mut self ) -> TkEventModifier { self.0.push_str( "<Triple" ); TkEventModifier( self.0 )}
pub fn quadruple( mut self ) -> TkEventModifier { self.0.push_str( "<Quadruple" ); TkEventModifier( self.0 )}
}
impl TkEventSeq {
pub fn activate ( mut self ) -> Self { self.0.push_str( "<activate>" ); self }
pub fn button_press ( mut self ) -> Self { self.0.push_str( "<ButtonPress" ); self }
pub fn button_press_1 ( mut self ) -> Self { self.0.push_str( "<ButtonPress-1>" ); self }
pub fn button_press_2 ( mut self ) -> Self { self.0.push_str( "<ButtonPress-2>" ); self }
pub fn button_press_3 ( mut self ) -> Self { self.0.push_str( "<ButtonPress-3>" ); self }
pub fn button_press_4 ( mut self ) -> Self { self.0.push_str( "<ButtonPress-4>" ); self }
pub fn button_press_5 ( mut self ) -> Self { self.0.push_str( "<ButtonPress-5>" ); self }
pub fn button_release ( mut self ) -> Self { self.0.push_str( "<ButtonRelease>" ); self }
pub fn button_release_1 ( mut self ) -> Self { self.0.push_str( "<ButtonRelease-1>" ); self }
pub fn button_release_2 ( mut self ) -> Self { self.0.push_str( "<ButtonRelease-2>" ); self }
pub fn button_release_3 ( mut self ) -> Self { self.0.push_str( "<ButtonRelease-3>" ); self }
pub fn button_release_4 ( mut self ) -> Self { self.0.push_str( "<ButtonRelease-4>" ); self }
pub fn button_release_5 ( mut self ) -> Self { self.0.push_str( "<ButtonRelease-5>" ); self }
pub fn circulate ( mut self ) -> Self { self.0.push_str( "<Circulate>" ); self }
pub fn circulate_request( mut self ) -> Self { self.0.push_str( "<CirculateRequest>" ); self }
pub fn colormap ( mut self ) -> Self { self.0.push_str( "<Colormap>" ); self }
pub fn configure ( mut self ) -> Self { self.0.push_str( "<Configure>" ); self }
pub fn configure_request( mut self ) -> Self { self.0.push_str( "<ConfigureRequest>" ); self }
pub fn create ( mut self ) -> Self { self.0.push_str( "<Create>" ); self }
pub fn deactivate ( mut self ) -> Self { self.0.push_str( "<Deactivate>" ); self }
pub fn destroy ( mut self ) -> Self { self.0.push_str( "<Destroy>" ); self }
pub fn enter ( mut self ) -> Self { self.0.push_str( "<Enter>" ); self }
pub fn expose ( mut self ) -> Self { self.0.push_str( "<Expose>" ); self }
pub fn focus_in ( mut self ) -> Self { self.0.push_str( "<FocusIn>" ); self }
pub fn focus_out ( mut self ) -> Self { self.0.push_str( "<FocusOut>" ); self }
pub fn gravity ( mut self ) -> Self { self.0.push_str( "<Gravity>" ); self }
pub fn map ( mut self ) -> Self { self.0.push_str( "<Map>" ); self }
pub fn map_request ( mut self ) -> Self { self.0.push_str( "<MapRequest>" ); self }
pub fn motion ( mut self ) -> Self { self.0.push_str( "<Motion>" ); self }
pub fn mouse_wheel ( mut self ) -> Self { self.0.push_str( "<MouseWheel>" ); self }
pub fn leave ( mut self ) -> Self { self.0.push_str( "<Leave>" ); self }
pub fn property ( mut self ) -> Self { self.0.push_str( "<Property>" ); self }
pub fn reparent ( mut self ) -> Self { self.0.push_str( "<Reparent>" ); self }
pub fn resize_request ( mut self ) -> Self { self.0.push_str( "<ResizeRequest>" ); self }
pub fn unmap ( mut self ) -> Self { self.0.push_str( "<Unmap>" ); self }
pub fn visibility ( mut self ) -> Self { self.0.push_str( "<Visibility>" ); self }
pub fn key_press ( mut self, key: impl Into<TkKey> ) -> Self { self.0.push_str( &format!( "<KeyPress-{}>" , key.into().to_string() )); self }
pub fn key_release( mut self, key: impl Into<TkKey> ) -> Self { self.0.push_str( &format!( "<KeyRelease-{}>", key.into().to_string() )); self }
pub fn any_key_press ( mut self ) -> Self { self.0.push_str( "<KeyPress>" ); self }
pub fn any_key_release( mut self ) -> Self { self.0.push_str( "<KeyRelease>" ); self }
}
impl TkEventSeq {
pub fn virtual_event( mut self, name: &str ) -> Self { self.0.push_str( &format!( "<<{}>>", name )); self }
}
impl From<TkEvent> for Obj {
fn from( seq: TkEvent ) -> Obj {
seq.0.into()
}
}
impl From<TkEventSeq> for Obj {
fn from( seq: TkEventSeq ) -> Obj {
seq.0.into()
}
}
impl From<TkEvent> for TkEventSeq {
fn from( event: TkEvent ) -> TkEventSeq { TkEventSeq( event.0 )}
}
pub fn alt_underlined() -> TkEvent { TkEvent( "<<AltUnderlined>>" .to_owned() )}
pub fn invoke() -> TkEvent { TkEvent( "<<Invoke>>" .to_owned() )}
pub fn listbox_select() -> TkEvent { TkEvent( "<<ListboxSelect>>" .to_owned() )}
pub fn menu_select() -> TkEvent { TkEvent( "<<MenuSelect>>" .to_owned() )}
pub fn modified() -> TkEvent { TkEvent( "<<Modified>>" .to_owned() )}
pub fn selection() -> TkEvent { TkEvent( "<<Selection>>" .to_owned() )}
pub fn theme_changed() -> TkEvent { TkEvent( "<<ThemeChanged>>" .to_owned() )}
pub fn traverse_in() -> TkEvent { TkEvent( "<<TraverseIn>>" .to_owned() )}
pub fn traverse_out() -> TkEvent { TkEvent( "<<TraverseOut>>" .to_owned() )}
pub fn undo_stack() -> TkEvent { TkEvent( "<<UndoStack>>" .to_owned() )}
pub fn widget_view_sync() -> TkEvent { TkEvent( "<<WidgetViewSync>>" .to_owned() )}
pub fn clear() -> TkEvent { TkEvent( "<<Clear>>" .to_owned() )}
pub fn copy() -> TkEvent { TkEvent( "<<Copy>>" .to_owned() )}
pub fn cut() -> TkEvent { TkEvent( "<<Cut>>" .to_owned() )}
pub fn line_end() -> TkEvent { TkEvent( "<<LineEnd>>" .to_owned() )}
pub fn line_start() -> TkEvent { TkEvent( "<<LineStart>>" .to_owned() )}
pub fn next_char() -> TkEvent { TkEvent( "<<NextChar>>" .to_owned() )}
pub fn next_line() -> TkEvent { TkEvent( "<<NextLine>>" .to_owned() )}
pub fn next_para() -> TkEvent { TkEvent( "<<NextPara>>" .to_owned() )}
pub fn next_word() -> TkEvent { TkEvent( "<<NextWord>>" .to_owned() )}
pub fn paste() -> TkEvent { TkEvent( "<<Paste>>" .to_owned() )}
pub fn paste_selection() -> TkEvent { TkEvent( "<<PasteSelection>>" .to_owned() )}
pub fn prev_char() -> TkEvent { TkEvent( "<<PrevChar>>" .to_owned() )}
pub fn prev_line() -> TkEvent { TkEvent( "<<PrevLine>>" .to_owned() )}
pub fn prev_para() -> TkEvent { TkEvent( "<<PrevPara>>" .to_owned() )}
pub fn prev_window() -> TkEvent { TkEvent( "<<PrevWindow>>" .to_owned() )}
pub fn prev_word() -> TkEvent { TkEvent( "<<PrevWord>>" .to_owned() )}
pub fn redo() -> TkEvent { TkEvent( "<<Redo>>" .to_owned() )}
pub fn select_all() -> TkEvent { TkEvent( "<<SelectAll>>" .to_owned() )}
pub fn select_line_end() -> TkEvent { TkEvent( "<<SelectLineEnd>>" .to_owned() )}
pub fn select_line_start() -> TkEvent { TkEvent( "<<SelectLineStart>>" .to_owned() )}
pub fn select_next_char() -> TkEvent { TkEvent( "<<SelectNextChar>>" .to_owned() )}
pub fn select_next_line() -> TkEvent { TkEvent( "<<SelectNextLine>>" .to_owned() )}
pub fn select_next_para() -> TkEvent { TkEvent( "<<SelectNextPara>>" .to_owned() )}
pub fn select_next_word() -> TkEvent { TkEvent( "<<SelectNextWord>>" .to_owned() )}
pub fn select_none() -> TkEvent { TkEvent( "<<SelectNone>>" .to_owned() )}
pub fn select_prev_char() -> TkEvent { TkEvent( "<<SelectPrevChar>>" .to_owned() )}
pub fn select_prev_line() -> TkEvent { TkEvent( "<<SelectPrevLine>>" .to_owned() )}
pub fn select_prev_para() -> TkEvent { TkEvent( "<<SelectPrevPara>>" .to_owned() )}
pub fn select_prev_word() -> TkEvent { TkEvent( "<<SelectPrevWord>>" .to_owned() )}
pub fn toggle_selection() -> TkEvent { TkEvent( "<<ToggleSelection>>" .to_owned() )}
pub fn undo() -> TkEvent { TkEvent( "<<Undo>>" .to_owned() )}
impl<Inst:TkInstance> Tk<Inst> {
pub fn event_add( &self, virtual_event: TkEvent, sequences: Vec<TkEventSeq> ) -> InterpResult<()> {
let mut command = Vec::<Obj>::with_capacity( sequences.len() + 3 );
command.push( "event".into() );
command.push( "add".into() );
command.push( virtual_event.into() );
command.extend( sequences.into_iter().map( |seq| seq.into() ));
self.run( command )
}
pub fn event_delete( &self, virtual_event: TkEvent, sequences: Option<Vec<TkEventSeq>> ) -> InterpResult<()> {
let mut command = Vec::<Obj>::with_capacity( sequences.as_ref().map( |s| s.len() ).unwrap_or(0) + 3 );
command.push( "event".into() );
command.push( "delete".into() );
command.push( virtual_event.into() );
if let Some( sequences ) = sequences {
command.extend( sequences.into_iter().map( |seq| seq.into() ));
}
self.run( command )
}
#[cex]
pub fn event_info( &self ) -> Result!( Vec<TkEvent> throws InterpError, NotList ) {
let obj = self.eval(( "event", "info" ))?;
Ok( obj .get_elements()?
.map( |elem| TkEvent( elem.to_string() ))
.collect() )
}
#[cex]
pub fn event_info_sequences_of( &self, virtual_event: TkEvent ) -> Result!( Vec<TkEventSeq>
throws InterpError, NotList )
{
let obj = self.eval(( "event", "info", virtual_event ))?;
Ok( obj .get_elements()?
.map( |elem| TkEventSeq( elem.to_string() ))
.collect() )
}
}
impl<Inst:TkInstance> Widget<Inst> {
pub fn event_generate<Opts>( &self, event: TkEvent, opts: impl Into<PathOptsWidgets<Opts,()>> ) -> InterpResult<()>
where Opts: IntoHomoTuple<TkEventOpt>
+ IntoHomoTuple<OptPair>
{
let mut command = Vec::<Obj>::with_capacity( <<Opts as IntoHomoTuple<OptPair>>::Output as tuplex::Len>::LEN * 2 + 4 );
command.push( "event" .into() );
command.push( "generate" .into() );
command.push( self.path.into() );
command.push( event .into() );
append_opts( &mut command, opts.into().opts );
self.tk().run( command )
}
}
macro_rules! i32enum_obj_conversion {
($ty:ident, $err:ident) => {
impl From<$ty> for Obj {
fn from( ty: $ty ) -> Obj {
i32::from( ty ).into()
}
}
impl TryFrom<Obj> for $ty {
type Error = $err;
fn try_from( obj: Obj ) -> Result<Self, Self::Error> {
Self::try_from(
i32::try_from( obj.clone() )
.map_err( |_| $err( obj.clone() ))? )
.map_err( |_| $err( obj ))
}
}
}
}
macro_rules! strum_obj_conversion {
($ty:ident, $err:ident) => {
impl From<$ty> for Obj {
fn from( notify_mode: $ty ) -> Obj {
notify_mode.to_string().into()
}
}
impl TryFrom<Obj> for $ty {
type Error = $err;
fn try_from( obj: Obj ) -> Result<Self, Self::Error> {
obj.get_string().parse().map_err( |_| $err( obj.clone() ))
}
}
}
}
#[derive( Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive )]
#[repr( i32 )]
pub enum ButtonNo {
Button1 = 1,
Button2 = 2,
Button3 = 3,
Button4 = 4,
Button5 = 5,
}
i32enum_obj_conversion!{ ButtonNo, TkButtonNoError }
#[derive( Debug, strum_macros::Display, strum_macros::EnumString )]
pub enum TkNotifyMode {
NotifyNormal,
NotifyGrab,
NotifyUngrab,
NotifyWhileGrabbed
}
strum_obj_conversion!{ TkNotifyMode, TkNotifyModeParseError }
#[derive( Debug, strum_macros::Display, strum_macros::EnumString )]
pub enum TkPlaceOn {
PlaceOnTop,
PlaceOnBottom,
}
strum_obj_conversion!{ TkPlaceOn, TkPlaceOnParseError }
#[derive( Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive )]
#[repr( i32 )]
pub enum TkEventType {
KeyPress = 2,
KeyRelease = 3,
ButtonPress = 4,
ButtonRelease = 5,
MotionNotify = 6,
EnterNotify = 7,
LeaveNotify = 8,
FocusIn = 9,
FocusOut = 10,
KeymapNotify = 11,
Expose = 12,
GraphicsExpose = 13,
NoExpose = 14,
VisibilityNotify = 15,
CreateNotify = 16,
DestroyNotify = 17,
UnmapNotify = 18,
MapNotify = 19,
MapRequest = 20,
ReparentNotify = 21,
ConfigureNotify = 22,
ConfigureRequest = 23,
GravityNotify = 24,
ResizeRequest = 25,
CirculateNotify = 26,
CirculateRequest = 27,
PropertyNotify = 28,
SelectionClear = 29,
SelectionRequest = 30,
SelectionNotify = 31,
ColormapNotify = 32,
ClientMessage = 33,
MappingNotify = 34,
GenericEvent = 35,
}
i32enum_obj_conversion!{ TkEventType, TkEventTypeError }
#[derive( Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive )]
#[repr( i32 )]
pub enum TkValidatingAction {
Insert = 1,
Delete = 0,
FocusOrForcedOrTextvariable = -1,
}
i32enum_obj_conversion!{ TkValidatingAction, TkValidatingActionError }
#[derive( Debug, strum_macros::Display, strum_macros::EnumString )]
#[strum( serialize_all = "lowercase" )]
pub enum TkValidationSet {
None,
Focus,
FocusIn,
FocusOut,
Key,
All,
}
strum_obj_conversion!{ TkValidationSet, TkValidationSetParseError }
#[derive( Debug, strum_macros::Display, strum_macros::EnumString )]
#[strum( serialize_all = "lowercase" )]
pub enum TkValidationOp {
FocusIn,
FocusOut,
Forced,
Key,
}
strum_obj_conversion!{ TkValidationOp, TkValidationOpParseError }