File: display.h

package info (click to toggle)
wxpython4.0 4.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 221,752 kB
  • sloc: cpp: 962,555; python: 230,573; ansic: 170,731; makefile: 51,756; sh: 9,342; perl: 1,564; javascript: 584; php: 326; xml: 200
file content (164 lines) | stat: -rw-r--r-- 5,360 bytes parent folder | download | duplicates (4)
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/////////////////////////////////////////////////////////////////////////////
// Name:        wx/display.h
// Purpose:     wxDisplay class
// Author:      Royce Mitchell III, Vadim Zeitlin
// Created:     06/21/02
// Copyright:   (c) 2002-2006 wxWidgets team
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

#ifndef _WX_DISPLAY_H_BASE_
#define _WX_DISPLAY_H_BASE_

#include "wx/defs.h"
#include "wx/gdicmn.h"      // wxSize

// NB: no #if wxUSE_DISPLAY here, the display geometry part of this class (but
//     not the video mode stuff) is always available but if wxUSE_DISPLAY == 0
//     it becomes just a trivial wrapper around the old wxDisplayXXX() functions

#if wxUSE_DISPLAY
    #include "wx/dynarray.h"
    #include "wx/vidmode.h"

    WX_DECLARE_EXPORTED_OBJARRAY(wxVideoMode, wxArrayVideoModes);

    // default, uninitialized, video mode object
    extern WXDLLIMPEXP_DATA_CORE(const wxVideoMode) wxDefaultVideoMode;
#endif // wxUSE_DISPLAY

class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_FWD_CORE wxPoint;
class WXDLLIMPEXP_FWD_CORE wxRect;
class WXDLLIMPEXP_FWD_BASE wxString;

class WXDLLIMPEXP_FWD_CORE wxDisplayFactory;
class WXDLLIMPEXP_FWD_CORE wxDisplayImpl;

// ----------------------------------------------------------------------------
// wxDisplay: represents a display/monitor attached to the system
// ----------------------------------------------------------------------------

class WXDLLIMPEXP_CORE wxDisplay
{
public:
    // default ctor creates the object corresponding to the primary display
    wxDisplay();

    // initialize the object containing all information about the given
    // display
    //
    // the displays are numbered from 0 to GetCount() - 1
    explicit wxDisplay(unsigned n);

    // create display object corresponding to the display of the given window
    // or the default one if the window display couldn't be found
    explicit wxDisplay(const wxWindow* window);

    // dtor is not virtual as this is a concrete class not meant to be derived
    // from


    // return the number of available displays, valid parameters to
    // wxDisplay ctor are from 0 up to this number
    static unsigned GetCount();

    // find the display where the given point lies, return wxNOT_FOUND if
    // it doesn't belong to any display
    static int GetFromPoint(const wxPoint& pt);

    // find the display where the given window lies, return wxNOT_FOUND if it
    // is not shown at all
    static int GetFromWindow(const wxWindow *window);


    // return true if the object was initialized successfully
    bool IsOk() const { return m_impl != NULL; }

    // get the full display size
    wxRect GetGeometry() const;

    // get the client area of the display, i.e. without taskbars and such
    wxRect GetClientArea() const;

    // get the depth, i.e. number of bits per pixel (0 if unknown)
    int GetDepth() const;

    // get the resolution of this monitor in pixels per inch
    wxSize GetPPI() const;

    // get the default resolution for displays on this platform
    static int GetStdPPIValue()
    {
#ifdef __WXOSX__
        return 72;
#else
        return 96;
#endif
    }

    static wxSize GetStdPPI()
    {
        return wxSize(GetStdPPIValue(), GetStdPPIValue());
    }

    // get the scaling used by this display
    double GetScaleFactor() const;

    // name may be empty
    wxString GetName() const;

    // display 0 is usually the primary display
    bool IsPrimary() const;


#if wxUSE_DISPLAY
    // enumerate all video modes supported by this display matching the given
    // one (in the sense of wxVideoMode::Match())
    //
    // as any mode matches the default value of the argument and there is
    // always at least one video mode supported by display, the returned array
    // is only empty for the default value of the argument if this function is
    // not supported at all on this platform
    wxArrayVideoModes
        GetModes(const wxVideoMode& mode = wxDefaultVideoMode) const;

    // get current video mode
    wxVideoMode GetCurrentMode() const;

    // change current mode, return true if succeeded, false otherwise
    //
    // for the default value of the argument restores the video mode to default
    bool ChangeMode(const wxVideoMode& mode = wxDefaultVideoMode);

    // restore the default video mode (just a more readable synonym)
    void ResetMode() { (void)ChangeMode(); }
#endif // wxUSE_DISPLAY

    // If the implementation caches any information about the displays, calling
    // this function clears it -- this should be done e.g. after a display
    // [dis]connection.
    static void InvalidateCache();

private:
    // returns the factory used to implement our static methods and create new
    // displays
    static wxDisplayFactory& Factory();

    // creates the factory object, called by Factory() when it is called for
    // the first time and should return a pointer allocated with new (the
    // caller will delete it)
    //
    // this method must be implemented in platform-specific code if
    // wxUSE_DISPLAY == 1 (if it is 0 we provide the stub in common code)
    static wxDisplayFactory *CreateFactory();


    // the real implementation
    wxDisplayImpl *m_impl;


    wxDECLARE_NO_COPY_CLASS(wxDisplay);
};

#endif // _WX_DISPLAY_H_BASE_