1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
#[macro_use] extern crate bitflags; #[macro_use] extern crate lazy_static; extern crate winapi; #[cfg(feature="flexbox")] pub extern crate stretch; #[cfg(feature="all")] #[cfg(test)] mod tests; mod errors; pub use errors::{NwgError}; mod events; pub use events::*; mod common_types; pub use common_types::*; pub(crate) mod win32; pub use win32::{ dispatch_thread_events, dispatch_thread_events_with_callback, stop_thread_dispatch, enable_visual_styles, init_common_controls, window::{ EventHandler, RawEventHandler, full_bind_event_handler, bind_event_handler, unbind_event_handler, bind_raw_event_handler, has_raw_handler, unbind_raw_event_handler }, message_box::{MessageButtons, MessageIcons, MessageChoice, MessageParams, message, fatal_message, error_message, simple_message}}; pub(crate) use win32::window::bind_raw_event_handler_inner; #[allow(deprecated)] pub use win32::high_dpi::{set_dpi_awareness, scale_factor, dpi}; #[cfg(feature="cursor")] pub use win32::cursor::GlobalCursor; #[cfg(feature="clipboard")] pub use win32::clipboard::{Clipboard, ClipboardFormat, ClipboardData}; mod resources; pub use resources::*; mod controls; pub use controls::*; mod layouts; pub use layouts::*; #[cfg(feature = "winnls")] mod winnls; #[cfg(feature = "winnls")] pub use winnls::*; /** A structure that implements this trait is considered a GUI structure. The structure will hold GUI components and possibly user data. A structure that implements `PartialUi` must be part of another UI structure and cannot be used at it is. It will most likely used as a struct member of another struct that implements `NativeUi`. The goal of `NativeUi` and `PartialUi` is to provide a common way to define NWG applications. Native-windows-derive can automatically implements this trait. For an example on how to implement this trait, see the **Small application layout** section in the NWG documentation. */ pub trait PartialUi { /** Should initializes the GUI components. Similar to `NativeUi::build_ui` except it doesn't handle events binding. Parameters: - `data`: A reference to the struct data from the parent struct - `parent`: An optional reference to the parent UI control. If this is defined, ui controls of the partial should be children of this value. */ fn build_partial<W: Into<ControlHandle>>(data: &mut Self, parent: Option<W>) -> Result<(), NwgError>; /** Should process the events of the partial. This method will probably be called from an event handler bound in the parent GUI structure. Parameters: - `base`: A reference to the parent struct data - `evt`: The event raised - `evt_data`: The data of the event raised - `handle`: Handle of the control that raised the event */ fn process_event(&self, _evt: Event, _evt_data: &EventData, _handle: ControlHandle) {} /** Should return the handles of the top level parent controls (such as Windows). Those handle should be used to bind the default events handler. */ fn handles<'a>(&'a self) -> Vec<&'a ControlHandle> { vec![] } } /** A structure that implements this trait is considered a GUI structure. The structure will hold GUI components and possibly user data. The goal of `NativeUi` and `PartialUi` is to provide a common way to define NWG applications. Native-windows-derive can automatically implements this trait. For an example on how to implement this trait, see the **Small application layout** section in the NWG documentation. */ pub trait NativeUi<UI> { /** A constructor for the structure. It should initializes the GUI components and bind GUI events. Parameters: - `inital_state`: should contain the initial user data. `NativeUi` assumes this data will be wrapped in another type (`UI`). */ fn build_ui(inital_state: Self) -> Result<UI, NwgError>; } /// Initialize some application wide GUI settings. /// This includes default styling and common controls resources. pub fn init() -> std::result::Result<(), errors::NwgError> { if cfg!(not(feature="no-styling")) { enable_visual_styles(); } init_common_controls() }