Beispiel #1
0
/**************************************************************************
  ...
**************************************************************************/
void set_new_group_start_pos(const struct widget *pBeginGroupWidgetList,
			     const struct widget *pEndGroupWidgetList,
			     Sint16 Xrel, Sint16 Yrel)
{
  struct widget *pTmpWidget = (struct widget *) pEndGroupWidgetList;

  while (pTmpWidget) {

    widget_set_position(pTmpWidget, pTmpWidget->size.x + Xrel,
                                    pTmpWidget->size.y + Yrel);
    
    if (get_wtype(pTmpWidget) == WT_VSCROLLBAR
      && pTmpWidget->private_data.adv_dlg
      && pTmpWidget->private_data.adv_dlg->pScroll) {
      pTmpWidget->private_data.adv_dlg->pScroll->max += Yrel;
      pTmpWidget->private_data.adv_dlg->pScroll->min += Yrel;
    }
    
    if (get_wtype(pTmpWidget) == WT_HSCROLLBAR
      && pTmpWidget->private_data.adv_dlg
      && pTmpWidget->private_data.adv_dlg->pScroll) {
      pTmpWidget->private_data.adv_dlg->pScroll->max += Xrel;
      pTmpWidget->private_data.adv_dlg->pScroll->min += Xrel;
    }
    
    if (pTmpWidget == pBeginGroupWidgetList) {
      break;
    }

    pTmpWidget = pTmpWidget->prev;
  }
}
Beispiel #2
0
int set_new_checkbox_theme(struct widget *pCBox ,
				SDL_Surface *pTrue, SDL_Surface *pFalse)
{
  struct CHECKBOX *pTmp;
  
  if(!pCBox || (get_wtype(pCBox) != WT_CHECKBOX)) {
    return -1;
  }
  
  if(!pCBox->private_data.cbox) {
    pCBox->private_data.cbox = fc_calloc(1, sizeof(struct CHECKBOX));
    set_wflag(pCBox, WF_FREE_PRIVATE_DATA);
    pCBox->private_data.cbox->state = FALSE;
  }
  
  pTmp = pCBox->private_data.cbox;
  pTmp->pTRUE_Theme = pTrue;
  pTmp->pFALSE_Theme = pFalse;
  if(pTmp->state) {
    pCBox->theme = pTrue;
  } else {
    pCBox->theme = pFalse;
  }
  return 0;
}
Beispiel #3
0
/**************************************************************************
   ...
**************************************************************************/
void widget_free(struct widget **pWidget)
{
  struct widget *pGUI = *pWidget;
  
  if ((get_wflags(pGUI) & WF_FREE_STRING) == WF_FREE_STRING) {
    FREESTRING16(pGUI->string16);
  }
  if ((get_wflags(pGUI) & WF_WIDGET_HAS_INFO_LABEL)
      == WF_WIDGET_HAS_INFO_LABEL) {
    FREESTRING16(pGUI->info_label);
  }
  if ((get_wflags(pGUI) & WF_FREE_GFX) == WF_FREE_GFX) {
    FREESURFACE(pGUI->gfx);
  }
  if ((get_wflags(pGUI) & WF_FREE_THEME) == WF_FREE_THEME) {
    if (get_wtype(pGUI) == WT_CHECKBOX) {
      FREESURFACE(pGUI->private_data.cbox->pTRUE_Theme);
      FREESURFACE(pGUI->private_data.cbox->pFALSE_Theme);
    } else {
      FREESURFACE(pGUI->theme);
    }
  }
  if ((get_wflags(pGUI) & WF_FREE_THEME2) == WF_FREE_THEME2) {
    FREESURFACE(pGUI->theme2);
  }
  if ((get_wflags(pGUI) & WF_FREE_DATA) == WF_FREE_DATA) {
    FC_FREE(pGUI->data.ptr);
  }
  if ((get_wflags(pGUI) & WF_FREE_PRIVATE_DATA) == WF_FREE_PRIVATE_DATA) {
    FC_FREE(pGUI->private_data.ptr);
  }
  if (NULL != pGUI->destroy) {
    pGUI->destroy(pGUI);
  }

  FC_FREE(*pWidget);
}
Beispiel #4
0
/**************************************************************************
  Do default Widget action when pressed, and then call widget callback
  function.

  example for Button:
    set flags FW_Pressed
    redraw button ( pressed )
    refresh screen ( to see result )
    wait 300 ms	( to see result :)
    If exist (button callback function) then
      call (button callback function)

    Function normal return Widget ID.
    NOTE: NOZERO return of this function deterninate exit of
        MAIN_SDL_GAME_LOOP
    if ( pWidget->action )
      if ( pWidget->action(pWidget)  ) ID = 0;
    if widget callback function return = 0 then return NOZERO
    I default return (-1) from Widget callback functions.
**************************************************************************/
Uint16 widget_pressed_action(struct widget * pWidget)
{
  Uint16 ID = 0;

  if (!pWidget) {
    return 0;
  }
  
  widget_info_counter = 0;
  if (pInfo_Area) {
    sdl_dirty_rect(*pInfo_Area);
    FC_FREE(pInfo_Area);
    FREESURFACE(pInfo_Label);
  }

  switch (get_wtype(pWidget)) {
    case WT_TI_BUTTON:
    case WT_I_BUTTON:    
    case WT_ICON:
    case WT_ICON2:
      if (Main.event.button.button == SDL_BUTTON_LEFT) {
        set_wstate(pWidget, FC_WS_PRESSED);
        widget_redraw(pWidget);
        widget_mark_dirty(pWidget);
        flush_dirty();
        set_wstate(pWidget, FC_WS_SELLECTED);
        SDL_Delay(300);
      }
      ID = pWidget->ID;
      if (pWidget->action) {
        if (pWidget->action(pWidget)) {
          ID = 0;
        }
      }
      break;

    case WT_EDIT:
    {
      if (Main.event.button.button == SDL_BUTTON_LEFT) {
        bool ret, loop = ((get_wflags(pWidget) & WF_EDIT_LOOP) == WF_EDIT_LOOP);
        enum Edit_Return_Codes change;
        do {
          ret = FALSE;
          change = edit_field(pWidget);
          if (change != ED_FORCE_EXIT && (!loop || change != ED_RETURN)) {
            widget_redraw(pWidget);
            widget_mark_dirty(pWidget);
            flush_dirty();
          }
          if (change != ED_FORCE_EXIT && change != ED_ESC && pWidget->action) {
            if (pWidget->action(pWidget)) {
              ID = 0;
            }
          }
          if (loop && change == ED_RETURN) {
            ret = TRUE;
          }
        } while(ret);
        ID = 0;
      }
      break;
    }
    case WT_VSCROLLBAR:
    case WT_HSCROLLBAR:
      if (Main.event.button.button == SDL_BUTTON_LEFT) {
        set_wstate(pWidget, FC_WS_PRESSED);
        widget_redraw(pWidget);
        widget_mark_dirty(pWidget);
        flush_dirty();
      }
      ID = pWidget->ID;
      if (pWidget->action) {
        if (pWidget->action(pWidget)) {
          ID = 0;
        }
      }
      break;
    case WT_CHECKBOX:
    case WT_TCHECKBOX:
      if (Main.event.button.button == SDL_BUTTON_LEFT) {
        set_wstate(pWidget, FC_WS_PRESSED);
        widget_redraw(pWidget);
        widget_mark_dirty(pWidget);
        flush_dirty();
        set_wstate(pWidget, FC_WS_SELLECTED);
        togle_checkbox(pWidget);
        SDL_Delay(300);
      }
      ID = pWidget->ID;  
      if (pWidget->action) {
        if (pWidget->action(pWidget)) {
          ID = 0;
        }
      }
      break;
    case WT_COMBO:
      if (Main.event.button.button == SDL_BUTTON_LEFT) {
        set_wstate(pWidget, FC_WS_PRESSED);
        combo_popup(pWidget);
      } else {
        combo_popdown(pWidget);
      }
      break;
    default:
      ID = pWidget->ID;
      if (pWidget->action) {
        if (pWidget->action(pWidget) != 0) {
          ID = 0;
        }
      }
      break;
  }

  return ID;
}