Merge pull request #7 from KapiX/extract-tabview-cleanup
Extract some cleanup to functions
This commit is contained in:
@@ -386,39 +386,12 @@ int YabInterface::CloseWindow(const char* view)
|
|||||||
{
|
{
|
||||||
while(child)
|
while(child)
|
||||||
{
|
{
|
||||||
if(is_kind_of(child, YabTabView))
|
CleanupYabTabView(child);
|
||||||
{
|
|
||||||
for(int i = 0; i<((YabTabView*)child)->CountTabs(); i++)
|
|
||||||
{
|
|
||||||
YabView *t = (YabView*)((YabTabView*)child)->TabAt(i)->View();
|
|
||||||
RemoveView(t);
|
|
||||||
viewList->DelView(t->NameForTabView());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(is_kind_of(child, YabBitmapView))
|
if(is_kind_of(child, YabBitmapView))
|
||||||
yabcanvas->RemoveItem(child);
|
yabcanvas->RemoveItem(child);
|
||||||
|
|
||||||
// viewList->PrintOut();
|
// viewList->PrintOut();
|
||||||
BView *subchild;
|
CleanupSubchildView(child->ChildAt(0));
|
||||||
if(subchild = child->ChildAt(0))
|
|
||||||
while(subchild)
|
|
||||||
{
|
|
||||||
if(is_kind_of(subchild, YabTabView))
|
|
||||||
{
|
|
||||||
for(int i = 0; i<((YabTabView*)subchild)->CountTabs(); i++)
|
|
||||||
{
|
|
||||||
YabView *t = (YabView*)((YabTabView*)subchild)->TabAt(i)->View();
|
|
||||||
RemoveView(t);
|
|
||||||
viewList->DelView(t->NameForTabView());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(viewList->GetView(subchild->Name()))
|
|
||||||
{
|
|
||||||
RemoveView(subchild);
|
|
||||||
viewList->DelView(subchild->Name());
|
|
||||||
}
|
|
||||||
subchild = subchild->NextSibling();
|
|
||||||
}
|
|
||||||
if(viewList->GetView(child->Name()))
|
if(viewList->GetView(child->Name()))
|
||||||
{
|
{
|
||||||
RemoveView(child);
|
RemoveView(child);
|
||||||
@@ -3379,37 +3352,10 @@ void YabInterface::WindowClear(const char* window)
|
|||||||
{
|
{
|
||||||
while(child)
|
while(child)
|
||||||
{
|
{
|
||||||
if(is_kind_of(child, YabTabView))
|
CleanupYabTabView(child);
|
||||||
{
|
|
||||||
for(int i = 0; i<((YabTabView*)child)->CountTabs(); i++)
|
|
||||||
{
|
|
||||||
YabView *t = (YabView*)((YabTabView*)child)->TabAt(i)->View();
|
|
||||||
RemoveView(t);
|
|
||||||
viewList->DelView(t->NameForTabView());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(is_kind_of(child, YabBitmapView))
|
if(is_kind_of(child, YabBitmapView))
|
||||||
yabcanvas->RemoveItem(child);
|
yabcanvas->RemoveItem(child);
|
||||||
BView *subchild;
|
CleanupSubchildView(child->ChildAt(0));
|
||||||
if(subchild = child->ChildAt(0))
|
|
||||||
while(subchild)
|
|
||||||
{
|
|
||||||
if(is_kind_of(subchild, YabTabView))
|
|
||||||
{
|
|
||||||
for(int i = 0; i<((YabTabView*)subchild)->CountTabs(); i++)
|
|
||||||
{
|
|
||||||
YabView *t = (YabView*)((YabTabView*)subchild)->TabAt(i)->View();
|
|
||||||
RemoveView(t);
|
|
||||||
viewList->DelView(t->NameForTabView());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(viewList->GetView(subchild->Name()))
|
|
||||||
{
|
|
||||||
RemoveView(subchild);
|
|
||||||
viewList->DelView(subchild->Name());
|
|
||||||
}
|
|
||||||
subchild = subchild->NextSibling();
|
|
||||||
}
|
|
||||||
if(viewList->GetView(child->Name()))
|
if(viewList->GetView(child->Name()))
|
||||||
{
|
{
|
||||||
RemoveView(child);
|
RemoveView(child);
|
||||||
@@ -3458,38 +3404,10 @@ void YabInterface::RemoveView(BView *myView)
|
|||||||
if(child = myView->ChildAt(0))
|
if(child = myView->ChildAt(0))
|
||||||
while(child)
|
while(child)
|
||||||
{
|
{
|
||||||
|
CleanupYabTabView(child);
|
||||||
if(is_kind_of(child, YabTabView))
|
|
||||||
{
|
|
||||||
for(int i = 0; i<((YabTabView*)child)->CountTabs(); i++)
|
|
||||||
{
|
|
||||||
YabView *t = (YabView*)((YabTabView*)child)->TabAt(i)->View();
|
|
||||||
RemoveView(t);
|
|
||||||
viewList->DelView(t->NameForTabView());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(is_kind_of(child, YabBitmapView))
|
if(is_kind_of(child, YabBitmapView))
|
||||||
yabcanvas->RemoveItem(child);
|
yabcanvas->RemoveItem(child);
|
||||||
BView *subchild;
|
CleanupSubchildView(child->ChildAt(0));
|
||||||
if(subchild = child->ChildAt(0))
|
|
||||||
while(subchild)
|
|
||||||
{
|
|
||||||
if(is_kind_of(subchild, YabTabView))
|
|
||||||
{
|
|
||||||
for(int i = 0; i<((YabTabView*)subchild)->CountTabs(); i++)
|
|
||||||
{
|
|
||||||
YabView *t = (YabView*)((YabTabView*)subchild)->TabAt(i)->View();
|
|
||||||
RemoveView(t);
|
|
||||||
viewList->DelView(t->NameForTabView());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(viewList->GetView(subchild->Name()))
|
|
||||||
{
|
|
||||||
RemoveView(subchild);
|
|
||||||
viewList->DelView(subchild->Name());
|
|
||||||
}
|
|
||||||
subchild = subchild->NextSibling();
|
|
||||||
}
|
|
||||||
if(viewList->GetView(child->Name()))
|
if(viewList->GetView(child->Name()))
|
||||||
{
|
{
|
||||||
RemoveView(child);
|
RemoveView(child);
|
||||||
@@ -3527,6 +3445,37 @@ void YabInterface::RemoveView(BView *myView)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void YabInterface::CleanupYabTabView(BView* view)
|
||||||
|
{
|
||||||
|
if(view == NULL || viewList == NULL) return;
|
||||||
|
|
||||||
|
if(is_kind_of(view, YabTabView)) {
|
||||||
|
YabTabView* tabView = static_cast<YabTabView*>(view);
|
||||||
|
for(int i = 0; i < tabView->CountTabs(); i++)
|
||||||
|
{
|
||||||
|
YabView *t = static_cast<YabView*>(tabView->TabAt(i)->View());
|
||||||
|
RemoveView(t);
|
||||||
|
viewList->DelView(t->NameForTabView());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabInterface::CleanupSubchildView(BView* view)
|
||||||
|
{
|
||||||
|
if(view == NULL || viewList == NULL) return;
|
||||||
|
|
||||||
|
while(view)
|
||||||
|
{
|
||||||
|
CleanupYabTabView(view);
|
||||||
|
if(viewList->GetView(view->Name()))
|
||||||
|
{
|
||||||
|
RemoveView(view);
|
||||||
|
viewList->DelView(view->Name());
|
||||||
|
}
|
||||||
|
view = view->NextSibling();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void YabInterface::TextEdit(BRect frame, const char* title, int scrollbar, const char* window)
|
void YabInterface::TextEdit(BRect frame, const char* title, int scrollbar, const char* window)
|
||||||
{
|
{
|
||||||
YabView *myView = cast_as((BView*)viewList->GetView(window), YabView);
|
YabView *myView = cast_as((BView*)viewList->GetView(window), YabView);
|
||||||
|
|||||||
@@ -248,6 +248,8 @@
|
|||||||
void GetMMsgInfo(BString &t, int mouseStateInfo, int mouseLButton, int mouseMButton, int mouseRButton, int x, int y, const char* name);
|
void GetMMsgInfo(BString &t, int mouseStateInfo, int mouseLButton, int mouseMButton, int mouseRButton, int x, int y, const char* name);
|
||||||
BBitmap* loadImage(const char* name);
|
BBitmap* loadImage(const char* name);
|
||||||
static int compare(BListItem **firstArg, BListItem **secondArg);
|
static int compare(BListItem **firstArg, BListItem **secondArg);
|
||||||
|
void CleanupYabTabView(BView* view);
|
||||||
|
void CleanupSubchildView(BView* view);
|
||||||
|
|
||||||
BTranslatorRoster *Roster;
|
BTranslatorRoster *Roster;
|
||||||
char ApplicationDirectory[1024];
|
char ApplicationDirectory[1024];
|
||||||
|
|||||||
Reference in New Issue
Block a user