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

📄 picshow.c

📁 飞漫公司的minigui的1.6.8收费增值版本的demon等示例程序
💻 C
📖 第 1 页 / 共 2 页
字号:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#ifndef WIN32#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <time.h>#include <sys/time.h>#endif#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/control.h>#include <minigui/mywindows.h>#include <minigui/mgext.h>#include <minigui/skin.h>#include "bitmap.h"
#include "english_config.h"#define IDC_PICTURESHOW_FILENAME       1static HWND hPictureShow=HWND_INVALID;static int  showstyle = 0;static int  picnum, firstpic;static char **pichead;static int hidemenu = 0, dispmenu = 0;static HDC mdc;static RECT rcMenu[] = {    {115, 155, 200, 215},    {115, 155, 200, 174},    {115, 175, 200, 194},    {115, 195, 200, 215}};static RECT rcButton[] = {    {2, 216, 105, 238},    {108, 216, 211, 238},    {214, 216, 317, 238},    {0, 4, 320, 16}};typedef struct {    POINT *pos;    int w, h;} PPOS;POINT pful[1] = {{0, 0}}, p2x2[4], p3x3[9];PPOS ppful = {pful, 320, 240}, pp2x2 = {p2x2}, pp3x3 = {p3x3};static RECT frame2x2[4];static RECT frame3x3[9];static int cursel, oldsel;static void refreshmenu(HDC hdc);static void initframe(void){    int left = 10, top = 15;    int x, y, i, space = 5;    int frame_w, frame_h;     frame_h = (215 - 30) / 2;    pp2x2.h = frame_h - 2;    frame_w = frame_h * 4 / 3;    pp2x2.w = frame_w - 2;    left = (320 - 3 * space - 2 * frame_w) / 2;    i = 0;    for (y = 0; y < 2; y++) {        for (x = 0; x < 2; x++) {            frame2x2[i].top = top + space + space * y + y * frame_h;            p2x2[i].y = frame2x2[i].top + 1;            frame2x2[i].left = left + space + space * x + x * frame_w;            p2x2[i].x = frame2x2[i].left + 1;            frame2x2[i].bottom = frame2x2[i].top + frame_h;            frame2x2[i].right = frame2x2[i].left + frame_w;            i++;        }    }    frame_h = (215 - 35) / 3;    pp3x3.h = frame_h - 2;    frame_w = frame_h * 4 / 3;    pp3x3.w = frame_w - 2;    left = (320 - 4 * space - 3 * frame_w) / 2;    i = 0;    for (y = 0; y < 3; y++) {        for (x = 0; x < 3; x++) {            frame3x3[i].top = top + space + space * y + y * frame_h;            p3x3[i].y = frame3x3[i].top + 1;            frame3x3[i].left = left + space + space * x + x * frame_w;             p3x3[i].x = frame3x3[i].left + 1;            frame3x3[i].bottom = frame3x3[i].top + frame_h;            frame3x3[i].right = frame3x3[i].left + frame_w;            i++;        }    }}static void drawframe(HWND hwnd){    RECT *rect;    HDC hdc;    char *picname = pichead[firstpic + cursel];    hdc = GetClientDC(hwnd);    if (showstyle == 1)        rect = frame2x2;    else if (showstyle == 2)        rect = frame3x3;    else        return;    if (oldsel >= 0) {        SetPenColor(hdc, RGB2Pixel (HDC_SCREEN, 0, 0, 0));        Rectangle(hdc, rect[oldsel].left - 1, rect[oldsel].top - 1,                             rect[oldsel].right + 1, rect[oldsel].bottom + 1);    }    if (firstpic + cursel <= picnum - 1) {        SetPenColor(hdc, RGB2Pixel (HDC_SCREEN, 250, 250, 250));        Rectangle(hdc, rect[cursel].left - 1, rect[cursel].top - 1,                            rect[cursel].right + 1, rect[cursel].bottom + 1);    }        if (!hidemenu) {        SetBkMode(hdc, BM_TRANSPARENT);        SetTextColor(hdc, RGB2Pixel(hdc, 250, 250, 250));        BitBlt(mdc, 0, 4, 320, 12, hdc, 0, 4, 0);        DrawText(hdc, picname, -1, &rcButton[3], DT_CENTER);    }    ReleaseDC(hdc);}static void DisPic(HWND hwnd, char **pic, POINT *pos, int w, int h, int count){    int i, x, y;    HDC hdc;     hdc = GetClientDC(hwnd);    SetBrushColor (hdc, 0);    FillBox(hdc, 0, 0, 320, 240);    SetBrushColor (mdc, 0);    FillBox(mdc, 0, 0, 320, 240);    refreshmenu(hdc);    for (i = 0; i < count; i++) {        int fitw, fith;        BITMAP bitmap;        if (pdag_load_bitmap(&bitmap, NULL, NULL, pic[i]) < 0)            continue;        if (bitmap.bmWidth <= w && bitmap.bmHeight <= h) {            fitw = bitmap.bmWidth;            fith = bitmap.bmHeight;            x = pos[i].x + (w - bitmap.bmWidth) / 2;            y = pos[i].y + (h - bitmap.bmHeight) / 2;        }        else {            fitw = w;            fith = w * ((float)bitmap.bmHeight / (float)bitmap.bmWidth);            x = pos[i].x;            y = pos[i].y + (h - fith) / 2;            if (fith > h) {                fith = h;                fitw = h * ((float)bitmap.bmWidth / (float)bitmap.bmHeight);                x = pos[i].x + (w - fitw) / 2;                y = pos[i].y;            }        }        FillBoxWithBitmap (mdc, x, y, fitw, fith, &bitmap);        FillBoxWithBitmap (hdc, x, y, fitw, fith, &bitmap);        pdag_unload_bitmap(&bitmap);    }    refreshmenu(hdc);    ReleaseDC(hdc);}static void disppic (HWND hwnd, char **pic, int num){    PPOS *pos;    if (showstyle == 0) {        pos = &ppful;    }    else if (showstyle == 1) {        pos = &pp2x2;    }    else if (showstyle == 2) {        pos = &pp3x3;    }    else        return;    DisPic(hwnd, pic, pos->pos, pos->w, pos->h, num);}#define DISPNUM (firstpic + (showstyle + 1) * (showstyle + 1) > picnum) ? \                (picnum - firstpic) : (showstyle + 1) * (showstyle + 1)static void lfsel(HWND hwnd, int direction){    int n = 0;    if (dispmenu)        return;    if (showstyle == 0) {        if (direction) {            if (firstpic < picnum - 1) {                firstpic++;                disppic (hwnd, pichead + firstpic, DISPNUM);            }        }        else {            if (firstpic > 0) {                firstpic--;                disppic (hwnd, pichead + firstpic, DISPNUM);            }        }        return;    }    else if (showstyle == 1)        n = 4;    else if (showstyle == 2)        n = 9;    oldsel = cursel;    if (direction) {        if (firstpic + cursel + 1 < picnum) {            if( cursel + 1 < n)                 cursel++;            else {                firstpic += n;                cursel = 0;                disppic (hwnd, pichead + firstpic, DISPNUM);            }        }    }    else {        if (cursel > 0)            cursel--;        else if (firstpic > 0) {            firstpic -= n;            cursel = n - 1;            disppic (hwnd, pichead + firstpic, DISPNUM);        }    }    drawframe(hwnd);}static void updownsel(HWND hwnd, int direction){    if (dispmenu)        return;    if (!showstyle) {        if (direction) {            if (firstpic < picnum - 1) {                firstpic++;                disppic (hwnd, pichead + firstpic, DISPNUM);            }        }        else {            if (firstpic > 0) {                firstpic--;                disppic (hwnd, pichead + firstpic, DISPNUM);            }        }        goto exit;    }    oldsel = cursel;    if (direction) {        if (cursel + (showstyle + 1) < (showstyle + 1) * (showstyle + 1)) {            if (firstpic + cursel + showstyle + 1 <= picnum - 1)                cursel += (showstyle + 1);             else                goto exit;        }        else if (firstpic + (showstyle + 1) * (showstyle + 1) <= picnum - 1) {            firstpic += (showstyle + 1) * (showstyle + 1);            cursel = cursel % (showstyle + 1);            if (firstpic + cursel > picnum - 1)                cursel = picnum % (showstyle + 1) - 1;            disppic (hwnd, pichead + firstpic, DISPNUM);        }    }    else {        if (cursel - (showstyle + 1) >= 0)            cursel -= (showstyle + 1);        else if (firstpic > 0) {            firstpic -= (showstyle + 1) * (showstyle + 1);            cursel = (showstyle + 1) * showstyle + cursel;            disppic (hwnd, pichead + firstpic, DISPNUM);        }    }    drawframe(hwnd);exit:    return;}static void mousesel(HWND hwnd, int x, int y){    int i, count;    RECT *rect = NULL;    if (dispmenu) {        return;    }    if (!showstyle)        return;    oldsel = cursel;    if (showstyle == 1)        rect = frame2x2;    else if (showstyle == 2)        rect = frame3x3;    count = (showstyle + 1) * (showstyle + 1);    for (i = 0; i < count; i++) {        if (PtInRect (&rect[i], x, y)) {            if (firstpic + i > picnum - 1)                break;            cursel = i;            drawframe(hwnd);            break;        }    }}static void cancelsel(HWND hwnd){    RECT *rect = NULL;    HDC hdc;    if (!showstyle || cursel < 0)        return;    oldsel = cursel;    if (showstyle == 1)        rect = frame2x2;    else if (showstyle == 2)        rect = frame3x3;     hdc = GetClientDC(hwnd);    SetPenColor (hdc, RGB2Pixel(hdc, 0, 0, 0));    Rectangle (hdc, rect[cursel].left, rect[cursel].top, rect[cursel].right, rect[cursel].bottom);    ReleaseDC(hdc);    oldsel = -1;}static void fullpic(HWND hwnd){    if (showstyle) {        cancelsel(hwnd);        showstyle = 0;        firstpic = firstpic + cursel;        cursel = 0;        disppic (hwnd, pichead + firstpic, DISPNUM);        InvalidateRect (hwnd, NULL, FALSE);    }}

⌨️ 快捷键说明

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