Patch level :2.1 nopatch x ora
Files correlati : Ricompilazione Demo : [ ] Commento :prima faSe dei nuovi menu git-svn-id: svn://10.65.10.50/trunk@11984 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									a51c6b17ba
								
							
						
					
					
						commit
						ea084b5afd
					
				| @ -119,6 +119,7 @@ inline TMenu_application& app() | |||||||
| class TPicture_mask : public TMask | class TPicture_mask : public TMask | ||||||
| { | { | ||||||
|   TSubmenu* _submenu; |   TSubmenu* _submenu; | ||||||
|  |   TImage* _logo; | ||||||
| 
 | 
 | ||||||
| protected: // TMask
 | protected: // TMask
 | ||||||
|   virtual void update(); |   virtual void update(); | ||||||
| @ -175,6 +176,8 @@ void TPicture_mask::update() | |||||||
| 
 | 
 | ||||||
| 			maxx = rctbut.left - CHARX; | 			maxx = rctbut.left - CHARX; | ||||||
| 			maxy = client.bottom - 4 * ROWY; | 			maxy = client.bottom - 4 * ROWY; | ||||||
|  |       if (_logo != NULL) | ||||||
|  |         maxy -= _logo->height(); | ||||||
| 
 | 
 | ||||||
| 			const double ratiox = double(maxx) / image.width(); | 			const double ratiox = double(maxx) / image.width(); | ||||||
| 			const double ratioy = double(maxy) / image.height(); | 			const double ratioy = double(maxy) / image.height(); | ||||||
| @ -190,6 +193,9 @@ void TPicture_mask::update() | |||||||
|     ::xvt_rect_set(&dst, x, y, x+maxx, y+maxy); |     ::xvt_rect_set(&dst, x, y, x+maxx, y+maxy); | ||||||
|     if (::xvt_dwin_is_update_needed(win(), &dst)) |     if (::xvt_dwin_is_update_needed(win(), &dst)) | ||||||
|       image.draw(win(), dst); |       image.draw(win(), dst); | ||||||
|  | 
 | ||||||
|  |     if (_logo != NULL) | ||||||
|  |       _logo->draw(win(), x, y+maxy+1); | ||||||
|   }   |   }   | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -232,13 +238,38 @@ void TPicture_mask::set_current(const TSubmenu& sm) | |||||||
| 
 | 
 | ||||||
| TPicture_mask::TPicture_mask(const char* name, int dx, int dy,  | TPicture_mask::TPicture_mask(const char* name, int dx, int dy,  | ||||||
|                              const TSubmenu& submenu, int x, int y) |                              const TSubmenu& submenu, int x, int y) | ||||||
|                              : TMask(name, 1, dx, dy, x, y), _submenu(NULL) |                              : TMask(name, 1, dx, dy, x, y), _submenu(NULL), _logo(NULL) | ||||||
| {   | {   | ||||||
|   set_current(submenu); |   set_current(submenu); | ||||||
|  |   TFilename logoname; | ||||||
|  |   const char* ext[3] = { "jpg", "gif", "bmp" }; | ||||||
|  |   for (int i = 0; i < 3; i++) | ||||||
|  |   { | ||||||
|  |     logoname = "logo"; | ||||||
|  |     logoname << '.' << ext[i]; | ||||||
|  |     logoname.custom_path(); | ||||||
|  |     if (logoname.exist()) | ||||||
|  |       break; | ||||||
|  |   } | ||||||
|  |   TImage logo(logoname); | ||||||
|  |   if(logo.ok()) | ||||||
|  |   { | ||||||
|  |     RCT rct; xvt_vobj_get_client_rect(win(), &rct); | ||||||
|  | 		const double ratio = rct.right / logo.width() / 2.0; | ||||||
|  | 		const int maxx = int(ratio * logo.width());  | ||||||
|  | 		const int maxy = int(ratio * logo.height()); | ||||||
|  | 		_logo = new TImage(logo, maxx, maxy); | ||||||
|  |     if (can_be_transparent(*_logo)) | ||||||
|  | 			_logo->convert_transparent_color(MASK_BACK_COLOR); | ||||||
|  | 
 | ||||||
|  |   } | ||||||
|  | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TPicture_mask::~TPicture_mask() | TPicture_mask::~TPicture_mask() | ||||||
| { | { | ||||||
|  |   if (_logo != NULL) | ||||||
|  |     delete _logo; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ///////////////////////////////////////////////////////////
 | ///////////////////////////////////////////////////////////
 | ||||||
| @ -1647,7 +1678,7 @@ int TMenu_application::do_explore() | |||||||
|   _mask = &mask; |   _mask = &mask; | ||||||
| 
 | 
 | ||||||
| 	const int margin = (mask.columns()-80) / 2; | 	const int margin = (mask.columns()-80) / 2; | ||||||
|   const int tree_width = margin+28;  // Usa la metà di sinistra
 |   const int tree_width = margin+21;  // Usa la metà di sinistra
 | ||||||
|    |    | ||||||
|   _menu.jumpto_root(); |   _menu.jumpto_root(); | ||||||
|   TMenu_tree tree(_menu); |   TMenu_tree tree(_menu); | ||||||
| @ -1657,7 +1688,7 @@ int TMenu_application::do_explore() | |||||||
|   tree_fld.hide_leaves(true); |   tree_fld.hide_leaves(true); | ||||||
| 
 | 
 | ||||||
|   TMenulist_field* mf = new TMenulist_field(&mask); |   TMenulist_field* mf = new TMenulist_field(&mask); | ||||||
|   mf->create(DLG_LIST, tree_width-margin+4, 0, -3, -5); |   mf->create(DLG_LIST, tree_width-margin+3, 0, -3, -5); | ||||||
|   mask.add_field(mf); |   mask.add_field(mf); | ||||||
| 	mf->set_menu(tree); | 	mf->set_menu(tree); | ||||||
| 	 | 	 | ||||||
|  | |||||||
							
								
								
									
										139
									
								
								ba/ba0102.cpp
									
									
									
									
									
								
							
							
						
						
									
										139
									
								
								ba/ba0102.cpp
									
									
									
									
									
								
							| @ -294,25 +294,7 @@ void synchronize_tree_field(TTree_field& tf) | |||||||
|   win.force_update(); |   win.force_update(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ///////////////////////////////////////////////////////////
 | bool can_be_transparent(const TImage& i) | ||||||
| // TMenulist_field
 |  | ||||||
| ///////////////////////////////////////////////////////////
 |  | ||||||
| 
 |  | ||||||
| class TMenulist_images : public TCache |  | ||||||
| { |  | ||||||
|   WINDOW _win; |  | ||||||
| 
 |  | ||||||
| protected: |  | ||||||
| 	TObject* key2obj(const char* key); |  | ||||||
| 	bool can_be_transparent(const TImage& i) const; |  | ||||||
| 
 |  | ||||||
| public: |  | ||||||
| 	void set_owner(WINDOW win) { _win = win; } |  | ||||||
| 	TImage* image(const TString& filename); |  | ||||||
| 	TMenulist_images() : TCache(17), _win(NULL_WIN) { } |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| bool TMenulist_images::can_be_transparent(const TImage& i) const |  | ||||||
| { | { | ||||||
| 	const int w = i.width()-1; | 	const int w = i.width()-1; | ||||||
| 	const int h = i.height()-1; | 	const int h = i.height()-1; | ||||||
| @ -326,6 +308,23 @@ bool TMenulist_images::can_be_transparent(const TImage& i) const | |||||||
| 	return TRUE; | 	return TRUE; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | ///////////////////////////////////////////////////////////
 | ||||||
|  | // TMenulist_field
 | ||||||
|  | ///////////////////////////////////////////////////////////
 | ||||||
|  | 
 | ||||||
|  | class TMenulist_images : public TCache | ||||||
|  | { | ||||||
|  |   WINDOW _win; | ||||||
|  | 
 | ||||||
|  | protected: | ||||||
|  | 	TObject* key2obj(const char* key); | ||||||
|  | 
 | ||||||
|  | public: | ||||||
|  | 	void set_owner(WINDOW win) { _win = win; } | ||||||
|  | 	TImage* image(const TString& filename); | ||||||
|  | 	TMenulist_images() : TCache(17), _win(NULL_WIN) { } | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| inline int fast_hypot(int x, int y) | inline int fast_hypot(int x, int y) | ||||||
| { | { | ||||||
|   // loop unrolled
 |   // loop unrolled
 | ||||||
| @ -362,36 +361,61 @@ TObject* TMenulist_images::key2obj(const char* key) | |||||||
| 
 | 
 | ||||||
| 		const int w = image.width(); | 		const int w = image.width(); | ||||||
| 		const int h = image.height(); | 		const int h = image.height(); | ||||||
|     const int radius = min(w, h) / 4; |  | ||||||
| //		const clock_t start_timer = clock();
 |  | ||||||
| 		for (int y = h-1; y >= 0; y--) |  | ||||||
| 		{ |  | ||||||
| 			for (int x = w-1; x >= 0; x--) |  | ||||||
| 			{ |  | ||||||
| 				const int r = fast_hypot(x-w/2, y-h/2); |  | ||||||
| 				if (r > radius) |  | ||||||
|         { |  | ||||||
|           const double perc = 1.0 - (double(r - radius) / (radius*1.5)); |  | ||||||
|           if (perc >= 0.0) |  | ||||||
|           { |  | ||||||
| 				    COLOR col = image.get_pixel(x, y); |  | ||||||
| 				    COLOR bri = blend_colors(col, NORMAL_BACK_COLOR, perc); |  | ||||||
| 				    image.set_pixel(x, y, bri); |  | ||||||
|           } |  | ||||||
|           else |  | ||||||
|             image.set_pixel(x, y, NORMAL_BACK_COLOR); |  | ||||||
|         } |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
|  //   const clock_t stop_timer = clock()-start_timer;
 |  | ||||||
| 
 | 
 | ||||||
| 		RCT rct; xvt_vobj_get_client_rect(_win, &rct); | 	  RCT rct; xvt_vobj_get_client_rect(_win, &rct); | ||||||
| 		const double ratiox = double(rct.right) / image.width(); |     const double max_img = 2.0 * rct.bottom / 5.0; | ||||||
| 		const double ratioy = double(rct.bottom) / image.height(); |     const double max_lgo = rct.right - max_img; | ||||||
| 		const double ratio = max(ratiox, ratioy); | 
 | ||||||
| 		const int maxx = int(ratio * image.width())-2;  |     if (strcmp(key,"logo") != 0) | ||||||
| 		const int maxy = int(ratio * image.height())-2; |     { | ||||||
| 		img = new TImage(image, maxx, maxy); | 		  RCT rct; xvt_vobj_get_client_rect(_win, &rct); | ||||||
|  | 		  const double ratiox = max_img / image.width(); | ||||||
|  | 		  const double ratioy = max_img / image.height(); | ||||||
|  | 		  const double ratio = min(ratiox, ratioy); | ||||||
|  | 		  const int maxx = int(ratio * image.width());  | ||||||
|  | 		  const int maxy = int(ratio * image.height()); | ||||||
|  | 		  img = new TImage(image, maxx, maxy); | ||||||
|  | 
 | ||||||
|  | //      const int radius = (maxx+maxy)/2;
 | ||||||
|  |       const double radius = min(maxx,maxy)/5.0; | ||||||
|  | 		  for (int y = 0; y < maxy; y++) | ||||||
|  | 		  { | ||||||
|  | 			  for (int x = 0; x < maxx; x++) | ||||||
|  | 			  { | ||||||
|  | /* Sfumatura a semicerchio
 | ||||||
|  | 				  const int r = fast_hypot(maxx-x, maxy-y); | ||||||
|  | 				  if (r > radius) | ||||||
|  |           { | ||||||
|  |             const double perc = 5*double(radius-r)/radius+1.0; | ||||||
|  |             if (perc >= 0.0) | ||||||
|  |             { | ||||||
|  | 				      COLOR col = img->get_pixel(x, y); | ||||||
|  | 				      COLOR bri = blend_colors(col, NORMAL_BACK_COLOR, perc); | ||||||
|  | 				      img->set_pixel(x, y, bri); | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |               img->set_pixel(x, y, NORMAL_BACK_COLOR);*/ | ||||||
|  | //Sfumatura costante sui lati sx e up
 | ||||||
|  |           if (x <= radius || y <= radius) | ||||||
|  |           { | ||||||
|  |             const double perc = min(x,y)/radius; | ||||||
|  | 				    COLOR col = img->get_pixel(x, y); | ||||||
|  | 				    COLOR bri = blend_colors(col, NORMAL_BACK_COLOR, perc); | ||||||
|  | 				    img->set_pixel(x, y, bri); | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  | 		  } | ||||||
|  |    //   const clock_t stop_timer = clock()-start_timer;
 | ||||||
|  | 
 | ||||||
|  |     } | ||||||
|  |     else | ||||||
|  |     { | ||||||
|  | 		  RCT rct; xvt_vobj_get_client_rect(_win, &rct); | ||||||
|  | 		  const double ratio = max_lgo / image.width(); | ||||||
|  | 		  const int maxx = int(ratio * image.width());  | ||||||
|  | 		  const int maxy = int(ratio * image.height()); | ||||||
|  | 		  img = new TImage(image, maxx, maxy); | ||||||
|  |     } | ||||||
| 	} | 	} | ||||||
| 	return img; | 	return img; | ||||||
| } | } | ||||||
| @ -406,7 +430,7 @@ TImage* TMenulist_images::image(const TString& filename) | |||||||
| 
 | 
 | ||||||
| class TMenulist_window : public TField_window | class TMenulist_window : public TField_window | ||||||
| { | { | ||||||
| 	enum { MENU_COLS = 3, MENU_ROWS = 5 }; | 	enum { MENU_COLS = 4, MENU_ROWS = 5 }; | ||||||
|    |    | ||||||
| private: | private: | ||||||
| 	TMenu_tree* _tree; | 	TMenu_tree* _tree; | ||||||
| @ -452,12 +476,12 @@ void TMenulist_window::draw_item(int i) | |||||||
|   const TMenuitem& item = (const TMenuitem&)_sorted[i]; |   const TMenuitem& item = (const TMenuitem&)_sorted[i]; | ||||||
| 	if (i == _selected && item.enabled()) | 	if (i == _selected && item.enabled()) | ||||||
|   { |   { | ||||||
|  |   //testo nero su sfondo con colore del focus
 | ||||||
| 		set_color(item.color(), FOCUS_BACK_COLOR); | 		set_color(item.color(), FOCUS_BACK_COLOR); | ||||||
|   } |   } | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		COLOR bc = item.enabled() ? REQUIRED_BACK_COLOR : DISABLED_BACK_COLOR; |     set_color(item.color(), NORMAL_BACK_COLOR); //testo nero su sfondo trasparente
 | ||||||
| 		set_color(item.color(), bc); |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	const int row = i / MENU_COLS; | 	const int row = i / MENU_COLS; | ||||||
| @ -514,11 +538,20 @@ void TMenulist_window::update() | |||||||
| 	if (img != NULL) | 	if (img != NULL) | ||||||
| 	{ | 	{ | ||||||
| 		RCT rct; xvt_vobj_get_client_rect(win(), &rct); | 		RCT rct; xvt_vobj_get_client_rect(win(), &rct); | ||||||
|     const int x = (rct.right - img->width())/2; |     const int x = (rct.right - img->width()); | ||||||
|     const int y = (rct.bottom - img->height())/2; |     const int y = (rct.bottom - img->height()); | ||||||
| 		img->draw(win(), x, y); | 		img->draw(win(), x, y); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   TImage* logo = db ? _images.image("logo") : NULL; //logo del programma
 | ||||||
|  |   if (logo != NULL) //disegna il logo
 | ||||||
|  |   { | ||||||
|  | 		RCT rct; xvt_vobj_get_client_rect(win(), &rct); | ||||||
|  |     const int x = rct.left; | ||||||
|  |     const int y = rct.bottom - logo->height(); | ||||||
|  | 		logo->draw(win(), x, y); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
| 	for (int i = 0; i < _sorted.items(); i++) | 	for (int i = 0; i < _sorted.items(); i++) | ||||||
| 		draw_item(i); | 		draw_item(i); | ||||||
| } | } | ||||||
|  | |||||||
| @ -71,5 +71,6 @@ public: | |||||||
| 
 | 
 | ||||||
| // Utilities
 | // Utilities
 | ||||||
| void synchronize_tree_field(TTree_field& tf); | void synchronize_tree_field(TTree_field& tf); | ||||||
|  | bool can_be_transparent(const TImage& i); | ||||||
| 
 | 
 | ||||||
| #endif | #endif | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user