/* resize children after the sheet resized. */
static void 
resize_children (PPROPSHEETDATA propsheet, const RECT* rcPage, DWORD style)
{
    PPROPPAGE page;
    int w, h;

#ifdef __TARGET_MSTUDIO__
    w = RECTWP(rcPage) - OFFSET_VALUE; 
    h = RECTHP(rcPage) -RECTH(propsheet->head_rc) - OFFSET_VALUE;
#else
    w = RECTWP(rcPage) - 2*OFFSET_VALUE; 
    h = RECTHP(rcPage) -RECTH(propsheet->head_rc) - 2*OFFSET_VALUE;
#endif

    page = propsheet->head;
    while (page) {
        if ((style & 0xf0L) == PSS_BOTTOM) {
            MoveWindow (page->hwnd, OFFSET_VALUE, OFFSET_VALUE, 
                    w, h,
                    page == propsheet->active);
        } else {
            MoveWindow (page->hwnd, 
                    OFFSET_VALUE, OFFSET_VALUE + propsheet->head_rc.bottom,
                    w, h,
                    page == propsheet->active);
        }
        page = page->next;
    }
}
static void fill_dlg_data(comm_dlg_data_t *p_data, u8 style, u32 strid,
                          rect_t *p_dlg_rc, u32 tm_out)
{
  memset(p_data, 0, sizeof(comm_dlg_data_t));
  
  p_data->parent_root = 0;
  p_data->style = style;
  p_data->content = strid;
  p_data->dlg_tmout = tm_out;

  if (p_dlg_rc != NULL)
  {
    p_data->x = (u16)p_dlg_rc->left;
    p_data->y = (u16)p_dlg_rc->top;
    p_data->w = (u16)RECTWP(p_dlg_rc);
    p_data->h = (u16)RECTHP(p_dlg_rc);
  }
  else
  {
    p_data->x = COMM_DLG_X;
    p_data->y = COMM_DLG_Y;
    p_data->w = COMM_DLG_W;
    p_data->h = COMM_DLG_H;
  }
}
Example #3
0
static void _config_osd(rect_t *p_scr)
{
  palette_t pal;
  u8 format;
  u32 cdef, ckey;
  u16 ss_value;
  rsc_palette_t hdr_pal;
  osd_set_t osd_set;
  u8*bits = NULL;

  format = COLORFORMAT_ARGB1555;

  sys_status_get_osd_set(&osd_set);
  ss_value = osd_set.palette;
  rsc_get_palette(gui_get_rsc_handle(),ss_value, &hdr_pal, (u8**)&bits);
  pal.cnt = hdr_pal.color_num;
  pal.p_entry = (color_t *)bits;
  pal.p_entry[C_TRANS].a = 0;
  rsc_set_curn_palette(gui_get_rsc_handle(),ss_value);

  cdef = C_TRANS, ckey = C_KEY;

//  gdi_clear_screen();
  gdi_reset_screen(format, &pal, p_scr, cdef, ckey);

  OS_PRINTF("\n\n-----config OSD-----: %d, %d, %d, %d\n\n", 
    p_scr->left, p_scr->top, 
    RECTWP(p_scr), RECTHP(p_scr));
}
Example #4
0
static void draw_bitmap_button(PCONTROL pCtrl, HDC hdc, DWORD dwStyle, 
                          RECT *prcText)
{
    if (BUTTON_DATA(pCtrl)) {
        int x = prcText->left;
        int y = prcText->top;
        int w = RECTWP (prcText);
        int h = RECTHP (prcText);
        PBITMAP bmp = (PBITMAP)(BUTTON_DATA(pCtrl));
        RECT prcClient;

        GetClientRect ((HWND)pCtrl, &prcClient);
        if (dwStyle & BS_REALSIZEIMAGE) {
            x += (w - bmp->bmWidth) >> 1;
            y += (h - bmp->bmHeight) >> 1;
            w = h = 0;

            if (bmp->bmWidth > RECTW(prcClient)){
                x = prcClient.top + BTN_WIDTH_BORDER;
                y = prcClient.left + BTN_WIDTH_BORDER;
                w = RECTW(prcClient) - 2*BTN_WIDTH_BORDER-1;
            }

            if (bmp->bmHeight > RECTH(prcClient)){
                x = prcClient.top + BTN_WIDTH_BORDER;
                y = prcClient.left + BTN_WIDTH_BORDER;
                h = RECTH(prcClient) - 2*BTN_WIDTH_BORDER-1;
            }

        }
        else {
void kernel_ShowCursorForGDI(BOOL fShow, void* pdc)
{
    PDC cur_pdc = (PDC)pdc;
    const RECT* prc = NULL;

    prc = &cur_pdc->rc_output;

    if (fShow)
        GAL_UpdateRect (cur_pdc->surface, 
                        prc->left, prc->top, RECTWP(prc), RECTHP(prc));
}
Example #6
0
static void a_refresh (_THIS, const RECT* update)
{
    MAN_LCD_REFRESH lcd;

    lcd.startX = update->left;
    lcd.startY = update->top;
    lcd.width = RECTWP (update);
    lcd.height = RECTHP (update);
    
    tp_man_lcd_refresh (&lcd);
}
static void myDrawItem (HWND hWnd, HSVITEM hsvi, HDC hdc, RECT *rcDraw)
{
    const char *name = (const char*)scrollview_get_item_adddata (hsvi);

    SetBkMode (hdc, BM_TRANSPARENT);
    SetTextColor (hdc, PIXEL_black);

    if (scrollview_is_item_hilight(hWnd, hsvi)) {
        SetBrushColor (hdc, PIXEL_blue);
        FillBox (hdc, rcDraw->left+1, rcDraw->top+1, RECTWP(rcDraw)-2, RECTHP(rcDraw)-1);
        SetBkColor (hdc, PIXEL_blue);
        SetTextColor (hdc, PIXEL_lightwhite);
    }

    Rectangle (hdc, rcDraw->left, rcDraw->top, rcDraw->right - 1, rcDraw->bottom);
    TextOut (hdc, rcDraw->left + 3, rcDraw->top + 2, name);
}
Example #8
0
static RET_CODE ap_pic_play_start(pic_player_priv_t *p_priv, u32 index)
{
  chain_t *p_chain = (chain_t *)p_priv->p_pic[index].p_f_chain;
  ifilter_t *p_fsrc_filter = p_priv->p_pic[index].p_source_filter;
  ifilter_t *p_pic_filter = p_priv->p_pic[index].p_pic_play_filter;
  ifilter_t *p_render_filter = p_priv->p_pic[index].p_pic_render_filter;
  icmd_t icmd = {0};
  src_pin_attr_t sp_attr = {0};
  u32 input_size = 0; 
  u32 output_size = 0;
  rect_size_t rect_size = {0};
  u8 *p_input = NULL;
  u8 *p_output = NULL;
  pic_filter_cfg_t pic_cfg = {0};

  rect_size.w = RECTWP(&(p_priv->p_pic[index].pic_data.rect));
  rect_size.h = RECTHP(&(p_priv->p_pic[index].pic_data.rect));
  if(p_priv->p_pic[index].pic_data.file_or_mem)
  {
    input_size = ((p_priv->p_pic[index].pic_data.file_size - 1) / 8 + 1) * 8;
    MT_ASSERT(p_priv->p_pic[index].pic_data.p_mem != NULL);
    MT_ASSERT(p_priv->p_pic[index].pic_data.mem_size >= input_size);
    output_size = p_priv->p_pic[index].pic_data.mem_size - input_size;
   // memset(p_priv->p_pic[index].pic_data.p_mem, 0, input_size + output_size);
    p_input = p_priv->p_pic[index].pic_data.p_mem;
    p_output = p_priv->p_pic[index].pic_data.p_mem + input_size;
  }
  else
  {
    output_size = rect_size.w * rect_size.h * 4 + 512;
    MT_ASSERT(p_priv->p_pic[index].pic_data.p_mem != NULL);
    MT_ASSERT(p_priv->p_pic[index].pic_data.mem_size >= output_size);
    output_size = p_priv->p_pic[index].pic_data.mem_size;
//    memset(p_priv->p_pic[index].pic_data.p_mem, 0, output_size);
    p_output = p_priv->p_pic[index].pic_data.p_mem;
  }

  //config source pin
  if(p_priv->p_pic[index].pic_data.file_or_mem)
  {
    icmd.cmd = FSRC_CFG_FILE_NAME;
    icmd.p_para = p_priv->p_pic[index].pic_data.file_name;
    //sp_attr.src = SRC_FROM_FILE;
  }
  else
  {
    OS_PRINTF("\n##debug: pic_data.buf_get [0x%x]\n", p_priv->p_pic[index].pic_data.buf_get);
    icmd.cmd = FSRC_CFG_FILE_NAME;
    icmd.lpara = p_priv->p_pic[index].pic_data.buf_get;
    icmd.p_para = NULL;
    //sp_attr.src = SRC_FROM_BUFFER;
  }
  p_fsrc_filter->do_command(p_fsrc_filter, &icmd);

  //config pin
  sp_attr.buffers = 2;
  sp_attr.buffer_size = 100 * KBYTES;
  sp_attr.is_circular = FALSE;
  sp_attr.is_share = FALSE;
  icmd.cmd = FSRC_CFG_SOURCE_PIN;
  icmd.p_para = &sp_attr;
  p_fsrc_filter->do_command(p_fsrc_filter, &icmd);
#if 0
  if(p_priv->p_pic[index].pic_data.file_or_mem)
  {
    //config jpeg filter input pin
    icmd.cmd = PIC_CFG_INPUT_BUFFER;
    icmd.lpara = input_size;
    icmd.p_para = p_input;
    p_pic_filter->do_command(p_pic_filter, &icmd);
  }

  //config jpeg filter output pin
  icmd.cmd = PIC_CFG_OUTPUT_BUFFER;
  icmd.lpara = output_size;
  icmd.p_para = p_output;
  p_pic_filter->do_command(p_pic_filter, &icmd);

  //config render pin
  icmd.cmd = PIC_RENDER_CFG_RECT;
  icmd.p_para = &p_priv->p_pic[index].pic_data.rect;
  p_render_filter->do_command(p_render_filter, &icmd);

  icmd.cmd = PIC_RENDER_CFG_RGN;
  icmd.p_para = p_priv->p_pic[index].pic_data.p_rgn;
  p_render_filter->do_command(p_render_filter, &icmd);

  icmd.cmd = PIC_CFG_SIZE;
  icmd.lpara = 0;
  icmd.p_para = (void *)&rect_size;
  p_pic_filter->do_command(p_pic_filter, &icmd);

  icmd.cmd = PIC_CFG_FLIP;
  icmd.lpara = PIC_FLIP_0;
  icmd.p_para = NULL;
  p_pic_filter->do_command(p_pic_filter, &icmd);

  icmd.cmd = PIC_CFG_OUT_FMT;
  icmd.lpara = JPEG_OUTFMT_444;//PIC_OUTFMT_422;
  icmd.p_para = NULL;
  p_pic_filter->do_command(p_pic_filter, &icmd);

  icmd.cmd = PIC_CFG_DEC_MODE;
  icmd.lpara = p_priv->p_pic[index].pic_data.dec_mode;
  icmd.p_para = NULL;
  p_pic_filter->do_command(p_pic_filter, &icmd);
#else
  pic_cfg.input_buf_size = input_size;
  pic_cfg.p_input_buf = p_input;
  pic_cfg.out_buf_size = output_size;
  pic_cfg.p_out_buf = p_output;
  pic_cfg.w = rect_size.w;
  pic_cfg.h = rect_size.h;
  pic_cfg.flip = PIC_FLIP_0;
  pic_cfg.out_fmt = JPEG_OUTFMT_444;
  pic_cfg.dec_mode = p_priv->p_pic[index].pic_data.dec_mode;
  
  icmd.cmd = PIC_FILTER_CFG;
  icmd.lpara = 0;
  icmd.p_para = &pic_cfg;
  p_pic_filter->do_command(p_pic_filter, &icmd);

#endif

  //config render pin
  icmd.cmd = PIC_RENDER_CFG_RECT;
  icmd.p_para = &p_priv->p_pic[index].pic_data.rect;
  p_render_filter->do_command(p_render_filter, &icmd);

  icmd.cmd = PIC_RENDER_CFG_RGN;
  icmd.p_para = p_priv->p_pic[index].pic_data.p_rgn;
  p_render_filter->do_command(p_render_filter, &icmd);


  p_chain->open(p_chain);
  p_chain->start(p_chain);

  return SUCCESS;
}
/* window procedure of the property sheet. */
static int 
PropSheetCtrlProc (HWND hwnd, int message, WPARAM wParam, LPARAM lParam)
{
    PCONTROL      ctrl;
    PPROPSHEETDATA propsheet;

    ctrl = gui_Control (hwnd); 
    propsheet = (PROPSHEETDATA *) ctrl->dwAddData2;
    
    switch (message) {
        
    case MSG_CREATE: {
#ifdef __TARGET_MSTUDIO__
        SetWindowBkColor(hwnd, 
                GetWindowElementPixel (hwnd, WE_MAINC_THREED_BODY));
#endif

        if (!(propsheet = calloc (1, sizeof (PROPSHEETDATA)))) {
            return -1;
        }
        ctrl->dwAddData2 = (DWORD)propsheet;
        break;
    }
        
    /* make the client size same as window size */
    case MSG_SIZECHANGED: {
        const RECT* rcWin = (RECT *)wParam;
        RECT* rcClient = (RECT *)lParam;
        
        /* cale the width of content page */
        *rcClient = *rcWin;
        propsheet->head_rc.right = RECTWP (rcClient);

        if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
            propsheet->head_rc.top = RECTHP (rcClient) - get_metrics (MWM_ICONY)
                - 2 - _ICON_OFFSET * 2;
            propsheet->head_rc.bottom = RECTHP (rcClient);
        } else {
            propsheet->head_rc.bottom = get_metrics (MWM_ICONY) + 2 
                + _ICON_OFFSET * 2;
        }

        if ((ctrl->dwStyle & 0x0fL)!= PSS_SCROLLABLE) {
            recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle);
        } else {
            HDC hdc; 
            propsheet->head_width = propsheet->head_rc.right;

            if (propsheet->head) {
                PPROPPAGE page;
                hdc = GetClientDC(hwnd);
                page = propsheet->head;
                while(page) {
                    page->width = tab_required_width (hdc, propsheet, page);
                    page = page->next;
                }

                ReleaseDC (hdc);

                update_propsheet (propsheet);
            }
        }
        resize_children (propsheet, rcClient, ctrl->dwStyle);
        InvalidateRect (hwnd, &propsheet->head_rc, TRUE);
        return 1;
    }

    case MSG_DESTROY: {
        PPROPPAGE page, temp;
        page = propsheet->head;
        while (page) {
            temp = page->next;
            destroy_page (page);
            free (page);
            page = temp;
        }
        free (propsheet);
        break;
    }

    case MSG_GETDLGCODE: {
        return DLGC_WANTTAB | DLGC_WANTARROWS;
    }
     
    case PSM_SHEETCMD: {
        int index = 0;
        PPROPPAGE page = propsheet->head;
        while (page) {
            if (SendMessage (page->hwnd, MSG_SHEETCMD, wParam, lParam))
                /* when encounter an error, return page index plus 1. */
                return index + 1;
            index++;
            page = page->next;
        }
        return 0; /* success */
    }

    case PSM_SETACTIVEINDEX: {
        PPROPPAGE page;

        if ((page = get_page (propsheet, wParam)) && page != propsheet->active)         {
            show_hide_page (propsheet->active, SW_HIDE);
            propsheet->active = page;
            update_propsheet (propsheet);
            NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED);
            show_hide_page (page, SW_SHOW);
            
            InvalidateRect (hwnd, &propsheet->head_rc, TRUE);
            return PS_OKAY;
        }
        return PS_ERR;
    }
        
    case PSM_GETACTIVEINDEX: {
        int index = 0;
        PPROPPAGE page = propsheet->head;
        while (page) {
            if (page == propsheet->active) {
                return index;
            }
            index ++;
            page = page->next;
        }
        return PS_ERR;
    }

    case PSM_GETACTIVEPAGE: {
        return (propsheet->active) ? 
          propsheet->active->hwnd : HWND_INVALID;
    }

    case PSM_GETPAGE: {
        int index = 0;
        PPROPPAGE page = propsheet->head;
        while (page) {
            if (index == wParam) {
                return page->hwnd;
            }
            index ++;
            page = page->next;
        }
        return HWND_INVALID;
    }
        
    case PSM_GETPAGEINDEX: {
        int index = 0;
        PPROPPAGE page = propsheet->head;
        while (page) {
            if (page->hwnd == wParam) {
                return index;
            }
            index ++;
            page = page->next;
        }
        return PS_ERR;
    }
        
    case PSM_GETPAGECOUNT: {
        return propsheet->page_count;
    }

    case PSM_GETTITLELENGTH: {
        int len = PS_ERR;
        PPROPPAGE page;
        
        if ((page = get_page (propsheet, wParam))) {
            len = strlen (page->title);
        }
        return len;
    }

    case PSM_GETTITLE: {
        char* buffer = (char*)lParam;
        PPROPPAGE page;
        
        if ((page = get_page (propsheet, wParam))) {
            strcpy (buffer, page->title);
            return PS_OKAY;
        }
        
        return PS_ERR;
    }

    case PSM_SETTITLE: {
        BOOL rc = PS_ERR;
        char* buffer = (char*)lParam;
        PPROPPAGE page;
        HDC hdc;
        if ((ctrl->dwStyle & 0x0fL) != PSS_SCROLLABLE) {
            if ((page = get_page (propsheet, wParam))) {
                rc = set_page_title (page, buffer);
                recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle);
                InvalidateRect (hwnd, &propsheet->head_rc, TRUE);
            }
        } else {
            if ((page = get_page (propsheet, wParam))) {
                hdc = GetClientDC (hwnd);
                rc = set_page_title_normal_style (hdc, propsheet, page, buffer);
                ReleaseDC (hdc);
                InvalidateRect (hwnd, &propsheet->head_rc, TRUE);
            }
        }
        return rc;
    }

    case PSM_ADDPAGE: {
        if ((ctrl->dwStyle & 0x0fL)  != PSS_SCROLLABLE) {
            int index;
            PPROPPAGE page;
            if ((propsheet->head_rc.right / (propsheet->page_count + 1)) < 
                    _MIN_TAB_WIDTH) {
                return PS_ERR;
            }
            if (!(page = calloc (1, sizeof (PROPPAGE)))) {
                return PS_ERR;
            }
            if (!create_page (hwnd, ctrl->dwStyle, propsheet, page, 
                        (DLGTEMPLATE *)wParam, (WNDPROC)lParam)) {
                free (page);
                return PS_ERR;
            }
            
            index = append_page (propsheet, page);
            if (propsheet->active) {
                show_hide_page (propsheet->active, SW_HIDE);
            }
            propsheet->active = page;
            NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED);
            show_hide_page (page, SW_SHOW);
            recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle);
            InvalidateRect (hwnd, &propsheet->head_rc, TRUE);
            return index;
        } else {
            return add_new_page_normal_style (hwnd, ctrl, 
                       propsheet, (DLGTEMPLATE *)wParam, 
                      (WNDPROC)lParam);
        }
    }
        
    case PSM_REMOVEPAGE: {
        if ((ctrl->dwStyle & 0x0fL) != PSS_SCROLLABLE) {
            PPROPPAGE page;
            if ((page = get_page (propsheet, wParam))) {
                remove_page (propsheet, page);
                destroy_page (page);
                free (page);
                recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle);
            } else {
                return PS_ERR;
            }
            if (propsheet->active == page) {
                propsheet->active = propsheet->head;
                NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED);
                if (propsheet->active) {
                    show_hide_page (propsheet->active, SW_SHOW);
                }
            }
            InvalidateRect (hwnd, &propsheet->head_rc, TRUE);
            return PS_OKAY;
        } else {
            return delete_page (hwnd, ctrl, propsheet, wParam);
        }
    }
        
    case MSG_LBUTTONDOWN: {
        click_tab_bar (hwnd, ctrl, propsheet, lParam);
        /* dump_propsheetdata (propsheet); */
        break;
    }

    case MSG_KEYDOWN: {
        PPROPPAGE page, new_active = NULL;
        if (!(lParam & KS_CTRL) || (propsheet->head == NULL)) {
            break;
        }
        /* Key borad message for PSS_COMPACTTAB and PSS_SIMPLE */
        switch (LOWORD (wParam)) {
        case SCANCODE_CURSORBLOCKDOWN:
        case SCANCODE_CURSORBLOCKRIGHT:
            if ((ctrl->dwStyle & 0x0fL)!= PSS_SCROLLABLE) {
                new_active = propsheet->active->next;
                if (new_active == NULL)
                    new_active = propsheet->head;
                break;
            } else {
                scroll_tab_right (hwnd, ctrl, propsheet);
                InvalidateRect (hwnd, &propsheet->head_rc, TRUE);
                return 0;
            }
        case SCANCODE_CURSORBLOCKUP:
        case SCANCODE_CURSORBLOCKLEFT:
            if ((ctrl->dwStyle & 0x0fL)!= PSS_SCROLLABLE) {
                page = propsheet->head;
                if (propsheet->head == propsheet->active) {
                    while (page && page->next) {
                        page = page->next;
                    }
                } else {
                    while (page) {
                        if (page->next == propsheet->active)
                            break;
                        page = page->next;
                    }
                }
                new_active = page;
                break;
            } else {
                scroll_tab_left (hwnd, ctrl, propsheet);
                InvalidateRect (hwnd, &propsheet->head_rc, TRUE);
                return 0;
            }
        }  /* switch */
        if (new_active == NULL) {
            break;
        }
        show_hide_page (propsheet->active, SW_HIDE);
        propsheet->active = new_active;
        NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED);
        show_hide_page (new_active, SW_SHOW);
        InvalidateRect (hwnd, &propsheet->head_rc, TRUE);
        return 0;
    }

    case MSG_NCPAINT:
        
    case MSG_PAINT: {
        HDC  hdc = BeginPaint (hwnd);
        PPROPPAGE page = ((ctrl->dwStyle & 0x0fL) == PSS_SCROLLABLE) ? 
          propsheet->first_display_page : propsheet->head;
        draw_propsheet (hwnd, hdc, ctrl, propsheet, page);
        EndPaint (hwnd, hdc);
        return 0;
    }
        
    default:
        break;
    }
    
    return DefaultControlProc (hwnd, message, wParam, lParam);
}
static int PlatformProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
        case MSG_CREATE:
            {
                if (!hmWnd)
                    hmWnd = hWnd;

                unsigned char* pdr = 0;
                int w,h,p;
                RECT r;
                key_down = FALSE;
                GetClientRect(hWnd, &r);
#if RGB555
            sdc = CreateMemDC(width, height, 16, MEMDC_FLAG_SWSURFACE, 0x7C00, 0x3E0, 0x1F, 0x8000);    
#else
            sdc = CreateMemDC(width, height, 16, MEMDC_FLAG_SWSURFACE, 0xF800, 0x7E0, 0x1F, 0x00);    
#endif
                pdr = LockDC(sdc, &r, &w, &h, &p);
                UnlockDC(sdc);
#if RGB555
                fmt = COLOR_FORMAT_RGB555;
#else
                fmt = COLOR_FORMAT_RGB565;
#endif
                ps_initialize();

                canvas = ps_canvas_create_with_data(pdr, fmt, w, h, p);
                context = ps_context_create(canvas, 0);
                on_init(context, width, height);    
            }
            break;
        case MSG_TIMER:
            on_timer();
            break;
        case MSG_PAINT:
            {
                HDC hdc = BeginPaint(hWnd);
                on_draw(context);
                BitBlt(sdc, 0, 0, width, height, hdc, 0, 0, 0);
                EndPaint(hWnd, hdc);
            }
            return 0;
        case MSG_ERASEBKGND:
            return 0;
        case MSG_LBUTTONDOWN:
            {
                key_down = TRUE;
                on_mouse_event(LEFT_BUTTON_DOWN, key_conv(wParam), LOSWORD(lParam), HISWORD(lParam));
            }
            break;
        case MSG_LBUTTONUP:
            {
                key_down = FALSE;
                on_mouse_event(LEFT_BUTTON_UP, key_conv(wParam), LOSWORD(lParam), HISWORD(lParam));
            }
            break;
        case MSG_MOUSEMOVE:
            {
                DWORD k = key_conv(wParam);
                if (key_down)
                    k |= EVT_LBUTTON;
                on_mouse_event(MOUSE_MOVE, k, LOSWORD(lParam), HISWORD(lParam));
            }
            break;
        case MSG_KEYDOWN:
            on_key_event(KEY_EVENT_DOWN, get_virtual_key(wParam));
            break;
        case MSG_KEYUP:
            on_key_event(KEY_EVENT_UP, get_virtual_key(wParam));
            break;
        case MSG_SIZECHANGED:
            {
                RECT r;
                int w,h,p;
                unsigned char* pdr = 0;
                ps_canvas* old_canvas = 0;
                RECT* rc = (RECT*)lParam;
                width = RECTWP(rc);
                height = RECTHP(rc);
                if (sdc)
                    DeleteMemDC(sdc);

                if (width < 1)
                    width = 1;
                if (height < 1)
                    height = 1;
#if RGB555
            sdc = CreateMemDC(width, height, 16, MEMDC_FLAG_SWSURFACE, 0x7C00, 0x3E0, 0x1F, 0x8000);    
#else
            sdc = CreateMemDC(width, height, 16, MEMDC_FLAG_SWSURFACE, 0xF800, 0x7E0, 0x1F, 0x00);    
#endif
                GetClientRect(hWnd, &r);
                pdr = LockDC(sdc, &r, &w, &h, &p);
                UnlockDC(sdc);
                canvas = ps_canvas_create_with_data(pdr, fmt, w, h, p);
                old_canvas = ps_context_set_canvas(context, canvas);
                ps_canvas_unref(old_canvas);
                on_size(width, height);
            }
            break;
        case MSG_CLOSE:
            on_term(context);
            ps_context_unref(context);
            ps_canvas_unref(canvas);
            ps_shutdown();
            DeleteMemDC(sdc);
            DestroyMainWindow (hWnd);
            PostQuitMessage (hWnd);
            return 0;
    }
    return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
Example #11
0
static void btnPaintContent (PCONTROL pCtrl, HDC hdc, DWORD dwStyle, 
                             RECT* prcText)
{
    switch (dwStyle & BS_CONTENTMASK)
    {
        case BS_TEXT:
        case BS_LEFTTEXT:
        {
            UINT uFormat;
            
            if (dwStyle & BS_MULTLINE)
                uFormat = DT_WORDBREAK;
            else
                uFormat = DT_SINGLELINE;

            if ((dwStyle & BS_TYPEMASK) == BS_PUSHBUTTON
                    || (dwStyle & BS_TYPEMASK) == BS_DEFPUSHBUTTON
                    || (dwStyle & BS_PUSHLIKE))
                uFormat |= DT_CENTER | DT_VCENTER;
            else {
                uFormat = DT_TOP | DT_LEFT;

                if ((dwStyle & BS_ALIGNMASK) == BS_LEFT)
                    uFormat = DT_WORDBREAK | DT_LEFT;
                else if ((dwStyle & BS_ALIGNMASK) == BS_RIGHT)
                    uFormat = DT_WORDBREAK | DT_RIGHT;
                else if ((dwStyle & BS_ALIGNMASK) == BS_CENTER)
                    uFormat = DT_WORDBREAK | DT_CENTER;
            
                if ((dwStyle & BS_ALIGNMASK) == BS_TOP)
                    uFormat = DT_SINGLELINE | DT_TOP;
                else if ((dwStyle & BS_ALIGNMASK) == BS_BOTTOM)
                    uFormat = DT_SINGLELINE | DT_BOTTOM;
                else if ((dwStyle & BS_ALIGNMASK) == BS_VCENTER)
                    uFormat = DT_SINGLELINE | DT_VCENTER;
            }
            
            SetBkColor (hdc, GetWindowBkColor ((HWND)pCtrl));
            if (dwStyle & WS_DISABLED) {
                RECT rc = *prcText;
                
                SetBkMode (hdc, BM_TRANSPARENT);
                SetTextColor (hdc, PIXEL_lightwhite);
                OffsetRect (prcText, 2, 2);
                DrawText (hdc, pCtrl->spCaption, -1, prcText, uFormat);
                
                SetTextColor (hdc, PIXEL_darkgray);
                DrawText (hdc, pCtrl->spCaption, -1, &rc, uFormat);
            }
            else {
                SetBkMode (hdc, BM_TRANSPARENT);
                SetTextColor (hdc, PIXEL_black);
                OffsetRect (prcText, 1, 1);
                DrawText (hdc, pCtrl->spCaption, -1, prcText, uFormat);
            }
        }
        break;
        
        case BS_BITMAP:
            if (BUTTON_DATA(pCtrl)) {
                int x = prcText->left;
                int y = prcText->top;
                int w = RECTWP (prcText);
                int h = RECTHP (prcText);
                PBITMAP bmp = (PBITMAP)(BUTTON_DATA(pCtrl));

                if (dwStyle & BS_REALSIZEIMAGE) {
                    x += (w - bmp->bmWidth) >> 1;
                    y += (h - bmp->bmHeight) >> 1;
                    w = h = 0;
                }
                FillBoxWithBitmap (hdc, x, y, w, h, bmp);
            }
        break;
         
        case BS_ICON:
            if (BUTTON_DATA(pCtrl)) {
                int x = prcText->left;
                int y = prcText->top;
                int w = RECTWP (prcText);
                int h = RECTHP (prcText);
                HICON icon = (HICON)(BUTTON_DATA(pCtrl));

                if (dwStyle & BS_REALSIZEIMAGE) {
                    int iconw, iconh;

                    GetIconSize (icon, &iconw, &iconh);
                    x += (w - iconw) >> 1;
                    y += (h - iconh) >> 1;
                    w = h = 0;
                }

                DrawIcon (hdc, x, y, w, h, icon);
            }
/*
 * FloodFillGenerator:
 */
BOOL GUIAPI FloodFillGenerator (void* context, const RECT* dst_rc, int x, int y,
                CB_EQUAL_PIXEL cb_equal_pixel, CB_FLOOD_FILL cb_flood_fill)
{
    FLOODER_INFO fi;
    int c, done;
    FLOODED_LINE *p;

    /* make sure we have a valid starting point */ 
    if ((x < dst_rc->left) || (x >= dst_rc->right) || (y < dst_rc->top) || (y >= dst_rc->bottom)) {
        return TRUE;
    }

    /* set up the list of flooded segments */
    fi.flood_count = RECTHP (dst_rc);
    fi.flooded_lines = (FLOODED_LINE*) malloc (sizeof(FLOODED_LINE) * fi.flood_count);
    if (!(p = fi.flooded_lines)) {
        return FALSE;
    }

    fi.context = context;
    fi.dst_rc = dst_rc;
    fi.cb_equal_pixel = cb_equal_pixel;
    fi.cb_flood_fill = cb_flood_fill;

    for (c = 0; c < fi.flood_count; c++) {
        p[c].flags = 0;
        p[c].lpos = SHRT_MAX;
        p[c].rpos = SHRT_MIN;
        p[c].y = y;
        p[c].next = 0;
    }

    /* start up the flood algorithm */
    flooder (&fi, x, y);

    /* continue as long as there are some segments still to test */
    do {
        done = TRUE;

        /* for each line on the screen */
        for (c = 0; c < fi.flood_count; c++) {

            p = FLOOD_LINE (c);
    
            /* check below the segment? */
            if (p->flags & FLOOD_TODO_BELOW) {
                p->flags &= ~FLOOD_TODO_BELOW;
            if (check_flood_line (&fi, p->y+1, p->lpos, p->rpos)) {
                done = FALSE;
                p = FLOOD_LINE (c);
            }
        }

        /* check above the segment? */
        if (p->flags & FLOOD_TODO_ABOVE) {
            p->flags &= ~FLOOD_TODO_ABOVE;
            if (check_flood_line (&fi, p->y-1, p->lpos, p->rpos)) {
                done = FALSE;
                /* special case shortcut for going backwards */
                if ((c < RECTHP (dst_rc)) && (c > 0))
                    c -= 2;
                }
            }
        }

    } while (!done);

    free (fi.flooded_lines);
    return TRUE;
}