Exemple #1
0
/*
 * Function    : libaroma_window_free
 * Return Value: byte
 * Descriptions: free window
 */
byte libaroma_window_free(
  LIBAROMA_WINDOWP win
){
  __CHECK_WM(0);
  if (win==NULL){
    return 0;
  }
  
  /* inactivate it */
  if (win->parent==NULL){
    if (libaroma_wm_get_active_window()==win){
      /* detach active window from window manager */
      libaroma_wm_set_active_window(NULL);
    }
    
    LIBAROMA_MSG _msg;
    libaroma_window_process_event(win,
      libaroma_wm_compose(&_msg, LIBAROMA_MSG_WIN_INACTIVE, NULL, 0, 0));
  }
  
  if (win->handler!=NULL){
    if (win->handler->prefree!=NULL){
      win->handler->prefree(win);
    }
  }
  
  /* delete childs */
  int i;
  if (win->childn>0){
#ifdef LIBAROMA_CONFIG_OPENMP
  #pragma omp parallel for
#endif
    for (i=0;i<win->childn;i++){
      libaroma_control_free(win->childs[i]);
    }
    free(win->childs);
  }
  if (win->bg){
    libaroma_canvas_free(win->bg);
    win->bg=NULL;
  }
  if (win->dc){
    libaroma_canvas_free(win->dc);
    win->dc=NULL;
  }
  

  if (win->handler!=NULL){
    if (win->handler->postfree!=NULL){
      win->handler->postfree(win);
    }
  }
  free(win);
  return 1;
} /* End of libaroma_window_free */
/*
 * Function    : libaroma_window_measure_size
 * Return Value: byte
 * Descriptions: measure window size
 */
byte libaroma_window_measure_size(LIBAROMA_WINDOWP win){
  if (win){
    if (win->parent!=NULL){
      ALOGW("window_resize cannot be used for child window");
      return 0;
    }
    if (_libaroma_window_measurement_dp){
      win->x = libaroma_dp(win->rx);
      win->y = libaroma_dp(win->ry);
      win->w = libaroma_dp(win->rw);
      win->h = libaroma_dp(win->rh);
    }
    else{
      win->x = win->rx;
      win->y = win->ry;
      win->w = win->rw;
      win->h = win->rh;
    }
    win->ax=win->x;
    win->ay=win->y;
    
    win->x=libaroma_window_measure_calculate(
      win->x, win->rx, libaroma_wm()->w, 0, 0
    );
    win->y=libaroma_window_measure_calculate(
      win->y, win->ry, libaroma_wm()->h, 0, 0
    );
    win->w=libaroma_window_measure_calculate(
      win->w, win->rw, libaroma_wm()->w, 1, win->x
    );
    win->h=libaroma_window_measure_calculate(
      win->h, win->rh, libaroma_wm()->h, 1, win->y
    );
    
    if (win->w+win->x>libaroma_wm()->w){
      win->w = libaroma_wm()->w-win->x;
    }
    if (win->h+win->y>libaroma_wm()->h){
      win->h = libaroma_wm()->h-win->y;
    }
    _libaroma_window_measure_save(win,NULL);
    LIBAROMA_MSG _msg;
    libaroma_window_process_event(win,libaroma_wm_compose(
      &_msg, LIBAROMA_MSG_WIN_MEASURED, NULL, 0, 0)
    );
    return 1;
  }
  return 0;
} /* End of libaroma_window_measure */
Exemple #3
0
/*
 * Function    : libaroma_window_pool
 * Return Value: dword
 * Descriptions: poll window messages
 */
dword libaroma_window_pool(
    LIBAROMA_WINDOWP win,
    LIBAROMA_MSGP msg){
  if (!win){
    return 0;
  }
  if (win->parent!=NULL){
    ALOGW("cannot pool child window...");
    return 0;
  }
  LIBAROMA_MSG _msg;
  LIBAROMA_MSGP cmsg=(msg!=NULL)?msg:&_msg;
  byte ret = libaroma_wm_getmessage(cmsg);
  if (ret){
    return libaroma_window_process_event(win,cmsg);
  }
  return 0;
} /* End of libaroma_window_pool */
Exemple #4
0
/*
 * Function    : libaroma_window_anishow
 * Return Value: byte
 * Descriptions: show window - animated
 */
byte libaroma_window_anishow(
    LIBAROMA_WINDOWP win,
    byte animation,
    int duration){
  __CHECK_WM(0);
  if (!win){
    return 0;
  }
  if (win->parent!=NULL){
    ALOGW("Child window cannot shown directly...");
    return 0;
  }
  
  /* set initial focus
    libaroma_window_setfocus(win, NULL);
  */
  
  if ((!animation)||(duration<50)){
    return libaroma_wm_set_active_window(win);
  }
  
  /* lock and retval */
  byte retval = 0;
  win->lock_sync = 1;
  
  if (libaroma_wm_set_active_window(win)){
    win->active=2;
    
    /* draw window into temp canvas */
    LIBAROMA_CANVASP wmc = win->dc;
    LIBAROMA_CANVASP tdc = libaroma_canvas(wmc->w,wmc->h);
    libaroma_draw(tdc,wmc,0,0,0);
    win->dc=tdc; /* switch dc */
    
    LIBAROMA_CANVASP back = libaroma_canvas(wmc->w, wmc->h);
    libaroma_draw(back,wmc,0,0,0);
    
    /* invalidate now */
    libaroma_window_invalidate(win, 10);
    
    long start = libaroma_tick();
    int delta = 0;
    while ((delta=libaroma_tick()-start)<duration){
      float state = ((float) delta)/((float) duration);
      if (state>=1.0){
        break;
      }
      switch (animation){
        case LIBAROMA_WINDOW_SHOW_ANIMATION_SLIDE_LEFT:
        case LIBAROMA_WINDOW_SHOW_ANIMATION_PAGE_LEFT:
          {
            float swift_out_state = libaroma_cubic_bezier_swiftout(state);
            int x = win->w - (swift_out_state * win->w);
            int w = win->w - x;
            if (w>0){
              if (animation==LIBAROMA_WINDOW_SHOW_ANIMATION_SLIDE_LEFT){
                if (w<win->w){
                  libaroma_draw_ex(
                    wmc,
                    back,
                    0, 0, win->w - (win->w - w), 0, win->w - w, win->h,
                    0, 0xff
                  );
                }
              }
              libaroma_draw_ex(
                wmc,
                win->dc,
                x, 0, 0, 0, w, win->h,
                0, 0xff
              );
              if (animation==LIBAROMA_WINDOW_SHOW_ANIMATION_SLIDE_LEFT){
                libaroma_wm_sync(win->x,win->y,win->w,win->h);
              }
              else{
                libaroma_wm_sync(win->x+x,win->y,w, win->h);
              }
            }
          }
          break;
        case LIBAROMA_WINDOW_SHOW_ANIMATION_SLIDE_RIGHT:
        case LIBAROMA_WINDOW_SHOW_ANIMATION_PAGE_RIGHT:
          {
            float swift_out_state = libaroma_cubic_bezier_swiftout(state);
            int x = 0 - (win->w - (swift_out_state * win->w));
            int w = win->w + x;
            if (w>0){
              if (animation==LIBAROMA_WINDOW_SHOW_ANIMATION_SLIDE_RIGHT){
                if (w<win->w){
                  libaroma_draw_ex(
                    wmc,
                    back,
                    w, 0, 0, 0, win->w - w, win->h,
                    0, 0xff
                  );
                }
              }
              libaroma_draw_ex(
                wmc,
                win->dc,
                0, 0, win->w-w, 0, w, win->h,
                0, 0xff
              );
              if (animation==LIBAROMA_WINDOW_SHOW_ANIMATION_SLIDE_RIGHT){
                libaroma_wm_sync(win->x,win->y,win->w,win->h);
              }
              else{
                libaroma_wm_sync(win->x,win->y,w, win->h);
              }
            }
          }
          break;
        default:
          /* invalid animation */
          start=0;
          break;
      }
    }
    
    retval = 1;
    libaroma_draw(wmc,win->dc,0,0,0);
              
    win->dc=wmc; /* switch dc back */
  
    /* cleanup */
    libaroma_canvas_free(back);
    libaroma_canvas_free(tdc);
  }
  
  win->lock_sync = 0;
  
  /* sync view now */
  if (retval){
    win->active=1;
    libaroma_window_sync(win, 0, 0, win->w, win->h);
  }
  
  /* send activate */
  LIBAROMA_MSG _msg;
  libaroma_window_process_event(win,libaroma_wm_compose(
    &_msg, LIBAROMA_MSG_WIN_ACTIVE, NULL, 10, 0)
  );
  
  return retval;
} /* End of libaroma_window_show */