Jump to content

Radiobutton custom draw problem


Recommended Posts

Posted (edited)

Hi! It seems that there are some problems with the Custom Draw Routines assignment for the RadioButton. Look at the code and comments pls:

	// Custom Draw Routines for RadioButton: replace RadioButton with two (in one) image:
	void gwinRadioDraw_Image(GWidgetObject *gw, void *param) {
		
		coord_t				sy;
		
	    if ((gw->g.flags & GRADIO_FLG_PRESSED)) {
			sy = gw->g.height;
		} else {
			sy = 0;
		}

		gdispGImageDraw(gw->g.display, (gdispImage *)param, gw->g.x, gw->g.y, gw->g.width, gw->g.height, 0, sy);
	}

	// create button widget: ghButton4  - THIS ONE DISPLAYED IMAGES AND WORK GREATE 
	wi.g.show = TRUE;
	wi.g.x = 0;
	wi.g.y = 204;
	wi.g.width = 68;
	wi.g.height = 68;
	wi.g.parent = ghContainerPage0;
	wi.text = "Button";
	wi.customDraw = gwinButtonDraw_Image;
	wi.customParam = &MyImage;          // image, everything OK with button!
	wi.customStyle = 0;
	ghButton4 = gwinButtonCreate(0, &wi);
	gwinSetFont(ghButton4, dejavu_sans_10);
	gwinRedraw(ghButton4);

	
	// create radio button widget: ghRadioButton1 - THIS ONE DISPLAYED STANDART RADIO AND WORK GREATE TOO
	wi.g.show = TRUE;
	wi.g.x = 80;
	wi.g.y = 60;
	wi.g.width = 68;
	wi.g.height = 68;
	wi.g.parent = ghContainerPage0;
	wi.text = "RadioButton1";
	wi.customDraw = gwinRadioDraw_Radio;
	wi.customParam = 0; 
	wi.customStyle = 0;
	ghRadioButton1 = gwinRadioCreate(0, &wi, MAIN_GROUP);
	gwinRadioPress(ghRadioButton1);
	gwinRedraw(ghRadioButton1);


	// create radio button widget: ghRadioButton2 - THIS ONE DOESN'T DISPLAYED and then the microcontroller freezes
	wi.g.show = TRUE;
	wi.g.x = 80;
	wi.g.y = 0;
	wi.g.width = 68;
	wi.g.height = 68;
	wi.g.parent = ghContainerPage0;
	wi.text = "RadioButton2";
	wi.customDraw = gwinRadioDraw_Image;
	wi.customParam = &MyImage;                // the same image!
	wi.customStyle = 0;
	ghRadioButton2 = gwinRadioCreate(0, &wi, MAIN_GROUP);
	gwinRedraw(ghRadioButton2);
}

I tried simple draw image without conditions or simple draw rect or text  instead image, but I always got the same effect. 

uGFX from repository. Everything else works fine.  Could your tell me pls, what's I doing wrong?

 

Edited by Dvor_nik
Posted

Your custom rendering routine seems fine. That definitely shouldn't be a problem. I can't find any problem in the rest of your code either. Can you please use your debugger to grab a stack trace to figure out what causes the crash? Also, check whether it really is a crash. a "freeze" could also just being stuck in a loop waiting for something. Again, using the debugger will give you more information.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...