Greatly improved wxWebKitCtrl positioning logic to accomodate most situations.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31565 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
dc2e913348
commit
39104bc1bd
@ -256,38 +256,56 @@ void wxWebKitCtrl::SetPageSource(wxString& source, const wxString& baseUrl){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void wxWebKitCtrl::OnSize(wxSizeEvent &event){
|
void wxWebKitCtrl::OnSize(wxSizeEvent &event){
|
||||||
// This is a nasty hack because WebKit does not seem to recognize a Tabs control as its parent.
|
// This is a nasty hack because WebKit seems to lose its position when it is embedded
|
||||||
// Therefore, coordinates must be relative to the left-hand side of the screen, rather than
|
// in a control that is not itself the content view for a TLW.
|
||||||
// relative to the Tabs control.
|
|
||||||
wxWindow* parent = GetParent();
|
wxWindow* parent = GetParent();
|
||||||
bool inNotebook = false;
|
bool isParentTopLevel = true;
|
||||||
int x = 0;
|
if (!parent->IsTopLevel())
|
||||||
int y = 18;
|
isParentTopLevel = false;
|
||||||
|
|
||||||
|
int x = GetPosition().x;
|
||||||
|
// we must take into account the title bar size as well, which is 26 pixels
|
||||||
|
int y = GetPosition().y + 26;
|
||||||
|
|
||||||
|
NSRect bounds = [m_webView frame];
|
||||||
|
wxWindow* tlw = NULL;
|
||||||
|
|
||||||
while(parent != NULL)
|
while(parent != NULL)
|
||||||
{
|
{
|
||||||
// keep adding the position until we hit the notebook
|
if (parent->IsTopLevel())
|
||||||
if (!inNotebook){
|
tlw = parent;
|
||||||
x += parent->GetPosition().x;
|
|
||||||
y += parent->GetPosition().y;
|
x += parent->GetPosition().x;
|
||||||
|
y += parent->GetPosition().y;
|
||||||
|
|
||||||
|
if ( parent->IsKindOf( CLASSINFO( wxNotebook ) ) ){
|
||||||
|
//manually account for the size the tabs take up
|
||||||
|
y += 14;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( parent->GetClassInfo()->GetClassName() == wxT("wxSplitterWindow") ){
|
//if ( parent->GetClassInfo()->GetClassName() == wxT("wxSplitterWindow") ){
|
||||||
x += 3;
|
// x += 3;
|
||||||
}
|
//}
|
||||||
|
|
||||||
if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) ){
|
|
||||||
inNotebook = true;
|
|
||||||
}
|
|
||||||
parent = parent->GetParent();
|
parent = parent->GetParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inNotebook){
|
if (!isParentTopLevel){
|
||||||
|
if (tlw){
|
||||||
|
//x = tlw->GetSize().x - (GetSize().x + x);
|
||||||
|
y = tlw->GetSize().y - (GetSize().y + y);
|
||||||
|
}
|
||||||
NSRect bounds = [m_webView frame];
|
NSRect bounds = [m_webView frame];
|
||||||
bounds.origin.x += x;
|
bounds.origin.x += x;
|
||||||
bounds.origin.y += y;
|
bounds.origin.y += y;
|
||||||
|
//leaving debug checks in until I know it works everywhere ;-)
|
||||||
|
//printf("Added to bounds x=%d, y=%d\n", x, y);
|
||||||
[m_webView setFrame:bounds];
|
[m_webView setFrame:bounds];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printf("Carbon position x=%d, y=%d\n", GetPosition().x, GetPosition().y);
|
||||||
|
|
||||||
[m_webView display];
|
[m_webView display];
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user