예제 #1
0
static void
InstallClose(
        ChangeDirRec *change_dir_rec,
        XtCallbackProc callback,
        XtPointer client_data )
{
   Widget close_widget;
   Atom delete_window_atom;

   close_widget =
      XmSelectionBoxGetChild (change_dir_rec->change_dir,
                                             XmDIALOG_CANCEL_BUTTON);

   XtAddCallback (close_widget, XmNactivateCallback, callback, client_data);

   delete_window_atom = XmInternAtom (XtDisplay(change_dir_rec->shell),
                                      "WM_DELETE_WINDOW", True);
   XmRemoveWMProtocols( change_dir_rec->shell, &delete_window_atom, 1 );
   XmAddWMProtocolCallback( change_dir_rec->shell, delete_window_atom, callback,
                            (XtPointer)client_data );
}
예제 #2
0
bool wxTopLevelWindowMotif::Create( wxWindow *parent, wxWindowID id,
                                    const wxString& title,
                                    const wxPoint& pos,
                                    const wxSize& size,
                                    long style,
                                    const wxString& name )
{
    SetName(name);
    m_windowStyle = style;

    if ( parent )
        parent->AddChild(this);

    wxTopLevelWindows.Append(this);

    m_windowId = ( id > -1 ) ? id : NewControlId();
    // MBN: More backward compatible, but uglier
    m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
    m_inheritFont = true;

    bool retval = XmDoCreateTLW( parent, id, title, pos, size, style, name );

    if( !retval ) return false;

    // Intercept CLOSE messages from the window manager
    Widget shell = (Widget)GetShellWidget();
    Atom WM_DELETE_WINDOW = XmInternAtom( XtDisplay( shell ),
                                          "WM_DELETE_WINDOW", False );

    // Remove and add WM_DELETE_WINDOW so ours is only handler
    // This only appears to be necessary for wxDialog, but does not hurt
    // for wxFrame
    XmRemoveWMProtocols( shell, &WM_DELETE_WINDOW, 1 );
    XmAddWMProtocols( shell, &WM_DELETE_WINDOW, 1 );
    XmActivateWMProtocol( shell, WM_DELETE_WINDOW );

    // Modified Steve Hammes for Motif 2.0
#if (XmREVISION > 1 || XmVERSION > 1)
    XmAddWMProtocolCallback( shell, WM_DELETE_WINDOW,
                             (XtCallbackProc)wxCloseTLWCallback,
                             (XtPointer)this );
#elif XmREVISION == 1
    XmAddWMProtocolCallback( shell, WM_DELETE_WINDOW,
                             (XtCallbackProc)wxCloseTLWCallback,
                             (caddr_t)this );
#else
    XmAddWMProtocolCallback( shell, WM_DELETE_WINDOW,
                             (void (*)())wxCloseTLWCallback, (caddr_t)this );
#endif

    // This patch come from Torsten Liermann [email protected]
    if( XmIsMotifWMRunning( shell ) )
    {
        int decor = 0 ;
        if( !(m_windowStyle & wxNO_BORDER) )
            decor |= MWM_DECOR_BORDER;
        if( m_windowStyle & wxRESIZE_BORDER )
            decor |= MWM_DECOR_RESIZEH;
        if( m_windowStyle & wxSYSTEM_MENU )
            decor |= MWM_DECOR_MENU;
        if( ( m_windowStyle & wxCAPTION ) ||
            ( m_windowStyle & wxTINY_CAPTION_HORIZ ) ||
            ( m_windowStyle & wxTINY_CAPTION_VERT ) )
            decor |= MWM_DECOR_TITLE;
        if( m_windowStyle & wxRESIZE_BORDER )
            decor |= MWM_DECOR_BORDER;
        if( m_windowStyle & wxMINIMIZE_BOX )
            decor |= MWM_DECOR_MINIMIZE;
        if( m_windowStyle & wxMAXIMIZE_BOX )
            decor |= MWM_DECOR_MAXIMIZE;

        XtVaSetValues( shell,
                       XmNmwmDecorations, decor,
                       NULL );
    }
    else
    {
        // This allows non-Motif window managers to support at least the
        // no-decorations case.
        if( ( m_windowStyle & wxCAPTION ) != wxCAPTION )
            XtVaSetValues( shell,
                           XmNoverrideRedirect, True,
                           NULL );
    }

    XtAddEventHandler( (Widget)GetClientWidget(),
                       ButtonPressMask | ButtonReleaseMask |
                       PointerMotionMask | KeyPressMask,
                       False,
                       wxTLWEventHandler,
                       (XtPointer)this );

    return retval;
}