wxdragon 0.9.15

Safe Rust bindings for wxWidgets via the wxDragon C wrapper
Documentation
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
use crate::event::{Event, EventType, WxEvtHandler};
use crate::window::{Window, WindowHandle, WxWidget};
use std::cell::RefCell;
use std::collections::HashMap;
use std::ffi::{CStr, CString};
use std::marker::PhantomData;
use std::sync::atomic::{AtomicU64, Ordering};
use wxdragon_sys as ffi;

// ============================================================================
// AuiManagerHandle: Safe, Copy-able handle to wxWidgets AuiManager
// ============================================================================

/// Counter for generating unique AuiManager handle IDs
static NEXT_AUI_HANDLE_ID: AtomicU64 = AtomicU64::new(1);

thread_local! {
    /// Maps handle IDs to raw AuiManager pointers
    static AUI_MANAGER_REGISTRY: RefCell<HashMap<u64, *mut ffi::wxd_AuiManager_t>> =
        RefCell::new(HashMap::new());
}

/// A safe, Copy-able handle to a wxAuiManager.
///
/// Unlike raw pointers, `AuiManagerHandle` tracks the manager's lifecycle
/// through its managed window. When the managed window is destroyed, the handle
/// becomes invalid.
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
struct AuiManagerHandle(u64);

impl AuiManagerHandle {
    /// Creates a new handle for an AuiManager pointer.
    ///
    /// # Safety
    /// The caller must ensure `ptr` points to a valid wxAuiManager.
    fn new(ptr: *mut ffi::wxd_AuiManager_t) -> Self {
        if ptr.is_null() {
            return AuiManagerHandle(0); // Invalid handle for null pointers
        }

        let handle_id = NEXT_AUI_HANDLE_ID.fetch_add(1, Ordering::SeqCst);

        // Register the manager pointer
        AUI_MANAGER_REGISTRY.with(|r| r.borrow_mut().insert(handle_id, ptr));

        AuiManagerHandle(handle_id)
    }

    /// Get the raw pointer if the manager is still valid, `None` if destroyed.
    #[inline]
    fn get_ptr(&self) -> Option<*mut ffi::wxd_AuiManager_t> {
        if self.0 == 0 {
            return None;
        }
        AUI_MANAGER_REGISTRY.with(|r| r.borrow().get(&self.0).copied())
    }

    /// Check if the underlying manager is still valid (not destroyed).
    #[inline]
    fn is_valid(&self) -> bool {
        self.get_ptr().is_some()
    }

    /// Internal: Remove handle from registry (called when manager should be invalidated)
    fn invalidate(&self) {
        if self.0 == 0 {
            return;
        }
        AUI_MANAGER_REGISTRY.with(|r| {
            r.borrow_mut().remove(&self.0);
        });
    }
}

/// Direction for docking panes in an AuiManager
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum DockDirection {
    /// Dock on the left side of the managed window
    Left = 0,
    /// Dock on the right side of the managed window
    Right = 1,
    /// Dock at the top of the managed window
    Top = 2,
    /// Dock at the bottom of the managed window
    Bottom = 3,
    /// Dock in the center of the managed window
    Center = 4,
}

/// Information about a pane in the AuiManager
#[derive(Debug)]
pub struct PaneInfo {
    ptr: *mut ffi::wxd_AuiPaneInfo_t,
}

impl Default for PaneInfo {
    fn default() -> Self {
        Self::new()
    }
}

impl PaneInfo {
    /// Create a new PaneInfo
    pub fn new() -> Self {
        let ptr = unsafe { ffi::wxd_AuiPaneInfo_Create() };
        if ptr.is_null() {
            panic!("Failed to create AuiPaneInfo");
        }
        PaneInfo { ptr }
    }

    /// Set the name for this pane
    pub fn with_name(self, name: &str) -> Self {
        let c_name = CString::new(name).expect("CString::new failed for name");
        unsafe {
            ffi::wxd_AuiPaneInfo_Name(self.ptr, c_name.as_ptr());
        }
        self
    }

    /// Set the caption (title) for this pane
    pub fn with_caption(self, caption: &str) -> Self {
        let c_caption = CString::new(caption).expect("CString::new failed for caption");
        unsafe {
            ffi::wxd_AuiPaneInfo_Caption(self.ptr, c_caption.as_ptr());
        }
        self
    }

    /// Dock this pane on the left side
    pub fn left(self) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_Left(self.ptr);
        }
        self
    }

    /// Dock this pane on the right side
    pub fn right(self) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_Right(self.ptr);
        }
        self
    }

    /// Dock this pane at the top
    pub fn top(self) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_Top(self.ptr);
        }
        self
    }

    /// Dock this pane at the bottom
    pub fn bottom(self) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_Bottom(self.ptr);
        }
        self
    }

    /// Dock this pane in the center
    pub fn center(self) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_Center(self.ptr);
        }
        self
    }

    /// Make this pane the center pane (main content)
    pub fn center_pane(self) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_CenterPane(self.ptr);
        }
        self
    }

    /// Set whether this pane can be floated
    pub fn floatable(self, enable: bool) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_Floatable(self.ptr, enable);
        }
        self
    }

    /// Set whether this pane can be docked
    pub fn dockable(self, enable: bool) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_Dockable(self.ptr, enable);
        }
        self
    }

    /// Set whether this pane can be moved
    pub fn movable(self, enable: bool) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_Movable(self.ptr, enable);
        }
        self
    }

    /// Set whether this pane can be resized
    pub fn resizable(self, enable: bool) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_Resizable(self.ptr, enable);
        }
        self
    }

    /// Set whether this pane has a close button
    pub fn close_button(self, visible: bool) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_CloseButton(self.ptr, visible);
        }
        self
    }

    /// Set whether this pane has a maximize button
    pub fn maximize_button(self, visible: bool) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_MaximizeButton(self.ptr, visible);
        }
        self
    }

    /// Set whether this pane has a minimize button
    pub fn minimize_button(self, visible: bool) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_MinimizeButton(self.ptr, visible);
        }
        self
    }

    /// Set whether this pane has a pin button
    pub fn pin_button(self, visible: bool) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_PinButton(self.ptr, visible);
        }
        self
    }

    /// Set whether this pane has a border
    pub fn pane_border(self, visible: bool) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_PaneBorder(self.ptr, visible);
        }
        self
    }

    /// Set whether this pane has a gripper
    pub fn gripper(self, visible: bool) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_Gripper(self.ptr, visible);
        }
        self
    }

    /// Set whether the gripper is at the top
    pub fn gripper_top(self, attop: bool) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_GripperTop(self.ptr, attop);
        }
        self
    }

    /// Set the layer for this pane
    pub fn layer(self, layer: i32) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_Layer(self.ptr, layer);
        }
        self
    }

    /// Set the minimum size for this pane
    pub fn min_size(self, width: i32, height: i32) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_MinSize(self.ptr, width, height);
        }
        self
    }

    /// Set the maximum size for this pane
    pub fn max_size(self, width: i32, height: i32) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_MaxSize(self.ptr, width, height);
        }
        self
    }

    /// Set the row position for this pane
    pub fn row(self, row: i32) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_Row(self.ptr, row);
        }
        self
    }

    /// Set the position for this pane
    pub fn position(self, position: i32) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_Position(self.ptr, position);
        }
        self
    }

    /// Set default properties for this pane
    pub fn default_pane(self) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_DefaultPane(self.ptr);
        }
        self
    }

    /// Set properties for a toolbar pane
    pub fn toolbar_pane(self) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_ToolbarPane(self.ptr);
        }
        self
    }

    /// Set the best size for this pane
    pub fn best_size(self, width: i32, height: i32) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_BestSize(self.ptr, width, height);
        }
        self
    }

    /// Set whether this pane is shown
    pub fn show(self, show: bool) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_Show(self.ptr, show);
        }
        self
    }

    /// Hide this pane
    pub fn hide(self) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_Hide(self.ptr);
        }
        self
    }

    /// Set whether the caption is visible for this pane
    pub fn caption_visible(self, visible: bool) -> Self {
        unsafe {
            ffi::wxd_AuiPaneInfo_CaptionVisible(self.ptr, visible);
        }
        self
    }
}

impl Drop for PaneInfo {
    fn drop(&mut self) {
        // Note: There is a potential memory management issue here.
        // When a PaneInfo is added to the AuiManager via add_pane_with_info,
        // the wxWidgets C++ side makes a copy of the pane info.
        // We need to be careful about deleting the original here,
        // but this is necessary to avoid leaks for PaneInfo objects
        // that aren't added to a manager.
        unsafe {
            ffi::wxd_AuiPaneInfo_Delete(self.ptr);
        }
    }
}

/// Builder for AuiManager that ensures it's always attached to a window
pub struct AuiManagerBuilder<'a> {
    parent_ptr: *mut ffi::wxd_Window_t,
    parent_handle: WindowHandle,
    _marker: PhantomData<&'a ()>,
}

impl<'a> AuiManagerBuilder<'a> {
    /// Build the AuiManager with the configured parent window
    pub fn build(self) -> AuiManager {
        let ptr = unsafe { ffi::wxd_AuiManager_Create() };
        if ptr.is_null() {
            panic!("Failed to create AuiManager");
        }

        // Create the handle for the manager
        let handle = AuiManagerHandle::new(ptr);

        let mgr = AuiManager {
            handle,
            managed_window: self.parent_handle,
        };

        // Immediately set the managed window to ensure proper lifecycle management
        unsafe {
            ffi::wxd_AuiManager_SetManagedWindow(ptr, self.parent_ptr);
        }

        // Set up a destroy handler on the managed window to invalidate this manager
        let handle_copy = handle;
        let parent = unsafe { Window::from_ptr(self.parent_ptr) };
        parent.bind_internal(EventType::DESTROY, move |_event| {
            handle_copy.invalidate();
        });

        mgr
    }
}

/// AuiManager - Advanced User Interface manager for docking windows and toolbars
///
/// The AuiManager is responsible for managing the layout of windows within a frame.
/// It allows windows to be "docked" into different regions of the frame and provides
/// a draggable, floating interface for rearranging windows.
///
/// AuiManager uses a handle-based pattern for memory safety. When the managed window
/// is destroyed, the handle becomes invalid and all operations become safe no-ops.
///
/// # Example
/// ```ignore
/// let frame = Frame::builder().build();
/// let manager = AuiManager::builder(&frame).build();
///
/// // AuiManager is Copy - no clone needed for closures!
/// manager.on_pane_close(move |_| {
///     // Safe: if frame was destroyed, this is a no-op
///     manager.update();
/// });
///
/// // After frame destruction, manager operations are safe no-ops
/// frame.destroy();
/// assert!(!manager.is_valid());
/// ```
#[derive(Clone, Copy)]
pub struct AuiManager {
    /// Safe handle to the underlying wxAuiManager - automatically invalidated when managed window is destroyed
    handle: AuiManagerHandle,
    /// Handle to the managed window - used to track lifecycle
    managed_window: WindowHandle,
}

impl AuiManager {
    /// Create a new AuiManager builder, which requires a parent window to build
    pub fn builder(parent: &impl WxWidget) -> AuiManagerBuilder<'_> {
        let parent_ptr = parent.handle_ptr();
        // Try to look up existing handle, or create a new one if needed
        let parent_handle = WindowHandle::from_ptr(parent_ptr).unwrap_or_else(|| WindowHandle::new(parent_ptr));

        AuiManagerBuilder {
            parent_ptr,
            parent_handle,
            _marker: PhantomData,
        }
    }

    /// Helper to get raw AuiManager pointer, returns null if manager has been destroyed
    #[inline]
    fn manager_ptr(&self) -> *mut ffi::wxd_AuiManager_t {
        self.handle.get_ptr().unwrap_or(std::ptr::null_mut())
    }

    /// Check if the AuiManager is still valid (managed window not destroyed)
    pub fn is_valid(&self) -> bool {
        self.handle.is_valid() && self.managed_window.is_valid()
    }

    /// Set the window that this AuiManager will manage
    /// No-op if the manager has been destroyed.
    pub fn set_managed_window(&self, window: &impl WxWidget) {
        let ptr = self.manager_ptr();
        if ptr.is_null() {
            return;
        }
        unsafe {
            ffi::wxd_AuiManager_SetManagedWindow(ptr, window.handle_ptr());
        }
    }

    /// Get the window that this AuiManager is managing
    /// Returns None if the manager has been destroyed.
    pub fn get_managed_window(&self) -> Option<Window> {
        let ptr = self.manager_ptr();
        if ptr.is_null() {
            return None;
        }
        let window_ptr = unsafe { ffi::wxd_AuiManager_GetManagedWindow(ptr) };
        if window_ptr.is_null() {
            None
        } else {
            Some(unsafe { Window::from_ptr(window_ptr) })
        }
    }

    /// Uninitialize the manager (detaches from the managed window)
    /// No-op if the manager has been destroyed.
    pub fn uninit(&self) {
        let ptr = self.manager_ptr();
        if ptr.is_null() {
            return;
        }
        unsafe {
            ffi::wxd_AuiManager_UnInit(ptr);
        }
    }

    /// Add a pane to the manager with a simple direction
    /// Returns false if the manager has been destroyed.
    pub fn add_pane(&self, window: &impl WxWidget, direction: DockDirection, caption: &str) -> bool {
        let ptr = self.manager_ptr();
        if ptr.is_null() {
            return false;
        }
        let c_caption = CString::new(caption).expect("CString::new failed for caption");
        unsafe { ffi::wxd_AuiManager_AddPane(ptr, window.handle_ptr(), direction as i32, c_caption.as_ptr()) }
    }

    /// Add a pane with detailed pane information
    /// Returns false if the manager has been destroyed.
    pub fn add_pane_with_info(&self, window: &impl WxWidget, pane_info: PaneInfo) -> bool {
        let ptr = self.manager_ptr();
        if ptr.is_null() {
            return false;
        }
        // The pane_info is still managed by Rust and will be dropped automatically
        unsafe { ffi::wxd_AuiManager_AddPaneWithInfo(ptr, window.handle_ptr(), pane_info.ptr) }
    }

    /// Update the manager's layout (must be called after adding/removing panes)
    /// Returns false if the manager has been destroyed.
    pub fn update(&self) -> bool {
        let ptr = self.manager_ptr();
        if ptr.is_null() {
            return false;
        }
        unsafe { ffi::wxd_AuiManager_Update(ptr) }
    }

    /// Save the current layout as a perspective string
    /// Returns empty string if the manager has been destroyed.
    pub fn save_perspective(&self) -> String {
        let ptr = self.manager_ptr();
        if ptr.is_null() {
            return String::new();
        }
        let len = unsafe { ffi::wxd_AuiManager_SavePerspective(ptr, std::ptr::null_mut(), 0) };
        if len <= 0 {
            return String::new();
        }

        // Create a buffer to hold the perspective string
        let mut b = vec![0; len as usize + 1]; // +1 for null terminator
        unsafe { ffi::wxd_AuiManager_SavePerspective(ptr, b.as_mut_ptr(), b.len()) };
        unsafe { CStr::from_ptr(b.as_ptr()).to_string_lossy().to_string() }
    }

    /// Load a perspective from a string
    /// Returns false if the manager has been destroyed.
    pub fn load_perspective(&self, perspective: &str, update: bool) -> bool {
        let ptr = self.manager_ptr();
        if ptr.is_null() {
            return false;
        }
        let c_perspective = CString::new(perspective).expect("CString::new failed for perspective");
        unsafe { ffi::wxd_AuiManager_LoadPerspective(ptr, c_perspective.as_ptr(), update) }
    }

    /// Detach a pane from the manager
    /// Returns false if the manager has been destroyed.
    pub fn detach_pane(&self, window: &impl WxWidget) -> bool {
        let ptr = self.manager_ptr();
        if ptr.is_null() {
            return false;
        }
        unsafe { ffi::wxd_AuiManager_DetachPane(ptr, window.handle_ptr()) }
    }
}

// Implement WxEvtHandler for AuiManager to allow event binding
impl WxEvtHandler for AuiManager {
    unsafe fn get_event_handler_ptr(&self) -> *mut ffi::wxd_EvtHandler_t {
        self.manager_ptr() as *mut ffi::wxd_EvtHandler_t
    }
}

// Implement common event traits that all Window-based widgets support
impl crate::event::WindowEvents for AuiManager {}

// Re-export PaneInfo to make it easier to use
pub use PaneInfo as AuiPaneInfo;

// Add enum for AuiManager events
/// Events specific to AuiManager
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AuiManagerEvent {
    /// Fired when a button is clicked on a pane
    PaneButton,
    /// Fired when a pane close button is clicked
    PaneClose,
    /// Fired when a pane is maximized
    PaneMaximize,
    /// Fired when a maximized pane is restored
    PaneRestore,
    /// Fired when a pane is activated
    PaneActivated,
    /// Fired when the AUI manager is rendering
    Render,
}

/// Event data for AuiManager events
#[derive(Debug)]
pub struct AuiManagerEventData {
    /// The raw event from wxWidgets
    event: Event,
}

impl AuiManagerEventData {
    /// Create a new AuiManagerEventData from an Event
    pub fn new(event: Event) -> Self {
        Self { event }
    }

    /// Gets the ID associated with this event
    pub fn get_id(&self) -> i32 {
        self.event.get_id()
    }

    /// Gets the pane affected by this event.
    /// This will return the Window associated with the pane if available.
    pub fn get_pane(&self) -> Option<Window> {
        self.event.get_event_object()
    }

    /// Skip this event (allow default processing to occur)
    pub fn skip(&self) {
        self.event.skip(true);
    }
}

// Implement event handling for AuiManager
impl AuiManager {
    /// Bind a handler for the pane button event
    pub fn on_pane_button<F>(&self, callback: F)
    where
        F: FnMut(AuiManagerEventData) + 'static,
    {
        self.bind_aui_event(EventType::AUI_PANE_BUTTON, callback);
    }

    /// Bind a handler for the pane close event
    pub fn on_pane_close<F>(&self, callback: F)
    where
        F: FnMut(AuiManagerEventData) + 'static,
    {
        self.bind_aui_event(EventType::AUI_PANE_CLOSE, callback);
    }

    /// Bind a handler for the pane maximize event
    pub fn on_pane_maximize<F>(&self, callback: F)
    where
        F: FnMut(AuiManagerEventData) + 'static,
    {
        self.bind_aui_event(EventType::AUI_PANE_MAXIMIZE, callback);
    }

    /// Bind a handler for the pane restore event
    pub fn on_pane_restore<F>(&self, callback: F)
    where
        F: FnMut(AuiManagerEventData) + 'static,
    {
        self.bind_aui_event(EventType::AUI_PANE_RESTORE, callback);
    }

    /// Bind a handler for the pane activated event
    pub fn on_pane_activated<F>(&self, callback: F)
    where
        F: FnMut(AuiManagerEventData) + 'static,
    {
        self.bind_aui_event(EventType::AUI_PANE_ACTIVATED, callback);
    }

    /// Bind a handler for the render event
    pub fn on_render<F>(&self, callback: F)
    where
        F: FnMut(AuiManagerEventData) + 'static,
    {
        self.bind_aui_event(EventType::AUI_RENDER, callback);
    }

    // Internal helper to bind AUI events
    fn bind_aui_event<F>(&self, event_type: EventType, mut callback: F)
    where
        F: FnMut(AuiManagerEventData) + 'static,
    {
        self.bind_internal(event_type, move |event| {
            let data = AuiManagerEventData::new(event);
            callback(data);
        });
    }
}