diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-12-04 17:11:52 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-12-04 20:08:08 +0000 |
commit | 0bde9091b00516096657cb7ed82898d486072355 (patch) | |
tree | 2e941b79f3f6430a758b6e99e75e3de254e214ef /vcl/source/window | |
parent | 839272421fcf4c7bd1ebb0e526fb1476a0cb84c6 (diff) |
remove ability to auto-replace .res widgets with .ui versions
it worked, and was sort of cool, but complicated and potentially fragile and
I've lost interest in maintaining it as a stepping stone towards full .ui
conversion in favour of just fully converted to .ui
Change-Id: I27cfd4061ef15cd691ac6ddaa7155afd025182ec
Diffstat (limited to 'vcl/source/window')
-rw-r--r-- | vcl/source/window/builder.cxx | 83 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 71 | ||||
-rw-r--r-- | vcl/source/window/tabpage.cxx | 11 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/window2.cxx | 152 |
5 files changed, 6 insertions, 315 deletions
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 5b4b5e29f452..e5711e989615 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -586,13 +586,10 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri { //We have to add a page - //make default pageid == -position. Partitioning the - //id space into negative numbers for auto-generated - //ids and positive numbers for the handleTabChild - //derived ids + //make default pageid == position TabControl *pTabControl = static_cast<TabControl*>(pParent); sal_uInt16 nNewPageCount = pTabControl->GetPageCount()+1; - sal_uInt16 nNewPageId = -nNewPageCount; + sal_uInt16 nNewPageId = nNewPageCount; pTabControl->InsertPage(nNewPageId, OUString()); pTabControl->SetCurPageId(nNewPageId); @@ -944,31 +941,6 @@ Window *VclBuilder::insertObject(Window *pParent, const OString &rClass, return pCurrentChild; } -sal_uInt16 VclBuilder::getPositionWithinParent(Window &rWindow) -{ - if (rWindow.mpWindowImpl->mpParent != rWindow.mpWindowImpl->mpRealParent) - { - assert(rWindow.mpWindowImpl->mpBorderWindow == - rWindow.mpWindowImpl->mpParent); - assert(rWindow.mpWindowImpl->mpBorderWindow->mpWindowImpl->mpParent == - rWindow.mpWindowImpl->mpRealParent); - return getPositionWithinParent(*rWindow.mpWindowImpl->mpBorderWindow); - } - - assert(rWindow.GetParent() == rWindow.mpWindowImpl->mpRealParent); - - sal_uInt16 nPosition = 0; - Window* pChild = rWindow.GetParent()->mpWindowImpl->mpFirstChild; - while (pChild) - { - if (pChild == &rWindow) - break; - pChild = pChild->mpWindowImpl->mpNext; - ++nPosition; - } - return nPosition; -} - void VclBuilder::reorderWithinParent(Window &rWindow, sal_uInt16 nNewPosition) { if (rWindow.mpWindowImpl->mpParent != rWindow.mpWindowImpl->mpRealParent) @@ -1036,24 +1008,8 @@ void VclBuilder::handleTabChild(Window *pParent, xmlreader::XmlReader &reader) VclBuilder::stringmap::iterator aFind = aProperties.find(OString("label")); if (aFind != aProperties.end()) { - pTabControl->SetPageText(pTabControl->GetCurPageId(), OStringToOUString(aFind->second, RTL_TEXTENCODING_UTF8)); - - sal_Int32 nID = 0; - //To make it easier to retro fit pre-builder dialog code we take the - //notebook child id (falling back to notebook label id) and if its a - //positive number use that as the page id so existing code can find the - //right tabpage by id - TabPage *pPage = pTabControl->GetTabPage(pTabControl->GetCurPageId()); - if (pPage) - { - VclBin *pContainer = static_cast<VclBin*>(pPage->GetWindow(WINDOW_FIRSTCHILD)); - Window *pChild = pContainer->get_child(); - nID = pChild ? get_by_window(pChild).toInt32() : 0; - } - if (nID == 0) - nID = sID.toInt32(); - if (nID > 0) - pTabControl->ReassignPageId(pTabControl->GetCurPageId(), nID); + pTabControl->SetPageText(pTabControl->GetCurPageId(), + OStringToOUString(aFind->second, RTL_TEXTENCODING_UTF8)); } else pTabControl->RemovePage(pTabControl->GetCurPageId()); @@ -1701,37 +1657,6 @@ const VclBuilder::Adjustment *VclBuilder::get_adjustment_by_name(OString sID) co return NULL; } -void VclBuilder::swapGuts(Window &rOrig, Window &rReplacement) -{ - sal_uInt16 nPosition = getPositionWithinParent(rOrig); - - rReplacement.take_properties(rOrig); - - reorderWithinParent(rReplacement, nPosition); - - assert(nPosition == getPositionWithinParent(rReplacement)); -} - -bool VclBuilder::replace(OString sID, Window &rReplacement) -{ - for (std::vector<WinAndId>::iterator aI = m_aChildren.begin(), - aEnd = m_aChildren.end(); aI != aEnd; ++aI) - { - if (aI->m_sID.equals(sID)) - { - Window *pOrig = aI->m_pWindow; - swapGuts(*pOrig, rReplacement); - delete pOrig; - - aI->m_pWindow = &rReplacement; - aI->m_bOwned = false; - return true; - } - } - SAL_WARN("vcl.layout", "no sign of :" << sID.getStr()); - return false; -} - void VclBuilder::mungeModel(ListBox &rTarget, const ListStore &rStore) { for (std::vector<ListStore::row>::const_iterator aI = rStore.m_aEntries.begin(), aEnd = rStore.m_aEntries.end(); diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 3ef0f445b446..24da8ef7c23b 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -540,41 +540,12 @@ Dialog::Dialog( Window* pParent, WinBits nStyle ) ImplInit( pParent, nStyle ); } -VclBuilder* VclBuilderContainer::overrideResourceWithUIXML(Window *pWindow, const ResId& rResId) -{ - sal_Int32 nUIid = static_cast<sal_Int32>(rResId.GetId()); - - rtl::OUString sRoot = getUIRootDir(); - rtl::OUString sPath = rtl::OUStringBuffer( - rResId.GetResMgr()->getPrefixName()). - append("/ui/"). - append(nUIid). - appendAscii(".ui"). - makeStringAndClear(); - - osl::File aUIFile(sRoot + sPath); - osl::File::RC error = aUIFile.open(osl_File_OpenFlag_Read); - //good, use the preferred GtkBuilder xml - if (error == osl::File::E_None) - return new VclBuilder(pWindow, sRoot, sPath, rtl::OString::valueOf(nUIid)); - return NULL; -} - WinBits Dialog::init(Window *pParent, const ResId& rResId) { WinBits nStyle = ImplInitRes( rResId ); ImplInit( pParent, nStyle ); - - m_pUIBuilder = overrideResourceWithUIXML(this, rResId); - - if (m_pUIBuilder) - loadAndSetJustHelpID(rResId); - else - { - //fallback to using the binary resource file - ImplLoadRes( rResId ); - } + ImplLoadRes( rResId ); return nStyle; } @@ -1254,46 +1225,6 @@ VclBuilderContainer::~VclBuilderContainer() delete m_pUIBuilder; } -bool VclBuilderContainer::replace_buildable(Window *pParent, const ResId& rResId, Window &rReplacement) -{ - if (!pParent) - return false; - - VclBuilderContainer *pBuilderContainer = dynamic_cast<VclBuilderContainer*>(pParent); - if (!pBuilderContainer) - return false; - - VclBuilder *pUIBuilder = pBuilderContainer->m_pUIBuilder; - if (!pUIBuilder) - return false; - - sal_Int32 nID = rResId.GetId(); - - bool bFound = pUIBuilder->replace(rtl::OString::valueOf(nID), rReplacement); - if (bFound) - { - rReplacement.loadAndSetJustHelpID(rResId); - } - else - { - SAL_WARN("vcl.layout", "widget " << nID << " " << &rReplacement << " not found, hiding"); - //move "missing" elements into the action area (just to have - //a known container as an owner) and hide it - Window* pArbitraryParent; - if (pParent->IsDialog()) - { - Dialog *pDialog = static_cast<Dialog*>(pParent); - pArbitraryParent = getActionArea(pDialog); - } - else - pArbitraryParent = pParent->GetWindow(WINDOW_FIRSTCHILD); - rReplacement.ImplInit(pArbitraryParent, 0, NULL); - rReplacement.Hide(); - } - - return true; -} - // ----------------------------------------------------------------------- ModelessDialog::ModelessDialog( Window* pParent, const ResId& rResId ) : diff --git a/vcl/source/window/tabpage.cxx b/vcl/source/window/tabpage.cxx index 3546c4f15508..5f04373db18a 100644 --- a/vcl/source/window/tabpage.cxx +++ b/vcl/source/window/tabpage.cxx @@ -89,16 +89,7 @@ TabPage::TabPage( Window* pParent, const ResId& rResId ) : rResId.SetRT( RSC_TABPAGE ); WinBits nStyle = ImplInitRes( rResId ); ImplInit( pParent, nStyle ); - - m_pUIBuilder = overrideResourceWithUIXML(this, rResId); - - if (m_pUIBuilder) - loadAndSetJustHelpID(rResId); - else - { - //fallback to using the binary resource file - ImplLoadRes(rResId); - } + ImplLoadRes(rResId); if ( !(nStyle & WB_HIDE) ) Show(); diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index bf7da997cf5a..15b8e8f429a7 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -4207,10 +4207,6 @@ Window::Window( Window* pParent, const ResId& rResId ) rResId.SetRT( RSC_WINDOW ); WinBits nStyle = ImplInitRes( rResId ); - - if (VclBuilderContainer::replace_buildable(pParent, rResId, *this)) - return; - ImplInitWindowData( WINDOW_WINDOW ); ImplInit( pParent, nStyle, NULL ); ImplLoadRes( rResId ); diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index 0459a5be7b86..051dfecec930 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -1779,158 +1779,6 @@ void Window::queue_resize() pDialog->queue_layout(); } -//We deliberately do not overwrite our maHelpId here -//so that the .res loaded id is not overwritten -//by the .ui loaded one -void Window::take_properties(Window &rOther) -{ - if (!mpWindowImpl) - { - ImplInitWindowData(WINDOW_WINDOW); - ImplInit(rOther.GetParent(), rOther.GetStyle(), NULL); - } - - WindowImpl *pWindowImpl = rOther.mpWindowImpl; - if (!mpWindowImpl->mpRealParent) - ImplInit(pWindowImpl->mpRealParent, rOther.GetStyle(), NULL); - std::swap(mpWindowImpl->mpUserData, pWindowImpl->mpUserData); - std::swap(mpWindowImpl->mpCursor, pWindowImpl->mpCursor); - std::swap(mpWindowImpl->maPointer, pWindowImpl->maPointer); - mpWindowImpl->maZoom = pWindowImpl->maZoom; - mpWindowImpl->maText = pWindowImpl->maText; - std::swap(mpWindowImpl->mpControlFont, pWindowImpl->mpControlFont); - mpWindowImpl->maControlForeground = pWindowImpl->maControlForeground; - mpWindowImpl->maControlBackground = pWindowImpl->maControlBackground; - mpWindowImpl->mnLeftBorder = pWindowImpl->mnLeftBorder; - mpWindowImpl->mnTopBorder = pWindowImpl->mnTopBorder; - mpWindowImpl->mnRightBorder = pWindowImpl->mnRightBorder; - mpWindowImpl->mnBottomBorder = pWindowImpl->mnBottomBorder; - mpWindowImpl->mnWidthRequest = pWindowImpl->mnWidthRequest; - mpWindowImpl->mnHeightRequest = pWindowImpl->mnHeightRequest; - mpWindowImpl->mnX = pWindowImpl->mnX; - mpWindowImpl->mnY = pWindowImpl->mnY; - mpWindowImpl->mnAbsScreenX = pWindowImpl->mnAbsScreenX; - mpWindowImpl->maPos = pWindowImpl->maPos; - mpWindowImpl->maUniqId = pWindowImpl->maUniqId; - mpWindowImpl->maHelpText = pWindowImpl->maHelpText; - mpWindowImpl->maQuickHelpText = pWindowImpl->maQuickHelpText; - std::swap(mpWindowImpl->maInputContext, pWindowImpl->maInputContext); - mpWindowImpl->mnStyle = pWindowImpl->mnStyle; - mpWindowImpl->mnPrevStyle = pWindowImpl->mnPrevStyle; - mpWindowImpl->mnExtendedStyle = pWindowImpl->mnExtendedStyle; - mpWindowImpl->mnPrevExtendedStyle = pWindowImpl->mnPrevExtendedStyle; - mpWindowImpl->mnType = pWindowImpl->mnType; - mpWindowImpl->mnNativeBackground = pWindowImpl->mnNativeBackground; - mpWindowImpl->mnWaitCount = pWindowImpl->mnWaitCount; - mpWindowImpl->mnPaintFlags = pWindowImpl->mnPaintFlags; - mpWindowImpl->mnGetFocusFlags = pWindowImpl->mnGetFocusFlags; - mpWindowImpl->mnParentClipMode = pWindowImpl->mnParentClipMode; - mpWindowImpl->mnActivateMode = pWindowImpl->mnActivateMode; - mpWindowImpl->mnDlgCtrlFlags = pWindowImpl->mnDlgCtrlFlags; - mpWindowImpl->mnLockCount = pWindowImpl->mnLockCount; - mpWindowImpl->meAlwaysInputMode = pWindowImpl->meAlwaysInputMode; - mpWindowImpl->meHalign = pWindowImpl->meHalign; - mpWindowImpl->meValign = pWindowImpl->meValign; - mpWindowImpl->mePackType = pWindowImpl->mePackType; - mpWindowImpl->mnPadding = pWindowImpl->mnPadding; - mpWindowImpl->mnGridHeight = pWindowImpl->mnGridHeight; - mpWindowImpl->mnGridLeftAttach = pWindowImpl->mnGridLeftAttach; - mpWindowImpl->mnGridTopAttach = pWindowImpl->mnGridTopAttach; - mpWindowImpl->mnGridWidth = pWindowImpl->mnGridWidth; - mpWindowImpl->mnBorderWidth = pWindowImpl->mnBorderWidth; - mpWindowImpl->mnMarginLeft = pWindowImpl->mnMarginLeft; - mpWindowImpl->mnMarginRight = pWindowImpl->mnMarginRight; - mpWindowImpl->mnMarginTop = pWindowImpl->mnMarginTop; - mpWindowImpl->mnMarginBottom = pWindowImpl->mnMarginBottom; - mpWindowImpl->mbFrame = pWindowImpl->mbFrame; - mpWindowImpl->mbBorderWin = pWindowImpl->mbBorderWin; - mpWindowImpl->mbOverlapWin = pWindowImpl->mbOverlapWin; - mpWindowImpl->mbSysWin = pWindowImpl->mbSysWin; - mpWindowImpl->mbDialog = pWindowImpl->mbDialog; - mpWindowImpl->mbDockWin = pWindowImpl->mbDockWin; - mpWindowImpl->mbFloatWin = pWindowImpl->mbFloatWin; - mpWindowImpl->mbPushButton = pWindowImpl->mbPushButton; - mpWindowImpl->mbVisible = pWindowImpl->mbVisible; - mpWindowImpl->mbDisabled = pWindowImpl->mbDisabled; - mpWindowImpl->mbInputDisabled = pWindowImpl->mbInputDisabled; - mpWindowImpl->mbDropDisabled = pWindowImpl->mbDropDisabled; - mpWindowImpl->mbNoUpdate = pWindowImpl->mbNoUpdate; - mpWindowImpl->mbNoParentUpdate = pWindowImpl->mbNoParentUpdate; - mpWindowImpl->mbActive = pWindowImpl->mbActive; - mpWindowImpl->mbParentActive = pWindowImpl->mbParentActive; - mpWindowImpl->mbReallyVisible = pWindowImpl->mbReallyVisible; - mpWindowImpl->mbReallyShown = pWindowImpl->mbReallyShown; - mpWindowImpl->mbInInitShow = pWindowImpl->mbInInitShow; - mpWindowImpl->mbChildNotify = pWindowImpl->mbChildNotify; - mpWindowImpl->mbChildPtrOverwrite = pWindowImpl->mbChildPtrOverwrite; - mpWindowImpl->mbNoPtrVisible = pWindowImpl->mbNoPtrVisible; - mpWindowImpl->mbPaintFrame = pWindowImpl->mbPaintFrame; - mpWindowImpl->mbInPaint = pWindowImpl->mbInPaint; - mpWindowImpl->mbMouseMove = pWindowImpl->mbMouseMove; - mpWindowImpl->mbMouseButtonDown = pWindowImpl->mbMouseButtonDown; - mpWindowImpl->mbMouseButtonUp = pWindowImpl->mbMouseButtonUp; - mpWindowImpl->mbKeyInput = pWindowImpl->mbKeyInput; - mpWindowImpl->mbKeyUp = pWindowImpl->mbKeyUp; - mpWindowImpl->mbCommand = pWindowImpl->mbCommand; - mpWindowImpl->mbDefPos = pWindowImpl->mbDefPos; - mpWindowImpl->mbDefSize = pWindowImpl->mbDefSize; - mpWindowImpl->mbCallMove = pWindowImpl->mbCallMove; - mpWindowImpl->mbCallResize = pWindowImpl->mbCallResize; - mpWindowImpl->mbWaitSystemResize = pWindowImpl->mbWaitSystemResize; - mpWindowImpl->mbInitWinClipRegion = pWindowImpl->mbInitWinClipRegion; - mpWindowImpl->mbInitChildRegion = pWindowImpl->mbInitChildRegion; - mpWindowImpl->mbWinRegion = pWindowImpl->mbWinRegion; - mpWindowImpl->mbClipChildren = pWindowImpl->mbClipChildren; - mpWindowImpl->mbClipSiblings = pWindowImpl->mbClipSiblings; - mpWindowImpl->mbChildTransparent = pWindowImpl->mbChildTransparent; - mpWindowImpl->mbPaintTransparent = pWindowImpl->mbPaintTransparent; - mpWindowImpl->mbMouseTransparent = pWindowImpl->mbMouseTransparent; - mpWindowImpl->mbDlgCtrlStart = pWindowImpl->mbDlgCtrlStart; - mpWindowImpl->mbFocusVisible = pWindowImpl->mbFocusVisible; - mpWindowImpl->mbTrackVisible = pWindowImpl->mbTrackVisible; - mpWindowImpl->mbUseNativeFocus = pWindowImpl->mbUseNativeFocus; - mpWindowImpl->mbNativeFocusVisible = pWindowImpl->mbNativeFocusVisible; - mpWindowImpl->mbInShowFocus = pWindowImpl->mbInShowFocus; - mpWindowImpl->mbInHideFocus = pWindowImpl->mbInHideFocus; - mpWindowImpl->mbControlForeground = pWindowImpl->mbControlForeground; - mpWindowImpl->mbControlBackground = pWindowImpl->mbControlBackground; - mpWindowImpl->mbAlwaysOnTop = pWindowImpl->mbAlwaysOnTop; - mpWindowImpl->mbCompoundControl = pWindowImpl->mbCompoundControl; - mpWindowImpl->mbCompoundControlHasFocus = pWindowImpl->mbCompoundControlHasFocus; - mpWindowImpl->mbPaintDisabled = pWindowImpl->mbPaintDisabled; - mpWindowImpl->mbAllResize = pWindowImpl->mbAllResize; - mpWindowImpl->mbInDtor = pWindowImpl->mbInDtor; - mpWindowImpl->mbExtTextInput = pWindowImpl->mbExtTextInput; - mpWindowImpl->mbInFocusHdl = pWindowImpl->mbInFocusHdl; - mpWindowImpl->mbOverlapVisible = pWindowImpl->mbOverlapVisible; - mpWindowImpl->mbCreatedWithToolkit = pWindowImpl->mbCreatedWithToolkit; - mpWindowImpl->mbToolBox = pWindowImpl->mbToolBox; - mpWindowImpl->mbSplitter = pWindowImpl->mbSplitter; - mpWindowImpl->mbSuppressAccessibilityEvents = pWindowImpl->mbSuppressAccessibilityEvents; - mpWindowImpl->mbMenuFloatingWindow = pWindowImpl->mbMenuFloatingWindow; - mpWindowImpl->mbDrawSelectionBackground = pWindowImpl->mbDrawSelectionBackground; - mpWindowImpl->mbIsInTaskPaneList = pWindowImpl->mbIsInTaskPaneList; - mpWindowImpl->mbToolbarFloatingWindow = pWindowImpl->mbToolbarFloatingWindow; - mpWindowImpl->mbCallHandlersDuringInputDisabled = pWindowImpl->mbCallHandlersDuringInputDisabled; - mpWindowImpl->mbDisableAccessibleLabelForRelation = pWindowImpl->mbDisableAccessibleLabelForRelation; - mpWindowImpl->mbDisableAccessibleLabeledByRelation = pWindowImpl->mbDisableAccessibleLabeledByRelation; - mpWindowImpl->mbHelpTextDynamic = pWindowImpl->mbHelpTextDynamic; - mpWindowImpl->mbFakeFocusSet = pWindowImpl->mbFakeFocusSet; - mpWindowImpl->mbHexpand = pWindowImpl->mbHexpand; - mpWindowImpl->mbVexpand = pWindowImpl->mbVexpand; - mpWindowImpl->mbExpand = pWindowImpl->mbExpand; - mpWindowImpl->mbFill = pWindowImpl->mbFill; - mpWindowImpl->mbSecondary = pWindowImpl->mbSecondary; - - bool bHasBorderWindow = mpWindowImpl->mpBorderWindow; - bool bOtherHasBorderWindow = pWindowImpl->mpBorderWindow; - - assert(bHasBorderWindow == bOtherHasBorderWindow); - - if (bHasBorderWindow && bOtherHasBorderWindow) - mpWindowImpl->mpBorderWindow->take_properties(*pWindowImpl->mpBorderWindow); -} - namespace { VclAlign toAlign(const OString &rValue) |