Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-04

force redraw on hscale

5 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marc Santhoff

Hi!

I know this seems to be a gtk issue, but I'm using pascal so:

Talking of GTK+ 1.2

I'm trying to chnge the background color on a hscale.

There seems to be some sort of bug or misunderstanding by me. The actual change in color happens delayed on a hscale I'm using and switching color on.

If the color is changed programmatically, nothing is drawn changed. After the next change in value at the gui, the background is changing from grey to green (SPEED_COLOR_ACTIVE) exactly at the position the slider has been at (it is going in increments of 17).

My question: how can I force a redraw on selected widgets or the whole window when needed?

TIA,
Marc

P.S.: some code:

var
	st	: pGtkRcStyle;
	cola, colp	: TGdkColor;
begin
...
		{ swap the visual focus }
		gdk_color_parse(SPEED_COLOR_ACTIVE, @cola);
		gdk_color_parse(SPEED_COLOR_PASSIVE, @colp);
		st := gtk_rc_style_new ();
		if (target = 1) then begin
			gtk_widget_grab_focus(GTK_WIDGET(scales[1]));
			st^.bg[GTK_STATE_ACTIVE] := colp;
			st^.color_flags[GTK_STATE_ACTIVE] :=
		                 st^.color_flags[GTK_STATE_ACTIVE] OR GTK_RC_BG;
			gtk_widget_modify_style(GTK_WIDGET(scales[0]), st);
			//gdk_flush(); no use ...
Jeff Pohlmeyer
My question: how can I force a redraw on selected widgets or the whole window when needed?

Maybe this will help:

  procedure UpdateWidget(w:pGtkWidget);
  var
    update_rect: tGdkRectangle;
  begin
    update_rect.x:=0;
    update_rect.y:=0;
    update_rect.width:=w^.allocation.width;
    update_rect.height:=w^.allocation.height;
    gtk_widget_draw(w, @update_rect);
  end;

__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
http://hotjobs.sweepstakes.yahoo.com/careermakeover

Marc Santhoff
to Jeff Pohlmeyer
Show quoted text 15 lines
> My question: how can I force a redraw on selected > widgets or the whole window when needed? Maybe this will help: procedure UpdateWidget(w:pGtkWidget); var update_rect: tGdkRectangle; begin update_rect.x:=0; update_rect.y:=0; update_rect.width:=w^.allocation.width; update_rect.height:=w^.allocation.height; gtk_widget_draw(w, @update_rect); end;

Hi Jeff!

I think it does work, but the color on the GtkHScale does not really change, only after changing the value at the slider, as before.

I added (hint from the gtk mailing list) this:

gtk_widget_queue_draw(GTK_WIDGET(scales[0]));
			while (gtk_events_pending()=gtk_true) do gtk_main_iteration ();

to process all pending draw event afterwards, but no luck. :(

Must be a bug or some plan I do not get.

Has anyone ever managed to change a GtkHScales color on the fly?

I can do it at startup from the ressource file, but changing afterwards is not possible. But it does work when i minimize the window and restore it! And it is colorizing the whole bar, not only the places where the slider steps ...

Any further hints?

Marc Santhoff
to Jeff Pohlmeyer: Maybe this will help: procedure UpdateWidget(w:pGtkWidget); var update_rect:…
Show quoted text 15 lines
> My question: how can I force a redraw on selected > widgets or the whole window when needed? Maybe this will help: procedure UpdateWidget(w:pGtkWidget); var update_rect: tGdkRectangle; begin update_rect.x:=0; update_rect.y:=0; update_rect.width:=w^.allocation.width; update_rect.height:=w^.allocation.height; gtk_widget_draw(w, @update_rect); end;

More information on the problem:

The color update is not drawn until the window is forced to redraw!

A testing program written in C to be sure it's not a fault of the pascal binding teached me that.

Now I'll try a forced resize and hope to get no flickering.

Marc

Marc Santhoff
to Marc Santhoff

Am Di, den 27.04.2004 schrieb Marc Santhoff um 19:06: [...]

Show quoted text 9 lines
More information on the problem: The color update is not drawn until the window is forced to redraw! A testing program written in C to be sure it's not a fault of the pascal binding teached me that. Now I'll try a forced resize and hope to get no flickering.

I'm really, really sad to write this:

It was the theme engine. Although apparently unistalled a library and activated definition im my .gtkrc were still there.

This was very stupid, sorry.

Marc