Introduce platform-dependent wxTLWGeometry class
Previously, TLW geometry was implicitly defined as just its position, size and the maximized/iconized state by wxPersistentTLW code. This already wasn't enough for wxGTK which added the decoration sizes to the geometry being saved/restored, but this had to be done using conditional compilation, which was not ideal. And it didn't allow using an entirely different geometry representation as will be done for wxMSW soon. Change the code to use wxTLWGeometry class defining the geometry, as used by the current port, explicitly and move wxPersistentTLW logic into it, as wxPersistentXXX classes are supposed to be very simple, which wasn't really the case. Also provide public SaveGeometry() and RestoreToGeometry() methods in wxTopLevelWindow, which can be useful even to people not using wxPersistentTLW for whatever reason. There should be no changes in behaviour so far.
This commit is contained in:
@@ -238,6 +238,35 @@ public:
|
||||
wxWindow *SetTmpDefaultItem(wxWindow *win)
|
||||
{ wxWindow *old = GetDefaultItem(); m_winTmpDefault = win; return old; }
|
||||
|
||||
|
||||
// Class for saving/restoring fields describing the window geometry.
|
||||
//
|
||||
// This class is used by the functions below to allow saving the geometry
|
||||
// of the window and restoring it later. The components describing geometry
|
||||
// are platform-dependent, so there is no struct containing them and
|
||||
// instead the methods of this class are used to save or [try to] restore
|
||||
// whichever components are used under the current platform.
|
||||
class GeometrySerializer
|
||||
{
|
||||
public:
|
||||
virtual ~GeometrySerializer() {}
|
||||
|
||||
// If saving a field returns false, it's fatal error and SaveGeometry()
|
||||
// will return false.
|
||||
virtual bool SaveField(const wxString& name, int value) const = 0;
|
||||
|
||||
// If restoring a field returns false, it just means that the field is
|
||||
// not present and RestoreToGeometry() still continues with restoring
|
||||
// the other values.
|
||||
virtual bool RestoreField(const wxString& name, int* value) = 0;
|
||||
};
|
||||
|
||||
// Save the current window geometry using the provided serializer and
|
||||
// restore the window to the previously saved geometry.
|
||||
bool SaveGeometry(const GeometrySerializer& ser) const;
|
||||
bool RestoreToGeometry(GeometrySerializer& ser);
|
||||
|
||||
|
||||
// implementation only from now on
|
||||
// -------------------------------
|
||||
|
||||
|
Reference in New Issue
Block a user