コード例 #1
0
ファイル: slider.c プロジェクト: VVillwin/minigui
static int get_changed_pos (skin_item_t* item, int x, int y)
{
	sie_slider_t sie;
	int cur_pos = 0;
	si_nrmslider_t* nrmslider = (si_nrmslider_t*) item->type_data;
	
	sie.min_pos = 0;

	if (item->style & SI_NRMSLIDER_HORZ) {	/* - */
		sie.max_pos = RECTW (item->rc_hittest)  - BMP(item,nrmslider->thumb_bmp_index).bmWidth;
		sie.cur_pos = x - item->rc_hittest.left - BMP(item,nrmslider->thumb_bmp_index).bmWidth/2;

		ROUND (sie.cur_pos, sie.min_pos, sie.max_pos);

		cur_pos = .5 + nrmslider->slider_info.min_pos + sie.cur_pos *
			(0. + nrmslider->slider_info.max_pos - nrmslider->slider_info.min_pos) / sie.max_pos;
	}
	else {	/* | */
		sie.max_pos = RECTH (item->rc_hittest)  - BMP(item,nrmslider->thumb_bmp_index).bmHeight;
		sie.cur_pos = y - item->rc_hittest.top  - BMP(item,nrmslider->thumb_bmp_index).bmHeight/2;

		ROUND (sie.cur_pos, sie.min_pos, sie.max_pos);

		cur_pos = .5 + nrmslider->slider_info.min_pos + sie.cur_pos *
			(0. + nrmslider->slider_info.max_pos - nrmslider->slider_info.min_pos) / sie.max_pos;
	}
	return cur_pos;
}
コード例 #2
0
ファイル: slider.c プロジェクト: VVillwin/minigui
static void slider_draw_attached (HDC hdc, skin_item_t* item)
{
	int pos_min, pos_max, x, y, w, h;
    si_nrmslider_t* slider = (si_nrmslider_t*) item->type_data;
	double percent;
    
    if ( slider->slider_info.cur_pos < slider->slider_info.min_pos ) 
        slider->slider_info.cur_pos = slider->slider_info.min_pos;
	if ( slider->slider_info.cur_pos > slider->slider_info.max_pos )
        slider->slider_info.cur_pos = slider->slider_info.max_pos;

    percent = (slider->slider_info.cur_pos - slider->slider_info.min_pos) * 1. /
					 (slider->slider_info.max_pos - slider->slider_info.min_pos);
					 
	if (item->style & SI_NRMSLIDER_HORZ) {	/* - */
		pos_min = item->rc_hittest.left;
		pos_max = item->rc_hittest.right - BMP(item, slider->thumb_bmp_index).bmWidth;
		x = pos_min + (pos_max - pos_min) * percent; 
		y = item->rc_hittest.top;
		// pbar
		w = RECTW(item->rc_hittest) * percent;
		h = RECTH(item->rc_hittest);

        h = h < BMP(item, slider->thumb_bmp_index).bmHeight ? 
            h : BMP(item, slider->thumb_bmp_index).bmHeight; 
	}
	else{	/* | */
		pos_min = item->rc_hittest.top;
		pos_max = item->rc_hittest.bottom - BMP(item, slider->thumb_bmp_index).bmHeight;
		y = pos_min + (pos_max - pos_min) * percent;
		x = item->rc_hittest.left;
		// pbar
		h = RECTH(item->rc_hittest) * percent;
		w = RECTW(item->rc_hittest);

        w = w < BMP(item, slider->thumb_bmp_index).bmWidth? 
            w : BMP(item, slider->thumb_bmp_index).bmWidth; 
	}
	if ( item->style & SI_NRMSLIDER_STATIC )
		FillBoxWithBitmap ( hdc, item->rc_hittest.left, item->rc_hittest.top, 
							w, h, &BMP(item, slider->thumb_bmp_index) );
	else
    	FillBoxWithBitmapPart ( hdc, x, y, 
								BMP(item, slider->thumb_bmp_index).bmWidth,
								BMP(item, slider->thumb_bmp_index).bmHeight,
								0, 0, 
								&BMP(item, slider->thumb_bmp_index),
								0, 0);
}
コード例 #3
0
ファイル: sdl.c プロジェクト: andrewbird/dosemu2
static struct bitmap_desc lock_surface(void)
{
  int err;

  err = SDL_LockSurface(surface);
  assert(!err);
  return BMP(surface->pixels, win_width, win_height, surface->pitch);
}
コード例 #4
0
GLuint BMPTextureLoader::loadTexture(string fileName) {
	BMP bitMap = BMP(fileName);

	if(!bitMap.isValid()) {
		cerr << "Could not load texture file: " << fileName << endl;
		return 0;
	}
	GLuint res = 0;
	// Generate a texture with the associative texture ID stored in the array
	glGenTextures(1, &res);
	cerr << "Texture " + fileName + ": " << res << endl;

	// Bind the texture to the texture arrays index and init the texture
	glBindTexture(GL_TEXTURE_2D, res);

	// This sets the alignment requirements for the start of each pixel row in memory.
	glPixelStorei (GL_UNPACK_ALIGNMENT, 1);

/*
	// Build Mipmaps (builds different versions of the picture for distances - looks better)
	gluBuild2DMipmaps(GL_TEXTURE_2D, 3, bitMap.dimX(), bitMap.dimY(), GL_RGB, GL_UNSIGNED_BYTE, bitMap.data());

	// Lastly, we need to tell OpenGL the quality of our texture map.  GL_LINEAR_MIPMAP_LINEAR
	// is the smoothest.  GL_LINEAR_MIPMAP_NEAREST is faster than GL_LINEAR_MIPMAP_LINEAR,
	// but looks blochy and pixilated.  Good for slower computers though.

	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);

	// The default GL_TEXTURE_WRAP_S and ""_WRAP_T property is GL_REPEAT.
	// We need to turn this to GL_CLAMP_TO_EDGE, otherwise it creates ugly seems
	// in our sky box.  GL_CLAMP_TO_EDGE does not repeat when bound to an object.
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
*/

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, bitMap.dimX(), bitMap.dimY(), 0, GL_RGB, GL_UNSIGNED_BYTE, bitMap.data());


	return res;
}
コード例 #5
0
//---------------------------------------------------------
void CVIEW_ScatterPlot::On_ToClipboard(wxCommandEvent &event)
{
	wxBitmap	BMP(GetSize());
	wxMemoryDC	dc;
	
	dc.SelectObject(BMP);
	dc.SetBackground(*wxWHITE_BRUSH);
	dc.Clear();

	_Draw(dc, wxRect(BMP.GetSize()));

	dc.SelectObject(wxNullBitmap);

	if( wxTheClipboard->Open() )
	{
		wxBitmapDataObject	*pBMP	= new wxBitmapDataObject;
		pBMP->SetBitmap(BMP);
		wxTheClipboard->SetData(pBMP);
		wxTheClipboard->Close();
	}
}
コード例 #6
0
ファイル: GUICheckBox.cpp プロジェクト: Flacko/maguific
{
	_value = v;
}

bool GUI::CheckBox::value() const
{
	return _value;
}

void GUI::CheckBox::draw (GBox menupos, Resource& res)
{
	GBox dbox (box() >> menupos);
#define BMP(x) res.getGfx(GFX_ID::checkbox_##x)
#define BW al_get_bitmap_width
#define BH al_get_bitmap_height
	al_draw_tinted_bitmap (BMP (bg), backColor, dbox.x, dbox.y, 0);
	if (value())
	{
		al_draw_tinted_bitmap (BMP (fg), foreColor, dbox.x + BW (BMP (bg)) / 2 - BW (BMP (fg)) / 2, dbox.y + BH (BMP (bg)) / 2 - BH (BMP (fg)) / 2, 0);
	}
#undef BH
#undef BW
#undef BMP
}

GUI::Input* GUI::CheckBox::getInput (GBox menupos, Resource& /*res*/, ALLEGRO_EVENT& ev, ALLEGRO_EVENT_QUEUE* /*eq*/)
{
	GBox colbox (box() >> menupos);
	if (ev.type == ALLEGRO_EVENT_MOUSE_BUTTON_UP)
	{
		if (clicked)
コード例 #7
0
ファイル: main.cpp プロジェクト: KoljaWindeler/speedoino
int main(void) {
	SystemInit(); // Quarz Einstellungen aktivieren
	init_speedo();

	//	SD.prefetched_animation(37); // 37
	//	Speedo.initial_draw_screen(); // draw symbols
	/******************** setup procedure ********************************************
	 * all initialisations must been made before the main loop, before THIS
	 ******************** setup procedure ********************************************/
	unsigned long previousMillis = 0;
#ifdef LOAD_CALC
	unsigned long load_calc=0;
	unsigned long lasttime_calc=0;
#endif

	for (;;) {
		Sensors.mCAN.check_message();
		//////////////////////////////////////////////////
		//		Sensors.m_reset->set_deactive(false,false);
		//		Serial3.end();
		//		Serial3.begin(115200);
		//		while(true){
		//			while(Serial3.available()>0){
		//				Serial.print(Serial3.read(),BYTE);
		//			}
		//			while(Serial.available()>0){
		//				Serial3.print(Serial.read(),BYTE);
		//			}
		//		}
		//////////////////////////////////////////////////
		Sensors.mReset.toggle(); // toggle pin, if we don't toggle it, the ATmega8 will reset us, kind of watchdog<
		Debug.speedo_loop(21, 1, 0, " "); // intensive debug= EVERY loop access reports the Menustate
		Sensors.mGPS.check_flag();    	// check if a GPS sentence is ready
		//		pAktors.check_flag(); 				// updated expander
		Sensors.pull_values();	// very important, updates all the sensor values

		/************************* timer *********************/
		Timer.every_sec();		// 1000 ms
		Timer.every_qsec();			// 250  ms
		Timer.every_custom(); // one custom timer, redrawing the speedo, time is defined by "refresh_cycle" in the base.txt
		/************************* push buttons *********************
		 * using true as argument, this will activate bluetooth input as well
		 ************************* push buttons*********************/
		//Menu.button_test(true,false);     // important!! if we have a pushed button we will draw something, depending on the menustate
		if (Menu.button_test(true, false)) { // important!! if we have a pushed button we will draw something, depending on the menustate
			Serial.puts(USART1, "Menustate:");
			Serial.puts_ln(USART1, Menu.state);
		}
		/************************ every deamon activity is clear, now draw speedo ********************
		 * we are round about 0000[1]1 - 0000[1]9
		 ************************ every deamon activity is clear, now draw speedo ********************/
		Sensors.mCAN.check_message();

		if ((Menu.state / 10) == 1 || Menu.state == 7311111) {
			Speedo.loop(previousMillis);
		}
		//////////////////// Sprint Speedo ///////////////////
		else if (Menu.state == MENU_SPRINT * 10 + 1) {
			Sprint.loop();
		}
		////////////////// Clock Mode ////////////////////////
		else if (Menu.state == 291) {
			Sensors.mClock.loop();
		}
		////////////////// Speed Cam Check - Mode ////////////////////////
		else if (Menu.state
				== BMP(0, 0, 0, 0, M_TOUR_ASSISTS,
						SM_TOUR_ASSISTS_SPEEDCAM_STATUS, 1)) {
			//			SpeedCams.calc();
			//			SpeedCams.interface();
		}
		////////////////// race mode ////////////////////
		else if (Menu.state == M_LAP_T * 100 + 11) {
			LapTimer.waiting_on_speed_up();
		} else if (Menu.state == M_LAP_T * 1000 + 111) {
			LapTimer.race_loop();
		}
		////////////////// set gps point ////////////////////
		else if (Menu.state == M_LAP_T * 10000L + 3111) {
			LapTimer.gps_capture_loop();
		}
		//////////////////// voltage mode ///////////////////
		else if (Menu.state == 531) {
			Sensors.addinfo_show_loop();
		}
		//////////////////// stepper mode ///////////////////
		else if (Menu.state == 541) {
			//			Aktors.mStepper.loop();
		}
		//////////////////// gps scan ///////////////////
		else if (Menu.state == 511) {
			Sensors.mGPS.loop();
		}
		//////////////////// outline scan ///////////////////
		else if (Menu.state == 721) {
			Sensors.mSpeed.check_umfang();
		}
		////////////////// gear scan ///////////////
		else if (floor(Menu.state / 100) == 71) {
			Sensors.mGear.calibrate();
		}

#ifdef LOAD_CALC
		load_calc++;
		if(millis()-lasttime_calc>1000) {
			Serial.print(load_calc);
			Serial.println(" cps"); // 182 w/o interrupts, 175 w/ interrupts, 172 w/ much interrupts
			load_calc=0;
			lasttime_calc=millis();
		}
#endif
	} // end for
}