dialog.cpp revision 86a54db20793c3e93ddec04e6438b32c0535594f
/**
* \brief Base class for dialogs in Inkscape. This class provides certain
* common behaviors and styles wanted of all dialogs in the application.
*
* Authors:
* Bryce W. Harrington <bryce@bryceharrington.org>
* buliabyak@gmail.com
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
* Gustav Broberg <broberg@kth.se>
*
* Copyright (C) 2004--2007 Authors
*
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gdk/gdkkeysyms.h>
#include "application/application.h"
#include "application/editor.h"
#include "inkscape.h"
#include "event-context.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "dialog-manager.h"
#include "modifier-fns.h"
#include "shortcuts.h"
#include "prefs-utils.h"
#include "interface.h"
#include "verbs.h"
#define MIN_ONSCREEN_DISTANCE 50
namespace Inkscape {
namespace UI {
namespace Dialog {
void
{
}
{
dlg->retransientize_suppress = false;
return FALSE; // so that it is only called once
}
void
{
dlg->onShutdown();
}
{
}
{
}
//=====================================================================
/**
* UI::Dialog::Dialog is a base class for all dialogs in Inkscape. The
* purpose of this class is to provide a unified place for ensuring
* style and behavior. Specifically, this class provides functionality
* for saving and restoring the size and position of dialogs (through
* the user's preferences file).
*
* It also provides some general purpose signal handlers for things like
* showing and hiding all dialogs.
*/
const char *apply_label)
: _hiddenF12 (false),
{
if (verb_num)
_behavior = behavior_factory(*this);
_desktop_activated_connection = Inkscape::NSApplication::Editor::connectDesktopActivated (sigc::mem_fun (*this, &Dialog::onDesktopActivated));
_dialogs_hidden_connection = Inkscape::NSApplication::Editor::connectDialogsHidden (sigc::mem_fun (*this, &Dialog::onHideF12));
_dialogs_unhidden_connection = Inkscape::NSApplication::Editor::connectDialogsUnhidden (sigc::mem_fun (*this, &Dialog::onShowF12));
_shutdown_connection = Inkscape::NSApplication::Editor::connectShutdown (sigc::mem_fun (*this, &Dialog::onShutdown));
} else {
g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(sp_retransientize), (void *)this);
}
// TODO: make the order of buttons obey the global preference
if (apply_label) {
}
}
}
{
{
}
delete _behavior;
}
//---------------------------------------------------------------------
void
{
}
void
Dialog::onShutdown()
{
_user_hidden = true;
_behavior->onShutdown();
}
void
{
_hiddenF12 = true;
}
void
{
if (_user_hidden)
return;
if (_hiddenF12) {
}
_hiddenF12 = false;
}
inline void Dialog::set_size_request(int width, int height) { _behavior->set_size_request(width, height); }
inline void Dialog::size_request(Gtk::Requisition& requisition) { _behavior->size_request(requisition); }
inline void Dialog::set_position(Gtk::WindowPosition position) { _behavior->set_position(position); }
void Dialog::set_resizable(bool) { }
inline void Dialog::set_default_response(int response_id) { _behavior->set_default_response(response_id); }
void
{
_user_hidden = false;
// g_print ("read %d %d %d %d\n", x, y, w, h);
// If there are stored height and width values for the dialog,
// resize the window to match; otherwise we leave it at its default
if (w != 0 && h != 0) {
resize(w, h);
}
// If there are stored values for where the dialog should be
// located, then restore the dialog to that position.
// also check if (x,y) is actually onscreen with the current screen dimensions
if ( (x >= 0) && (y >= 0) && (x < (gdk_screen_width()-MIN_ONSCREEN_DISTANCE)) && (y < (gdk_screen_height()-MIN_ONSCREEN_DISTANCE)) ) {
move(x, y);
} else {
// ...otherwise just put it in the middle of the screen
}
}
void
{
int y, x, w, h;
get_position(x, y);
get_size(w, h);
// g_print ("write %d %d %d %d\n", x, y, w, h);
if (x<0) x=0;
if (y<0) y=0;
}
void
{
switch (response_id) {
case Gtk::RESPONSE_APPLY: {
_apply();
break;
}
case Gtk::RESPONSE_CLOSE: {
_close();
break;
}
}
}
bool
{
_user_hidden = true;
return false;
}
bool
{
bool ret = false;
case GDK_KEY_PRESS: {
break;
}
default:
;
}
return ret;
}
bool
{
bool ret = false;
switch (get_group0_keyval (event)) {
case GDK_Escape: {
_defocus();
ret = true;
break;
}
case GDK_F4:
case GDK_w:
case GDK_W: {
_close();
ret = true;
}
break;
}
default: { // pass keypress to the canvas
unsigned int shortcut;
SP_SHORTCUT_SHIFT_MASK : 0 ) |
SP_SHORTCUT_CONTROL_MASK : 0 ) |
SP_SHORTCUT_ALT_MASK : 0 );
break;
}
}
return ret;
}
void
{
g_warning("Apply button clicked for dialog [Dialog::_apply()]");
}
void
{
/* this code sends a delete_event to the dialog,
* instead of just destroying it, so that the
* dialog can do some housekeeping, such as remember
* its position.
*/
}
void
{
if (desktop) {
// make sure the canvas window is present before giving it focus
if (toplevel_window)
canvas->grab_focus();
}
}
{
return sp_desktop_selection(SP_ACTIVE_DESKTOP);
}
} // namespace Dialog
} // namespace UI
} // namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :