Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a81fef3c7d | ||
|
|
365732b5d4 |
@@ -694,6 +694,10 @@ impl App {
|
|||||||
_ => continue,
|
_ => continue,
|
||||||
};
|
};
|
||||||
t.dvlc_set_cell(disp, ci, &encoded);
|
t.dvlc_set_cell(disp, ci, &encoded);
|
||||||
|
// The Errors cell gets the full message list as a hover tooltip.
|
||||||
|
if matches!(c, Column::Error) {
|
||||||
|
t.dvlc_set_cell_tooltip(disp, ci, &r.errors.join("\n"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(row) = top {
|
if let Some(row) = top {
|
||||||
|
|||||||
+9
-1
@@ -10,7 +10,7 @@
|
|||||||
+pub use widgets::*;
|
+pub use widgets::*;
|
||||||
--- a/src/widgets.rs
|
--- a/src/widgets.rs
|
||||||
+++ b/src/widgets.rs
|
+++ b/src/widgets.rs
|
||||||
@@ -0,0 +1,720 @@
|
@@ -0,0 +1,728 @@
|
||||||
+// widgets.rs — alkane-toolkit extension: Rust bindings for the widget bridge
|
+// widgets.rs — alkane-toolkit extension: Rust bindings for the widget bridge
|
||||||
+// in cpp_src/widgets_bridge.cpp. Handles are opaque pointers owned by the
|
+// in cpp_src/widgets_bridge.cpp. Handles are opaque pointers owned by the
|
||||||
+// wxWidgets object tree (parents own children; nothing to free in Rust).
|
+// wxWidgets object tree (parents own children; nothing to free in Rust).
|
||||||
@@ -71,6 +71,7 @@
|
|||||||
+ pub fn wxbr_dvlc_clear(win: *mut c_void);
|
+ pub fn wxbr_dvlc_clear(win: *mut c_void);
|
||||||
+ pub fn wxbr_dvlc_row_count(win: *mut c_void) -> c_int;
|
+ pub fn wxbr_dvlc_row_count(win: *mut c_void) -> c_int;
|
||||||
+ pub fn wxbr_dvlc_set_cell(win: *mut c_void, row: usize, col: usize, value: *const c_char);
|
+ pub fn wxbr_dvlc_set_cell(win: *mut c_void, row: usize, col: usize, value: *const c_char);
|
||||||
|
+ pub fn wxbr_dvlc_set_cell_tooltip(win: *mut c_void, row: usize, col: usize, text: *const c_char);
|
||||||
+ pub fn wxbr_dvlc_get_cell(win: *mut c_void, row: usize, col: usize, buf: *mut c_char, cap: c_int) -> c_int;
|
+ pub fn wxbr_dvlc_get_cell(win: *mut c_void, row: usize, col: usize, buf: *mut c_char, cap: c_int) -> c_int;
|
||||||
+ pub fn wxbr_dvlc_col_count(win: *mut c_void) -> c_int;
|
+ pub fn wxbr_dvlc_col_count(win: *mut c_void) -> c_int;
|
||||||
+ pub fn wxbr_dvlc_autosize_col(win: *mut c_void, pos: c_int);
|
+ pub fn wxbr_dvlc_autosize_col(win: *mut c_void, pos: c_int);
|
||||||
@@ -495,6 +496,13 @@
|
|||||||
+ unsafe { notsafe::wxbr_dvlc_set_cell(self.0, row, col, c.as_ptr()) }
|
+ unsafe { notsafe::wxbr_dvlc_set_cell(self.0, row, col, c.as_ptr()) }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ /// Set the hover tooltip for one cell (empty clears it). GTK only; a no-op
|
||||||
|
+ /// on other platforms until they gain per-cell tooltip support.
|
||||||
|
+ pub fn dvlc_set_cell_tooltip(&self, row: usize, col: usize, text: &str) {
|
||||||
|
+ let c = CString::new(text).unwrap_or_default();
|
||||||
|
+ unsafe { notsafe::wxbr_dvlc_set_cell_tooltip(self.0, row, col, c.as_ptr()) }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ pub fn dvlc_get_cell(&self, row: usize, col: usize) -> Option<String> {
|
+ pub fn dvlc_get_cell(&self, row: usize, col: usize) -> Option<String> {
|
||||||
+ let mut buf = vec![0i8; 4096];
|
+ let mut buf = vec![0i8; 4096];
|
||||||
+ let n = unsafe {
|
+ let n = unsafe {
|
||||||
|
|||||||
+76
-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,1059 @@
|
||||||
+// 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 {
|
||||||
@@ -71,6 +80,9 @@
|
|||||||
+ public:
|
+ public:
|
||||||
+ std::vector<wxColour> row_fg;
|
+ std::vector<wxColour> row_fg;
|
||||||
+ wxColour zebra; // odd-row background; unset (=off) unless the app sets it
|
+ wxColour zebra; // odd-row background; unset (=off) unless the app sets it
|
||||||
|
+ // Per-cell hover tooltip text, keyed by (row, model column). Used for the
|
||||||
|
+ // Errors column's full-message tooltip (see the GTK query-tooltip handler).
|
||||||
|
+ std::map<std::pair<unsigned, unsigned>, wxString> cell_tip;
|
||||||
+ bool GetAttrByRow(unsigned int row, unsigned int col,
|
+ bool GetAttrByRow(unsigned int row, unsigned int col,
|
||||||
+ wxDataViewItemAttr& attr) const override {
|
+ wxDataViewItemAttr& attr) const override {
|
||||||
+ (void)col;
|
+ (void)col;
|
||||||
@@ -453,6 +465,36 @@
|
|||||||
+ return static_cast<AttrListStore*>(((wxDataViewCtrl*)win)->GetModel());
|
+ return static_cast<AttrListStore*>(((wxDataViewCtrl*)win)->GetModel());
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
|
+#ifdef __WXGTK__
|
||||||
|
+// GtkTreeView "query-tooltip" handler: show the per-cell tooltip stored for the
|
||||||
|
+// (row, model column) under the pointer (used by the Errors column). wx does
|
||||||
|
+// not surface per-cell tooltips on wxDataViewCtrl, and mouse-motion events are
|
||||||
|
+// not delivered to wx handlers on the native GTK control, so this hooks the
|
||||||
|
+// native signal directly.
|
||||||
|
+static gboolean dvlc_query_tooltip(GtkWidget* tv, gint x, gint y, gboolean keyboard,
|
||||||
|
+ GtkTooltip* tooltip, gpointer user_data) {
|
||||||
|
+ (void)keyboard;
|
||||||
|
+ wxDataViewCtrl* dv = static_cast<wxDataViewCtrl*>(user_data);
|
||||||
|
+ gint bx = 0, by = 0;
|
||||||
|
+ gtk_tree_view_convert_widget_to_bin_window_coords(GTK_TREE_VIEW(tv), x, y, &bx, &by);
|
||||||
|
+ GtkTreePath* path = nullptr;
|
||||||
|
+ GtkTreeViewColumn* gcol = nullptr;
|
||||||
|
+ if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), bx, by, &path, &gcol, nullptr, nullptr))
|
||||||
|
+ return FALSE;
|
||||||
|
+ gint* idx = gtk_tree_path_get_indices(path);
|
||||||
|
+ int row = idx ? idx[0] : -1;
|
||||||
|
+ gtk_tree_path_free(path);
|
||||||
|
+ if (row < 0 || !gcol) return FALSE;
|
||||||
|
+ wxDataViewColumn* wxcol = dv->GTKColumnToWX(gcol);
|
||||||
|
+ if (!wxcol) return FALSE;
|
||||||
|
+ AttrListStore* store = static_cast<AttrListStore*>(dv->GetModel());
|
||||||
|
+ auto it = store->cell_tip.find({(unsigned)row, wxcol->GetModelColumn()});
|
||||||
|
+ if (it == store->cell_tip.end() || it->second.IsEmpty()) return FALSE;
|
||||||
|
+ gtk_tooltip_set_text(tooltip, it->second.utf8_str());
|
||||||
|
+ return TRUE;
|
||||||
|
+}
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
+void* wxbr_dvlc(void* parent) {
|
+void* wxbr_dvlc(void* parent) {
|
||||||
+ // Multi-select (ctrl/shift-click) + row lines. Selection replaces the old
|
+ // Multi-select (ctrl/shift-click) + row lines. Selection replaces the old
|
||||||
+ // checkbox column. A custom AttrListStore backs it so rows can be coloured by
|
+ // checkbox column. A custom AttrListStore backs it so rows can be coloured by
|
||||||
@@ -490,10 +532,25 @@
|
|||||||
+ 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);
|
||||||
|
+ // Per-cell hover tooltips (Errors column) via the native signal.
|
||||||
|
+ gtk_widget_set_has_tooltip(tv, TRUE);
|
||||||
|
+ g_signal_connect(tv, "query-tooltip", G_CALLBACK(dvlc_query_tooltip), dv);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+#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 +591,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) {
|
||||||
@@ -605,6 +663,18 @@
|
|||||||
+ AttrListStore* store = dvlc_store(win);
|
+ AttrListStore* store = dvlc_store(win);
|
||||||
+ store->DeleteAllItems();
|
+ store->DeleteAllItems();
|
||||||
+ store->row_fg.clear();
|
+ store->row_fg.clear();
|
||||||
|
+ store->cell_tip.clear();
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+// Set (or clear, with an empty string) the hover tooltip for one cell,
|
||||||
|
+// addressed by (row, model column). Used for the Errors column's full text.
|
||||||
|
+void wxbr_dvlc_set_cell_tooltip(void* win, unsigned row, unsigned col, const char* text) {
|
||||||
|
+ AttrListStore* store = dvlc_store(win);
|
||||||
|
+ if (text && text[0]) {
|
||||||
|
+ store->cell_tip[{row, col}] = wxString::FromUTF8(text);
|
||||||
|
+ } else {
|
||||||
|
+ store->cell_tip.erase({row, col});
|
||||||
|
+ }
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+// Set (or clear, when r<0) a row's text colour; used to paint rows by status.
|
+// Set (or clear, when r<0) a row's text colour; used to paint rows by status.
|
||||||
|
|||||||
@@ -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 {
|
||||||
@@ -68,6 +77,9 @@ class AttrListStore : public wxDataViewListStore {
|
|||||||
public:
|
public:
|
||||||
std::vector<wxColour> row_fg;
|
std::vector<wxColour> row_fg;
|
||||||
wxColour zebra; // odd-row background; unset (=off) unless the app sets it
|
wxColour zebra; // odd-row background; unset (=off) unless the app sets it
|
||||||
|
// Per-cell hover tooltip text, keyed by (row, model column). Used for the
|
||||||
|
// Errors column's full-message tooltip (see the GTK query-tooltip handler).
|
||||||
|
std::map<std::pair<unsigned, unsigned>, wxString> cell_tip;
|
||||||
bool GetAttrByRow(unsigned int row, unsigned int col,
|
bool GetAttrByRow(unsigned int row, unsigned int col,
|
||||||
wxDataViewItemAttr& attr) const override {
|
wxDataViewItemAttr& attr) const override {
|
||||||
(void)col;
|
(void)col;
|
||||||
@@ -450,6 +462,36 @@ static AttrListStore* dvlc_store(void* win) {
|
|||||||
return static_cast<AttrListStore*>(((wxDataViewCtrl*)win)->GetModel());
|
return static_cast<AttrListStore*>(((wxDataViewCtrl*)win)->GetModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
// GtkTreeView "query-tooltip" handler: show the per-cell tooltip stored for the
|
||||||
|
// (row, model column) under the pointer (used by the Errors column). wx does
|
||||||
|
// not surface per-cell tooltips on wxDataViewCtrl, and mouse-motion events are
|
||||||
|
// not delivered to wx handlers on the native GTK control, so this hooks the
|
||||||
|
// native signal directly.
|
||||||
|
static gboolean dvlc_query_tooltip(GtkWidget* tv, gint x, gint y, gboolean keyboard,
|
||||||
|
GtkTooltip* tooltip, gpointer user_data) {
|
||||||
|
(void)keyboard;
|
||||||
|
wxDataViewCtrl* dv = static_cast<wxDataViewCtrl*>(user_data);
|
||||||
|
gint bx = 0, by = 0;
|
||||||
|
gtk_tree_view_convert_widget_to_bin_window_coords(GTK_TREE_VIEW(tv), x, y, &bx, &by);
|
||||||
|
GtkTreePath* path = nullptr;
|
||||||
|
GtkTreeViewColumn* gcol = nullptr;
|
||||||
|
if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), bx, by, &path, &gcol, nullptr, nullptr))
|
||||||
|
return FALSE;
|
||||||
|
gint* idx = gtk_tree_path_get_indices(path);
|
||||||
|
int row = idx ? idx[0] : -1;
|
||||||
|
gtk_tree_path_free(path);
|
||||||
|
if (row < 0 || !gcol) return FALSE;
|
||||||
|
wxDataViewColumn* wxcol = dv->GTKColumnToWX(gcol);
|
||||||
|
if (!wxcol) return FALSE;
|
||||||
|
AttrListStore* store = static_cast<AttrListStore*>(dv->GetModel());
|
||||||
|
auto it = store->cell_tip.find({(unsigned)row, wxcol->GetModelColumn()});
|
||||||
|
if (it == store->cell_tip.end() || it->second.IsEmpty()) return FALSE;
|
||||||
|
gtk_tooltip_set_text(tooltip, it->second.utf8_str());
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void* wxbr_dvlc(void* parent) {
|
void* wxbr_dvlc(void* parent) {
|
||||||
// Multi-select (ctrl/shift-click) + row lines. Selection replaces the old
|
// Multi-select (ctrl/shift-click) + row lines. Selection replaces the old
|
||||||
// checkbox column. A custom AttrListStore backs it so rows can be coloured by
|
// checkbox column. A custom AttrListStore backs it so rows can be coloured by
|
||||||
@@ -487,10 +529,25 @@ 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);
|
||||||
|
// Per-cell hover tooltips (Errors column) via the native signal.
|
||||||
|
gtk_widget_set_has_tooltip(tv, TRUE);
|
||||||
|
g_signal_connect(tv, "query-tooltip", G_CALLBACK(dvlc_query_tooltip), dv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#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 +588,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) {
|
||||||
@@ -602,6 +660,18 @@ void wxbr_dvlc_clear(void* win) {
|
|||||||
AttrListStore* store = dvlc_store(win);
|
AttrListStore* store = dvlc_store(win);
|
||||||
store->DeleteAllItems();
|
store->DeleteAllItems();
|
||||||
store->row_fg.clear();
|
store->row_fg.clear();
|
||||||
|
store->cell_tip.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set (or clear, with an empty string) the hover tooltip for one cell,
|
||||||
|
// addressed by (row, model column). Used for the Errors column's full text.
|
||||||
|
void wxbr_dvlc_set_cell_tooltip(void* win, unsigned row, unsigned col, const char* text) {
|
||||||
|
AttrListStore* store = dvlc_store(win);
|
||||||
|
if (text && text[0]) {
|
||||||
|
store->cell_tip[{row, col}] = wxString::FromUTF8(text);
|
||||||
|
} else {
|
||||||
|
store->cell_tip.erase({row, col});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set (or clear, when r<0) a row's text colour; used to paint rows by status.
|
// Set (or clear, when r<0) a row's text colour; used to paint rows by status.
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ mod notsafe {
|
|||||||
pub fn wxbr_dvlc_clear(win: *mut c_void);
|
pub fn wxbr_dvlc_clear(win: *mut c_void);
|
||||||
pub fn wxbr_dvlc_row_count(win: *mut c_void) -> c_int;
|
pub fn wxbr_dvlc_row_count(win: *mut c_void) -> c_int;
|
||||||
pub fn wxbr_dvlc_set_cell(win: *mut c_void, row: usize, col: usize, value: *const c_char);
|
pub fn wxbr_dvlc_set_cell(win: *mut c_void, row: usize, col: usize, value: *const c_char);
|
||||||
|
pub fn wxbr_dvlc_set_cell_tooltip(win: *mut c_void, row: usize, col: usize, text: *const c_char);
|
||||||
pub fn wxbr_dvlc_get_cell(win: *mut c_void, row: usize, col: usize, buf: *mut c_char, cap: c_int) -> c_int;
|
pub fn wxbr_dvlc_get_cell(win: *mut c_void, row: usize, col: usize, buf: *mut c_char, cap: c_int) -> c_int;
|
||||||
pub fn wxbr_dvlc_col_count(win: *mut c_void) -> c_int;
|
pub fn wxbr_dvlc_col_count(win: *mut c_void) -> c_int;
|
||||||
pub fn wxbr_dvlc_autosize_col(win: *mut c_void, pos: c_int);
|
pub fn wxbr_dvlc_autosize_col(win: *mut c_void, pos: c_int);
|
||||||
@@ -482,6 +483,13 @@ impl Widget {
|
|||||||
unsafe { notsafe::wxbr_dvlc_set_cell(self.0, row, col, c.as_ptr()) }
|
unsafe { notsafe::wxbr_dvlc_set_cell(self.0, row, col, c.as_ptr()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the hover tooltip for one cell (empty clears it). GTK only; a no-op
|
||||||
|
/// on other platforms until they gain per-cell tooltip support.
|
||||||
|
pub fn dvlc_set_cell_tooltip(&self, row: usize, col: usize, text: &str) {
|
||||||
|
let c = CString::new(text).unwrap_or_default();
|
||||||
|
unsafe { notsafe::wxbr_dvlc_set_cell_tooltip(self.0, row, col, c.as_ptr()) }
|
||||||
|
}
|
||||||
|
|
||||||
pub fn dvlc_get_cell(&self, row: usize, col: usize) -> Option<String> {
|
pub fn dvlc_get_cell(&self, row: usize, col: usize) -> Option<String> {
|
||||||
let mut buf = vec![0i8; 4096];
|
let mut buf = vec![0i8; 4096];
|
||||||
let n = unsafe {
|
let n = unsafe {
|
||||||
|
|||||||
Reference in New Issue
Block a user