Subject: [PATCH 0012] linux: word-wrapping multiline text control --- a/cpp_src/widgets_bridge.cpp +++ b/cpp_src/widgets_bridge.cpp @@ -890,6 +890,15 @@ wxDefaultPosition, wxSize(-1, -1), style); } +// A multiline text control that word-wraps at the control's width instead of +// scrolling horizontally (no wxTE_DONTWRAP). For prose entry such as the bug +// report box, where long lines should wrap rather than run off the edge. +void* wxbr_text_ctrl_wrap(void* parent) { + return (void*)new wxTextCtrl((wxWindow*)parent, wxID_ANY, wxT(""), + wxDefaultPosition, wxSize(-1, -1), + wxTE_MULTILINE | wxTE_BESTWRAP); +} + // A single-line text control that masks its content (wxTE_PASSWORD), for secret // entry so a saved password is never rendered in the clear (round 18 #12). void* wxbr_text_ctrl_password(void* parent) { --- a/src/widgets.rs +++ b/src/widgets.rs @@ -41,6 +41,7 @@ pub fn wxbr_button(parent: *mut c_void, label: *const c_char, id: c_int) -> *mut c_void; pub fn wxbr_bind_click(win: *mut c_void, id: c_int); pub fn wxbr_text_ctrl(parent: *mut c_void, multiline: c_int) -> *mut c_void; + pub fn wxbr_text_ctrl_wrap(parent: *mut c_void) -> *mut c_void; pub fn wxbr_text_ctrl_password(parent: *mut c_void) -> *mut c_void; pub fn wxbr_text_ctrl_get(win: *mut c_void, buf: *mut c_char, cap: c_int) -> c_int; pub fn wxbr_text_ctrl_set(win: *mut c_void, value: *const c_char); @@ -463,6 +464,12 @@ Widget(unsafe { notsafe::wxbr_text_ctrl(parent.0, multiline as c_int) }) } + /// A multiline text control that word-wraps at its width (no horizontal + /// scroll), for prose entry such as the bug-report box. + pub fn text_ctrl_wrapped(parent: Widget) -> Widget { + Widget(unsafe { notsafe::wxbr_text_ctrl_wrap(parent.0) }) + } + /// A single-line text control that masks its content (for password entry). pub fn password_ctrl(parent: Widget) -> Widget { Widget(unsafe { notsafe::wxbr_text_ctrl_password(parent.0) })