示例#1
0
/*
 * Function    : libaroma_ctl_list_item_position
 * Return Value: byte
 * Descriptions: get item position
 */
byte libaroma_ctl_list_item_position(
    LIBAROMA_CONTROLP ctl,LIBAROMA_CTL_LIST_ITEMP item,
    LIBAROMA_RECTP rect, byte absolute){
  if (!rect){
    return 0;
  }
  if (!item){
    return 0;
  }
  LIBAROMA_CTL_SCROLL_CLIENTP client = libaroma_ctl_scroll_get_client(ctl);
  if (!client){
    return 0;
  }
  if (client->handler!=&_libaroma_ctl_list_handler){
    return 0;
  }
  LIBAROMA_CTL_LISTP mi = (LIBAROMA_CTL_LISTP) client->internal;
  
  int x=0;
  int y=0;
  if (absolute){
    libaroma_window_calculate_pos_abs(NULL,ctl,&x,&y);
  }
  else{
    libaroma_window_calculate_pos(NULL,ctl,&x,&y);
  }
  int ctl_y = libaroma_ctl_scroll_get_scroll(ctl,NULL);
  rect->x=x;
  rect->y=item->y-(y+ctl_y+mi->vpad);
  rect->w=ctl->w-(mi->hpad*2);
  rect->h=item->h;
  return 1;
} /* End of libaroma_ctl_list_item_position */
示例#2
0
/*
 * Function    : libaroma_window_process_event
 * Return Value: dword
 * Descriptions: process message
 */
dword libaroma_window_process_event(LIBAROMA_WINDOWP win, LIBAROMA_MSGP msg){
  __CHECK_WM(0);
  if (win==NULL){
    ALOGW("window_event win is null");
    return 0;
  }
  if (win->parent!=NULL){
    ALOGW("window_event cannot used for child window...");
    return 0;
  }
  dword ret = 0;
  if (win->handler){
    if (win->handler->message_hooker){
      if (win->handler->message_hooker(win,msg,&ret)){
        return ret;
      }
    }
  }
  switch (msg->msg){
    case LIBAROMA_MSG_WIN_ACTIVE:
      {
          /* set current window size */
        if (msg->x!=10){
          _libaroma_window_ready(win);
        }
        if ((!win->lock_sync)||(msg->x==10)){
          if ((!win->active)||(msg->x==10)){
            int i;
            win->active=1;
            
            /* signal child */
            for (i=0;i<win->childn;i++){
              if (win->childs[i]->handler->message){
                win->childs[i]->handler->message(win->childs[i], msg);
              }
            }
          }
        }
      }
      break;
    case LIBAROMA_MSG_WIN_RESIZE:
      {
        int i;
        _libaroma_window_ready(win);
        for (i=0;i<win->childn;i++){
          if (win->childs[i]->handler->message){
            win->childs[i]->handler->message(win->childs[i], msg);
          }
        }
      }
      break;
    case LIBAROMA_MSG_WIN_INACTIVE:
      {
        if (win->active){
          /* stop thread manager */
          win->active=0;
          
          /* send inactive message to child */
          int i;
          for (i=0;i<win->childn;i++){
            if (win->childs[i]->handler->message){
              win->childs[i]->handler->message(win->childs[i], msg);
            }
          }
        }
      }
      break;
    case LIBAROMA_MSG_WIN_MEASURED:
      {
        /* remeasured all childs */
        int i;
        for (i=0;i<win->childn;i++){
          libaroma_window_measure(win,win->childs[i]);
        }
      }
      break;
    case LIBAROMA_MSG_WIN_DIRECTMSG:
      {
        return (dword) msg->x;
      }
      break;
    case LIBAROMA_MSG_WIN_INVALIDATE:
      {
        libaroma_window_invalidate(win, 1);
      }
      break;
    case LIBAROMA_MSG_TOUCH:
      {
        /* touch handler */
        if (msg->state==LIBAROMA_HID_EV_STATE_DOWN){
          win->touched = NULL;
          int x = msg->x;
          int y = msg->y;
          libaroma_window_calculate_pos(win,NULL,&x,&y);
          int i;
          for (i=0;i<win->childn;i++){
            if (_libaroma_window_is_inside(win->childs[i],x,y)){
              win->touched = win->childs[i];
              break;
            }
          }
          if (win->touched!=NULL){
            if (win->touched->handler->message){
              ret=win->touched->handler->message(win->touched, msg);
            }
          } 
        }
        else if (win->touched!=NULL){
          if (msg->state==LIBAROMA_HID_EV_STATE_MOVE){
            if (win->touched->handler->message){
              ret=win->touched->handler->message(win->touched, msg);
            }
          }
          else if (msg->state==LIBAROMA_HID_EV_STATE_UP){
            if (win->touched->handler->message){
              ret=win->touched->handler->message(win->touched, msg);
            }
            win->touched=NULL;
          }
        }
      }
      break;
  }
  return ret;
} /* End of libaroma_window_process_event */