Skip to content

Commit

Permalink
wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBa…
Browse files Browse the repository at this point in the history
…r widget (OSGeo#1689)

Builds status bars based on wx.StatusBar for SwipeMapFrame, IClassMapFrame, Image2Target Frame, Photo2Image Frame, and GCP manager MapFrame.
Some general methods related to a status bar and toolbars moved to gui_core class MapFrameBase.
  • Loading branch information
a0x8o committed Sep 5, 2024
1 parent 07d94d7 commit 8d52a1c
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 0 deletions.
10 changes: 10 additions & 0 deletions gui/wxpython/gcp/mapdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ def __init__(
sbgcp.SbRMSError,
]
self.statusbar = self.CreateStatusbar(statusbarItems)
<<<<<<< HEAD
=======
self.statusbarManager.SetMode(8) # goto GCP
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))

#
# Init map display (buffered DC & set default cursor)
Expand Down Expand Up @@ -237,13 +241,19 @@ def AddToolbar(self, name):
# default toolbar
if name == "map":
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
if "map" not in self.toolbars:
self.toolbars["map"] = MapToolbar(
self, self._toolSwitcher, self._giface
)
<<<<<<< HEAD
=======
self.toolbars["map"] = MapToolbar(self, self._toolSwitcher, self._giface)
>>>>>>> 953489b535 (wxGUI: fix layout flag assert in wms dialog (#1764))
=======
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))

self._mgr.AddPane(
self.toolbars["map"],
Expand Down
38 changes: 38 additions & 0 deletions gui/wxpython/gui_core/mapdisp.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
from gui_core.toolbars import ToolSwitcher
from gui_core.wrap import NewId
from mapdisp import statusbar as sb
<<<<<<< HEAD
from mapwin.base import MapWindowProperties
=======
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))

from grass.script import core as grass

Expand Down Expand Up @@ -159,6 +162,17 @@ def OnSize(self, event):
# update statusbar
self.StatusbarUpdate()
<<<<<<< HEAD
=======
def OnFullScreen(self, event):
"""!Switch fullscreen mode, hides also toolbars"""
for toolbar in self.toolbars:
self._mgr.GetPane(self.toolbars[toolbar]).Show(self.IsFullScreen())
self._mgr.Update()
self.ShowFullScreen(not self.IsFullScreen())
event.Skip()
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
def OnCloseWindow(self, event):
self.Destroy()
Expand Down Expand Up @@ -326,17 +340,31 @@ def CreateStatusbar(self, statusbarItems):
# create statusbar and its manager
statusbar = wx.StatusBar(self, id=wx.ID_ANY)
statusbar.SetMinHeight(24)
<<<<<<< HEAD
statusbar.SetFieldsCount(3)
statusbar.SetStatusWidths([-6, -2, -1])
=======
statusbar.SetFieldsCount(4)
statusbar.SetStatusWidths([-5, -2, -1, -1])
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
self.statusbarManager = sb.SbManager(mapframe=self, statusbar=statusbar)
# fill statusbar manager
self.statusbarManager.AddStatusbarItemsByClass(
statusbarItems, mapframe=self, statusbar=statusbar
)
self.statusbarManager.AddStatusbarItem(
<<<<<<< HEAD
sb.SbRender(self, statusbar=statusbar, position=2)
)
=======
sb.SbMask(self, statusbar=statusbar, position=2)
)
self.statusbarManager.AddStatusbarItem(
sb.SbRender(self, statusbar=statusbar, position=3)
)
self.statusbarManager.Update()
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
return statusbar
def AddStatusbarPane(self):
Expand All @@ -357,7 +385,11 @@ def AddStatusbarPane(self):
)
def SetStatusText(self, *args):
<<<<<<< HEAD
"""Override wx.StatusBar method"""
=======
"""Overide wx.StatusBar method"""
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
self.statusbar.SetStatusText(*args)
def ShowStatusbar(self, show):
Expand All @@ -381,6 +413,9 @@ def StatusbarEnableLongHelp(self, enable=True):
toolbar.EnableLongHelp(enable)
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
def ShowAllToolbars(self, show=True):
if not show: # hide
action = self.RemoveToolbar
Expand Down Expand Up @@ -422,8 +457,11 @@ def IsPaneShown(self, name):
return self._mgr.GetPane(name).IsShown()
return False
<<<<<<< HEAD
=======
>>>>>>> 953489b535 (wxGUI: fix layout flag assert in wms dialog (#1764))
=======
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
def OnRender(self, event):
"""Re-render map composition (each map layer)"""
raise NotImplementedError("OnRender")
Expand Down
16 changes: 16 additions & 0 deletions gui/wxpython/iclass/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,19 @@ def __init__(
sb.SbCoordinates,
sb.SbRegionExtent,
sb.SbCompRegionExtent,
<<<<<<< HEAD
sb.SbDisplayGeometry,
sb.SbMapScale,
sb.SbGoTo,
=======
sb.SbShowRegion,
sb.SbAlignExtent,
sb.SbResolution,
sb.SbDisplayGeometry,
sb.SbMapScale,
sb.SbGoTo,
sb.SbProjection,
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
]
self.statusbar = self.CreateStatusbar(statusbarItems)
self._addPanes()
Expand Down Expand Up @@ -364,6 +374,9 @@ def AddToolbar(self, name):

if name == "vdigit":
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
if "vdigit" not in self.toolbars:
self.toolbars[name] = VDigitToolbar(
parent=self,
Expand All @@ -385,6 +398,7 @@ def AddToolbar(self, name):
],
)

<<<<<<< HEAD
=======
self.toolbars[name] = VDigitToolbar(
parent=self,
Expand All @@ -406,6 +420,8 @@ def AddToolbar(self, name):
],
)
>>>>>>> 953489b535 (wxGUI: fix layout flag assert in wms dialog (#1764))
=======
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
self._mgr.AddPane(
self.toolbars[name],
wx.aui.AuiPaneInfo()
Expand Down
11 changes: 11 additions & 0 deletions gui/wxpython/image2target/ii2t_mapdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ def __init__(

# create statusbar and its manager
self.statusbar = self.CreateStatusbar(statusbarItems)
<<<<<<< HEAD
=======

self.statusbarManager.SetMode(8) # goto GCP
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))

#
# Init map display (buffered DC & set default cursor)
Expand Down Expand Up @@ -240,13 +245,19 @@ def AddToolbar(self, name):
# default toolbar
if name == "map":
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
if "map" not in self.toolbars:
self.toolbars["map"] = MapToolbar(
self, self._toolSwitcher, self._giface
)
<<<<<<< HEAD
=======
self.toolbars["map"] = MapToolbar(self, self._toolSwitcher, self._giface)
>>>>>>> 953489b535 (wxGUI: fix layout flag assert in wms dialog (#1764))
=======
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))

self._mgr.AddPane(
self.toolbars["map"],
Expand Down
34 changes: 34 additions & 0 deletions gui/wxpython/mapdisp/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,36 @@ def __init__(
if statusbar:
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
# items for choice
statusbarItems = [
sb.SbCoordinates,
sb.SbRegionExtent,
sb.SbCompRegionExtent,
<<<<<<< HEAD
sb.SbDisplayGeometry,
sb.SbMapScale,
sb.SbGoTo,
]
self.statusbarItemsDisabledInNviz = (
sb.SbDisplayGeometry,
=======
sb.SbShowRegion,
sb.SbAlignExtent,
sb.SbResolution,
sb.SbDisplayGeometry,
sb.SbMapScale,
sb.SbGoTo,
sb.SbProjection,
]
self.statusbarItemsHiddenInNviz = (
sb.SbAlignExtent,
sb.SbDisplayGeometry,
sb.SbShowRegion,
sb.SbResolution,
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
sb.SbMapScale,
)
self.statusbar = self.CreateStatusbar(statusbarItems)
Expand All @@ -176,12 +195,15 @@ def __init__(
% {"command": " ".join(cmd), "error": error}
)
)
<<<<<<< HEAD
=======
self.statusbar = self.CreateStatusbar()
>>>>>>> 015cec3442 (wxGUI/map display: manage wx.StatusBar widget by AUI (#1646))
=======
self.statusbar = self.CreateStatusbar()
>>>>>>> 270077e68a (wxGUI/map display: manage wx.StatusBar widget by AUI (#1646))
=======
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))

# init decoration objects
self.decorations = {}
Expand Down Expand Up @@ -251,6 +273,7 @@ def __init__(
.Layer(0),
)

<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
# statusbar
Expand Down Expand Up @@ -278,6 +301,11 @@ def __init__(
>>>>>>> 015cec3442 (wxGUI/map display: manage wx.StatusBar widget by AUI (#1646))
=======
>>>>>>> 270077e68a (wxGUI/map display: manage wx.StatusBar widget by AUI (#1646))
=======
# statusbar
self.AddStatusbarPane()

>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
self._mgr.Update()

#
Expand Down Expand Up @@ -338,6 +366,7 @@ def on_show_hide_statusbar(event):
action=on_show_hide_statusbar,
)

<<<<<<< HEAD
def CreateStatusbar(self):
if self.statusbarManager:
return
Expand Down Expand Up @@ -450,6 +479,8 @@ def SetStatusText(self, *args):
"""Overide wx.StatusBar method"""
self.statusbar.SetStatusText(*args)
=======
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
def GetMapWindow(self):
return self.MapWindow
Expand Down Expand Up @@ -815,6 +846,7 @@ def RemoveToolbar(self, name, destroy=False):

self._mgr.Update()

<<<<<<< HEAD
<<<<<<< HEAD
=======
def ShowAllToolbars(self, show=True):
Expand All @@ -835,6 +867,8 @@ def IsPaneShown(self, name):
return False
>>>>>>> da7f79c3f9 (libpython: Save and load benchmark results (#1711))
=======
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
def RemoveQueryLayer(self):
"""Removes temporary map layers (queries)"""
qlayer = self.GetMap().GetListOfLayers(name=globalvar.QUERYLAYER)
Expand Down
22 changes: 22 additions & 0 deletions gui/wxpython/mapswipe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,19 @@ def __init__(
sb.SbCoordinates,
sb.SbRegionExtent,
sb.SbCompRegionExtent,
<<<<<<< HEAD
sb.SbDisplayGeometry,
sb.SbMapScale,
sb.SbGoTo,
=======
sb.SbShowRegion,
sb.SbAlignExtent,
sb.SbResolution,
sb.SbDisplayGeometry,
sb.SbMapScale,
sb.SbGoTo,
sb.SbProjection,
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
]
self.statusbar = self.CreateStatusbar(statusbarItems)

Expand Down Expand Up @@ -274,7 +284,11 @@ def AddToolbar(self, name):
.Layer(2)
.Row(1)
.Position(0)
<<<<<<< HEAD
.BestSize(self.toolbars["swipeMain"].GetBestSize()),
=======
.BestSize((self.toolbars["swipeMain"].GetBestSize())),
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
)

if name == "swipeMap":
Expand All @@ -296,7 +310,11 @@ def AddToolbar(self, name):
.Layer(2)
.Row(1)
.Position(1)
<<<<<<< HEAD
.BestSize(self.toolbars["swipeMap"].GetBestSize()),
=======
.BestSize((self.toolbars["swipeMap"].GetBestSize())),
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
)

if name == "swipeMisc":
Expand All @@ -318,7 +336,11 @@ def AddToolbar(self, name):
.Layer(2)
.Row(1)
.Position(2)
<<<<<<< HEAD
.BestSize(self.toolbars["swipeMisc"].GetBestSize()),
=======
.BestSize((self.toolbars["swipeMisc"].GetBestSize())),
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
)

def _addPanes(self):
Expand Down
10 changes: 10 additions & 0 deletions gui/wxpython/photo2image/ip2i_mapdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ def __init__(

# create statusbar and its manager
self.statusbar = self.CreateStatusbar(statusbarItems)
<<<<<<< HEAD
=======
self.statusbarManager.SetMode(8) # goto GCP
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))

#
# Init map display (buffered DC & set default cursor)
Expand Down Expand Up @@ -232,13 +236,19 @@ def AddToolbar(self, name):
# default toolbar
if name == "map":
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))
if "map" not in self.toolbars:
self.toolbars["map"] = MapToolbar(
self, self._toolSwitcher, self._giface
)
<<<<<<< HEAD
=======
self.toolbars["map"] = MapToolbar(self, self._toolSwitcher, self._giface)
>>>>>>> 953489b535 (wxGUI: fix layout flag assert in wms dialog (#1764))
=======
>>>>>>> 03a790ad9a (wxGUI: refactoring: build GUI tools' status bars based on wx.StatusBar widget (#1689))

self._mgr.AddPane(
self.toolbars["map"],
Expand Down
Loading

0 comments on commit 8d52a1c

Please sign in to comment.