Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7a77cbed8 |
+50
-3
@@ -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,1413 @@
|
@@ -0,0 +1,1460 @@
|
||||||
+// 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).
|
||||||
@@ -552,12 +552,31 @@
|
|||||||
+// ---- check list box ---------------------------------------------------------
|
+// ---- check list box ---------------------------------------------------------
|
||||||
+
|
+
|
||||||
+void* wxbr_check_list_box(void* parent) {
|
+void* wxbr_check_list_box(void* parent) {
|
||||||
|
+ // wxLB_EXTENDED so several rows can be selected at once (ctrl/shift-click and
|
||||||
|
+ // rubber-band drag, native to wxListBox); a checkbox toggle on any selected
|
||||||
|
+ // row then applies to every selected row (see the handler below). This is the
|
||||||
|
+ // Excel-style batch-check the filter menu needs (round 12 #7).
|
||||||
+ wxCheckListBox* clb = new wxCheckListBox((wxWindow*)parent, wxID_ANY,
|
+ wxCheckListBox* clb = new wxCheckListBox((wxWindow*)parent, wxID_ANY,
|
||||||
+ wxDefaultPosition, wxSize(-1, -1),
|
+ wxDefaultPosition, wxSize(-1, -1),
|
||||||
+ 0, NULL, wxLB_SINGLE | wxLB_NEEDED_SB);
|
+ 0, NULL, wxLB_EXTENDED | wxLB_NEEDED_SB);
|
||||||
+ clb->Bind(wxEVT_CHECKLISTBOX, [clb](wxCommandEvent& e) {
|
+ clb->Bind(wxEVT_CHECKLISTBOX, [clb](wxCommandEvent& e) {
|
||||||
|
+ int idx = e.GetInt();
|
||||||
|
+ // Batch toggle: if the clicked row is part of a multi-row selection, give
|
||||||
|
+ // every selected row the clicked row's new state. Check() does not itself
|
||||||
|
+ // fire wxEVT_CHECKLISTBOX, so there is no recursion.
|
||||||
|
+ wxArrayInt sel;
|
||||||
|
+ clb->GetSelections(sel);
|
||||||
|
+ if (sel.GetCount() > 1) {
|
||||||
|
+ bool inSel = false;
|
||||||
|
+ for (size_t i = 0; i < sel.GetCount(); i++)
|
||||||
|
+ if (sel[i] == idx) { inSel = true; break; }
|
||||||
|
+ if (inSel) {
|
||||||
|
+ bool state = clb->IsChecked(idx);
|
||||||
|
+ for (size_t i = 0; i < sel.GetCount(); i++) clb->Check(sel[i], state);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
+ if (g_widget_event)
|
+ if (g_widget_event)
|
||||||
+ g_widget_event(WxEV_CLB_TOGGLED, (long)(intptr_t)clb, e.GetInt());
|
+ g_widget_event(WxEV_CLB_TOGGLED, (long)(intptr_t)clb, idx);
|
||||||
+ });
|
+ });
|
||||||
+ return (void*)clb;
|
+ return (void*)clb;
|
||||||
+}
|
+}
|
||||||
@@ -1155,6 +1174,34 @@
|
|||||||
+ lc->SetItemData(row, (long)idx);
|
+ lc->SetItemData(row, (long)idx);
|
||||||
+ lc->CheckItem(row, enc >= 0);
|
+ lc->CheckItem(row, enc >= 0);
|
||||||
+ }
|
+ }
|
||||||
|
+ // Batch checkbox toggle: checking/unchecking a row that is part of a
|
||||||
|
+ // multi-row selection applies the same state to every selected row, so the
|
||||||
|
+ // user can ctrl/shift-click several columns and show/hide them together
|
||||||
|
+ // (round 12 #7). CheckItem() re-enters this handler, so guard against it.
|
||||||
|
+ auto batchCheck = [lc](long item, bool state) {
|
||||||
|
+ static bool busy = false;
|
||||||
|
+ if (busy) return;
|
||||||
|
+ if (!(lc->GetItemState(item, wxLIST_STATE_SELECTED) & wxLIST_STATE_SELECTED))
|
||||||
|
+ return;
|
||||||
|
+ wxVector<long> sel;
|
||||||
|
+ long it = -1;
|
||||||
|
+ for (;;) {
|
||||||
|
+ it = lc->GetNextItem(it, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||||
|
+ if (it == -1) break;
|
||||||
|
+ sel.push_back(it);
|
||||||
|
+ }
|
||||||
|
+ if (sel.size() <= 1) return;
|
||||||
|
+ busy = true;
|
||||||
|
+ for (size_t i = 0; i < sel.size(); i++)
|
||||||
|
+ if (sel[i] != item) lc->CheckItem(sel[i], state);
|
||||||
|
+ busy = false;
|
||||||
|
+ };
|
||||||
|
+ lc->Bind(wxEVT_LIST_ITEM_CHECKED, [batchCheck](wxListEvent& e) {
|
||||||
|
+ batchCheck(e.GetIndex(), true);
|
||||||
|
+ });
|
||||||
|
+ lc->Bind(wxEVT_LIST_ITEM_UNCHECKED, [batchCheck](wxListEvent& e) {
|
||||||
|
+ batchCheck(e.GetIndex(), false);
|
||||||
|
+ });
|
||||||
+ lc->Bind(wxEVT_LIST_BEGIN_DRAG, [lc](wxListEvent&) {
|
+ lc->Bind(wxEVT_LIST_BEGIN_DRAG, [lc](wxListEvent&) {
|
||||||
+ g_reorder_drag.clear();
|
+ g_reorder_drag.clear();
|
||||||
+ g_reorder_list = lc;
|
+ g_reorder_list = lc;
|
||||||
|
|||||||
@@ -549,12 +549,31 @@ void wxbr_check_box_set(void* win, int v) {
|
|||||||
// ---- check list box ---------------------------------------------------------
|
// ---- check list box ---------------------------------------------------------
|
||||||
|
|
||||||
void* wxbr_check_list_box(void* parent) {
|
void* wxbr_check_list_box(void* parent) {
|
||||||
|
// wxLB_EXTENDED so several rows can be selected at once (ctrl/shift-click and
|
||||||
|
// rubber-band drag, native to wxListBox); a checkbox toggle on any selected
|
||||||
|
// row then applies to every selected row (see the handler below). This is the
|
||||||
|
// Excel-style batch-check the filter menu needs (round 12 #7).
|
||||||
wxCheckListBox* clb = new wxCheckListBox((wxWindow*)parent, wxID_ANY,
|
wxCheckListBox* clb = new wxCheckListBox((wxWindow*)parent, wxID_ANY,
|
||||||
wxDefaultPosition, wxSize(-1, -1),
|
wxDefaultPosition, wxSize(-1, -1),
|
||||||
0, NULL, wxLB_SINGLE | wxLB_NEEDED_SB);
|
0, NULL, wxLB_EXTENDED | wxLB_NEEDED_SB);
|
||||||
clb->Bind(wxEVT_CHECKLISTBOX, [clb](wxCommandEvent& e) {
|
clb->Bind(wxEVT_CHECKLISTBOX, [clb](wxCommandEvent& e) {
|
||||||
|
int idx = e.GetInt();
|
||||||
|
// Batch toggle: if the clicked row is part of a multi-row selection, give
|
||||||
|
// every selected row the clicked row's new state. Check() does not itself
|
||||||
|
// fire wxEVT_CHECKLISTBOX, so there is no recursion.
|
||||||
|
wxArrayInt sel;
|
||||||
|
clb->GetSelections(sel);
|
||||||
|
if (sel.GetCount() > 1) {
|
||||||
|
bool inSel = false;
|
||||||
|
for (size_t i = 0; i < sel.GetCount(); i++)
|
||||||
|
if (sel[i] == idx) { inSel = true; break; }
|
||||||
|
if (inSel) {
|
||||||
|
bool state = clb->IsChecked(idx);
|
||||||
|
for (size_t i = 0; i < sel.GetCount(); i++) clb->Check(sel[i], state);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (g_widget_event)
|
if (g_widget_event)
|
||||||
g_widget_event(WxEV_CLB_TOGGLED, (long)(intptr_t)clb, e.GetInt());
|
g_widget_event(WxEV_CLB_TOGGLED, (long)(intptr_t)clb, idx);
|
||||||
});
|
});
|
||||||
return (void*)clb;
|
return (void*)clb;
|
||||||
}
|
}
|
||||||
@@ -1152,6 +1171,34 @@ void* wxbr_reorder_list(void* parent, int n, const int* order, const char** item
|
|||||||
lc->SetItemData(row, (long)idx);
|
lc->SetItemData(row, (long)idx);
|
||||||
lc->CheckItem(row, enc >= 0);
|
lc->CheckItem(row, enc >= 0);
|
||||||
}
|
}
|
||||||
|
// Batch checkbox toggle: checking/unchecking a row that is part of a
|
||||||
|
// multi-row selection applies the same state to every selected row, so the
|
||||||
|
// user can ctrl/shift-click several columns and show/hide them together
|
||||||
|
// (round 12 #7). CheckItem() re-enters this handler, so guard against it.
|
||||||
|
auto batchCheck = [lc](long item, bool state) {
|
||||||
|
static bool busy = false;
|
||||||
|
if (busy) return;
|
||||||
|
if (!(lc->GetItemState(item, wxLIST_STATE_SELECTED) & wxLIST_STATE_SELECTED))
|
||||||
|
return;
|
||||||
|
wxVector<long> sel;
|
||||||
|
long it = -1;
|
||||||
|
for (;;) {
|
||||||
|
it = lc->GetNextItem(it, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||||
|
if (it == -1) break;
|
||||||
|
sel.push_back(it);
|
||||||
|
}
|
||||||
|
if (sel.size() <= 1) return;
|
||||||
|
busy = true;
|
||||||
|
for (size_t i = 0; i < sel.size(); i++)
|
||||||
|
if (sel[i] != item) lc->CheckItem(sel[i], state);
|
||||||
|
busy = false;
|
||||||
|
};
|
||||||
|
lc->Bind(wxEVT_LIST_ITEM_CHECKED, [batchCheck](wxListEvent& e) {
|
||||||
|
batchCheck(e.GetIndex(), true);
|
||||||
|
});
|
||||||
|
lc->Bind(wxEVT_LIST_ITEM_UNCHECKED, [batchCheck](wxListEvent& e) {
|
||||||
|
batchCheck(e.GetIndex(), false);
|
||||||
|
});
|
||||||
lc->Bind(wxEVT_LIST_BEGIN_DRAG, [lc](wxListEvent&) {
|
lc->Bind(wxEVT_LIST_BEGIN_DRAG, [lc](wxListEvent&) {
|
||||||
g_reorder_drag.clear();
|
g_reorder_drag.clear();
|
||||||
g_reorder_list = lc;
|
g_reorder_list = lc;
|
||||||
|
|||||||
Reference in New Issue
Block a user