예제 #1
0
//__________________________________________________________________
void		_HYPlatformButton::_Paint (Ptr p)
{	
	_HYButton * theParent = (_HYButton*)this;

	GdkRectangle    	cRect = HYRect2GDKRect(*(_HYRect*)p);
	
	if (!(theParent->settings.width&HY_COMPONENT_TRANSP_BG))
	{
		if (theParent->parentWindow->window)
		{
			GdkGC *buttonGC				 = gdk_gc_new (theParent->parentWindow->window);
			gdk_gc_set_foreground(buttonGC,&bgColor);
			GdkRegion * r1 = gdk_region_rectangle(&cRect), 
					  * r2 = gdk_region_rectangle (&buttonRect);

			gdk_region_subtract	   (r1,r2);
			gdk_region_offset	   (r1,theParent->parentWindow->allocation.x,theParent->parentWindow->allocation.y);
			gdk_gc_set_clip_region (buttonGC,r1);
			gdk_draw_rectangle(theParent->parentWindow->window,buttonGC,true,cRect.x+theParent->parentWindow->allocation.x, 
							   cRect.y+theParent->parentWindow->allocation.y, cRect.width, cRect.height);
			gdk_region_destroy(r1);
			gdk_region_destroy(r2);
			g_object_unref (buttonGC);
		}
	}
		
  	(*theParent)._HYPlatformComponent::_Paint(p);
}
예제 #2
0
//__________________________________________________________________
void _HYPlatformGraphicPane::_InvertRect (_HYRect& rct)
{
	GdkRectangle clip_rect = HYRect2GDKRect (rct);
	GdkPixbuf* theImage = gdk_pixbuf_get_from_drawable (NULL, thePane, NULL, rct.left, rct.top, 0, 0, clip_rect.width, clip_rect.height);
	gdk_gc_set_function (theContext,GDK_INVERT);
	gdk_draw_pixbuf (thePane, theContext, theImage, 0,0, clip_rect.x, clip_rect.y, clip_rect.width, clip_rect.height, GDK_RGB_DITHER_NORMAL, 0, 0);
	gdk_gc_set_function (theContext,GDK_COPY);
	g_object_unref (theImage);
}
예제 #3
0
//__________________________________________________________________
void _HYPlatformGraphicPane::_DisplayText	 (_String& theText,_HYRect& r, char align)
{
	_HYGraphicPane* theParent = (_HYGraphicPane*)this;
	_EraseRect (r);
	pango_layout_set_width(textLayout, PANGO_SCALE*(r.right-r.left+1));
	pango_layout_set_text (textLayout, theText.sData, theText.sLength);
	GdkRectangle clip_rect = HYRect2GDKRect (r);
	gdk_gc_set_clip_rectangle  (theContext, &clip_rect);
	pango_layout_set_alignment (textLayout, align==HY_ALIGN_LEFT?PANGO_ALIGN_LEFT:(align==HY_ALIGN_RIGHT?PANGO_ALIGN_RIGHT:PANGO_ALIGN_CENTER));
	gdk_draw_layout (thePane, theContext, r.left, r.top, textLayout);	
	gdk_gc_set_clip_rectangle  (theContext, NULL);
}
예제 #4
0
//__________________________________________________________________
void _HYPlatformGraphicPane::_SlideRect (_HYRect& rct, int dv, int dh)
{
    _HYGraphicPane* theParent = (_HYGraphicPane*)this;

    GdkRectangle clipped_rect   = HYRect2GDKRect (rct),
                 full_rect        = {0,0,theParent->w, theParent->h},
                 clip_rect;

    if (gdk_rectangle_intersect(&clipped_rect, &full_rect, &clip_rect)) {
        gdk_gc_set_clip_rectangle  (theContext, &clip_rect);
        GdkPixbuf* theImage = gdk_pixbuf_get_from_drawable (NULL, thePane, NULL, rct.left, rct.top, 0, 0, clip_rect.width, clip_rect.height);
        gdk_draw_pixbuf (thePane, theContext, theImage, 0,0, clip_rect.x+dh, clip_rect.y+dv, -1,-1, GDK_RGB_DITHER_NONE, 0, 0);
        g_object_unref (theImage);
        gdk_gc_set_clip_rectangle  (theContext, NULL);
    }
}
예제 #5
0
//__________________________________________________________________
void        _HYPlatformPullDown::_Paint (Ptr p)
{
    _HYPullDown * theParent = (_HYPullDown*)this;

    GdkRectangle        cRect = HYRect2GDKRect(*(_HYRect*)p);
    _RefreshComboBox();
    if (!(theParent->settings.width&HY_COMPONENT_TRANSP_BG)) {
        if (theParent->parentWindow->window) {
            GdkGC *buttonGC              = gdk_gc_new (theParent->parentWindow->window);
            gdk_gc_set_foreground(buttonGC,&backFill);
            gdk_draw_rectangle(theParent->parentWindow->window,buttonGC,true,cRect.x+theParent->parentWindow->allocation.x,
                               cRect.y+theParent->parentWindow->allocation.y, cRect.width, cRect.height);
            g_object_unref (buttonGC);
        }
    }


    (*theParent)._HYPlatformComponent::_Paint(p);
}
예제 #6
0
void _HYPlatformGraphicPane::_DrawPicRes (_HYRect& r, long id)
{
	
	GdkPixbuf* theImage = (GdkPixbuf*)ProcureIconResource(id);
	if (theImage)
	{
		
		if (r.right-r.left<=0)
			r.right = r.left + gdk_pixbuf_get_width (theImage);
		if (r.bottom-r.top<=0)
			r.bottom = r.top + gdk_pixbuf_get_height (theImage);

		GdkRectangle clip_rect = HYRect2GDKRect (r);
		if (clip_rect.height != gdk_pixbuf_get_height (theImage) || clip_rect.width != gdk_pixbuf_get_width (theImage))
		{
			GdkPixbuf*  scaledImage = gdk_pixbuf_scale_simple  (theImage, clip_rect.width, clip_rect.height, GDK_INTERP_BILINEAR);
			checkPointer (scaledImage);
			gdk_draw_pixbuf (thePane, NULL, scaledImage, 0,0, clip_rect.x, clip_rect.y, clip_rect.width, clip_rect.height, GDK_RGB_DITHER_NORMAL, 0, 0);
			g_object_unref (scaledImage);
		}
		else
		{
			//theImage = gdk_pixbuf_add_alpha(theImage,true,255,255,255); 
			// add white transparency
			
			/*GdkPixbuf * copy = gdk_pixbuf_composite_color_simple (theImage, clip_rect.width, clip_rect.height,GDK_INTERP_BILINEAR,
																			128,1,0x00ffffff,0x00888888);
			
			gdk_draw_pixbuf (thePane, NULL, copy, 0,0, clip_rect.x, clip_rect.y, clip_rect.width, clip_rect.height, GDK_RGB_DITHER_NORMAL, 0, 0);
			g_object_unref (copy);*/
			// inactive button
			
			/*GdkPixbuf * copy = gdk_pixbuf_copy(theImage);
			gdk_pixbuf_fill (copy, 0x000000ff);
			gdk_pixbuf_composite (theImage, copy, 0, 0, clip_rect.width, clip_rect.height, 0., 0., 1., 1.,GDK_INTERP_BILINEAR, 100);
			gdk_draw_pixbuf (thePane, NULL, copy, 0,0, clip_rect.x, clip_rect.y, clip_rect.width, clip_rect.height, GDK_RGB_DITHER_NORMAL, 0, 0);
			g_object_unref (copy);*/
			// pressed-in
			gdk_draw_pixbuf (thePane, NULL, theImage, 0,0, clip_rect.x, clip_rect.y, clip_rect.width, clip_rect.height, GDK_RGB_DITHER_NORMAL, 0, 0);
		}
	}
}		
예제 #7
0
//__________________________________________________________________
void        _HYPlatformPullDown::_SetVisibleSize (_HYRect rel)
{
    _HYPullDown* theParent = (_HYPullDown*) this;

    menuRect = HYRect2GDKRect(rel);
    menuRect.x     += 3;
    menuRect.width -= 6;

    if (theMenu) {
        if (menuRect.height>20) {
            menuRect.height = 20;
        }

        long            naturalWidth = theParent->_SuggestDimensions ().right;

        if (menuRect.width > naturalWidth + 25) {
            menuRect.width = naturalWidth + 25;
        }
    }

    AlignRectangle (rel, menuRect, theParent->GetAlignFlags());
    gtk_fixed_move (GTK_FIXED(theParent->parentWindow), theMenu, rel.left, rel.top);
    gtk_widget_set_size_request(theMenu,menuRect.width,menuRect.height);
}
예제 #8
0
bool _HYSequencePane::_ProcessOSEvent (Ptr vEvent)
{
	static			bool	amScrolling = false,
							vertical;
					
	static			long   localPt_x,
						   localPt_y,	
						   originalStart,
						   originalSpan,
						   lastClick,
						   firstClick;


	if (_HYPlatformComponent::_ProcessOSEvent (vEvent)) 
		return true;	
		
	_HY_GTK_UI_Message *theMessage = (_HY_GTK_UI_Message*)vEvent;
	if (active) 
	{
		gdouble   xc, 
				  yc;

		if (gdk_event_get_coords (theMessage->theEvent,&xc,&yc))
		{
			switch (theMessage->theEvent->type)
			{
				case GDK_BUTTON_PRESS:
				case GDK_2BUTTON_PRESS:
					{
						GdkEventButton * bevent = (GdkEventButton*)theMessage->theEvent;
						
						long  globalPt_x = xc,
							  globalPt_y = yc;
							  
						localPt_x = globalPt_x-rel.left-parentWindow->allocation.x;
						localPt_y = globalPt_y-rel.top-parentWindow->allocation.y;
							  
						vertical = (localPt_x<headerWidth)&&(localPt_y>=(GetSlotHeight()+1));

						if (((GdkEventButton*)bevent)->button == 1)
						{
							if (vertical)
								ProcessVSelectionChange (localPt_x,localPt_y,bevent->state & GDK_SHIFT_MASK,bevent->state & GDK_CONTROL_MASK, false, bevent->type == GDK_2BUTTON_PRESS);
							else
								ProcessSelectionChange  (localPt_x,localPt_y,bevent->state & GDK_SHIFT_MASK,bevent->state & GDK_CONTROL_MASK);
						}
						else
						{
							if ((((GdkEventButton*)bevent)->button == 2 || ((GdkEventButton*)bevent)->button == 3 )&& (vertical&&vselection.lLength || !vertical &&selection.lLength))
							{
								ProcessContextualPopUp (globalPt_x, globalPt_y);
								return true;
							}
						}
					}
					break;
				case GDK_BUTTON_RELEASE:
				case GDK_LEAVE_NOTIFY:
				{
					if (amScrolling)
					{
						if (messageRecipient)
							((_HYTWindow*)messageRecipient)->trackMouseComponent = (Ptr)nil;
							
						/*gdk_pointer_ungrab (((GdkEventButton*)theMessage->theEvent)->time);*/
						
						if  (vertical)
						{
							_HYRect invalRectH = {parentWindow->allocation.x+rel.left,
												  parentWindow->allocation.y+rel.top+(GetSlotHeight()+1)+1,rel.left+headerWidth,rel.bottom-HY_SCROLLER_WIDTH};
							GdkRectangle irect = HYRect2GDKRect(invalRectH);
							irect.x+=parentWindow->allocation.x;
							irect.y+=parentWindow->allocation.y;
							gdk_window_invalidate_rect (parentWindow->window, &irect, false);
							if ( localPt_x<headerWidth && localPt_x>0 && lastClick>-2)
								MoveSpecies (firstClick+originalStart,lastClick+startRow);
						}
						amScrolling = false;
					}
					break;
				}
					
				case GDK_MOTION_NOTIFY:
				{
					GdkEventMotion * motEvent = (GdkEventMotion*)theMessage->theEvent;
					if (motEvent->state & GDK_BUTTON1_MASK)
					{
						if (amScrolling)
						{
							gint mousePt_x = motEvent->x - rel.left - parentWindow->allocation.x,
								 mousePt_y = motEvent->y - rel.top  - parentWindow->allocation.y;
								 
							if (vertical) // vertical scrolling
							{
								long  wHeight = rel.bottom-rel.top-HY_SCROLLER_WIDTH,
									  slotHeight = GetSlotHeight();

								if ( mousePt_y <  GetSlotHeight()+1 || localPt_y != mousePt_y || mousePt_y>wHeight )
								{
									localPt_x = mousePt_x;
									localPt_y = mousePt_y;
									
									if (mousePt_y>wHeight)
									{
										// scroll down
										if ((endRow<=speciesIndex.lLength)&&(vselection.lData[0]!=speciesIndex.lLength-1))
										{
											if (endRow-startRow<originalSpan) 
												break;
											startRow++;
											endRow++;
											_SetVScrollerPos(((double)MAX_CONTROL_VALUE*startRow)/
															 (speciesIndex.lLength-endRow+startRow+1));
											BuildPane();
											forceUpdateForScrolling = true;
											_MarkForUpdate();
											forceUpdateForScrolling = false;
											lastClick = -2;
										}
										break;
									}
									else
									{
										mousePt_y-=(GetSlotHeight()+1);
										if (mousePt_y<=slotHeight)
										{
											if (mousePt_y>=0)
											{
												if (mousePt_y<slotHeight/2)
													mousePt_y = -1;
												else
													mousePt_y = 0;
											}
											else
											{
												// scroll up
												if (startRow>0)
												{
													startRow--;
													endRow--;
													_SetVScrollerPos(((double)MAX_CONTROL_VALUE*startRow)/(speciesIndex.lLength-endRow+startRow+1));
													BuildPane();
													forceUpdateForScrolling = true;
													_MarkForUpdate();
													forceUpdateForScrolling = false;
													lastClick = -2;
												}
												break;
											}
										}
										else
											mousePt_y=(mousePt_y-(GetSlotHeight()+1))/slotHeight;
									}
										
									if ( mousePt_y<-1 || mousePt_y>= endRow-startRow ) 
										break;
										
									if (mousePt_y!=lastClick)
									{
										GdkDrawable * tempDr = GDK_DRAWABLE(parentWindow->window);
										GdkGC * tempGC = gdk_gc_new (tempDr);

										GdkColor black = HYColorToGDKColor((_HYColor){0,0,0});
										gdk_gc_set_foreground (theContext, &black);

										gdk_gc_set_function (tempGC, GDK_INVERT);
										gdk_gc_set_line_attributes (tempGC, 2, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
										if (lastClick>=-1)
										{
											lastClick = (GetSlotHeight()+1)+slotHeight*(lastClick+1)+rel.top+1;
											gdk_draw_line  (tempDr,tempGC,parentWindow->allocation.x+rel.left+1,parentWindow->allocation.y+lastClick,
																		  parentWindow->allocation.x+rel.left+headerWidth-1,parentWindow->allocation.y+lastClick);

										}
										
										lastClick = mousePt_y;
										
										if (lastClick+startRow != firstClick+originalStart)
										{
											mousePt_y = (GetSlotHeight()+1)+slotHeight*(lastClick+1)+rel.top+1;
											gdk_draw_line  (tempDr,tempGC,parentWindow->allocation.x+rel.left+1,parentWindow->allocation.y+mousePt_y,
																				parentWindow->allocation.x+rel.left+headerWidth-1,parentWindow->allocation.y+mousePt_y);
										}
										g_object_unref (tempGC);
									}
								}
								return true;
							}
							else // horizontal scrolling
							{
								long	rightWindowBound = _HYCanvas::GetMaxW()-HY_SCROLLER_WIDTH;
								guint32 serverTime = gdk_x11_get_server_time (parentWindow->window);
								if ( mousePt_x<headerWidth && startColumn>0 || localPt_x!=mousePt_x || mousePt_x> rightWindowBound)
								{
									forceUpdateForScrolling = true;
									if (mousePt_x<headerWidth && startColumn>0)
									{
										gint	  wx, wy;
										gdk_window_get_origin (parentWindow->window,&wx,&wy);
										wx += parentWindow->allocation.x+rel.left;
										wy += parentWindow->allocation.y+rel.top;
										do
										{
											guint32 serverTime2 = gdk_x11_get_server_time (parentWindow->window);
											if (serverTime2-serverTime < 100)
												ProcessSelectionChange (mousePt_x,mousePt_y,true,true,true);
											GdkModifierType keyDown;
											gdk_display_get_pointer (gdk_display_get_default(),NULL,&mousePt_x,&mousePt_y,&keyDown);
											mousePt_x -= wx;
											mousePt_y -= wy;
											serverTime = serverTime2;
											if ((keyDown & GDK_BUTTON1_MASK)==0)
												break;
												
											gtk_main_iteration_do(true);
										}
										while (mousePt_x<headerWidth && startColumn>0);
									}
									else
									{
										if (mousePt_x> rightWindowBound)
										{
											gint	  wx, wy;
											gdk_window_get_origin (parentWindow->window,&wx,&wy);
											wx += parentWindow->allocation.x;
											wy += parentWindow->allocation.y;
											do
											{
												guint32 serverTime2 = gdk_x11_get_server_time (parentWindow->window);
												if (serverTime2-serverTime < 100)
													ProcessSelectionChange (mousePt_x+HY_SCROLLER_WIDTH,mousePt_y,true,true,true);
												GdkModifierType keyDown;
												gdk_display_get_pointer (gdk_display_get_default(),NULL,&mousePt_x,&mousePt_y,&keyDown);
												mousePt_x -= wx;
												mousePt_y -= wy;
												serverTime = serverTime2;
												if ((keyDown & GDK_BUTTON1_MASK)==0)
													break;
													
												gtk_main_iteration_do(true);
											}
											while (mousePt_x> rightWindowBound && endColumn < columnStrings.lLength);
										}
										else
											if (serverTime-gdk_event_get_time(theMessage->theEvent) < 100)
												ProcessSelectionChange (mousePt_x,mousePt_y,true,true,true);	
									}
									
									forceUpdateForScrolling = false;
									localPt_x = mousePt_x;
									localPt_y = mousePt_y;
								}
								return true;
							}
						}					
						else
						{
							
							/*gdk_pointer_grab (parentWindow->window,false,
									  GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK,
									  NULL, NULL, (((GdkEventMotion*)theMessage->theEvent))->time);*/
											  
							if (messageRecipient)
								((_HYTWindow*)messageRecipient)->trackMouseComponent = (Ptr)((_HYComponent*)this);

							amScrolling = true;
							originalStart = startRow,
							originalSpan  = endRow-startRow;
							lastClick = -2;
							firstClick = (localPt_y-(GetSlotHeight()+1))/GetSlotHeight();
							return true;
						}					
					}
					break;
				}
			}
		}
	}


	return false;
}
예제 #9
0
//__________________________________________________________________
void        _HYPlatformButtonBar::_Paint (Ptr p)
{
    _HYButtonBar * theParent = (_HYButtonBar*)this;

    if (theParent->parentWindow->window) {
        GdkRectangle    cRect    = HYRect2GDKRect(*(_HYRect*)p),
                        iRect;

        if (!bbGC) {
            bbGC                 = gdk_gc_new (theParent->parentWindow->window);
            gdk_gc_set_line_attributes (bbGC, 1, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
        }

        cRect.x += theParent->parentWindow->allocation.x;
        cRect.y += theParent->parentWindow->allocation.y;

        if (!(theParent->settings.width&HY_COMPONENT_TRANSP_BG)) {
            gdk_gc_set_foreground(bbGC,&backFill);
            gdk_draw_rectangle(theParent->parentWindow->window,bbGC,true,cRect.x, cRect.y, cRect.width, cRect.height);
        }


        gdk_gc_set_clip_rectangle(bbGC,&cRect);

        cRect.x  = buttonRect.x;
        cRect.y  = buttonRect.y;

        int   step   = theParent->GetButtonDim()+2*HY_BUTTONBAR_BORDER;

        cRect.width  = cRect.height = step;

        gdk_gc_set_foreground(bbGC,&buttonBorder1);
        for (long i=0; i<theParent->ButtonCount(); i++) {
            if (i&& i%theParent->BarWidth()==0) {
                cRect.x  =  buttonRect.x;
                cRect.y  += step;
            }

            iRect    = cRect;
            iRect.x += theParent->parentWindow->allocation.x + HY_BUTTONBAR_BORDER;
            iRect.y += theParent->parentWindow->allocation.y + HY_BUTTONBAR_BORDER;

            iRect.width  -= 2*HY_BUTTONBAR_BORDER;
            iRect.height -= 2*HY_BUTTONBAR_BORDER;

            GdkPixbuf * buttonToPlot = nil;

            if (theParent->activationFlag) {
                if (i==pushed) {
                    buttonToPlot = gdk_pixbuf_composite_color_simple ((GdkPixbuf*)theParent->buttons.lData[i], iRect.width, iRect.height,GDK_INTERP_BILINEAR,128,1024,0x00000000,0x00000000);
                } else {
                    if (theParent->enabledButtons.Find(i)>=0) {
                        buttonToPlot = gdk_pixbuf_composite_color_simple ((GdkPixbuf*)theParent->buttons.lData[i], iRect.width, iRect.height,GDK_INTERP_BILINEAR,255,1024,0,0);
                    } else {
                        buttonToPlot = gdk_pixbuf_composite_color_simple ((GdkPixbuf*)theParent->buttons.lData[i], iRect.width, iRect.height,GDK_INTERP_BILINEAR,128,1,0x00ffffff,0x00888888);
                    }
                }
            } else {
                buttonToPlot = gdk_pixbuf_composite_color_simple ((GdkPixbuf*)theParent->buttons.lData[i], iRect.width, iRect.height,GDK_INTERP_BILINEAR,128,1,0x00ffffff,0x00888888);
            }
            gdk_draw_pixbuf (theParent->parentWindow->window,bbGC, buttonToPlot, 0,0, iRect.x, iRect.y, iRect.width, iRect.height, GDK_RGB_DITHER_NORMAL, 0, 0);
            g_object_unref (buttonToPlot);
            iRect.x --;
            iRect.y --;
            iRect.width += 2;
            iRect.height += 2;

            gdk_draw_rectangle(theParent->parentWindow->window,bbGC,false,iRect.x, iRect.y, iRect.width, iRect.height);
            cRect.x +=step;
        }
        gdk_gc_set_clip_rectangle(bbGC,nil);

    }

    (*theParent)._HYPlatformComponent::_Paint(p);
}