Last active
December 10, 2015 18:58
-
-
Save cjameshuff/4478672 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdlib> | |
#include <FL/Fl.H> | |
#include <FL/Fl_Window.H> | |
#include <FL/Fl_Box.H> | |
#include <FL/Fl_Button.H> | |
#include <FL/Fl_Text_Display.H> | |
#include <FL/Fl_Multiline_Input.H> | |
using namespace std; | |
Fl_Window * window; | |
Fl_Window * subwindow; | |
// #define ADD_REMOVE | |
#ifdef ADD_REMOVE | |
// Add/remove subwindow | |
// The console appears properly the first time, and is removed properly. | |
// On subsequent activations, the console remains invisible after show until window is resized. | |
static void ShowCB(Fl_Widget * widget, void * data) { | |
window->add(subwindow); | |
subwindow->show(); | |
// subwindow->redraw(); | |
window->redraw(); | |
} | |
static void HideCB(Fl_Widget * widget, void * data) { | |
subwindow->hide(); | |
// subwindow->redraw(); | |
window->remove(subwindow); | |
window->redraw(); | |
} | |
#else | |
// Show/hide subwindow | |
// Console remains invisible after show until window is resized. | |
// Hide works as expected. | |
static void ShowCB(Fl_Widget * widget, void * data) { | |
subwindow->show(); | |
window->redraw(); | |
} | |
static void HideCB(Fl_Widget * widget, void * data) { | |
subwindow->hide(); | |
window->redraw(); | |
} | |
#endif | |
int main(int argc, char * argv[]) | |
{ | |
Fl_Button * button; | |
{ | |
subwindow = new Fl_Window(0, 360, 512, 360); | |
subwindow->resizable(subwindow); | |
int hmargin = 30; | |
int vmargin = 20; | |
int w = subwindow->w() - hmargin*2; | |
int h = 20; | |
int x = hmargin; | |
int y = 20; | |
h = subwindow->h() - 20 - vmargin*2; | |
Fl_Text_Display * display = new Fl_Text_Display(x, y, w, h); | |
display->buffer(new Fl_Text_Buffer()); | |
y += h; | |
h = 20; | |
Fl_Multiline_Input * input = new Fl_Multiline_Input(x, y, w, h); | |
subwindow->end(); | |
} | |
{ | |
window = new Fl_Window(512, 720); | |
window->resizable(window); | |
int hmargin = 30; | |
int w = window->w() - hmargin*2; | |
int h = 20; | |
int ym = 10; | |
int x = hmargin; | |
int y = 150; | |
button = new Fl_Button(x, y, w, h, "Show console"); | |
y += h + ym; | |
button->callback(ShowCB); | |
button = new Fl_Button(x, y, w, h, "Hide console"); | |
y += h + ym; | |
button->callback(HideCB); | |
#ifndef ADD_REMOVE | |
window->add(subwindow); | |
subwindow->hide(); | |
#endif | |
window->end(); | |
} | |
window->show(argc, argv); | |
return Fl::run(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment