Re: spin buttons
- From: Jeff Shipman <shippy nmt edu>
- To: Loban Rahman <loban earthling net>
- Cc: Sven Neumann <sven gimp org>, GTK List <gtk-list gnome org>
- Subject: Re: spin buttons
- Date: Wed, 14 Feb 2001 17:33:25 -0700 (MST)
I've since changed to using the adjustment values and the
method you suggested. It definitely does clean up the code
a bit! As for the other spinbutton, it has to do some funky
date wrapping, so I found that using tm structures to normalize
the time and then plugging it back in is the way to go. I
really appreciate your help, it has been very enlightening!
Jeff "Shippy" Shipman E-Mail: shippy nmt edu
Computer Science Major ICQ: 1786493
New Mexico Institute of Mining and Technology
Homepage: http://www.nmt.edu/~shippy
On 14 Feb 2001, Loban Rahman wrote:
> Here is what I'd have done to solve the problem. My method might not be
> ideal for your case, but I'd use it because I tend to not mess with gui
> code unless it's actually the view that i want to change, not the model.
> Here it is:
>
> (1) Make the 3 spin buttons (with their 3 adjustments).
> (2) If the valid range of a spin button is from x to y inclusive, set
> the range instead to (x-s) to (y+s) inclusive, where s is the step (s =
> 1 in your case, since it is dates).
> (3) Set a function foo to be the handler for the value_changed signal
> for all 3 adjustments.
> (4) In foo, see if any value is (x-s) or (y+s) for each adjustment. If
> it is, change (x-s) to y or (y+s) to x, depending on which it is, and
> then bump the other adjustment up or down, again depending on which it
> is.
> (5) Your 4th spin button (i don't know what it does), can choose a
> similar approach, in that the handler for it's adjustment's
> value_changed does changes appropriately.
>
> (6) If this was for the year-month-day thing, as you said, then it's
> easy to modify step (4) so that instead of just checking for (x-s) or
> (y+s), it will check for anything exceeding the correct range at any
> point in time. For example, if the month was 2 (feb), then it would wrap
> the date if it went over 28 (or 29 for leap years), and increment the
> month to 3 (march).
> (7) The reason I like this approach is that, like I said, it isn't
> dependent on gui code at all, and so is easier to reuse elsewhere.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]