⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sec-gdkcursor.html

📁 gtk 开发手册和参考文档。 包括gtk glib gdk等
💻 HTML
📖 第 1 页 / 共 2 页
字号:
</pre>                </td>              </tr>            </table>            <p>              <code><code class="FUNCDEF">gint <tt class=              "FUNCTION">gdk_pointer_grab</tt></code>(GdkWindow*              <tt class="PARAMETER"><i>window</i></tt>, gint <tt              class="PARAMETER"><i>owner_events</i></tt>,              GdkWindow* <tt class="PARAMETER"><i>              confine_to</i></tt>, GdkCursor* <tt class=              "PARAMETER"><i>cursor</i></tt>, guint32 <tt class=               "PARAMETER"><i>time</i></tt>);</code>            </p>            <p>              <code><code class="FUNCDEF">void <tt class=              "FUNCTION">gdk_pointer_ungrab</tt></code>(guint32 <tt              class="PARAMETER"><i>time</i></tt>);</code>            </p>            <p>              <code><code class="FUNCDEF">gint <tt class=              "FUNCTION">              gdk_pointer_is_grabbed</tt></code>(void);</code>            </p>          </div>          <p>            <b>Figure 8. Grabbing the Pointer</b>          </p>        </div>      </div>      <div class="SECT2">        <h2 class="SECT2">          <a name="Z130">Changing the Cursor</a>        </h2>        <p>          You can change the cursor shape at any time; cursor          shapes are set on a window-by-window basis with <tt          class="FUNCTION">gdk_window_set_cursor()</tt> (<a href=           "sec-gdkcursor.html#FL-CURSOR">Figure 9</a>). By default,          windows use their parent's cursor; you can restore the          default cursor by setting a window's cursor to <span          class="STRUCTNAME">NULL</span>.        </p>        <p>          Two ways are provided to create a cursor. The simplest          way is to choose a cursor from the cursor font that comes          with X. The cursor font contains cursors instead of          characters; you can view it with the command <tt class=           "APPLICATION">xfd -fn cursor</tt>. You can also browse          the available cursors using the <tt class="APPLICATION">          testgtk</tt> program that comes with GTK+. Each cursor          shape has a constant defined in <tt class="FILENAME">          gdk/gdkcursors.h</tt>. <tt class="FUNCTION">          gdk_cursor_new()</tt> accepts one of these constants as          its only argument:        </p>        <table border="0" bgcolor="#E0E0E0" width="100%">          <tr>            <td><pre class="PROGRAMLISTING">&#13;  GdkCursor* cursor;  cursor = gdk_cursor_new(GDK_CLOCK);  gdk_window_set_cursor(window, cursor);  gdk_cursor_destroy(cursor);&#13;</pre>            </td>          </tr>        </table>        <p>          Notice that you can destroy the cursor as soon as you          attach it to a window; <span class="STRUCTNAME">          GdkCursor</span> is a client-side handle for a          server-side resource, and X will keep the server-side          resource around as long as it's in use.        </p>        <p>          If none of the cursors in the cursor font are          appropriate, you can create a custom cursor from a          bitmap. Two bitmaps, actually: the <span class=          "STRUCTNAME">source</span> pixmap, and the <span class=           "STRUCTNAME">mask</span>. Since these are bitmaps, every          pixel is either on or off (0 or 1). If a pixel is 0 in          the mask, that pixel will be transparent. If a pixel is 1          in both pixmaps, it will be displayed in the <span class=           "STRUCTNAME">fg</span> (foreground) color passed to <tt          class="FUNCTION">gdk_cursor_new_from_pixmap()</tt>. If a          pixel is 1 in the mask but 0 in the <span class=           "STRUCTNAME">source</span> pixmap, it will be displayed          in the <span class="STRUCTNAME">bg</span> (background)          color. The <span class="STRUCTNAME">source</span> and          <span class="STRUCTNAME">mask</span> pixmaps must be the          same size, and they must have a depth of one.        </p>        <p>          The foreground and background colors should be          contrasting, so the cursor will be visible against any          background. Most cursors are drawn in the foreground          color and outlined in the background color. (To see this,          move an X cursor over a dark background; you will notice          a white outline around its edges.) To achieve this, <span          class="STRUCTNAME">mask</span> should be slightly larger          than <span class="STRUCTNAME">source</span>, but the same          shape.        </p>        <p>          The final two arguments to <tt class="FUNCTION">          gdk_cursor_new_from_pixmap()</tt> are the coordinates of          the cursor's <i class="FIRSTTERM">hot spot</i>. This is          the point drawn at the mouse pointer's location---the tip          of an arrow cursor, or the center of a crosshair cursor.          <tt class="FUNCTION">gdk_cursor_new_from_pixmap()</tt>          will fail if the hot spot is not within the bitmap.        </p>        <div class="FIGURE">          <a name="FL-CURSOR"></a>          <div class="FUNCSYNOPSIS">            <a name="FL-CURSOR.SYNOPSIS"></a>            <table border="0" bgcolor="#E0E0E0" width="100%">              <tr>                <td><pre class="FUNCSYNOPSISINFO">#include &lt;gdk/gdk.h&gt;</pre>                </td>              </tr>            </table>            <p>              <code><code class="FUNCDEF">GdkCursor* <tt class=               "FUNCTION">gdk_cursor_new</tt></code>(GdkCursorType              <tt class="PARAMETER"><i>              cursor_type</i></tt>);</code>            </p>            <p>              <code><code class="FUNCDEF">GdkCursor* <tt class=               "FUNCTION">              gdk_cursor_new_from_pixmap</tt></code>(GdkPixmap* <tt              class="PARAMETER"><i>source</i></tt>, GdkPixmap* <tt              class="PARAMETER"><i>mask</i></tt>, GdkColor* <tt              class="PARAMETER"><i>fg</i></tt>, GdkColor* <tt              class="PARAMETER"><i>bg</i></tt>, gint <tt class=               "PARAMETER"><i>x</i></tt>, gint <tt class=              "PARAMETER"><i>y</i></tt>);</code>            </p>            <p>              <code><code class="FUNCDEF">void <tt class=              "FUNCTION">gdk_cursor_destroy</tt></code>(GdkCursor*              <tt class="PARAMETER"><i>cursor</i></tt>);</code>            </p>            <p>              <code><code class="FUNCDEF">void <tt class=              "FUNCTION">              gdk_window_set_cursor</tt></code>(GdkWindow* <tt              class="PARAMETER"><i>window</i></tt>, GdkCursor* <tt              class="PARAMETER"><i>cursor</i></tt>);</code>            </p>          </div>          <p>            <b>Figure 9. <span class="STRUCTNAME">            GdkCursor</span></b>          </p>        </div>      </div>    </div>    <div class="NAVFOOTER">      <br>      <br>      <table width="100%" border="0" bgcolor="#ffffff" cellpadding=       "1" cellspacing="0">        <tr>          <td width="25%" bgcolor="#ffffff" align="left">            <a href="sec-gdkevent.html"><font color="#0000ff" size=             "2"><b>&lt;&lt;&lt; Previous</b></font></a>          </td>          <td width="25%" colspan="2" bgcolor="#ffffff" align=           "center">            <font color="#0000ff" size="2"><b><a href="ggad.html">            <font color="#0000ff" size="2"><b>            Home</b></font></a></b></font>          </td>          <td width="25%" bgcolor="#ffffff" align="right">            <a href="sec-gdkfont.html"><font color="#0000ff" size=            "2"><b>Next &gt;&gt;&gt;</b></font></a>          </td>        </tr>        <tr>          <td colspan="2" align="left">            <font color="#000000" size="2"><b>Events</b></font>          </td>          <td colspan="2" align="right">            <font color="#000000" size="2"><b>Fonts</b></font>          </td>        </tr>      </table>    </div>  </body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -