⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iconc.c

📁 linux下的E_MAIL客户端源码
💻 C
📖 第 1 页 / 共 2 页
字号:
   if ( pixmap.mask ) {      XSetClipMask(halApp->display, gc, pixmap.mask);      XSetClipOrigin(halApp->display, gc, x, y);   }   Pixmap	src = selected ? pixmap.inv : pixmap.reg;   if ( src )      XCopyArea(halApp->display, src, window, gc, /*srcx*/0, /*srcy*/0,		pixmap.wd, pixmap.ht, /*dstx*/x, /*dsty*/y);   if ( pixmap.mask ) {      XSetClipMask(halApp->display, gc, None);      XSetClipOrigin(halApp->display, gc, 0, 0);   }//// Draw name string//   Pixel	fg = selected ? invFgColor : regFgColor;   XSetForeground(halApp->display, gc, fg);   DrawLabel();//// Draw highlight if necessary//   if ( focusHere ) DrawHighlight(hlColor);} // End IconC Draw/*----------------------------------------------------------------------- *  Method to draw the label */voidIconC::DrawLabel(){   if ( !realized ) return;   int	lx, y;   switch (labelPos) {      case (LABEL_BELOW):	 lx = 0;	 y = data.bounds.ymin + itemMarginHt + pixmap.ht + labelOffset;	 break;      case (LABEL_ABOVE):	 lx = 0;	 y = data.bounds.ymin + itemMarginHt;	 break;      case (LABEL_LEFT):	 lx = data.bounds.xmin + itemMarginWd;	 y = (int)(daHt - data.labelHt) / (int)2;	 break;      case (LABEL_RIGHT):	 lx = data.bounds.xmin + itemMarginWd + pixmap.wd + labelOffset;	 y = (int)(daHt - data.labelHt) / (int)2;	 break;   }//// Loop through label components//   unsigned	count = data.labelList.size();   for (int i=0; i<count; i++) {      LabelDataC	*ldata = data.labelList[i];//// Center component in icon//      int	x;      switch (labelPos) {	 case (LABEL_BELOW):	 case (LABEL_ABOVE):	    x = lx + (int)(daWd - ldata->width) / (int)2;	    break;	 case (LABEL_LEFT):	 case (LABEL_RIGHT):	    x = lx;	    break;      }      y += font->ascent;      XDrawString(halApp->display, window, gc, x, y, ldata->string,		  ldata->string.size());//// Move to top of next label//      y += font->descent + labelSpacing;   } // End for each label component} // End IconC DrawLabel/*----------------------------------------------------------------------- *  Draw a highlight border around the item */voidIconC::DrawHighlight(Pixel color){   if ( !realized ) return;   XSetForeground(halApp->display, gc, color);   XRectangle	rects[4];   XRectangle	*rect = rects;   rect->x      = hlRect.xmin;   rect->y      = hlRect.ymin;   rect->width  = hlRect.wd;   rect->height = hlThick;   rect++;   rect->x      = hlRect.xmin;   rect->y      = hlRect.ymin;   rect->width  = hlThick;   rect->height = hlRect.ht;   rect++;   rect->x      = hlRect.xmax - hlThick + 1;   rect->y      = hlRect.ymin;   rect->width  = hlThick;   rect->height = hlRect.ht;   rect++;   rect->x      = hlRect.xmin;   rect->y      = hlRect.ymax - hlThick + 1;   rect->width  = hlRect.wd;   rect->height = hlThick;   XFillRectangles(halApp->display, window, gc, rects, 4);} // End IconC DrawHighlight/*----------------------------------------------------------------------- *  Handle a keyboard focus change event in the area */voidIconC::HandleFocusChange(Widget, IconC *This, XEvent *ev, Boolean *){   switch (ev->type) {      case (FocusIn):      case (EnterNotify):	 This->focusHere = True;	 This->DrawHighlight(This->hlColor);	 break;      case (FocusOut):      case (LeaveNotify):	 This->focusHere = False;	 This->DrawHighlight(This->regBgColor);	 break;      default:	 break;   }   This->CallFocusChangeCallbacks();} // End IconC HandleFocusChange/*----------------------------------------------------------------------- *  Change the label for an item */voidIconC::SetLabel(const StringC& str){//// Clear drawing area//   if ( realized ) {      XSetForeground(halApp->display, gc, regBgColor);      XFillRectangle(halApp->display, window, gc, 0, 0, daWd, daHt);   }//// Calculate new sizes//   data.item->Label(str);   data.GetLabelSize(font, labelSpacing);   GetIconSize();   Draw();} // End IconC SetLabel/*----------------------------------------------------------------------- *  Change the label position for an item */voidIconC::SetLabelPosition(LabelPositionT pos){//// Clear drawing area//   if ( realized ) {      XSetForeground(halApp->display, gc, regBgColor);      XFillRectangle(halApp->display, window, gc, 0, 0, daWd, daHt);   }   labelPos = pos;   Draw();}/*----------------------------------------------------------------------- *  Change the pixmap */voidIconC::SetPixmap(const char *cs){//// Clear drawing area//   if ( realized ) {      XSetForeground(halApp->display, gc, regBgColor);      XFillRectangle(halApp->display, window, gc, 0, 0, daWd, daHt);   }   data.item->SetPixmaps(cs, NULL);   GetPixmap();   GetIconSize();   Draw();}voidIconC::SetPixmap(const XbmT *xbm){//// Clear drawing area//   if ( realized ) {      XSetForeground(halApp->display, gc, regBgColor);      XFillRectangle(halApp->display, window, gc, 0, 0, daWd, daHt);   }   data.item->SetPixmaps(xbm, NULL);   GetPixmap();   GetIconSize();   Draw();}voidIconC::SetPixmap(const XpmT xpm){//// Clear drawing area//   if ( realized ) {      XSetForeground(halApp->display, gc, regBgColor);      XFillRectangle(halApp->display, window, gc, 0, 0, daWd, daHt);   }   data.item->SetPixmaps(xpm, NULL);   GetPixmap();   GetIconSize();   Draw();}/*----------------------------------------------------------------------- *  Set the drawing colors */voidIconC::SetColors(Pixel bg, Pixel fg){   regBgColor = bg;   regFgColor = fg;   XtVaSetValues(iconDA, XmNbackground, bg, NULL);   GetPixmap();   GetIconSize();   if ( !selected ) Draw();}/*----------------------------------------------------------------------- *  Set the selection colors */voidIconC::SetSelectColors(Pixel bg, Pixel fg){   invBgColor = bg;   invFgColor = fg;   GetPixmap();   GetIconSize();   if ( selected ) Draw();}/*----------------------------------------------------------------------- *  Select the icon */voidIconC::Select(Boolean notify){   if ( selected ) return;   selected = True;   Draw();   if ( notify ) data.item->CallSelectCallbacks();}/*----------------------------------------------------------------------- *  Deselect the icon */voidIconC::Deselect(Boolean notify){   if ( !selected ) return;   selected = False;   Draw();   if ( notify ) data.item->CallDeselectCallbacks();}/*----------------------------------------------------------------------- *  Toggle the icon */voidIconC::Toggle(Boolean notify){   if ( selected ) Deselect(notify);   else		   Select(notify);}/*----------------------------------------------------------------------- *  Handle an input event */voidIconC::HandleInput(Widget, IconC *This, XmDrawingAreaCallbackStruct *da){   XButtonEvent   *be = (XButtonEvent *)da->event;   switch ( da->event->type ) {      case (ButtonPress):         if ( be->button == Button3 && This->data.item->HasMenu() )	    This->data.item->PostMenu(be);	 break;      case (ButtonRelease):         if ( be->button == Button1 ) {	    static Time	lastTime = 0;	    if ( be->time - lastTime > XtGetMultiClickTime(halApp->display) )	       This->HandleSingleClick(be);	    else if ( This->openOk )	       This->data.item->CallOpenCallbacks();	    lastTime = be->time;         }	 break;   } // End switch event type} // End IconViewC HandleInput/*----------------------------------------------------------------------- *  Handle a button release event in the icon */voidIconC::HandleSingleClick(XButtonEvent *be){   if ( !selectionOk ) return;   if ( be->state & (ShiftMask|ControlMask) ) Toggle();   else					      Select();}/*----------------------------------------------------------------------- *  Methods to control icon selection */voidIconC::EnableSelection(){   selectionOk = True;}voidIconC::DisableSelection(){   selectionOk = False;}/*----------------------------------------------------------------------- *  Methods to control icon double-click */voidIconC::EnableOpen(){   openOk = True;}voidIconC::DisableOpen(){   openOk = False;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -