コード例 #1
0
ファイル: OptDlg.cpp プロジェクト: Banbury/starshatter-open
void
OptDlg::OnEnter(AWEvent* event)
{
    ActiveWindow* src = event->window;

    if (src && description)
    description->SetText(src->GetAltText());
}
コード例 #2
0
ActiveWindow*
ActiveWindow::FindChild(int x, int y)
{
    ActiveWindow* mouse_tgt = 0;

    ListIter<ActiveWindow> iter = children;
    while (++iter) {
        ActiveWindow* test = iter.value();
        if (test->TargetRect().Contains(x,y))
        mouse_tgt = test;
    }

    return mouse_tgt;
}
コード例 #3
0
void MagicView::OnViewBackColor() 
{
   ModelView* view = GetModelViewByIndex(view_focus);

   if (view) {
      ActiveWindow*  win   = (ActiveWindow*) view->GetWindow();
      Color          c     = win->GetBackColor();
      COLORREF       crgb  = RGB(c.Red(), c.Green(), c.Blue());
      CColorDialog   chooser(crgb);

      if (chooser.DoModal() == IDOK) {
         crgb = chooser.GetColor();
         win->SetBackColor( Color(GetRValue(crgb), GetGValue(crgb), GetBValue(crgb)) );
      }
   }
}
コード例 #4
0
ActiveWindow*
ActiveWindow::FindChild(DWORD id)
{
    ListIter<ActiveWindow> iter = children;
    while (++iter) {
        ActiveWindow* w = iter.value();
        if (w->GetID() == id)
        return w;

        ActiveWindow* w2 = w->FindChild(id);

        if (w2)
        return w2;
    }

    return 0;
}
コード例 #5
0
void
ActiveWindow::Draw()
{
    int w = rect.w;
    int h = rect.h;

    if (w < 1 || h < 1 || !shown)
    return;

    float old_alpha = alpha;

    if (!enabled)
    SetAlpha(0.5);

    if (!transparent) {
        if (texture && texture->Width()) {
            DrawTextureGrid();
        }
        else {
            FillRect(0, 0, w, h, ShadeColor(back_color, 1.0));
        }
    }

    if (enabled && view_list.size()) {
        ListIter<View> v = view_list;
        while (++v)
        v->Refresh();
    }

    if (!transparent) {
        DrawStyleRect(0, 0, w, h, style);
    }

    // draw text here:
    DrawTabbedText();

    if (!enabled)
    SetAlpha(old_alpha);

    // update children windows:
    ListIter<ActiveWindow> iter = children;
    while (++iter) {
        ActiveWindow* child = iter.value();
        child->Draw();
    }
}
コード例 #6
0
int
MagicView::GetWinIndexByPoint(int x, int y)
{
   if (view_mode == 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];
            if (win->GetRect().Contains(x, y))
               return index;
         }
      }
   }

   return view_mode;
}
コード例 #7
0
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;
}
コード例 #8
0
void
ActiveWindow::Show()
{
    EventDispatch* dispatch = EventDispatch::GetInstance();
    if (dispatch)
    dispatch->Register(this);

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

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

    shown = true;
}
コード例 #9
0
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;
}
コード例 #10
0
void
FormWindow::CreateDefLabel(CtrlDef& def)
{
	ActiveWindow* ctrl = CreateLabel(def.GetText(),
	def.GetX(),
	def.GetY(),
	def.GetW(),
	def.GetH(),
	def.GetID(),
	def.GetParentID(),
	def.GetStyle());

	ctrl->SetAltText(def.GetAltText());
	ctrl->SetBackColor(def.GetBackColor());
	ctrl->SetForeColor(def.GetForeColor());
	ctrl->SetTextAlign(def.GetTextAlign());
	ctrl->SetSingleLine(def.GetSingleLine());
	ctrl->SetTransparent(def.GetTransparent());
	ctrl->SetHidePartial(def.GetHidePartial());

	ctrl->SetMargins(def.GetMargins());
	ctrl->SetTextInsets(def.GetTextInsets());
	ctrl->SetCellInsets(def.GetCellInsets());
	ctrl->SetCells(def.GetCells());
	ctrl->SetFixedWidth(def.GetFixedWidth());
	ctrl->SetFixedHeight(def.GetFixedHeight());

	ctrl->UseLayout(def.GetLayout().x_mins,
	def.GetLayout().y_mins,
	def.GetLayout().x_weights,
	def.GetLayout().y_weights);

	if (def.GetTexture().length() > 0) {
		Bitmap*     ctrl_tex = 0;
		DataLoader* loader   = DataLoader::GetLoader();
		loader->SetDataPath("Screens/");
		loader->LoadTexture(def.GetTexture(), ctrl_tex);
		loader->SetDataPath("");

		ctrl->SetTexture(ctrl_tex);
	}

	Font* f = FontMgr::Find(def.GetFont());
	if (f) ctrl->SetFont(f);
}
コード例 #11
0
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();
}
コード例 #12
0
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();
}
コード例 #13
0
void MagicView::OnInitialUpdate() 
{
	CView::OnInitialUpdate();
   Color::SetPalette(standard_palette, 256, inverse_palette);

   if (!video_settings)
      video_settings = new VideoSettings;

   GetClientRect(&client_rect);

   // Use client area to set video window size
   int w = client_rect.right - client_rect.left;
   int h = client_rect.bottom - client_rect.top;

   video_settings->is_windowed   = true;
   video_settings->window_width  = w;
   video_settings->window_height = h;

   if (!video) {
      video = new VideoDX9(GetSafeHwnd(), video_settings);
      *video_settings = *video->GetVideoSettings();

      if (video) {
         Color::UseVideo(video);
         video->UseXFont("System", 12, false, false);

         screen = new Screen(video);
         if (!screen) {
            ::Print("ERROR: Could not create Screen object.\n");
            return;
         }

         ::Print("  Created screen object (%d x %d).\n", w, h);
   
         if (!screen->SetBackgroundColor(Color::Black))
            ::Print("  WARNING: could not set video background color to Black\n");

         screen->ClearAllFrames(true);

         ::Print("  Established requested video parameters.\n");
         ::Print("  ---------------------------------------\n\n");

         if (!scene) {
            scene = new Scene;

            scene->SetAmbient(Color(60,60,60));

            Point light_pos(3e6, 5e6, 4e6);

            main_light = new Light(1.0f); //1.25f);
            main_light->MoveTo(light_pos);
            main_light->SetType(Light::LIGHT_DIRECTIONAL);
            main_light->SetColor(Color::White);
            main_light->SetShadow(true);

            scene->AddLight(main_light);

            back_light = new Light(0.5f);
            back_light->MoveTo(light_pos * -1);
            back_light->SetType(Light::LIGHT_DIRECTIONAL);
            back_light->SetColor(Color::White);

            scene->AddLight(back_light);

            Selection*  seln     = GetDocument()->GetSelection();
            Selector*   selector = GetDocument()->GetSelector();

            if (seln && selector) {
               scene->Graphics().clear();
               scene->AddGraphic(seln);
               scene->AddGraphic(selector);

               selector->UseModel(0);
            }
         }

         int   mins[2]     = { 0, 0 };
         float weights[2]  = { 1, 1 };

         main_win = new ActiveWindow(screen, 0, 0, w, h, 100, 0);
         main_win->UseLayout(2, 2, mins, mins, weights, weights);
         main_win->SetBackColor(Color::Gray);

         screen->AddWindow(main_win);

         DWORD view_types[] = { 
            ModelView::VIEW_PLAN,
            ModelView::VIEW_PROJECT,
            ModelView::VIEW_SIDE,
            ModelView::VIEW_FRONT
         };

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

               ActiveWindow* win = new ActiveWindow(screen, 
                                                    col*w/2, 
                                                    row*h/2, 
                                                    w/2, 
                                                    h/2, 
                                                    101+index, 
                                                    WIN_BLACK_FRAME, 
                                                    main_win);

               win->SetCells(col, row, 1, 1);
               win->SetCellInsets(Insets(1,1,1,1));
               win->SetBackColor(Color(160,160,160));

               ModelView* mv = new ModelView(win, scene, view_types[index]);

               if (view_types[index] == ModelView::VIEW_PROJECT)
                  mv->SetFillMode(ModelView::FILL_TEXTURE);

               mv->UseGrid(grid);
               win->AddView(mv);

               view_win[index]   = win;
               model_view[index] = mv;
            }
         }

         view_win[0]->SetStyle(WIN_WHITE_FRAME);

         uvmap_win  = new ActiveWindow(screen, 0, 0, w, h, 110, WIN_BLACK_FRAME, main_win);
         uvmap_view = new UVMapView(uvmap_win);
         uvmap_win->AddView(uvmap_view);

         main_win->DoLayout();
      }

      else {
         ::Print("  Could not establish requested video parameters.\n");
         ::Print("  -----------------------------------------------\n\n");
      }
   }
}