Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets
Commits:
934705ef by Vadim Zeitlin at 2026-06-19T17:14:39+02:00
Replace wxTopLevelWindow::GeometrySerializer with GeometryStore
The old class used incorrect const qualifiers on its member functions:
saving function typically modifies the object being saved into, and so
must not be const, while loading function should be const, but the old
class reversed this.
Do it right this time in the new GeometryStore class and keep the old
class for compatibility only.
See #26602.
- - - - -
96939340 by anhnong90 at 2026-06-19T17:16:08+02:00
Remove custom_search_functions.php and the regen.sh copy step.
Let upstream Doxygen provide its own version as it works with PHP 8
unlike our one.
Closes #26610.
- - - - -
9 changed files:
- − docs/doxygen/custom_search_functions.php
- docs/doxygen/regen.sh
- include/wx/gtk/private/tlwgeom.h
- include/wx/msw/private/tlwgeom.h
- include/wx/persist/toplevel.h
- include/wx/private/tlwgeom.h
- include/wx/toplevel.h
- interface/wx/toplevel.h
- src/common/toplvcmn.cpp
Changes:
=====================================
docs/doxygen/custom_search_functions.php deleted
=====================================
@@ -1,360 +0,0 @@
-<?php
-require_once "search_config.php";
-
-function end_form($value)
-{
- global $config;
- global $translator;
- if ($config['DISABLE_INDEX'] == false)
- {
- echo "</div>\n";
- }
- if ($config['GENERATE_TREEVIEW'])
- {
- echo $translator['split_bar'];
- }
-}
-
-function search_results()
-{
- global $translator;
- return $translator['search_results_title'];
-}
-
-function matches_text($num)
-{
- global $translator;
- $string = $translator['search_results'][($num>2)?2:$num];
- // The eval is used so that translator strings can contain $num.
- eval("\$result = \"$string\";");
- return $result;
-}
-
-function report_matches()
-{
- global $translator;
- return $translator['search_matches'];
-}
-
-function readInt($file)
-{
- $b1 = ord(fgetc($file)); $b2 = ord(fgetc($file));
- $b3 = ord(fgetc($file)); $b4 = ord(fgetc($file));
- return ($b1<<24)|($b2<<16)|($b3<<8)|$b4;
-}
-
-function readString($file)
-{
- $result="";
- while (ord($c=fgetc($file))) $result.=$c;
- return $result;
-}
-
-function readHeader($file)
-{
- $header =fgetc($file); $header.=fgetc($file);
- $header.=fgetc($file); $header.=fgetc($file);
- return $header;
-}
-
-function computeIndex($word)
-{
- // Simple hashing that allows for substring search
- if (strlen($word)<2) return -1;
- // high char of the index
- $hi = ord($word{0});
- if ($hi==0) return -1;
- // low char of the index
- $lo = ord($word{1});
- if ($lo==0) return -1;
- // return index
- return $hi*256+$lo;
-}
-
-function search($file,$word,&$statsList)
-{
- $index = computeIndex($word);
- if ($index!=-1) // found a valid index
- {
- fseek($file,$index*4+4); // 4 bytes per entry, skip header
- $index = readInt($file);
- if ($index) // found words matching the hash key
- {
- $start=sizeof($statsList);
- $count=$start;
- fseek($file,$index);
- $w = readString($file);
- while ($w)
- {
- $statIdx = readInt($file);
- if ($word==substr($w,0,strlen($word)))
- { // found word that matches (as substring)
- $statsList[$count++]=array(
- "word"=>$word,
- "match"=>$w,
- "index"=>$statIdx,
- "full"=>strlen($w)==strlen($word),
- "docs"=>array()
- );
- }
- $w = readString($file);
- }
- $totalHi=0;
- $totalFreqHi=0;
- $totalFreqLo=0;
- for ($count=$start;$count<sizeof($statsList);$count++)
- {
- $statInfo = &$statsList[$count];
- $multiplier = 1;
- // whole word matches have a double weight
- if ($statInfo["full"]) $multiplier=2;
- fseek($file,$statInfo["index"]);
- $numDocs = readInt($file);
- $docInfo = array();
- // read docs info + occurrence frequency of the word
- for ($i=0;$i<$numDocs;$i++)
- {
- $idx=readInt($file);
- $freq=readInt($file);
- $docInfo[$i]=array("idx" => $idx,
- "freq" => $freq>>1,
- "rank" => 0.0,
- "hi" => $freq&1
- );
- if ($freq&1) // word occurs in high priority doc
- {
- $totalHi++;
- $totalFreqHi+=$freq*$multiplier;
- }
- else // word occurs in low priority doc
- {
- $totalFreqLo+=$freq*$multiplier;
- }
- }
- // read name and url info for the doc
- for ($i=0;$i<$numDocs;$i++)
- {
- fseek($file,$docInfo[$i]["idx"]);
- $docInfo[$i]["name"]=readString($file);
- $docInfo[$i]["url"]=readString($file);
- }
- $statInfo["docs"]=$docInfo;
- }
- $totalFreq=($totalHi+1)*$totalFreqLo + $totalFreqHi;
- for ($count=$start;$count<sizeof($statsList);$count++)
- {
- $statInfo = &$statsList[$count];
- $multiplier = 1;
- // whole word matches have a double weight
- if ($statInfo["full"]) $multiplier=2;
- for ($i=0;$i<sizeof($statInfo["docs"]);$i++)
- {
- $docInfo = &$statInfo["docs"];
- // compute frequency rank of the word in each doc
- $freq=$docInfo[$i]["freq"];
- if ($docInfo[$i]["hi"])
- {
- $statInfo["docs"][$i]["rank"]=
- (float)($freq*$multiplier+$totalFreqLo)/$totalFreq;
- }
- else
- {
- $statInfo["docs"][$i]["rank"]=
- (float)($freq*$multiplier)/$totalFreq;
- }
- }
- }
- }
- }
- return $statsList;
-}
-
-function combine_results($results,&$docs)
-{
- foreach ($results as $wordInfo)
- {
- $docsList = &$wordInfo["docs"];
- foreach ($docsList as $di)
- {
- $key=$di["url"];
- $rank=$di["rank"];
- if (isset($docs[$key]))
- {
- $docs[$key]["rank"]+=$rank;
- }
- else
- {
- $docs[$key] = array("url"=>$key,
- "name"=>$di["name"],
- "rank"=>$rank
- );
- }
- $docs[$key]["words"][] = array(
- "word"=>$wordInfo["word"],
- "match"=>$wordInfo["match"],
- "freq"=>$di["freq"]
- );
- }
- }
- return $docs;
-}
-
-function filter_results($docs,&$requiredWords,&$forbiddenWords)
-{
- $filteredDocs=array();
- while (list ($key, $val) = each ($docs))
- {
- $words = &$docs[$key]["words"];
- $copy=1; // copy entry by default
- if (sizeof($requiredWords)>0)
- {
- foreach ($requiredWords as $reqWord)
- {
- $found=0;
- foreach ($words as $wordInfo)
- {
- $found = $wordInfo["word"]==$reqWord;
- if ($found) break;
- }
- if (!$found)
- {
- $copy=0; // document contains none of the required words
- break;
- }
- }
- }
- if (sizeof($forbiddenWords)>0)
- {
- foreach ($words as $wordInfo)
- {
- if (in_array($wordInfo["word"],$forbiddenWords))
- {
- $copy=0; // document contains a forbidden word
- break;
- }
- }
- }
- if ($copy) $filteredDocs[$key]=$docs[$key];
- }
- return $filteredDocs;
-}
-
-function compare_rank($a,$b)
-{
- if ($a["rank"] == $b["rank"])
- {
- return 0;
- }
- return ($a["rank"]>$b["rank"]) ? -1 : 1;
-}
-
-function sort_results($docs,&$sorted)
-{
- $sorted = $docs;
- usort($sorted,"compare_rank");
- return $sorted;
-}
-
-function report_results(&$docs)
-{
- echo "<div class=\"header\">";
- echo " <div class=\"headertitle\">\n";
- echo " <h1>".search_results()."</h1>\n";
- echo " </div>\n";
- echo "</div>\n";
- echo "<div class=\"searchresults\">\n";
- echo "<table cellspacing=\"2\">\n";
- $numDocs = sizeof($docs);
- if ($numDocs==0)
- {
- echo " <tr>\n";
- echo " <td colspan=\"2\">".matches_text(0)."</td>\n";
- echo " </tr>\n";
- }
- else
- {
- echo " <tr>\n";
- echo " <td colspan=\"2\">".matches_text($numDocs);
- echo "\n";
- echo " </td>\n";
- echo " </tr>\n";
- $num=1;
- foreach ($docs as $doc)
- {
- echo " <tr>\n";
- echo " <td align=\"right\">$num.</td>";
- echo "<td><a class=\"el\" href=\"".$doc["url"]."\">".$doc["name"]."</a></td>\n";
- echo " <tr>\n";
- echo " <td></td><td class=\"tiny\">".report_matches()." ";
- foreach ($doc["words"] as $wordInfo)
- {
- $word = $wordInfo["word"];
- $matchRight = substr($wordInfo["match"],strlen($word));
- echo "<b>$word</b>$matchRight(".$wordInfo["freq"].") ";
- }
- echo " </td>\n";
- echo " </tr>\n";
- $num++;
- }
- }
- echo "</table>\n";
- echo "</div>\n";
-}
-
-function run_query($query)
-{
- if(strcmp('4.1.0', phpversion()) > 0)
- {
- die("Error: PHP version 4.1.0 or above required!");
- }
- if (!($file=fopen("search/search.idx","rb")))
- {
- die("Error: Search index file could NOT be opened!");
- }
- if (readHeader($file)!="DOXS")
- {
- die("Error: Header of index file is invalid!");
- }
- $results = array();
- $requiredWords = array();
- $forbiddenWords = array();
- $foundWords = array();
- $word=strtok($query," ");
- while ($word) // for each word in the search query
- {
- if (($word{0}=='+')) { $word=substr($word,1); $requiredWords[]=$word; }
- if (($word{0}=='-')) { $word=substr($word,1); $forbiddenWords[]=$word; }
- if (!in_array($word,$foundWords))
- {
- $foundWords[]=$word;
- search($file,strtolower($word),$results);
- }
- $word=strtok(" ");
- }
- fclose($file);
- $docs = array();
- combine_results($results,$docs);
- // filter out documents with forbidden word or that do not contain
- // required words
- $filteredDocs = filter_results($docs,$requiredWords,$forbiddenWords);
- // sort the results based on rank
- $sorted = array();
- sort_results($filteredDocs,$sorted);
- return $sorted;
-}
-
-function main()
-{
- $query = "";
- if (array_key_exists("query", $_GET))
- {
- $query=$_GET["query"];
- }
- $sorted = run_query($query);
- // Now output the HTML stuff...
- // End the HTML form
- end_form(preg_replace("/[^a-zA-Z0-9\-\_\.\x80-\xFF]/i", " ", $query ));
- // report results to the user
- report_results($sorted);
-}
-?>
=====================================
docs/doxygen/regen.sh
=====================================
@@ -128,11 +128,6 @@ esac
#
$DOXYGEN Doxyfile
-if [[ "$1" = "php" ]]; then
- # Work around a bug in Doxygen < 1.8.19 PHP search function.
- cp custom_search_functions.php $WX_HTML_OUTPUT_DIR/search_functions.php
-fi
-
if [[ "$1" = "qch" ]]; then
# we need to add missing files to the .qhp
cd $WX_HTML_OUTPUT_DIR
=====================================
include/wx/gtk/private/tlwgeom.h
=====================================
@@ -14,9 +14,9 @@ class wxTLWGeometry : public wxTLWGeometryGeneric
{
typedef wxTLWGeometryGeneric BaseType;
public:
- virtual bool Save(const Serializer& ser) const override
+ virtual bool Save(Store& store) const override
{
- if ( !wxTLWGeometryGeneric::Save(ser) )
+ if ( !wxTLWGeometryGeneric::Save(store) )
return false;
// Don't save the decoration sizes if we don't really have any values
@@ -24,24 +24,24 @@ public:
if ( m_decorSize.left || m_decorSize.right ||
m_decorSize.top || m_decorSize.bottom )
{
- ser.SaveField("decor_l", m_decorSize.left);
- ser.SaveField("decor_r", m_decorSize.right);
- ser.SaveField("decor_t", m_decorSize.top);
- ser.SaveField("decor_b", m_decorSize.bottom);
+ store.SaveValue("decor_l", m_decorSize.left);
+ store.SaveValue("decor_r", m_decorSize.right);
+ store.SaveValue("decor_t", m_decorSize.top);
+ store.SaveValue("decor_b", m_decorSize.bottom);
}
return true;
}
- virtual bool Restore(Serializer& ser) override
+ virtual bool Restore(const Store& store) override
{
- if ( !wxTLWGeometryGeneric::Restore(ser) )
+ if ( !wxTLWGeometryGeneric::Restore(store) )
return false;
- ser.RestoreField("decor_l", &m_decorSize.left);
- ser.RestoreField("decor_r", &m_decorSize.right);
- ser.RestoreField("decor_t", &m_decorSize.top);
- ser.RestoreField("decor_b", &m_decorSize.bottom);
+ store.RestoreValue("decor_l", &m_decorSize.left);
+ store.RestoreValue("decor_r", &m_decorSize.right);
+ store.RestoreValue("decor_t", &m_decorSize.top);
+ store.RestoreValue("decor_b", &m_decorSize.bottom);
return true;
}
=====================================
include/wx/msw/private/tlwgeom.h
=====================================
@@ -27,7 +27,7 @@ public:
m_placement.length = sizeof(m_placement);
}
- virtual bool Save(const Serializer& ser) const override
+ virtual bool Save(Store& store) const override
{
// For compatibility with the existing saved positions/sizes, use the
// same keys as the generic version (which was previously used under
@@ -35,26 +35,26 @@ public:
// Normal position and size.
const RECT& rc = m_placement.rcNormalPosition;
- if ( !ser.SaveField(wxPERSIST_TLW_X, rc.left) ||
- !ser.SaveField(wxPERSIST_TLW_Y, rc.top) )
+ if ( !store.SaveValue(wxPERSIST_TLW_X, rc.left) ||
+ !store.SaveValue(wxPERSIST_TLW_Y, rc.top) )
return false;
- if ( !ser.SaveField(wxPERSIST_TLW_W, rc.right - rc.left) ||
- !ser.SaveField(wxPERSIST_TLW_H, rc.bottom - rc.top) )
+ if ( !store.SaveValue(wxPERSIST_TLW_W, rc.right - rc.left) ||
+ !store.SaveValue(wxPERSIST_TLW_H, rc.bottom - rc.top) )
return false;
// Maximized/minimized state.
UINT show = m_placement.showCmd;
- if ( !ser.SaveField(wxPERSIST_TLW_MAXIMIZED, show == SW_SHOWMAXIMIZED) )
+ if ( !store.SaveValue(wxPERSIST_TLW_MAXIMIZED, show == SW_SHOWMAXIMIZED) )
return false;
- if ( !ser.SaveField(wxPERSIST_TLW_ICONIZED, show == SW_SHOWMINIMIZED) )
+ if ( !store.SaveValue(wxPERSIST_TLW_ICONIZED, show == SW_SHOWMINIMIZED) )
return false;
// Maximized window position.
const POINT pt = m_placement.ptMaxPosition;
- if ( !ser.SaveField(wxPERSIST_TLW_MAX_X, pt.x) ||
- !ser.SaveField(wxPERSIST_TLW_MAX_Y, pt.y) )
+ if ( !store.SaveValue(wxPERSIST_TLW_MAX_X, pt.x) ||
+ !store.SaveValue(wxPERSIST_TLW_MAX_Y, pt.y) )
return false;
// We don't currently save the minimized window position, it doesn't
@@ -65,14 +65,14 @@ public:
return true;
}
- virtual bool Restore(Serializer& ser) override
+ virtual bool Restore(const Store& store) override
{
// Normal position and size.
wxRect r;
- if ( !ser.RestoreField(wxPERSIST_TLW_X, &r.x) ||
- !ser.RestoreField(wxPERSIST_TLW_Y, &r.y) ||
- !ser.RestoreField(wxPERSIST_TLW_W, &r.width) ||
- !ser.RestoreField(wxPERSIST_TLW_H, &r.height) )
+ if ( !store.RestoreValue(wxPERSIST_TLW_X, &r.x) ||
+ !store.RestoreValue(wxPERSIST_TLW_Y, &r.y) ||
+ !store.RestoreValue(wxPERSIST_TLW_W, &r.width) ||
+ !store.RestoreValue(wxPERSIST_TLW_H, &r.height) )
return false;
wxCopyRectToRECT(r, m_placement.rcNormalPosition);
@@ -87,16 +87,16 @@ public:
// the same thing as SW_SHOWMAXIMIZED.
int tmp;
UINT& show = m_placement.showCmd;
- if ( ser.RestoreField(wxPERSIST_TLW_MAXIMIZED, &tmp) && tmp )
+ if ( store.RestoreValue(wxPERSIST_TLW_MAXIMIZED, &tmp) && tmp )
show = SW_MAXIMIZE;
- else if ( ser.RestoreField(wxPERSIST_TLW_ICONIZED, &tmp) && tmp )
+ else if ( store.RestoreValue(wxPERSIST_TLW_ICONIZED, &tmp) && tmp )
show = SW_MINIMIZE;
else
show = SW_SHOWNORMAL;
// Maximized window position.
- if ( ser.RestoreField(wxPERSIST_TLW_MAX_X, &r.x) &&
- ser.RestoreField(wxPERSIST_TLW_MAX_Y, &r.y) )
+ if ( store.RestoreValue(wxPERSIST_TLW_MAX_X, &r.x) &&
+ store.RestoreValue(wxPERSIST_TLW_MAX_Y, &r.y) )
{
m_placement.ptMaxPosition.x = r.x;
m_placement.ptMaxPosition.y = r.y;
=====================================
include/wx/persist/toplevel.h
=====================================
@@ -28,12 +28,12 @@
// as maximized/iconized/restore state
// ----------------------------------------------------------------------------
-class wxPersistentTLW : public wxPersistentWindow<wxTopLevelWindow>,
- private wxTopLevelWindow::GeometrySerializer
+class wxPersistentTLW : public wxPersistentWindow<wxTopLevelWindow>
{
public:
wxPersistentTLW(wxTopLevelWindow *tlw)
- : wxPersistentWindow<wxTopLevelWindow>(tlw)
+ : wxPersistentWindow<wxTopLevelWindow>(tlw),
+ m_store{this}
{
}
@@ -41,28 +41,45 @@ public:
{
const wxTopLevelWindow * const tlw = Get();
- tlw->SaveGeometry(*this);
+ tlw->SaveGeometry(m_store);
}
virtual bool Restore() override
{
wxTopLevelWindow * const tlw = Get();
- return tlw->RestoreToGeometry(*this);
+ return tlw->RestoreToGeometry(m_store);
}
virtual wxString GetKind() const override { return wxASCII_STR(wxPERSIST_TLW_KIND); }
private:
- virtual bool SaveField(const wxString& name, int value) const override
+ class PersistentStore : public wxTopLevelWindow::GeometryStore
{
- return SaveValue(name, value);
- }
-
- virtual bool RestoreField(const wxString& name, int* value) override
- {
- return RestoreValue(name, value);
- }
+ public:
+ explicit PersistentStore(wxPersistentTLW *pers)
+ : m_pers(pers)
+ {
+ }
+
+ virtual bool SaveValue(const wxString& name, int value) override
+ {
+ return m_pers->SaveValue(name, value);
+ }
+
+ virtual bool RestoreValue(const wxString& name, int* value) const override
+ {
+ return m_pers->RestoreValue(name, value);
+ }
+
+ private:
+ wxPersistentTLW* const m_pers;
+ };
+
+ // This is mutable because we need to be able to call SaveValue() from
+ // const Save(). It is fine for the object which doesn't have any internal
+ // state anyhow.
+ mutable PersistentStore m_store;
};
inline wxPersistentObject *wxCreatePersistentObject(wxTopLevelWindow *tlw)
=====================================
include/wx/private/tlwgeom.h
=====================================
@@ -27,7 +27,7 @@
class wxTLWGeometryBase
{
public:
- typedef wxTopLevelWindow::GeometrySerializer Serializer;
+ typedef wxTopLevelWindow::GeometryStore Store;
wxTLWGeometryBase() = default;
virtual ~wxTLWGeometryBase() = default;
@@ -40,8 +40,8 @@ public:
// Serialize or deserialize the object by using the provided object for
// writing/reading the values of the different fields of this object.
- virtual bool Save(const Serializer& ser) const = 0;
- virtual bool Restore(Serializer& ser) = 0;
+ virtual bool Save(Store& store) const = 0;
+ virtual bool Restore(const Store& store) = 0;
};
// ----------------------------------------------------------------------------
@@ -71,38 +71,38 @@ public:
m_maximized = false;
}
- virtual bool Save(const Serializer& ser) const override
+ virtual bool Save(Store& store) const override
{
- if ( !ser.SaveField(wxPERSIST_TLW_X, m_rectScreen.x) ||
- !ser.SaveField(wxPERSIST_TLW_Y, m_rectScreen.y) )
+ if ( !store.SaveValue(wxPERSIST_TLW_X, m_rectScreen.x) ||
+ !store.SaveValue(wxPERSIST_TLW_Y, m_rectScreen.y) )
return false;
- if ( !ser.SaveField(wxPERSIST_TLW_W, m_rectScreen.width) ||
- !ser.SaveField(wxPERSIST_TLW_H, m_rectScreen.height) )
+ if ( !store.SaveValue(wxPERSIST_TLW_W, m_rectScreen.width) ||
+ !store.SaveValue(wxPERSIST_TLW_H, m_rectScreen.height) )
return false;
- if ( !ser.SaveField(wxPERSIST_TLW_MAXIMIZED, m_maximized) )
+ if ( !store.SaveValue(wxPERSIST_TLW_MAXIMIZED, m_maximized) )
return false;
- if ( !ser.SaveField(wxPERSIST_TLW_ICONIZED, m_iconized) )
+ if ( !store.SaveValue(wxPERSIST_TLW_ICONIZED, m_iconized) )
return false;
return true;
}
- virtual bool Restore(Serializer& ser) override
+ virtual bool Restore(const Store& store) override
{
- m_hasPos = ser.RestoreField(wxPERSIST_TLW_X, &m_rectScreen.x) &&
- ser.RestoreField(wxPERSIST_TLW_Y, &m_rectScreen.y);
+ m_hasPos = store.RestoreValue(wxPERSIST_TLW_X, &m_rectScreen.x) &&
+ store.RestoreValue(wxPERSIST_TLW_Y, &m_rectScreen.y);
- m_hasSize = ser.RestoreField(wxPERSIST_TLW_W, &m_rectScreen.width) &&
- ser.RestoreField(wxPERSIST_TLW_H, &m_rectScreen.height);
+ m_hasSize = store.RestoreValue(wxPERSIST_TLW_W, &m_rectScreen.width) &&
+ store.RestoreValue(wxPERSIST_TLW_H, &m_rectScreen.height);
int tmp;
- if ( ser.RestoreField(wxPERSIST_TLW_MAXIMIZED, &tmp) )
+ if ( store.RestoreValue(wxPERSIST_TLW_MAXIMIZED, &tmp) )
m_maximized = tmp != 0;
- if ( ser.RestoreField(wxPERSIST_TLW_ICONIZED, &tmp) )
+ if ( store.RestoreValue(wxPERSIST_TLW_ICONIZED, &tmp) )
m_iconized = tmp != 0;
// If we restored at least something, return true.
=====================================
include/wx/toplevel.h
=====================================
@@ -260,32 +260,58 @@ public:
wxWindow *SetTmpDefaultItem(wxWindow *win);
- // Class for saving/restoring fields describing the window geometry.
+ // Class for saving/restoring values 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
+ class GeometryStore
{
public:
- virtual ~GeometrySerializer() = default;
+ virtual ~GeometryStore() = default;
- // If saving a field returns false, it's fatal error and SaveGeometry()
+ // If saving a value returns false, it's fatal error and SaveGeometry()
// will return false.
- virtual bool SaveField(const wxString& name, int value) const = 0;
+ virtual bool SaveValue(const wxString& name, int value) = 0;
- // If restoring a field returns false, it just means that the field is
+ // If restoring a value returns false, it just means that the value is
// not present and RestoreToGeometry() still continues with restoring
// the other values.
- virtual bool RestoreField(const wxString& name, int* value) = 0;
+ virtual bool RestoreValue(const wxString& name, int* value) const = 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);
+ bool SaveGeometry(GeometryStore& store) const;
+ bool RestoreToGeometry(const GeometryStore& store);
+
+
+ // Deprecated class using wrong const qualifiers for its member functions,
+ // change your code to use GeometryStore instead and don't use in new code.
+ class wxDEPRECATED_MSG("Use GeometryStore instead") GeometrySerializer
+ : public GeometryStore
+ {
+ public:
+ virtual bool SaveValue(const wxString& name, int value) override
+ {
+ return SaveField(name, value);
+ }
+
+ virtual bool RestoreValue(const wxString& name, int* value) const override
+ {
+ // gcc 4.8 gives a warning for const-cast below.
+ wxGCC_WARNING_SUPPRESS(deprecated-declarations)
+
+ return const_cast<GeometrySerializer*>(this)->RestoreField(name, value);
+
+ wxGCC_WARNING_RESTORE(deprecated-declarations)
+ }
+
+ virtual bool SaveField(const wxString& name, int value) const = 0;
+ virtual bool RestoreField(const wxString& name, int* value) = 0;
+ };
// implementation only from now on
=====================================
interface/wx/toplevel.h
=====================================
@@ -408,16 +408,16 @@ public:
Class used with SaveGeometry() and RestoreToGeometry().
This is an abstract base class, i.e. to use it you must define a
- derived class implementing the pure virtual SaveField() and
- RestoreField() methods.
+ derived class implementing the pure virtual SaveValue() and
+ RestoreValue() methods.
For example, if you wished to store the window geometry in a database,
you could derive a class saving fields such as "width" or "height" in a
table in this database and restoring them from it later.
- @since 3.1.2
+ @since 3.3.0
*/
- class GeometrySerializer
+ class GeometryStore
{
/**
Save a single field with the given value.
@@ -434,12 +434,12 @@ public:
@return @true if the field was saved or @false if saving it failed,
resulting in wxTopLevelWindow::SaveGeometry() failure.
*/
- virtual bool SaveField(const wxString& name, int value) const = 0;
+ virtual bool SaveValue(const wxString& name, int value) = 0;
/**
Try to restore a single field.
- Unlike for SaveField(), returning @false from this function may
+ Unlike for SaveValue(), returning @false from this function may
indicate that the value simply wasn't present and doesn't prevent
RestoreToGeometry() from continuing with trying to restore the
other values.
@@ -451,7 +451,7 @@ public:
@return @true if the value was retrieved or @false if it wasn't
found or an error occurred.
*/
- virtual bool RestoreField(const wxString& name, int* value) = 0;
+ virtual bool RestoreValue(const wxString& name, int* value) const = 0;
};
/**
@@ -460,7 +460,7 @@ public:
This is a companion function to SaveGeometry() and can be called later
to restore the window to the geometry it had when it was saved.
- @param ser An object implementing GeometrySerializer virtual methods.
+ @param ser An object implementing GeometryStore virtual methods.
@return @true if any (and, usually, but not necessarily, all) of the
window geometry attributes were restored or @false if there was no
@@ -468,7 +468,7 @@ public:
@since 3.1.2
*/
- bool RestoreToGeometry(GeometrySerializer& ser);
+ bool RestoreToGeometry(const GeometryStore& ser);
/**
Save the current window geometry to allow restoring it later.
@@ -484,13 +484,13 @@ public:
simplest possible way. However is more flexibility is required, it can
be also used directly with a custom serializer object.
- @param ser An object implementing GeometrySerializer virtual methods.
+ @param ser An object implementing GeometryStore virtual methods.
@return @true if the geometry was saved, @false if doing it failed
@since 3.1.2
*/
- bool SaveGeometry(const GeometrySerializer& ser) const;
+ bool SaveGeometry(GeometryStore& ser) const;
/**
Changes the default item for the panel, usually @a win is a button.
=====================================
src/common/toplvcmn.cpp
=====================================
@@ -333,19 +333,19 @@ wxWindow* wxTopLevelWindowBase::SetTmpDefaultItem(wxWindow* win)
// Saving/restoring geometry
// ----------------------------------------------------------------------------
-bool wxTopLevelWindowBase::SaveGeometry(const GeometrySerializer& ser) const
+bool wxTopLevelWindowBase::SaveGeometry(GeometryStore& store) const
{
wxTLWGeometry geom;
if ( !geom.GetFrom(static_cast<const wxTopLevelWindow*>(this)) )
return false;
- return geom.Save(ser);
+ return geom.Save(store);
}
-bool wxTopLevelWindowBase::RestoreToGeometry(GeometrySerializer& ser)
+bool wxTopLevelWindowBase::RestoreToGeometry(const GeometryStore& store)
{
wxTLWGeometry geom;
- if ( !geom.Restore(ser) )
+ if ( !geom.Restore(store) )
return false;
return geom.ApplyTo(static_cast<wxTopLevelWindow*>(this));
View it on GitLab:
https://gitlab.com/wxwidgets/wxwidgets/-/compare/e743d674cf0121eca93988bb917736d26eba6dfa...96939340cc4f92be7c92727b3c57bc76961cf57b
--
View it on GitLab:
https://gitlab.com/wxwidgets/wxwidgets/-/compare/e743d674cf0121eca93988bb917736d26eba6dfa...96939340cc4f92be7c92727b3c57bc76961cf57b
You're receiving this email because of your account on
gitlab.com. Manage all notifications:
https://gitlab.com/-/profile/notifications | Help:
https://gitlab.com/help