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

📄 faqs.html

📁 gtk_text program sample&eg
💻 HTML
📖 第 1 页 / 共 4 页
字号:
            really good reason to change the appearance of a            widget. How do I override the theme?</a>          </h2>          <p>            write this          </p>        </div>        <div class="SECT2">          <h2 class="SECT2">            <a name="Z843">Why are signals specified as strings            rather than integers or some sort of macro?</a>          </h2>          <p>            Strings are nicer. They are easier to type and less            headache for <span class="STRUCTNAME">GtkObject</span>            authors to maintain. They don't clutter the C            namespace. Typing a string incorrectly will trigger a            runtime error so macros don't improve error checking.            Finally, strings are internally converted to a numeric            ID so there is no loss in efficiency.          </p>          <p>            Consider the maintenance headache of using enumerations            instead: both enumeration values and their names would            have to be unique across GTK+, Gnome, and third-party            extensions. A nightmare.          </p>        </div>        <div class="SECT2">          <h2 class="SECT2">            <a name="Z844">Why is GTK+ written in C?</a>          </h2>          <p>            First and foremost: asking this question in any public            forum is <i class="EMPHASIS">strongly discouraged</i>.            Don't do it. Check the archives for several extended            off-topic flamefests if you're interested.          </p>          <p>            Here are some reasons:          </p>          <ul>            <li>              <p>                The original authors wanted to write it in C, and                now many C-only applications are based on it. The                current authors enjoy C.&#13;              </p>            </li>            <li>              <p>                GTK+ handles types and objects much more flexibly                than C++; it is runtime-oriented, more like Java or                Objective C than C++ system. This is convenient for                GUI builders and language bindings.&#13;              </p>            </li>            <li>              <p>                C is the lingua franca of UNIX development; most                people know how to code in it. &#13;              </p>            </li>            <li>              <p>                There are already nice toolkits for languages such                as Java and Objective C. There are C++ wrappers for                GTK+; several, in fact. &#13;              </p>            </li>            <li>              <p>                C is more portable than C++; ANSI C++ is not yet                widely implemented, so only an ill-defined subset                of C++ can actually be used.&#13;              </p>            </li>            <li>              <p>                When GTK+ development first started, there was no                free, working C++ compiler. &#13;              </p>            </li>          </ul>          <p>            Again: do not ask this question on any mailing lists,            because people will not be amused.          </p>        </div>        <div class="SECT2">          <h2 class="SECT2">            <a name="Z845">My motion event handler is only invoked            once; why is that?</a>          </h2>          <p>            If you specify <span class="STRUCTNAME">            GDK_POINTER_MOTION_HINT_MASK</span>, you must call <tt            class="FUNCTION">gdk_window_get_pointer()</tt> to get            more motion events. One motion event is sent each time            you get the pointer location. See <a href=             "sec-gdkevent.html#SEC-MOVEMENTEVENTS">the section            called <i>Mouse Movement Events</i> in the chapter            called <i>GDK Basics</i></a>.          </p>        </div>        <div class="SECT2">          <h2 class="SECT2">            <a name="Z846">Can I move the mouse pointer myself?</a>          </h2>          <p>            There is an Xlib routine called <tt class="FUNCTION">            XWarpPointer()</tt> that does this, but GDK does not            wrap it. It is almost certainly a bad idea to use this            feature (in fact it is intended for window managers            only); you might consider writing to one of the GTK+ or            Gnome mailing lists to ask for another way to achieve            whatever you are trying to achieve. However, you can            always use Xlib routines (such as <tt class="FUNCTION">            XWarpPointer()</tt>) by including <tt class="FILENAME">            gdk/gdkx.h</tt> and <tt class="FILENAME">            gdk/gdkprivate.h</tt>, then manipulating the private            parts of the GDK data structures. If that sounds            unsavory, it probably should.          </p>        </div>        <div class="SECT2">          <h2 class="SECT2">            <a name="Z847">How do I read the pixels out of a <span            class="STRUCTNAME">GdkPixmap</span>?</a>          </h2>          <p>            First and foremost: remember that a pixmap is a            server-side resource, i.e. possibly across a network            and <i class="EMPHASIS">definitely</i> across some kind            of socket. Therefore, you do not want to request its            pixels one by one. Iterating over a pixmap that way            could easily take many seconds.          </p>          <p>            GDK wraps an Xlib object called <span class=            "STRUCTNAME">XImage</span>. The wrapper is called <span            class="STRUCTNAME">GdkImage</span>. A <span class=             "STRUCTNAME">GdkImage</span> is essentially a local            copy of the data in a pixmap. You can copy a region of            a pixmap or window into a <span class="STRUCTNAME">            GdkImage</span> with the <tt class="FUNCTION">            gdk_image_get()</tt> routine, then get and set pixels            with <tt class="FUNCTION">gdk_image_get_pixel()</tt>            and <tt class="FUNCTION">gdk_image_put_pixel()</tt>.            You can also access the image's data structures            directly, but this is quite complicated (due to            visuals, depths, differences between host and network            byte order, and so on). If you modify the image, you            use <tt class="FUNCTION">gdk_draw_image()</tt> to copy            it back to a server-side drawable.          </p>          <p>            Copying a pixmap to a <span class="STRUCTNAME">            GdkImage</span>, or copying a <span class="STRUCTNAME">            GdkImage</span> to a pixmap, still involves moving            quite a bit of data over the network; however, since            it's all in one burst the speed can be tolerable in            many cases. Also, if the client and the server are on            the same machine, and the X shared memory extension is            available, GDK will automatikcally set up a shared            memory segment to copy the data.          </p>          <p>            Most of the time, if you plan to do a lot of image            manipulation, you are better off using RGB buffers as            your primary data structure (see <a href=             "z132.html#SEC-GDKRGB">the section called <i>RGB            Buffers</i> in the chapter called <i>GDK            Basics</i></a>). The functions in <tt class="FILENAME">            gdk/gdkrgb.h</tt> allow you to copy an RGB buffer to a            drawable. These functions use <span class="STRUCTNAME">            GdkImage</span> internally, but they are tuned to be            very fast and handle all the complexities for you.          </p>        </div>        <div class="SECT2">          <h2 class="SECT2">            <a name="Z848">I'm drawing a lot of points to the            screen with <tt class="FUNCTION">gdk_draw_point()</tt>,            and it's unbelievably slow. What's wrong? How can I            render image data to the screen?</a>          </h2>          <p>            See the previous question. You should probably use the            GDK RGB functions (<a href="z132.html#SEC-GDKRGB">the            section called <i>RGB Buffers</i> in the chapter called            <i>GDK Basics</i></a>).          </p>        </div>        <div class="SECT2">          <h2 class="SECT2">            <a name="Z849">I'm trying to set the background of a            <tt class="CLASSNAME">GtkLabel</tt>, and it doesn't            work.</a>          </h2>          <p>            <tt class="CLASSNAME">GtkLabel</tt> is a windowless            widget; it is "transparent" and draws on its parent            container's background. If you want to set the            background, place the label in a <tt class="CLASSNAME">            GtkEventBox</tt>. The same answer applies to other            windowless widgets, such as <tt class="CLASSNAME">            GtkImage</tt>.          </p>        </div>        <div class="SECT2">          <h2 class="SECT2">            <a name="Z850">In the GTK+ and Gnome source code, many            functions have two variants: one called <tt class=             "FUNCTION">gtk_whatever_foo()</tt>, and another called            <tt class="FUNCTION">gtk_whatever_real_foo()</tt>.            What's the difference?</a>          </h2>          <p>            <tt class="FUNCTION">gtk_whatever_foo()</tt> is            typically a public function which emits the <span            class="SYMBOL">"foo"</span> signal, taking care of any            necessary details before and after emission (remember            that only <span class="STRUCTNAME">            GTK_RUN_ACTION</span> signals can be emitted without            special actions before and after). <tt class=            "FUNCTION">gtk_whatever_real_foo()</tt> will be the            default handler for the signal, installed in the            object's class struct. <a href="cha-widget.html">the            chapter called <i>Writing a <tt class="CLASSNAME">            GtkWidget</tt></i></a> has many examples of this.          </p>        </div>        <div class="SECT2">          <h2 class="SECT2">            <a name="Z851">How do I "gray out" a widget, so the            user can't select it?</a>          </h2>          <p>            See <a href="z57.html#SEC-SENSITIVITY">the section            called <i>Sensitivity</i> in the chapter called <i>GTK+            Basics</i></a>. Short answer:          </p>          <table border="0" bgcolor="#E0E0E0" width="100%">            <tr>              <td><pre class="PROGRAMLISTING">&#13;  gtk_widget_set_sensitive(widget, FALSE);&#13;</pre>              </td>            </tr>          </table>        </div>        <div class="SECT2">          <h2 class="SECT2">            <a name="Z852">I'm connecting to <span class="SYMBOL">            "button_press_event"</span> or some other event signal,            but the callback is never invoked.</a>          </h2>          <p>            There are several possibilities:          </p>          <ul>            <li>              <p>                The widget has no <span class="STRUCTNAME">                GdkWindow</span> (i.e. the <span class=                "STRUCTNAME">GTK_NO_WINDOW</span> flag is set), so                it does not receive events (other than synthesized                expose events).&#13;              </p>            </li>            <li>              <p>                The event you're trying to monitor isn't in the                event mask for the widget's <span class=                "STRUCTNAME">GdkWindow</span>. Use <tt class=                 "FUNCTION">gtk_widget_add_events()</tt> to add more                events to the mask.&#13;              </p>            </li>            <li>              <p>                The widget is a container, and some child widget is                "handling" the event by returning <span class=                 "STRUCTNAME">TRUE</span> from the event signal                emission. Only "unhandled" events are propagated                from child to parent. &#13;              </p>            </li>          </ul>          <p>            See <a href="sec-gdkevent.html#SEC-GTKEVENTS">the            section called <i>Receiving GDK Events in GTK+</i> in            the chapter called <i>GDK Basics</i></a> for more            details on events and how they are passed to widgets.          </p>

⌨️ 快捷键说明

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