void
MagicView::SetFocusModelView(int f)
{
   if (view_mode == VIEW_ALL) {
      view_focus = f;

      for (int row = 0; row < 2; row++) {
         for (int col = 0; col < 2; col++) {
            int index = 2*row + col;

            ActiveWindow* win = view_win[index];

            win->Show();
            win->SetCells(col, row, 1, 1);
            win->SetCellInsets(Insets(1,1,1,1));

            if (index == view_focus) {
               win->SetStyle(WIN_WHITE_FRAME);
            }
            else {
               win->SetStyle(WIN_BLACK_FRAME);
            }
         }
      }
   }
   else if (IsUVEdit()) {
      view_focus = view_mode;
   }
   else {
      view_mode  = f;
      view_focus = f;

      for (int i = 0; i < 4; i++) {
         ActiveWindow* win = view_win[i];

         if (i == view_mode) {
            win->Show();
            win->SetCells(0,0,2,2);
            win->SetStyle(WIN_WHITE_FRAME);
         }

         else {
            win->Hide();
            win->SetCells(0,0,0,0);
            win->SetStyle(WIN_BLACK_FRAME);
         }
      }
   }

   main_win->DoLayout();
}
ActiveWindow*
FormWindow::CreateLabel(const char* label_text, int ax, int ay, int aw, int ah, DWORD aid, DWORD pid, DWORD astyle)
{
	ActiveWindow*  label  = 0;
	ActiveWindow*  parent = this;

	if (pid)
	parent = FindControl(pid);

	label = new(__FILE__,__LINE__) ActiveWindow(screen, ax, ay, aw, ah, aid, astyle, parent);

	if (label) {
		label->SetForm(this);
		label->SetText(label_text);

		if (!shown)
		label->Hide();
	}

	return label;
}
void
ActiveWindow::Hide()
{
    EventDispatch* dispatch = EventDispatch::GetInstance();
    if (dispatch) {
        dispatch->Unregister(this);
        focus = false;
    }

    ListIter<View> v_iter = view_list;
    while (++v_iter) {
        View* view = v_iter.value();
        view->OnHide();
    }

    ListIter<ActiveWindow> c_iter = children;
    while (++c_iter) {
        ActiveWindow* child = c_iter.value();
        child->Hide();
    }

    shown = false;
}
void
MagicView::SetupModelViews()
{
   switch (view_mode) {
   case VIEW_ALL: {
         for (int row = 0; row < 2; row++) {
            for (int col = 0; col < 2; col++) {
               int index = 2*row + col;

               ActiveWindow* win = view_win[index];

               win->Show();
               win->SetCells(col, row, 1, 1);
               win->SetCellInsets(Insets(1,1,1,1));
            }
         }

         uvmap_win->Hide();
         uvmap_win->SetCells(0,0,0,0);
      }
      break;

   case VIEW_TOP:
   case VIEW_SIDE:
   case VIEW_FRONT:
   case VIEW_PERSPECTIVE: {
         view_focus = view_mode;

         for (int i = 0; i < 4; i++) {
            ActiveWindow* win = view_win[i];

            if (i == view_mode) {
               win->Show();
               win->SetCells(0,0,2,2);
               win->SetStyle(WIN_WHITE_FRAME);
            }

            else {
               win->Hide();
               win->SetCells(0,0,0,0);
               win->SetStyle(WIN_BLACK_FRAME);
            }
         }

         uvmap_win->Hide();
         uvmap_win->SetCells(0,0,0,0);
      }
      break;

   case VIEW_UV_MAP: {
         view_focus = view_mode;

         for (int i = 0; i < 4; i++) {
            ActiveWindow* win = view_win[i];
            win->Hide();
            win->SetCells(0,0,0,0);
            win->SetStyle(WIN_BLACK_FRAME);
         }

         uvmap_win->Show();
         uvmap_win->SetCells(0,0,2,2);
      }
      break;

   default:
      break;
   }

   main_win->DoLayout();
}