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

📄 dw_button.c

📁 飞漫公司的minigui的1.6.8收费增值版本的demon等示例程序
💻 C
📖 第 1 页 / 共 2 页
字号:
   DwButton *button = DW_BUTTON (widget);   if (button->child)      a_Dw_widget_set_descent         (button->child,          descent - (button->relief ? 2 : 0));}/* * Standard Dw function. */static void Dw_button_draw (DwWidget *widget,                            HDC hdc,                            DwRectangle *area){   DwButton *button = DW_BUTTON (widget);   BOOL updown;   DwRectangle dw_area;   DwRectangle child_area;   if (button->relief) {      if (button->sensitive) {         if (button->in_button) {            if (button->pressed) {#if 0               state = GTK_STATE_ACTIVE;               shadow = GTK_SHADOW_IN;#else                updown = FALSE;#endif            } else {#if 0               state = GTK_STATE_PRELIGHT;               shadow = GTK_SHADOW_OUT;#else                updown = TRUE;#endif            }         } else {#if 0            state = GTK_STATE_NORMAL;            shadow = GTK_SHADOW_OUT;#else            updown = TRUE;#endif         }      } else {#if 0         state = GTK_STATE_INSENSITIVE;         shadow = GTK_SHADOW_OUT;#else         updown = TRUE;#endif      }      dw_area.x =         p_Dw_widget_x_world_to_viewport (widget,                                          area->x + widget->allocation.x);      dw_area.y =         p_Dw_widget_y_world_to_viewport (widget,                                          area->y + widget->allocation.y);      dw_area.width = area->width;      dw_area.height = area->height;#if 0      gtk_paint_box (widget->viewport->style, DW_WIDGET_WINDOW (widget),                     state, shadow, &gdk_area, widget->viewport,                     "buttondefault",                     p_Dw_widget_x_world_to_viewport (widget,                                                      widget->allocation.x),                     p_Dw_widget_y_world_to_viewport (widget,                                                      widget->allocation.y),                     widget->allocation.width,                     DW_WIDGET_HEIGHT(widget));#else      Draw3DControlFrame (hdc, dw_area.x, dw_area.y,                         dw_area.x + dw_area.width, dw_area.y + dw_area.height,                        PIXEL_lightgray, updown);#endif   }   if (button->child &&       p_Dw_widget_intersect (button->child, area, &child_area))      a_Dw_widget_draw (button->child, hdc, &child_area);}/* * Standard Dw function. */static gboolean Dw_button_button_press (DwWidget *widget,                                        gint32 x,                                        gint32 y,                                        DWORD flags){   DwButton *button = DW_BUTTON (widget);#if 0   /* assert it was the left mouse button */   if (event->button != 1)      return FALSE;#endif   button->pressed = TRUE;   if (button->relief)      p_Dw_widget_queue_draw (widget);   return TRUE;}/* * Standard Dw function. */static gboolean Dw_button_button_release (DwWidget *widget,                                          gint32 x,                                          gint32 y,                                          DWORD flags){   DwButton *button = DW_BUTTON (widget);   gint32 cx, cy;   /* Notice that button->pressed may have been set to FALSE in    * Dw_button_leave_notify. */   if (button->pressed && button->in_button && button->sensitive) {      /* simple "click" */      g_signal_emit (G_OBJECT (widget), button_signals[CLICKED], 0);      /* "clicked_at": like "clicked", but position is passed, relative       * to the child widget. */      if (button->child) {         cx = x + widget->allocation.x - button->child->allocation.x;         cy = y + widget->allocation.y - button->child->allocation.y;         /* If position is outside of the child, clip at the child            allocation */         if (cx < 0)            cx = 0;         else if (cx > button->child->allocation.width - 1)            cx = button->child->allocation.width - 1;         if (cy < 0)            cy = 0;         else if (cy > (DW_WIDGET_HEIGHT(button->child) - 1))            cy = DW_WIDGET_HEIGHT(button->child) - 1;         g_signal_emit (G_OBJECT (widget), button_signals[CLICKED_AT], 0,                          cx, cy);      }   }   button->pressed = FALSE;   if (button->relief)      p_Dw_widget_queue_draw (widget);   return TRUE;}/*   Standard Dw function. */static gboolean Dw_button_enter_notify (DwWidget *widget,                                        DwWidget *last_widget,                                        DWORD flags){   DwButton *button = DW_BUTTON (widget);   button->in_button = TRUE;   if (button->relief)      p_Dw_widget_queue_draw (widget);   return TRUE;}/* * Standard Dw function. */static gboolean Dw_button_leave_notify (DwWidget *widget,                                        DwWidget *next_widget,                                        DWORD flags){   DwButton *button = DW_BUTTON (widget);   if (button->child == NULL || next_widget != button->child) {      button->in_button = FALSE;      /* See comment at the beginning. */      button->pressed = FALSE;      if (button->relief)         p_Dw_widget_queue_draw (widget);   }   return TRUE;}/* * Standard Dw function. */static void Dw_button_add (DwContainer *container,                           DwWidget *widget){   DwButton *button = DW_BUTTON (container);   g_return_if_fail (button->child == NULL);   button->child = widget;   p_Dw_widget_set_parent (widget, DW_WIDGET (container));}/* * Standard Dw function. */static void Dw_button_remove (DwContainer *container,                              DwWidget *widget){   DwButton *button = DW_BUTTON (container);   g_return_if_fail (button->child != NULL);   g_return_if_fail (widget == button->child);   button->child = NULL;}/* * Standard Dw function. */static void Dw_button_forall (DwContainer *container,                              DwCallback callback,                              gpointer callback_data){   DwButton *button = DW_BUTTON (container);   if (button->child)      callback (button->child, callback_data);}/* * An insensitive button does not respond on user interaction. Used * in HTML forms. */void a_Dw_button_set_sensitive (DwButton *button,                                gboolean sensitive){   button->sensitive = sensitive;   if (button->relief)      p_Dw_widget_queue_draw (DW_WIDGET (button));}static DwIterator *Dw_button_iterator (DwWidget *widget,                                       gint mask,                                       gboolean at_end){   DwIterator *it = g_new (DwIterator, 1);   it->widget = widget;   it->mask = mask;   it->content.type = (at_end ? DW_CONTENT_END : DW_CONTENT_START);   it->next = Dw_button_iterator_next;   it->prev = Dw_button_iterator_prev;   it->clone = p_Dw_iterator_clone_std;   it->compare = Dw_button_iterator_compare;   it->free = p_Dw_iterator_free_std;   it->highlight = p_Dw_iterator_highlight_std;   it->get_allocation = p_Dw_iterator_get_allocation_std;   return it;}static gboolean Dw_button_iterator_next (DwIterator *it){   if (it->content.type == DW_CONTENT_START &&       (it->mask & DW_CONTENT_WIDGET) &&       DW_BUTTON(it->widget)->child) {      it->content.type = DW_CONTENT_WIDGET;      it->content.data.widget = DW_BUTTON(it->widget)->child;      return TRUE;   } else {      it->content.type = DW_CONTENT_END;      return FALSE;   }}static gboolean Dw_button_iterator_prev (DwIterator *it){   if (it->content.type == DW_CONTENT_END &&       (it->mask & DW_CONTENT_WIDGET) &&       DW_BUTTON(it->widget)->child) {      it->content.type = DW_CONTENT_WIDGET;      it->content.data.widget = DW_BUTTON(it->widget)->child;      return TRUE;   } else {      it->content.type = DW_CONTENT_START;      return FALSE;   }}static gint Dw_button_iterator_compare (DwIterator *it1,                                        DwIterator *it2){   if (it1->content.type == it2->content.type)      return 0;   switch (it1->content.type) {   case DW_CONTENT_START:      return -1;   case DW_CONTENT_TEXT:      if (it2->content.type == DW_CONTENT_START)         return +1;      else         return -1;   case DW_CONTENT_END:      return +1;   default:      return 0;   }}

⌨️ 快捷键说明

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