/** * Copyright Mikael Högdahl - triyana@users.sourceforge.net * * This source is distributed under the terms of the Q Public License version 1.0, * created by Trolltech (www.trolltech.com). */ #include "Fl_Dialog.h" #include #include #include /** * */ Fl_Dialog::Fl_Dialog (int x, int y, int w, int h, const char* s) : Fl_Double_Window (w, h, s) { aW = w; aH = h; } /** * */ Fl_Dialog::Fl_Dialog (int w, int h, const char* s) : Fl_Double_Window (w, h, s) { aW = w; aH = h; } /** * Catch quitting with window manager quit button */ void Fl_Dialog::cb66() { aRetVal = 0; } /** * If cancel is pressed stop the dialog loop which returns to the caller of show_modal */ int Fl_Dialog::handle (int event) { //printf ("%d\n", event); if (1==2 && event == FL_KEYDOWN && Fl::event_key() == FL_Escape) { aRetVal = 0; return 1; } else return Fl_Window::handle (event); } /** * Ugly fix for resize bugg */ void Fl_Dialog::resize (int x, int y, int w, int h) { Fl_Window::resize (x, y, aW, aH); } /** * Show dialog and process events * Do not return until loop breaks by user event */ int Fl_Dialog::show_modal (Fl_Window* parent) { callback(Fl_Dialog::cb66_, this); aRetVal = -1; set_modal(); if (parent) position (parent->x() + (parent->w() / 2) - (w() / 2), parent->y() + (parent->h() / 2) - (h() / 2)); resize (x(), y(), aW, aH); show (); while (aRetVal == -1) Fl::wait (); hide(); return aRetVal; } /** * Show dialog */ void Fl_Dialog::show_modal2 (Fl_Window* parent) { aRetVal = -1; set_modal(); if (parent) position (parent->x() + (parent->w() / 2) - (w() / 2), parent->y() + (parent->h() / 2) - (h() / 2)); resize (x(), y(), aW, aH); show (); }