亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? gtk_tut-23.html

?? GTK development guide
?? HTML
?? 第 1 頁 / 共 2 頁
字號:
on the screen, is then:
<P>
<BLOCKQUOTE><CODE>
<PRE>
/* Draw a rectangle on the screen */
static void
draw_brush (GtkWidget *widget, gdouble x, gdouble y)
{
  GdkRectangle update_rect;

  update_rect.x = x - 5;
  update_rect.y = y - 5;
  update_rect.width = 10;
  update_rect.height = 10;
  gdk_draw_rectangle (pixmap,
                      widget->style->black_gc,
                      TRUE,
                      update_rect.x, update_rect.y,
                      update_rect.width, update_rect.height);
  gtk_widget_draw (widget, &amp;update_rect);
}
</PRE>
</CODE></BLOCKQUOTE>
<P>After we draw the rectangle representing the brush onto the pixmap,
we call the function:
<P>
<BLOCKQUOTE><CODE>
<PRE>
void       gtk_widget_draw                (GtkWidget           *widget,
                                           GdkRectangle        *area);
</PRE>
</CODE></BLOCKQUOTE>
<P>which notifies X that the area given by the <CODE>area</CODE> parameter
needs to be updated. X will eventually generate an expose event
(possibly combining the areas passed in several calls to
<CODE>gtk_widget_draw()</CODE>) which will cause our expose event handler
to copy the relevant portions to the screen.
<P>We have now covered the entire drawing program except for a few
mundane details like creating the main window.
<P>
<H2><A NAME="ss23.4">23.4 Adding XInput support</A>
</H2>

<P>It is now possible to buy quite inexpensive input devices such 
as drawing tablets, which allow drawing with a much greater
ease of artistic expression than does a mouse. The simplest way
to use such devices is simply as a replacement for the mouse,
but that misses out many of the advantages of these devices,
such as:
<P>
<UL>
<LI> Pressure sensitivity</LI>
<LI> Tilt reporting</LI>
<LI> Sub-pixel positioning</LI>
<LI> Multiple inputs (for example, a stylus with a point and eraser)</LI>
</UL>
<P>For information about the XInput extension, see the 
<A HREF="http://www.msc.cornell.edu/~otaylor/xinput/XInput-HOWTO.html">XInput-HOWTO</A>.
<P>If we examine the full definition of, for example, the GdkEventMotion
structure, we see that it has fields to support extended device
information.
<P>
<BLOCKQUOTE><CODE>
<PRE>
struct _GdkEventMotion
{
  GdkEventType type;
  GdkWindow *window;
  guint32 time;
  gdouble x;
  gdouble y;
  gdouble pressure;
  gdouble xtilt;
  gdouble ytilt;
  guint state;
  gint16 is_hint;
  GdkInputSource source;
  guint32 deviceid;
};
</PRE>
</CODE></BLOCKQUOTE>
<P><CODE>pressure</CODE> gives the pressure as a floating point number between
0 and 1. <CODE>xtilt</CODE> and <CODE>ytilt</CODE> can take on values between 
-1 and 1, corresponding to the degree of tilt in each direction.
<CODE>source</CODE> and <CODE>deviceid</CODE> specify the device for which the
event occurred in two different ways. <CODE>source</CODE> gives some simple
information about the type of device. It can take the enumeration
values:
<P>
<BLOCKQUOTE><CODE>
<PRE>
GDK_SOURCE_MOUSE
GDK_SOURCE_PEN
GDK_SOURCE_ERASER
GDK_SOURCE_CURSOR
</PRE>
</CODE></BLOCKQUOTE>
<P><CODE>deviceid</CODE> specifies a unique numeric ID for the device. This can
be used to find out further information about the device using the
<CODE>gdk_input_list_devices()</CODE> call (see below). The special value
<CODE>GDK_CORE_POINTER</CODE> is used for the core pointer device. (Usually
the mouse.)
<P>
<H3>Enabling extended device information</H3>

<P>To let GTK know about our interest in the extended device information,
we merely have to add a single line to our program:
<P>
<BLOCKQUOTE><CODE>
<PRE>
gtk_widget_set_extension_events (drawing_area, GDK_EXTENSION_EVENTS_CURSOR);
</PRE>
</CODE></BLOCKQUOTE>
<P>By giving the value <CODE>GDK_EXTENSION_EVENTS_CURSOR</CODE> we say that
we are interested in extension events, but only if we don't have
to draw our own cursor. See the section 
<A HREF="#sec_Further_Sophistications">Further Sophistications</A> below
for more information about drawing the cursor. We could also 
give the values <CODE>GDK_EXTENSION_EVENTS_ALL</CODE> if we were willing 
to draw our own cursor, or <CODE>GDK_EXTENSION_EVENTS_NONE</CODE> to revert
back to the default condition.
<P>This is not completely the end of the story however. By default,
no extension devices are enabled. We need a mechanism to allow
users to enable and configure their extension devices. GTK provides
the InputDialog widget to automate this process. The following
procedure manages an InputDialog widget. It creates the dialog if
it isn't present, and raises it to the top otherwise.
<P>
<BLOCKQUOTE><CODE>
<PRE>
void
input_dialog_destroy (GtkWidget *w, gpointer data)
{
  *((GtkWidget **)data) = NULL;
}

void
create_input_dialog ()
{
  static GtkWidget *inputd = NULL;

  if (!inputd)
    {
      inputd = gtk_input_dialog_new();

      gtk_signal_connect (GTK_OBJECT(inputd), "destroy",
                          (GtkSignalFunc)input_dialog_destroy, &amp;inputd);
      gtk_signal_connect_object (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->close_button),
                                 "clicked",
                                 (GtkSignalFunc)gtk_widget_hide,
                                 GTK_OBJECT(inputd));
      gtk_widget_hide ( GTK_INPUT_DIALOG(inputd)->save_button);

      gtk_widget_show (inputd);
    }
  else
    {
      if (!GTK_WIDGET_MAPPED(inputd))
        gtk_widget_show(inputd);
      else
        gdk_window_raise(inputd->window);
    }
}
</PRE>
</CODE></BLOCKQUOTE>
<P>(You might want to take note of the way we handle this dialog.  By
connecting to the "destroy" signal, we make sure that we don't keep a
pointer to dialog around after it is destroyed - that could lead to a
segfault.)
<P>The InputDialog has two buttons "Close" and "Save", which by default
have no actions assigned to them. In the above function we make
"Close" hide the dialog, hide the "Save" button, since we don't
implement saving of XInput options in this program.
<P>
<H3>Using extended device information</H3>

<P>Once we've enabled the device, we can just use the extended 
device information in the extra fields of the event structures.
In fact, it is always safe to use this information since these
fields will have reasonable default values even when extended
events are not enabled.
<P>Once change we do have to make is to call
<CODE>gdk_input_window_get_pointer()</CODE> instead of
<CODE>gdk_window_get_pointer</CODE>. This is necessary because
<CODE>gdk_window_get_pointer</CODE> doesn't return the extended device
information.
<P>
<BLOCKQUOTE><CODE>
<PRE>
void gdk_input_window_get_pointer( GdkWindow       *window,
                                   guint32         deviceid,
                                   gdouble         *x,
                                   gdouble         *y,
                                   gdouble         *pressure,
                                   gdouble         *xtilt,
                                   gdouble         *ytilt,
                                   GdkModifierType *mask);
</PRE>
</CODE></BLOCKQUOTE>
<P>When calling this function, we need to specify the device ID as
well as the window. Usually, we'll get the device ID from the
<CODE>deviceid</CODE> field of an event structure. Again, this function
will return reasonable values when extension events are not
enabled. (In this case, <CODE>event->deviceid</CODE> will have the value
<CODE>GDK_CORE_POINTER</CODE>).
<P>So the basic structure of our button-press and motion event handlers
doesn't change much - we just need to add code to deal with the
extended information.
<P>
<BLOCKQUOTE><CODE>
<PRE>
static gint
button_press_event (GtkWidget *widget, GdkEventButton *event)
{
  print_button_press (event->deviceid);
  
  if (event->button == 1 &amp;&amp; pixmap != NULL)
    draw_brush (widget, event->source, event->x, event->y, event->pressure);

  return TRUE;
}

static gint
motion_notify_event (GtkWidget *widget, GdkEventMotion *event)
{
  gdouble x, y;
  gdouble pressure;
  GdkModifierType state;

  if (event->is_hint)
    gdk_input_window_get_pointer (event->window, event->deviceid,
                                  &amp;x, &amp;y, &amp;pressure, NULL, NULL, &amp;state);
  else
    {
      x = event->x;
      y = event->y;
      pressure = event->pressure;
      state = event->state;
    }
    
  if (state &amp; GDK_BUTTON1_MASK &amp;&amp; pixmap != NULL)
    draw_brush (widget, event->source, x, y, pressure);
  
  return TRUE;
}
</PRE>
</CODE></BLOCKQUOTE>
<P>We also need to do something with the new information. Our new
<CODE>draw_brush()</CODE> function draws with a different color for
each <CODE>event->source</CODE> and changes the brush size depending
on the pressure.
<P>
<BLOCKQUOTE><CODE>
<PRE>
/* Draw a rectangle on the screen, size depending on pressure,
   and color on the type of device */
static void
draw_brush (GtkWidget *widget, GdkInputSource source,
            gdouble x, gdouble y, gdouble pressure)
{
  GdkGC *gc;
  GdkRectangle update_rect;

  switch (source)
    {
    case GDK_SOURCE_MOUSE:
      gc = widget->style->dark_gc[GTK_WIDGET_STATE (widget)];
      break;
    case GDK_SOURCE_PEN:
      gc = widget->style->black_gc;
      break;
    case GDK_SOURCE_ERASER:
      gc = widget->style->white_gc;
      break;
    default:
      gc = widget->style->light_gc[GTK_WIDGET_STATE (widget)];
    }

  update_rect.x = x - 10 * pressure;
  update_rect.y = y - 10 * pressure;
  update_rect.width = 20 * pressure;
  update_rect.height = 20 * pressure;
  gdk_draw_rectangle (pixmap, gc, TRUE,
                      update_rect.x, update_rect.y,
                      update_rect.width, update_rect.height);
  gtk_widget_draw (widget, &amp;update_rect);
}
</PRE>
</CODE></BLOCKQUOTE>
<P>
<H3>Finding out more about a device</H3>

<P>As an example of how to find out more about a device, our program
will print the name of the device that generates each button
press. To find out the name of a device, we call the function:
<P>
<BLOCKQUOTE><CODE>
<PRE>
GList *gdk_input_list_devices               (void);
</PRE>
</CODE></BLOCKQUOTE>
<P>which returns a GList (a linked list type from the GLib library)
of GdkDeviceInfo structures. The GdkDeviceInfo structure is defined
as:
<P>
<BLOCKQUOTE><CODE>
<PRE>
struct _GdkDeviceInfo
{
  guint32 deviceid;
  gchar *name;
  GdkInputSource source;
  GdkInputMode mode;
  gint has_cursor;
  gint num_axes;
  GdkAxisUse *axes;
  gint num_keys;
  GdkDeviceKey *keys;
};
</PRE>
</CODE></BLOCKQUOTE>
<P>Most of these fields are configuration information that you can ignore
unless you are implementing XInput configuration saving. The fieldwe
are interested in here is <CODE>name</CODE> which is simply the name that X
assigns to the device. The other field that isn't configuration
information is <CODE>has_cursor</CODE>. If <CODE>has_cursor</CODE> is false, then we
we need to draw our own cursor. But since we've specified
<CODE>GDK_EXTENSION_EVENTS_CURSOR</CODE>, we don't have to worry about this.
<P>Our <CODE>print_button_press()</CODE> function simply iterates through
the returned list until it finds a match, then prints out
the name of the device.
<P>
<BLOCKQUOTE><CODE>
<PRE>
static void
print_button_press (guint32 deviceid)
{
  GList *tmp_list;

  /* gdk_input_list_devices returns an internal list, so we shouldn't
     free it afterwards */
  tmp_list = gdk_input_list_devices();

  while (tmp_list)
    {
      GdkDeviceInfo *info = (GdkDeviceInfo *)tmp_list->data;

      if (info->deviceid == deviceid)
        {
          printf("Button press on device '%s'\n", info->name);
          return;
        }

      tmp_list = tmp_list->next;
    }
}
</PRE>
</CODE></BLOCKQUOTE>
<P>That completes the changes to "XInputize" our program.
<P>
<H3><A NAME="sec_Further_Sophistications"></A> Further sophistications </H3>

<P>Although our program now supports XInput quite well, it lacks some
features we would want in a full-featured application. First, the user
probably doesn't want to have to configure their device each time they
run the program, so we should allow them to save the device
configuration. This is done by iterating through the return of
<CODE>gdk_input_list_devices()</CODE> and writing out the configuration to a
file.
<P>To restore the state next time the program is run, GDK provides
functions to change device configuration:
<P>
<BLOCKQUOTE><CODE>
<PRE>
gdk_input_set_extension_events()
gdk_input_set_source()
gdk_input_set_mode()
gdk_input_set_axes()
gdk_input_set_key()
</PRE>
</CODE></BLOCKQUOTE>
<P>(The list returned from <CODE>gdk_input_list_devices()</CODE> should not be
modified directly.) An example of doing this can be found in the
drawing program gsumi. (Available from 
<A HREF="http://www.msc.cornell.edu/~otaylor/gsumi/">http://www.msc.cornell.edu/~otaylor/gsumi/</A>) Eventually, it
would be nice to have a standard way of doing this for all
applications. This probably belongs at a slightly higher level than
GTK, perhaps in the GNOME library.
<P>Another major omission that we have mentioned above is the lack of
cursor drawing. Platforms other than XFree86 currently do not allow
simultaneously using a device as both the core pointer and directly by
an application. See the 
<A HREF="http://www.msc.cornell.edu/~otaylor/xinput/XInput-HOWTO.html">XInput-HOWTO</A> for more information about this. This means that
applications that want to support the widest audience need to draw
their own cursor.
<P>An application that draws its own cursor needs to do two things:
determine if the current device needs a cursor drawn or not, and
determine if the current device is in proximity. (If the current
device is a drawing tablet, it's a nice touch to make the cursor 
disappear when the stylus is lifted from the tablet. When the
device is touching the stylus, that is called "in proximity.")
The first is done by searching the device list, as we did
to find out the device name. The second is achieved by selecting
"proximity_out" events. An example of drawing one's own cursor is
found in the "testinput" program found in the GTK distribution.
<P>
<HR>
<A HREF="gtk_tut-24.html">Next</A>
<A HREF="gtk_tut-22.html">Previous</A>
<A HREF="gtk_tut.html#toc23">Contents</A>
</BODY>
</HTML>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本成人在线不卡视频| 欧美一区二区在线看| 紧缚奴在线一区二区三区| 一区二区三区精品视频在线| 亚洲欧美怡红院| 亚洲欧美一区二区视频| 亚洲欧洲在线观看av| 亚洲人精品午夜| 亚洲一区二区三区美女| 亚洲国产三级在线| 亚洲va韩国va欧美va精品 | 97超碰欧美中文字幕| 暴力调教一区二区三区| 99免费精品视频| 色偷偷成人一区二区三区91| 91国产丝袜在线播放| 欧美日韩亚洲高清一区二区| 日韩欧美123| 久久先锋影音av鲁色资源| 久久精品夜夜夜夜久久| 国产精品久久久久aaaa樱花| 亚洲自拍偷拍九九九| 久久精品国产第一区二区三区| 国产精品中文字幕欧美| 99久久精品国产精品久久| 欧洲精品中文字幕| 日韩美女主播在线视频一区二区三区| 精品久久一二三区| 国产蜜臀97一区二区三区| 一区二区三区在线观看网站| 日韩国产在线观看| 东方aⅴ免费观看久久av| 91性感美女视频| 日韩一区二区三区观看| 国产精品乱人伦中文| 亚洲成a人片综合在线| 国产精品资源在线看| 欧美日韩在线电影| 国产精品日日摸夜夜摸av| 亚洲在线视频一区| 国产精品99久久久久久似苏梦涵| 在线亚洲一区观看| 久久久久国产成人精品亚洲午夜| 尤物在线观看一区| 国产激情视频一区二区三区欧美| 色婷婷久久久综合中文字幕 | 国产精品美女久久久久久久| 亚洲123区在线观看| 福利一区福利二区| 69堂成人精品免费视频| 亚洲欧洲制服丝袜| 国产一区不卡在线| 7777精品伊人久久久大香线蕉| 国产精品久久久久一区二区三区 | 色狠狠一区二区三区香蕉| 2020国产精品| 日韩电影在线观看电影| 欧美在线高清视频| 中文字幕在线一区| 国内精品伊人久久久久影院对白| 欧美性猛片aaaaaaa做受| 中文字幕亚洲在| 国产99一区视频免费| 26uuu国产一区二区三区 | 91麻豆精品国产91久久久久久 | 欧美在线色视频| 国产精品电影一区二区| 粉嫩欧美一区二区三区高清影视| 欧美成人r级一区二区三区| 五月天网站亚洲| 91福利资源站| 亚洲资源中文字幕| 在线观看不卡一区| 亚洲精品精品亚洲| 色婷婷精品大在线视频| 亚洲日本在线天堂| 在线一区二区三区四区| 夜夜嗨av一区二区三区四季av| 不卡的av电影在线观看| 中文字幕乱码日本亚洲一区二区| 国产一区二区在线影院| 国产日韩欧美制服另类| 成人免费视频caoporn| 亚洲国产成人午夜在线一区| 国产91精品久久久久久久网曝门 | 成人高清视频在线| 国产精品白丝在线| 色激情天天射综合网| 亚洲地区一二三色| 欧美一区二区三区性视频| 久久99精品久久久久久动态图| 精品少妇一区二区三区视频免付费| 美女在线视频一区| 国产精品色婷婷| 91国偷自产一区二区三区成为亚洲经典 | 色偷偷成人一区二区三区91| 一区二区三区加勒比av| 欧美精品一二三| 狠狠色狠狠色综合系列| 国产精品久久久久三级| 欧美三级电影网站| 狠狠色综合色综合网络| 国产精品久久久久婷婷| 欧美日韩dvd在线观看| 青娱乐精品视频在线| 欧美激情在线一区二区| 欧美制服丝袜第一页| 精品夜夜嗨av一区二区三区| 国产精品女同互慰在线看| 欧美午夜不卡在线观看免费| 国产在线视视频有精品| 亚洲免费在线观看视频| 91精品国产综合久久蜜臀 | 中文字幕亚洲一区二区av在线| 欧美亚洲自拍偷拍| 国产成人高清视频| 亚洲成人免费av| 久久婷婷国产综合国色天香| 色综合久久久久久久久久久| 久久国产精品99久久久久久老狼 | 亚洲成人tv网| 久久久久久久久99精品| 欧洲另类一二三四区| 国产精品18久久久| 亚洲一线二线三线视频| 国产精品免费久久久久| 欧美va亚洲va香蕉在线| 在线视频国内自拍亚洲视频| 国产成人精品影视| 另类专区欧美蜜桃臀第一页| 一区二区三区在线观看国产| 久久先锋影音av| 精品福利视频一区二区三区| 欧美天堂一区二区三区| caoporm超碰国产精品| 久久99精品国产麻豆不卡| 亚洲五码中文字幕| 亚洲视频 欧洲视频| 国产精品视频在线看| 337p粉嫩大胆色噜噜噜噜亚洲| 欧美老女人第四色| 欧美日韩另类一区| 在线观看一区日韩| zzijzzij亚洲日本少妇熟睡| 丰满亚洲少妇av| 国产精品亚洲第一 | 国产精品网站在线| 国产亚洲精品aa| 日韩精品中文字幕一区二区三区| 欧美人与禽zozo性伦| 日本道精品一区二区三区 | 亚洲国产日日夜夜| 亚洲一区二区三区在线| 一区二区三区国产精品| 亚洲免费伊人电影| 亚洲黄色免费电影| 一区二区三区影院| 亚洲自拍偷拍欧美| 日韩不卡一区二区三区| 日本不卡一二三| 奇米在线7777在线精品| 青青草原综合久久大伊人精品| 青青草伊人久久| 国内精品不卡在线| 大白屁股一区二区视频| 成人av电影在线网| 色婷婷av久久久久久久| 欧美性欧美巨大黑白大战| 欧美精品粉嫩高潮一区二区| 日韩一区二区在线播放| 精品日韩一区二区三区| 亚洲国产精品高清| 亚洲一区二区综合| 日韩va亚洲va欧美va久久| 狠狠狠色丁香婷婷综合久久五月| 国产寡妇亲子伦一区二区| av网站一区二区三区| 欧美视频一区二区在线观看| 日韩欧美精品三级| 日本一区二区不卡视频| 亚洲高清免费一级二级三级| 青娱乐精品视频| 成人黄色在线网站| 欧美三级视频在线观看| 精品粉嫩aⅴ一区二区三区四区 | 在线日韩国产精品| 日韩欧美一二三区| 18成人在线观看| 日韩av一区二区三区| 成人国产亚洲欧美成人综合网| 欧美性生交片4| 国产欧美日韩三区| 丝袜亚洲另类欧美| 成人一区二区三区在线观看| 在线播放中文一区| 中文字幕 久热精品 视频在线 | 久久精品在线免费观看| 亚洲国产毛片aaaaa无费看 | 中文字幕中文字幕在线一区 | 在线免费亚洲电影|