示例#1
0
文件: main.c 项目: pygmyos/testcode
void drawMainMenu( void )
{
    PYGMYCOLOR pygmyColor;
    PYGMYFILE pygmyFile;
    PYGMYWIDGET widgetButton;

    pinInterrupt( eventMouseMoveUp, A0, TRIGGER_RISING, 1 );
    pinInterrupt( eventMouseMoveDown, D3, TRIGGER_RISING, 1 );
    pinInterrupt( eventMouseMoveLeft, TA0, TRIGGER_RISING, 1 );
    pinInterrupt( eventMouseMoveRight, DAC1, TRIGGER_RISING, 1 );
    pinInterrupt( eventMouseClickLeft, DAC2, TRIGGER_RISING, 1 );
    pinInterrupt( eventMouseClickCenter, TX2, TRIGGER_RISING, 1 );
    pinInterrupt( eventMouseClickRight, RX2, TRIGGER_RISING, 1 );

    colorSetRGB( colorGetRootColor(), 0x65, 0xBE, 0xFF ); //0x48, 0x8E, 0xDF );
    colorSetRGB( colorGetRootBackColor(), 0x65, 0x65, 0x65 );
    colorSetRGB( colorGetRootFocusColor(), 0x65, 0x65, 0x65 );//0x38, 0x6E, 0xBF  );
    colorSetRGB( colorGetRootFocusBackColor(), 0x65, 0x8E, 0xDF );
    colorSetRGB( colorGetRootClearColor(), 0xFF, 0x0E, 0xE0 );//0xFF, 0xE0, 0xE0 );
     
    guiSetRadius( 8 );
    guiSetStyle( VISIBLE|BUTTON|ROUNDED|BORDER|CENTERED );
    
    formFreeAll();
    formNew( 0, 0, 128, 128 );
    //formCurrentSetColor;
    //formCurrentSetBackColor;
    //formCurrentSetClearColor;
    widgetButton.Style = CAPTION|FILLED|VISIBLE|ROUNDED|BORDER|CENTERED;
    //widgetButton.Style = FILLED|VISIBLE|ROUNDED|BORDER|CENTERED;
    widgetButton.Type = BUTTON;
    widgetButton.X = 0;
    widgetButton.Y = 6;
    widgetButton.Width = 127;
    widgetButton.Height = 36;
    widgetButton.String = "Start Game";
    formAddWidget( &widgetButton );
    //widgetAddEventHandler( widgetGetCurrent(), eventGotFocus, GOTFOCUS );
    //widgetAddEventHandler( widgetGetCurrent(), eventLostFocus, LOSTFOCUS );
    widgetAddEventHandler( widgetGetCurrent(), gemInit, SELECTED );
    
    widgetButton.Y = 46;
    widgetButton.String = "RF Demo";
    formAddWidget( &widgetButton );
    //widgetAddEventHandler( widgetGetCurrent(), eventGotFocus, GOTFOCUS );
    //widgetAddEventHandler( widgetGetCurrent(), eventLostFocus, LOSTFOCUS );
    widgetAddEventHandler( widgetGetCurrent(), drawRFTest, SELECTED );
    
    widgetButton.Y = 86;
    widgetButton.String = "Contrast";
    formAddWidget( &widgetButton );
    //widgetAddEventHandler( widgetGetCurrent(), eventGotFocus, GOTFOCUS );
    //widgetAddEventHandler( widgetGetCurrent(), eventLostFocus, LOSTFOCUS );
    //widgetAddEventHandler( widgetGetCurrent(), eventSelected, SELECTED );
    
    drawForms( );
}
示例#2
0
文件: main.c 项目: pygmyos/testcode
void drawRFTest( void )
{
    //PYGMYCOLOR pygmyColor;
    //PYGMYFILE pygmyFile;
    PYGMYWIDGET widgetButton;

    colorSetRGB( colorGetRootColor(), 0x65, 0xBE, 0xFF ); //0x48, 0x8E, 0xDF );
    colorSetRGB( colorGetRootBackColor(), 0x65, 0x65, 0x65 );
    colorSetRGB( colorGetRootFocusColor(), 0x65, 0x65, 0x65 );//0x38, 0x6E, 0xBF  );
    colorSetRGB( colorGetRootFocusBackColor(), 0x65, 0x8E, 0xDF );
    colorSetRGB( colorGetRootClearColor(), 0xFF, 0x0E, 0xE0 );
     
    guiSetRadius( 8 );
    guiSetStyle( VISIBLE|BUTTON|ROUNDED|BORDER|CENTERED );
    
    formFreeAll();
    formNew( 0, 0, 128, 128 );
    
    widgetButton.Style = CAPTION|CENTERED|VISIBLE|ROUNDED|BORDER;
    widgetButton.Type = LABEL;
    widgetButton.X = 0;
    widgetButton.Y = 6;
    widgetButton.Width = 127;
    widgetButton.Height = 36;
    widgetButton.String = "Humidity";
    formAddWidget( &widgetButton );
    
    widgetButton.Style = CAPTION|VISIBLE|ROUNDED;
    widgetButton.Type = LABEL;
    widgetButton.X = 0;
    widgetButton.Y = 46;
    widgetButton.Width = 127;
    widgetButton.Height = 36;
    copyString( "Waiting...", globalHumidity );
    widgetButton.String = globalHumidity;
    formAddWidget( &widgetButton );
    //formSetFocus( formGetWidgetCount() - 1 );
    
    widgetButton.Style = CAPTION|FILLED|VISIBLE|ROUNDED|BORDER|CENTERED;
    widgetButton.Type = BUTTON;
    widgetButton.Y = 86;
    widgetButton.String = "Back";
    formAddWidget( &widgetButton );
    formSetFocus( formGetWidgetCount() - 1 );
    
    widgetAddEventHandler( widgetGetCurrent(), eventRFBack, SELECTED );
    
    
    drawForms();
    //taskNewSimple( "humidity", 1000, (void*)threadRFHumidity );
}
示例#3
0
void buttonInit(button *self, const char *id, int w, int h)
{
	// Buttons need to be redrawn when the following events fire
	int i, handlers[] = {
	    EVT_ENABLE,
	    EVT_DISABLE,
	    EVT_MOUSE_ENTER,
	    EVT_MOUSE_LEAVE,
	    EVT_MOUSE_DOWN,
	    EVT_MOUSE_UP
	};

	// Init our parent
	widgetInit((widget *)self, id);

	// Prepare our vtable
	buttonInitVtbl(self);

	// Set our type
	((widget *)self)->classInfo = &buttonClassInfo;

	// initialise button state
	self->state = BUTTON_STATE_NORMAL;

	// Mask for exact mouse events
	widgetEnableMask(WIDGET(self));

	// Install necessary event handlers
	for (i = 0; i < sizeof(handlers) / sizeof(int); i++)
	{
		widgetAddEventHandler(WIDGET(self), handlers[i],
		                      buttonSetButtonStateHandler, NULL, NULL);
	}

	buttonSetPatternsForState(self, BUTTON_STATE_NORMAL, "button/normal/fill", "button/normal/contour");
	buttonSetPatternsForState(self, BUTTON_STATE_DISABLED, "button/disabled/fill", "button/disabled/contour");
	buttonSetPatternsForState(self, BUTTON_STATE_MOUSEOVER, "button/mouseover/fill", "button/mouseover/contour");
	buttonSetPatternsForState(self, BUTTON_STATE_MOUSEDOWN, "button/mousedown/fill", "button/mousedown/contour");

	widgetResize(WIDGET(self), w, h);
}
示例#4
0
void widgetInit(widget *self, const char *id)
{
	// Prepare our vtable
	widgetInitVtbl(self);

	// Set our type
	self->classInfo = &widgetClassInfo;

	// Prepare our container
	self->children = vectorCreate();

	// Prepare our events table
	self->eventVtbl = vectorCreate();

	// Copy the ID of the widget
	self->id = strdup(id);

	// Default parent is none
	self->parent = NULL;

	// Default size is (-1,-1) 'NULL' size
	self->size.x = -1.0f;
	self->size.y = -1.0f;

	// We are not rotated by default
	self->rotate = 0.0f;

	// Scale is (1,1)
	self->scale.x = 1.0f;
	self->scale.y = 1.0f;

	// Alpha is 1 (no change)
	self->alpha = 1.0f;

	// Zero the user data
	self->userData = 0;
	self->pUserData = NULL;

	// Create a dummy cairo context (getMin/MaxSize may depend on it)
	self->cr = NULL;
	widgetCairoCreate(&self->cr, CAIRO_FORMAT_ARGB32, 0, 0);

	// Ask OpenGL for a texture id
	glGenTextures(1, &self->textureId);

	// No tool-tip by default
	self->toolTip = NULL;
	self->toolTipVisible = false;

	// Install required event handlers for showing/hiding tool-tips
	widgetAddEventHandler(self, EVT_MOUSE_ENTER,
	                      widgetToolTipMouseEnterCallback, NULL, NULL);
	widgetAddEventHandler(self, EVT_MOUSE_LEAVE,
	                      widgetToolTipMouseLeaveCallback, NULL, NULL);

	// Focus and mouse are false by default
	self->hasFocus = false;
	self->hasMouse = false;
	self->hasMouseDown = false;

	// By default we need drawing
	self->needsRedraw = true;

	// Enabled by default
	self->isEnabled = true;

	// Also by default we need to be shown (hence are invisible)
	self->isVisible = false;

	// By default the mouse-event mask is disabled
	self->maskCr = NULL;
	self->maskEnabled = false;
}