Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
365732b5d4 |
+26
-6
@@ -1,6 +1,6 @@
|
|||||||
--- a/cpp_src/widgets_bridge.cpp
|
--- a/cpp_src/widgets_bridge.cpp
|
||||||
+++ b/cpp_src/widgets_bridge.cpp
|
+++ b/cpp_src/widgets_bridge.cpp
|
||||||
@@ -0,0 +1,989 @@
|
@@ -0,0 +1,1009 @@
|
||||||
+// widgets_bridge.cpp — alkane-toolkit extension to wx-rs
|
+// widgets_bridge.cpp — alkane-toolkit extension to wx-rs
|
||||||
+// Adds the widget/event surface the toolkit UI needs on top of the upstream
|
+// Adds the widget/event surface the toolkit UI needs on top of the upstream
|
||||||
+// render-callback bridge (which is kept untouched).
|
+// render-callback bridge (which is kept untouched).
|
||||||
@@ -36,12 +36,21 @@
|
|||||||
+#include <cstdio>
|
+#include <cstdio>
|
||||||
+#include <map>
|
+#include <map>
|
||||||
+#include <vector>
|
+#include <vector>
|
||||||
|
+#ifdef __WXGTK__
|
||||||
|
+// For native GtkTreeView rubber-band (click-drag) selection, which wx does not
|
||||||
|
+// enable and which cannot be done via wx mouse events on GTK (the native widget
|
||||||
|
+// grabs the pointer during a drag). Guarded so non-GTK builds are unaffected.
|
||||||
|
+#include <gtk/gtk.h>
|
||||||
|
+#endif
|
||||||
+
|
+
|
||||||
+typedef void (*WxWidgetEventFn)(int kind, long p1, long p2);
|
+typedef void (*WxWidgetEventFn)(int kind, long p1, long p2);
|
||||||
+static WxWidgetEventFn g_widget_event = nullptr;
|
+static WxWidgetEventFn g_widget_event = nullptr;
|
||||||
+
|
+
|
||||||
+// Anchor row per data-view control for rubber-band (click-drag) range select.
|
+#ifndef __WXGTK__
|
||||||
|
+// Anchor row per data-view control for the wx-mouse-event rubber-band fallback
|
||||||
|
+// (non-GTK platforms; GTK uses native GtkTreeView rubber-banding instead).
|
||||||
+static std::map<wxDataViewCtrl*, int> g_drag_anchor;
|
+static std::map<wxDataViewCtrl*, int> g_drag_anchor;
|
||||||
|
+#endif
|
||||||
+
|
+
|
||||||
+// Event kinds (must match Rust WxEventKind in src/widgets.rs)
|
+// Event kinds (must match Rust WxEventKind in src/widgets.rs)
|
||||||
+enum WxWidgetEventKind {
|
+enum WxWidgetEventKind {
|
||||||
@@ -490,10 +499,20 @@
|
|||||||
+ dv->Bind(wxEVT_DATAVIEW_COLUMN_REORDERED, [](wxDataViewEvent&) {
|
+ dv->Bind(wxEVT_DATAVIEW_COLUMN_REORDERED, [](wxDataViewEvent&) {
|
||||||
+ if (g_widget_event) g_widget_event(WxEV_DVLC_REORDERED, 0, 0);
|
+ if (g_widget_event) g_widget_event(WxEV_DVLC_REORDERED, 0, 0);
|
||||||
+ });
|
+ });
|
||||||
+ // Rubber-band (click-drag) range selection: wxDataViewCtrl has none natively
|
+ // Rubber-band (click-drag) range selection. wxDataViewCtrl has none natively.
|
||||||
+ // (only ctrl/shift-click), so track it here. LEFT_DOWN records the anchor row
|
+#ifdef __WXGTK__
|
||||||
+ // (and lets the native handler select it); dragging with the button down
|
+ // On GTK the control wraps a GtkTreeView, which supports native rubber-band
|
||||||
+ // extends the selection to the row under the cursor.
|
+ // selection -- just not enabled by wx. Enable it directly. (wx delivers no
|
||||||
|
+ // MOTION events during the native drag, so the mouse-event fallback below is
|
||||||
|
+ // inapplicable on GTK.)
|
||||||
|
+ {
|
||||||
|
+ GtkWidget* tv = dv->GtkGetTreeView();
|
||||||
|
+ if (tv) gtk_tree_view_set_rubber_banding(GTK_TREE_VIEW(tv), TRUE);
|
||||||
|
+ }
|
||||||
|
+#else
|
||||||
|
+ // Non-GTK fallback: track a drag anchor and extend the selection to the row
|
||||||
|
+ // under the cursor. LEFT_DOWN records the anchor (and lets the native handler
|
||||||
|
+ // select it); dragging with the button down selects the inclusive range.
|
||||||
+ dv->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent& e) {
|
+ dv->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent& e) {
|
||||||
+ wxDataViewCtrl* dv = (wxDataViewCtrl*)e.GetEventObject();
|
+ wxDataViewCtrl* dv = (wxDataViewCtrl*)e.GetEventObject();
|
||||||
+ if (!dv) { e.Skip(); return; }
|
+ if (!dv) { e.Skip(); return; }
|
||||||
@@ -534,6 +553,7 @@
|
|||||||
+ if (dv) g_drag_anchor.erase(dv);
|
+ if (dv) g_drag_anchor.erase(dv);
|
||||||
+ e.Skip();
|
+ e.Skip();
|
||||||
+ });
|
+ });
|
||||||
|
+#endif
|
||||||
+ // Row activation (double-click / Enter): report the row + column so the app
|
+ // Row activation (double-click / Enter): report the row + column so the app
|
||||||
+ // can, e.g., open the miner's IP in a browser.
|
+ // can, e.g., open the miner's IP in a browser.
|
||||||
+ dv->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, [](wxDataViewEvent& e) {
|
+ dv->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, [](wxDataViewEvent& e) {
|
||||||
|
|||||||
@@ -33,12 +33,21 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
// For native GtkTreeView rubber-band (click-drag) selection, which wx does not
|
||||||
|
// enable and which cannot be done via wx mouse events on GTK (the native widget
|
||||||
|
// grabs the pointer during a drag). Guarded so non-GTK builds are unaffected.
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef void (*WxWidgetEventFn)(int kind, long p1, long p2);
|
typedef void (*WxWidgetEventFn)(int kind, long p1, long p2);
|
||||||
static WxWidgetEventFn g_widget_event = nullptr;
|
static WxWidgetEventFn g_widget_event = nullptr;
|
||||||
|
|
||||||
// Anchor row per data-view control for rubber-band (click-drag) range select.
|
#ifndef __WXGTK__
|
||||||
|
// Anchor row per data-view control for the wx-mouse-event rubber-band fallback
|
||||||
|
// (non-GTK platforms; GTK uses native GtkTreeView rubber-banding instead).
|
||||||
static std::map<wxDataViewCtrl*, int> g_drag_anchor;
|
static std::map<wxDataViewCtrl*, int> g_drag_anchor;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Event kinds (must match Rust WxEventKind in src/widgets.rs)
|
// Event kinds (must match Rust WxEventKind in src/widgets.rs)
|
||||||
enum WxWidgetEventKind {
|
enum WxWidgetEventKind {
|
||||||
@@ -487,10 +496,20 @@ void* wxbr_dvlc(void* parent) {
|
|||||||
dv->Bind(wxEVT_DATAVIEW_COLUMN_REORDERED, [](wxDataViewEvent&) {
|
dv->Bind(wxEVT_DATAVIEW_COLUMN_REORDERED, [](wxDataViewEvent&) {
|
||||||
if (g_widget_event) g_widget_event(WxEV_DVLC_REORDERED, 0, 0);
|
if (g_widget_event) g_widget_event(WxEV_DVLC_REORDERED, 0, 0);
|
||||||
});
|
});
|
||||||
// Rubber-band (click-drag) range selection: wxDataViewCtrl has none natively
|
// Rubber-band (click-drag) range selection. wxDataViewCtrl has none natively.
|
||||||
// (only ctrl/shift-click), so track it here. LEFT_DOWN records the anchor row
|
#ifdef __WXGTK__
|
||||||
// (and lets the native handler select it); dragging with the button down
|
// On GTK the control wraps a GtkTreeView, which supports native rubber-band
|
||||||
// extends the selection to the row under the cursor.
|
// selection -- just not enabled by wx. Enable it directly. (wx delivers no
|
||||||
|
// MOTION events during the native drag, so the mouse-event fallback below is
|
||||||
|
// inapplicable on GTK.)
|
||||||
|
{
|
||||||
|
GtkWidget* tv = dv->GtkGetTreeView();
|
||||||
|
if (tv) gtk_tree_view_set_rubber_banding(GTK_TREE_VIEW(tv), TRUE);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// Non-GTK fallback: track a drag anchor and extend the selection to the row
|
||||||
|
// under the cursor. LEFT_DOWN records the anchor (and lets the native handler
|
||||||
|
// select it); dragging with the button down selects the inclusive range.
|
||||||
dv->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent& e) {
|
dv->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent& e) {
|
||||||
wxDataViewCtrl* dv = (wxDataViewCtrl*)e.GetEventObject();
|
wxDataViewCtrl* dv = (wxDataViewCtrl*)e.GetEventObject();
|
||||||
if (!dv) { e.Skip(); return; }
|
if (!dv) { e.Skip(); return; }
|
||||||
@@ -531,6 +550,7 @@ void* wxbr_dvlc(void* parent) {
|
|||||||
if (dv) g_drag_anchor.erase(dv);
|
if (dv) g_drag_anchor.erase(dv);
|
||||||
e.Skip();
|
e.Skip();
|
||||||
});
|
});
|
||||||
|
#endif
|
||||||
// Row activation (double-click / Enter): report the row + column so the app
|
// Row activation (double-click / Enter): report the row + column so the app
|
||||||
// can, e.g., open the miner's IP in a browser.
|
// can, e.g., open the miner's IP in a browser.
|
||||||
dv->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, [](wxDataViewEvent& e) {
|
dv->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, [](wxDataViewEvent& e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user