コード例 #1
0
ファイル: SettlersFrame.cpp プロジェクト: Dangr8/Cities3D
//---------------------------- PUBLIC           -----------------------------//
wxSettlersFrame::wxSettlersFrame(wxWindow *parent, const wxPoint &pos, 
								 const wxSize &size)
: wxBaseFrame(parent, swCitiesOnline, pos, size)
, mClickId(-1)
, mWasMaximized(false)
, mRestartEngine(false)
{
	SetBackgroundColour(SKIN.Element(shBackground));

	sInConstructor = true;

	mAuiManager.SetManagedWindow(this);
	
	GUI.SetMainFrame(this);
	PopupManager::get().SetMainFrame(this);

	// In Cities3D, the main window must always be at least 800x600.
	SetMinSize(wxSize(875, 600));

	CreateIconWindow(this, mAuiManager);
	
	wxInt32 width, height;

	width = CONFIG.read(swConfigSectionUI, swMainFrameWidth, 875);
	height = CONFIG.read(swConfigSectionUI, swMainFrameHeight, 600);

	SetSize(-1, -1, width, height);

	Controller::get().AddReceiver(shEventStartGame, 
		&wxSettlersFrame::OnStartGame, this);
	Controller::get().AddReceiver(shEventInitializeUI,
		&wxSettlersFrame::OnInitializeUI, this);
	Controller::get().AddReceiver(shEventQuit,
		&wxSettlersFrame::OnQuit, this);
	Controller::get().AddReceiver(shEventExit,
		&wxSettlersFrame::OnExit, this);
	Controller::get().AddReceiver(shEventImmediateExit,
		&wxSettlersFrame::OnImmediateExit, this);
	Controller::get().AddReceiver(shEventRequestUserAttention,
		&wxSettlersFrame::OnRequestUserAttention, this);
	Controller::get().AddReceiver(shEventChangeMainPane,
		&wxSettlersFrame::OnChangeMainPane, this);
	Controller::get().AddReceiver(shEventNewSidePane,
		&wxSettlersFrame::OnNewSidePane, this);
	Controller::get().AddReceiver(shEventAddSidePane,
		&wxSettlersFrame::OnAddSidePane, this);
	Controller::get().AddReceiver(shEventUncheckMenu,
		&wxSettlersFrame::OnUncheckMenu, this);
	Controller::get().AddReceiver(shEventSaveLayout,
		&wxSettlersFrame::OnSaveLayout, this);
	Controller::get().AddReceiver(shEventRestoreLayout,
		&wxSettlersFrame::OnRestoreLayout, this);
	
	sInConstructor = false;

	// Always load the core rulesets.  This has to be done after the frame
	// exists.
	PLUGIN.LoadRuleset(swCoreRules, swCore);
	PLUGIN.LoadRuleset(swCitiesOnlineRules, swCitiesOnlineNoSpace);
}
コード例 #2
0
ファイル: SettlersFrame.cpp プロジェクト: Dangr8/Cities3D
void wxSettlersFrame::OnQuit(wxWindow* window)
{
	if(true == GUI.CanQuit(window))
	{
		// Must destroy the GL canvas to free all GL memory first.
		Controller::get().Transmit(shEventCloseGameWindow, 0);

		// Destroy all UI.
		wxAuiPaneInfoArray info = mAuiManager.GetAllPanes();
		for(size_t i = 0; i < info.GetCount(); ++i)
		{
			wxWindow* window = info[i].window;

#ifdef __WXGTK__
			// this prevents wxgtk from triggering an destructive
			// resize event when detaching the window
			window->SetAutoLayout(false);
#endif

			mAuiManager.DetachPane(window);
			window->Destroy();
		}

		// Restart the game engine.
		RestartEngine();

		CreateIconWindow(this, mAuiManager);
	}
}
コード例 #3
0
ファイル: events.c プロジェクト: Bluerise/bitrig-xenocara
void HandlePropertyNotify()
{
  XTextProperty text_prop;
  Boolean       OnThisPage    =  False;

  DBUG("HandlePropertyNotify","Routine Entered");

  if ((!Tmp_win)||
      (XGetGeometry(dpy, Tmp_win->w, &JunkRoot, &JunkX, &JunkY,
		    &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth) == 0))
    return;

  /*
      Make sure at least part of window is on this page
      before giving it focus...
  */
  if ( (Tmp_win->Desk == Scr.CurrentDesk) &&
       ( ((Tmp_win->frame_x + Tmp_win->frame_width) >= 0 &&
          Tmp_win->frame_x < Scr.MyDisplayWidth) &&
         ((Tmp_win->frame_y + Tmp_win->frame_height) >= 0 &&
          Tmp_win->frame_y < Scr.MyDisplayHeight)
       )
     )
    {
      OnThisPage  =  True;
    }

  switch (Event.xproperty.atom)
    {
    case XA_WM_TRANSIENT_FOR:
      {
        if(XGetTransientForHint(dpy, Tmp_win->w, &Tmp_win->transientfor))
        {
           Tmp_win->flags |= TRANSIENT;
           RaiseWindow(Tmp_win);
        }
        else
        {
           Tmp_win->flags &= ~TRANSIENT;
        }
      }
      break;

    case XA_WM_NAME:
      if (!XGetWMName(dpy, Tmp_win->w, &text_prop))
	return;

      free_window_names (Tmp_win, True, False);

      Tmp_win->name = (char *)text_prop.value;
      if (Tmp_win->name && strlen(Tmp_win->name) > 200)
	/* limit to prevent hanging X server */
	Tmp_win->name[200] = 0;

      if (Tmp_win->name == NULL)
        Tmp_win->name = NoName;
      BroadcastName(M_WINDOW_NAME,Tmp_win->w,Tmp_win->frame,
		    (unsigned long)Tmp_win,Tmp_win->name);

      /* fix the name in the title bar */
      if(!(Tmp_win->flags & ICONIFIED))
	SetTitleBar(Tmp_win,(Scr.Hilite==Tmp_win),True);

      /*
       * if the icon name is NoName, set the name of the icon to be
       * the same as the window
       */
      if (Tmp_win->icon_name == NoName)
	{
	  Tmp_win->icon_name = Tmp_win->name;
	  BroadcastName(M_ICON_NAME,Tmp_win->w,Tmp_win->frame,
			(unsigned long)Tmp_win,Tmp_win->icon_name);
	  RedoIconName(Tmp_win);
	}
      break;

    case XA_WM_ICON_NAME:
      if (!XGetWMIconName (dpy, Tmp_win->w, &text_prop))
	return;
      free_window_names (Tmp_win, False, True);
      Tmp_win->icon_name = (char *) text_prop.value;
      if (Tmp_win->icon_name && strlen(Tmp_win->icon_name) > 200)
	/* limit to prevent hanging X server */
	Tmp_win->icon_name[200] = 0;
      if (Tmp_win->icon_name == NULL)
        Tmp_win->icon_name = NoName;
      BroadcastName(M_ICON_NAME,Tmp_win->w,Tmp_win->frame,
		    (unsigned long)Tmp_win,Tmp_win->icon_name);
      RedoIconName(Tmp_win);
      break;

    case XA_WM_HINTS:
      if (Tmp_win->wmhints)
	XFree ((char *) Tmp_win->wmhints);
      Tmp_win->wmhints = XGetWMHints(dpy, Event.xany.window);

      if(Tmp_win->wmhints == NULL)
	return;

      if((Tmp_win->wmhints->flags & IconPixmapHint)||
	 (Tmp_win->wmhints->flags & IconWindowHint))
	if(Tmp_win->icon_bitmap_file == Scr.DefaultIcon)
	  Tmp_win->icon_bitmap_file = (char *)0;

      if((Tmp_win->wmhints->flags & IconPixmapHint)||
         (Tmp_win->wmhints->flags & IconWindowHint))
	{
	  if (!(Tmp_win->flags & SUPPRESSICON))
	    {
              if (Tmp_win->icon_w)
                XDestroyWindow(dpy,Tmp_win->icon_w);
	      XDeleteContext(dpy, Tmp_win->icon_w, FvwmContext);
	      if(Tmp_win->flags & ICON_OURS)
		{
		  if(Tmp_win->icon_pixmap_w != None)
		    {
		      XDestroyWindow(dpy,Tmp_win->icon_pixmap_w);
		      XDeleteContext(dpy, Tmp_win->icon_pixmap_w, FvwmContext);
		    }
		}
	      else
		XUnmapWindow(dpy,Tmp_win->icon_pixmap_w);
	    }
          Tmp_win->icon_w = None;
          Tmp_win->icon_pixmap_w = None;
	  Tmp_win->iconPixmap = (Window)NULL;
	  if(Tmp_win->flags & ICONIFIED)
	    {
	      Tmp_win->flags &= ~ICONIFIED;
	      Tmp_win->flags &= ~ICON_UNMAPPED;
	      CreateIconWindow(Tmp_win,
			       Tmp_win->icon_x_loc,Tmp_win->icon_y_loc);
	      BroadcastPacket(M_ICONIFY, 7,
                              Tmp_win->w, Tmp_win->frame,
                              (unsigned long)Tmp_win,
                              Tmp_win->icon_x_loc, Tmp_win->icon_y_loc,
                              Tmp_win->icon_w_width, Tmp_win->icon_w_height);
	      BroadcastConfig(M_CONFIGURE_WINDOW, Tmp_win);

	      if (!(Tmp_win->flags & SUPPRESSICON))
		{
		  LowerWindow(Tmp_win);
		  AutoPlace(Tmp_win);
		  if(Tmp_win->Desk == Scr.CurrentDesk)
		    {
                      if(Tmp_win->icon_w)
                        XMapWindow(dpy, Tmp_win->icon_w);
		      if(Tmp_win->icon_pixmap_w != None)
			XMapWindow(dpy, Tmp_win->icon_pixmap_w);
		    }
		}
	      Tmp_win->flags |= ICONIFIED;
	      DrawIconWindow(Tmp_win);
	    }
	}
      break;

    case XA_WM_NORMAL_HINTS:
      GetWindowSizeHints (Tmp_win);
#if 0
      /*
      ** ckh - not sure why this next stuff was here, but fvwm 1.xx
      ** didn't do this, and it seems to cause a bug when changing
      ** fonts in XTerm
      */
      {
	int new_width, new_height;
	new_width = Tmp_win->frame_width;
	new_height = Tmp_win->frame_height;
	ConstrainSize(Tmp_win, &new_width, &new_height, False, 0, 0);
	if((new_width != Tmp_win->frame_width)||
	   (new_height != Tmp_win->frame_height))
	  SetupFrame(Tmp_win,Tmp_win->frame_x, Tmp_win->frame_y,
		     new_width,new_height,False);
      }
#endif /* 0 */
      BroadcastConfig(M_CONFIGURE_WINDOW,Tmp_win);
      break;

    default:
      if(Event.xproperty.atom == _XA_WM_PROTOCOLS)
	FetchWmProtocols (Tmp_win);
      else if (Event.xproperty.atom == _XA_WM_COLORMAP_WINDOWS)
	{
	  FetchWmColormapWindows (Tmp_win);	/* frees old data */
	  ReInstallActiveColormap();
	}
      else if(Event.xproperty.atom == _XA_WM_STATE)
	{
	  if((Tmp_win != NULL)&&(Tmp_win->flags & ClickToFocus)
	     &&(Tmp_win == Scr.Focus))
	    {
              if (OnThisPage)
              {
	        Scr.Focus = NULL;
	        SetFocus(Tmp_win->w,Tmp_win,0);
              }
	    }
	}
      break;
    }
}