This file is indexed.

/usr/include/wx-3.0/wx/modalhook.h is in wx3.0-headers 3.0.2-1+b1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
///////////////////////////////////////////////////////////////////////////////
// Name:        wx/modalhook.h
// Purpose:     Allows to hook into showing modal dialogs.
// Author:      Vadim Zeitlin
// Created:     2013-05-19
// Copyright:   (c) 2013 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence:     wxWindows licence
///////////////////////////////////////////////////////////////////////////////

#ifndef _WX_MODALHOOK_H_
#define _WX_MODALHOOK_H_

#include "wx/vector.h"

class WXDLLIMPEXP_FWD_CORE wxDialog;

// ----------------------------------------------------------------------------
// Class allowing to be notified about any modal dialog calls.
// ----------------------------------------------------------------------------

// To be notified about entering and exiting modal dialogs and possibly to
// replace them with something else (e.g. just return a predefined value for
// testing), define an object of this class, override its Enter() and
// possibly Exit() methods and call Register() on it.
class WXDLLIMPEXP_CORE wxModalDialogHook
{
public:
    // Default ctor doesn't do anything, call Register() to activate the hook.
    wxModalDialogHook() { }

    // Dtor unregisters the hook if it had been registered.
    virtual ~wxModalDialogHook() { DoUnregister(); }

    // Register this hook as being active, i.e. its Enter() and Exit() methods
    // will be called.
    //
    // Notice that the order of registration matters: the last hook registered
    // is called first, and if its Enter() returns something != wxID_NONE, the
    // subsequent hooks are skipped.
    void Register();

    // Unregister this hook. Notice that is done automatically from the dtor.
    void Unregister();

    // Called from wxWidgets code before showing any modal dialogs and calls
    // Enter() for every registered hook.
    static int CallEnter(wxDialog* dialog);

    // Called from wxWidgets code after dismissing the dialog and calls Exit()
    // for every registered hook.
    static void CallExit(wxDialog* dialog);

protected:
    // Called by wxWidgets before showing any modal dialogs, override this to
    // be notified about this and return anything but wxID_NONE to skip showing
    // the modal dialog entirely and just return the specified result.
    virtual int Enter(wxDialog* dialog) = 0;

    // Called by wxWidgets after dismissing the modal dialog. Notice that it
    // won't be called if Enter() hadn't been.
    virtual void Exit(wxDialog* WXUNUSED(dialog)) { }

private:
    // Unregister the given hook, return true if it was done or false if the
    // hook wasn't found.
    bool DoUnregister();

    // All the hooks in reverse registration order (i.e. in call order).
    typedef wxVector<wxModalDialogHook*> Hooks;
    static Hooks ms_hooks;

    wxDECLARE_NO_COPY_CLASS(wxModalDialogHook);
};

// Helper object used by WX_MODAL_DIALOG_HOOK below to ensure that CallExit()
// is called on scope exit.
class wxModalDialogHookExitGuard
{
public:
    wxEXPLICIT wxModalDialogHookExitGuard(wxDialog* dialog)
        : m_dialog(dialog)
    {
    }

    ~wxModalDialogHookExitGuard()
    {
        wxModalDialogHook::CallExit(m_dialog);
    }

private:
    wxDialog* const m_dialog;

    wxDECLARE_NO_COPY_CLASS(wxModalDialogHookExitGuard);
};

// This macro needs to be used at the top of every implementation of
// ShowModal() in order for wxModalDialogHook to work.
#define WX_HOOK_MODAL_DIALOG()                                                \
    const int modalDialogHookRC = wxModalDialogHook::CallEnter(this);         \
    if ( modalDialogHookRC != wxID_NONE )                                     \
        return modalDialogHookRC;                                             \
    wxModalDialogHookExitGuard modalDialogHookExit(this)

#endif // _WX_MODALHOOK_H_