new (stopgap) Gtk-- widget: Gtk_Spinner



somewhat frustrated with GtkSpinButton, i set out to write a
replacement in C. that left me even more frustrated. i ended up coding
the new one in C++.

what's wrong with GtkSpinButton ?

       * you can only spin through numeric values, because
         there is no provision for printing a non-numeric representation
	 of the current value
       * you have to move the mouse the change the spin direction
       * you can't easily access the page increment from the mouse
       * you can't control where the spin buttons go (left, right, top
            bottom)
       * its hard to get back to a precise starting point after a spin

I had developed a clever little button for XForms that allowed you to
control a display widget using a single event box and useful
combinations of keyboard states and mouse button events. It has proved
highly useful in a fairly unorthodox program i wrote for XForms, and
am now porting to Gtk--. I therefore needed something similar that
didn't suffer from the SpinButton limitations.

the Gtk_Spinner class answers all these problems. it is derived from a
Gtk_Table, and packs an Gtk_Entry into the center. The text in the
entry is printed by either a default function that just shows it as 
"%.*f", or you can use the set_filter() method to provide a "filter"
that will be given the new value, and can print whatever
representation it wishes in the Gtk_Entry.

Depending on the arguments you provide for the constructor, it will
pack up to 4 extra buttons around the entry, one for "step up", "step
down", "page up", and "page down". Where they end up in the NSWE table
grid is (mostly) up to you, and you can select all 4 buttons, just the
step buttons, just the page buttons, just the up buttons or just the
down buttons, or various combinations thereof. If you use only buttons
for one direction, the mouse buttons are differentiated: button 1
increments the value, button 3 decrements it. Button 2 always returns
the spinner to its "initial" value. Using shift-mousebutton selects
the page increment, rather than the step increment, regardless of the
button you are pressing.

The labels on the button are up to you to provide, using either text
or a pixmap, in the usual way.

Frankly, i would be really happy if someone else took the idea and
implemented a C version of it. I just don't have the patience to do
all the cut-n-paste coding needed with C widgets. If you're interested
in doing this, please let me know, and I'll do the Gtk-- wrapper. If I
don't here from anyone, i'll post my C++ source in a couple of days.

--p




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]