|
|
Sorry I mean't the base class's resize method.
Is there a way to modify posted messages?
On Tuesday, December 14, 2021 at 1:36:36 AM UTC+3 Mo_Al_ wrote:
So the C bindings did call the base class's constructor correctly. It was a mistake in the code example I put. It's actually a bug in fltk-rs. Calling the window's ::default constructor: Window::default().with_size(400, 100)
Actually calls force_position(0), instead of actually just passing 0 for x and y. This causes the window to ignore the x and y when reshown. So in fltk-rs, creating a window using Window::new(x, y, w, h, label) doesn't exhibit this behavior.
Mark, can you pull the latest changes using cargo update then rebuilding. You either have to give your form an initial x and y positions, otherwise you need to call form.force_position(true) before calling set_pos() or resize().
On Tuesday, December 14, 2021 at 12:48:44 AM UTC+3 Albrecht Schlosser wrote:
On 12/13/21 9:57 PM Mo_Al_ wrote:
make_modal() just calls Fl_Window::set_modal and set_non_modal
depending on the flag.
I think Mark's program can be translated into this in C++:
Thanks!
If this is a correct transcription, then only one statement is
missing. The virtual resize() method must call the resize() method
of the base class (Fl_Window). See below.
#include <FL/Enumerations.H> #include <FL/Fl.H> #include <FL/Fl_Window.H> #include <FL/Fl_Button.H>
static int last_x = 0; static int last_y = 0;
struct Form: public Fl_Window { Form(int x, int y, int w, int h, const char *label): Fl_Window(x, y, w, h, label) {} virtual void resize(int x, int y, int w, int h) override {
Fl_Window::resize(x, y, w, h); // ADD THIS HERE
last_x = x; last_y = y; printf("last pos: %d %d\n", last_x, last_y); } void show_again() { printf("shown again at: %d %d\n", last_x, last_y); show(); resize(last_x, last_y, w(), h()); } };
void btn_cb(Fl_Widget *w, void *data) { auto form = (Form *)data; form->show_again(); }
int main(int argc, char **argv) { auto win = new Fl_Window(400, 300, "Main Win"); auto btn = new Fl_Button(160, 200, 80, 30, "Show"); win->end(); win->show();
auto form = new Form(100, 100, 200, 100, "Form"); form->show(); btn->callback(btn_cb, form); return Fl::run(); }
I would however suggest to store the current position (only) when
the window is actually hidden. The attached file x.cxx shows both
ways, the "original" and the one which stores the position when the
window is hidden if you
(instead of 0)
Yet another way might be to use the callback of the Fl_Window class
which is called when the user clicks the close button. In that case
you'd have to call hide() explicitly after storing the coordinates.
Since the callback is not a class method it you require write access
to last_x and last_y which is a given for a struct but might not be
true for a class unless declared public or using an accessor method.
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/e587c567-0126-42e8-ac9c-1acb8fa97c5fn%40googlegroups.com.
[ Direct Link to Message ] | |
|
| |