示例#1
0
/**
 * gdk_screen_get_monitor_at_window:
 * @screen: a #GdkScreen.
 * @window: a #GdkWindow
 * @returns: the monitor number in which most of @window is located,
 *           or if @window does not intersect any monitors, a monitor,
 *           close to @window.
 *
 * Returns the number of the monitor in which the largest area of the 
 * bounding rectangle of @window resides.
 *
 * Since: 2.2
 **/
gint 
gdk_screen_get_monitor_at_window (GdkScreen      *screen,
				  GdkWindow	 *window)
{
  gint num_monitors, i, area = 0, screen_num = -1;
  GdkRectangle win_rect;

  g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);

  gdk_window_get_geometry (window, &win_rect.x, &win_rect.y, &win_rect.width,
			   &win_rect.height, NULL);
  gdk_window_get_origin (window, &win_rect.x, &win_rect.y);
  num_monitors = gdk_screen_get_n_monitors (screen);
  
  for (i=0;i<num_monitors;i++)
    {
      GdkRectangle tmp_monitor, intersect;
      
      gdk_screen_get_monitor_geometry (screen, i, &tmp_monitor);
      gdk_rectangle_intersect (&win_rect, &tmp_monitor, &intersect);
      
      if (intersect.width * intersect.height > area)
	{ 
	  area = intersect.width * intersect.height;
	  screen_num = i;
	}
    }
  if (screen_num >= 0)
    return screen_num;
  else
    return get_nearest_monitor (screen,
				win_rect.x + win_rect.width / 2,
				win_rect.y + win_rect.height / 2);
}
示例#2
0
/**
 * gdk_screen_get_monitor_at_point:
 * @screen: a #GdkScreen.
 * @x: the x coordinate in the virtual screen.
 * @y: the y coordinate in the virtual screen.
 *
 * Returns the monitor number in which the point (@x,@y) is located.
 *
 * Returns: the monitor number in which the point (@x,@y) lies, or
 *   a monitor close to (@x,@y) if the point is not in any monitor.
 *
 * Since: 2.2
 **/
gint 
gdk_screen_get_monitor_at_point (GdkScreen *screen,
				 gint       x,
				 gint       y)
{
  gint num_monitors, i;
  
  g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);

  num_monitors = gdk_screen_get_n_monitors (screen);
  
  for (i=0;i<num_monitors;i++)
    {
      GdkRectangle monitor;
      
      gdk_screen_get_monitor_geometry (screen, i, &monitor);

      if (x >= monitor.x &&
          x < monitor.x + monitor.width &&
          y >= monitor.y &&
          y < (monitor.y + monitor.height))
        return i;
    }

  return get_nearest_monitor (screen, x, y);
}
示例#3
0
int load_window_size(HWND hwnd,char *section)
{
	RECT rect={0};
	int width=0,height=0,x=0,y=0,maximized=0;
	int result=FALSE;
	get_ini_value(section,"width",&width);
	get_ini_value(section,"height",&height);
	get_ini_value(section,"xpos",&x);
	get_ini_value(section,"ypos",&y);
	get_ini_value(section,"maximized",&maximized);
	if(get_nearest_monitor(x,y,width,height,&rect)){
		int flags=SWP_SHOWWINDOW;
		if((GetKeyState(VK_SHIFT)&0x8000)==0){
			if(width<50 || height<50){
				RECT tmp={0};
				GetWindowRect(hwnd,&tmp);
				width=tmp.right-tmp.left;
				height=tmp.bottom-tmp.top;
				flags|=SWP_NOSIZE;
			}
			if(!clamp_window_size(&x,&y,&width,&height,&rect))
				flags|=SWP_NOMOVE;
			if(SetWindowPos(hwnd,HWND_TOP,x,y,width,height,flags)!=0)
				result=TRUE;
		}
	}
	if(maximized)
		PostMessage(hwnd,WM_SYSCOMMAND,SC_MAXIMIZE,0);
	return result;
}
//borrowed from gtk
static gint get_monitor_at_window(MetaWindow* window)
{
    gint num_monitors, i, area = 0, screen_num = -1;
    GdkRectangle win_rect;

    GdkScreen* screen = gdk_screen_get_default();

    meta_window_get_outer_rect(window, (MetaRectangle*)&win_rect);
    num_monitors = gdk_screen_get_n_monitors (screen);

    for (i=0; i<num_monitors; i++) {
        GdkRectangle tmp_monitor, intersect;

        gdk_screen_get_monitor_geometry (screen, i, &tmp_monitor);
        gdk_rectangle_intersect (&win_rect, &tmp_monitor, &intersect);

        if (intersect.width * intersect.height > area) { 
            area = intersect.width * intersect.height;
            screen_num = i;
        }
    }
    if (screen_num >= 0)
        return screen_num;
    else
        return get_nearest_monitor (screen,
                win_rect.x + win_rect.width / 2,
                win_rect.y + win_rect.height / 2);
}
示例#5
0
int populate_insert_dlg(HWND hwnd,HWND hlistview,TABLE_WINDOW *win)
{
	int i,count,widths[4]={0,0,0,0};
	int row_sel;
	char *cols[]={"field","data","type","size"};
	if(hlistview==0 || win==0)
		return FALSE;

	for(i=0;i<4;i++)
		widths[i]=lv_add_column(hlistview,cols[i],i);

	row_sel=ListView_GetSelectionMark(win->hlistview);

	count=lv_get_column_count(win->hlistview);

	for(i=0;i<count;i++){
		int w;
		char str[80]={0};
		lv_get_col_text(win->hlistview,i,str,sizeof(str));
		lv_insert_data(hlistview,i,FIELD_POS,str);
		w=get_str_width(hlistview,str);
		if(w>widths[FIELD_POS])
			widths[FIELD_POS]=w;
		if(row_sel>=0){
			str[0]=0;
			ListView_GetItemText(win->hlistview,row_sel,i,str,sizeof(str));
			lv_insert_data(hlistview,i,DATA_POS,str);
			w=get_str_width(hlistview,str);
			if(w>widths[DATA_POS])
				widths[DATA_POS]=w;
		}
		if(win->col_attr!=0){
			char *s="";
			if(!find_sql_type_str(win->col_attr[i].type,&s)){
				_snprintf(str,sizeof(str),"%i",win->col_attr[i].type);
				lv_insert_data(hlistview,i,TYPE_POS,str);
			}
			else
				lv_insert_data(hlistview,i,TYPE_POS,s);
			w=get_str_width(hlistview,s);
			if(w>widths[TYPE_POS])
				widths[TYPE_POS]=w;

			_snprintf(str,sizeof(str),"%i",win->col_attr[i].length);
			lv_insert_data(hlistview,i,SIZE_POS,str);
			w=get_str_width(hlistview,str);
			if(w>widths[SIZE_POS])
				widths[SIZE_POS]=w;
		}
	}
	{
		int total_width=0;
		for(i=0;i<4;i++){
			widths[i]+=12;
			ListView_SetColumnWidth(hlistview,i,widths[i]);
			total_width+=widths[i];
		}
		if(total_width>0){
			int width,height;
			RECT rect={0},irect={0},nrect={0};
			GetWindowRect(hwnd,&irect);
			get_nearest_monitor(irect.left,irect.top,total_width,100,&nrect);
			ListView_GetItemRect(hlistview,0,&rect,LVIR_BOUNDS);
			height=80+(count*(rect.bottom-rect.top+2));
			if((irect.top+height)>nrect.bottom){
				height=nrect.bottom-nrect.top-irect.top;
				if(height<320)
					height=320;
			}
			width=total_width+20;
			SetWindowPos(hwnd,NULL,0,0,width,height,SWP_NOMOVE|SWP_NOZORDER);
		}
	}

	return TRUE;
}