Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
6.4 kB
8
Indexable
Never
#include <iostream>
#include <winbgim.h>
#include <graphics.h>

using namespace std;

char numeButoane[9][20]={"1.Menu", "2.Open", "3.Back", "4.Rename", "5.Create", "6.Copy", "7.Move", "8.Delete", "9.Quit"};

void desenButon(int x, int y, int width, int height,char text[])//deseneaza butonul Enter,Exit si 1-9
{
    setfillstyle(SOLID_FILL, BLACK);
    bar(x, y, x + width, y + height);

    int textWidth = textwidth(text);
    int textHeight = textheight(text);
    setcolor(WHITE);
    int textX = x + (width - textWidth) / 2;
    int textY = y + (height - textHeight) / 2;
    outtextxy(textX, textY, text);
}

bool isMouseOverButton(int x, int y, int width, int height, int mx, int my)
{
    return (mx >= x && mx <= x + width && my >= y && my <= y + height);
}

//butonul 5.Create :

/*bool createDirectory()
{
    string directoryName;
    cout << "Enter directory name: ";
    cin >> directoryName;
    path directoryPath = directoryName;
    if (create_directory(directoryPath))
    {
        cout << "Directory '" << directoryName << "' created successfully!" << endl;
        return true;
    }
    else
    {
        cout << "Error creating directory '" << directoryName << "'." << endl;
        return false;
    }
}*/


int main()
{
    int width = 1000;
    int height = 600;

    initwindow(width, height);

    int windowWidth = getmaxx();
    int windowHeight = getmaxy();
    start://prima fereastra (1.Menu)
        setfillstyle(SOLID_FILL, COLOR(66, 72, 245));
        bar(0, 0, windowWidth, windowHeight);
        desenButon((windowWidth - 250) / 2, (windowHeight - 80) / 2 - 50, 250, 80,"Enter");
        desenButon((windowWidth - 80) / 2, (windowHeight - 30) / 2 + 70, 80, 30,"Exit");

    meniu_principal:
    while (1)
    {
        int mx, my;

        if (ismouseclick(WM_LBUTTONDOWN))
        {
            getmouseclick(WM_LBUTTONDOWN, mx, my);

            if (isMouseOverButton((windowWidth - 250) / 2, (windowHeight - 80) / 2 - 50, 250, 80, mx, my))//click pe Enter
            {
                cleardevice();
                setfillstyle(SOLID_FILL, COLOR(66, 72, 245));
                bar(0, 0, windowWidth, (9 * windowHeight) / 10);

                setfillstyle(SOLID_FILL, BLACK);
                bar(0, (9 * windowHeight) / 10, windowWidth, windowHeight);
                setcolor(COLOR(3, 244, 252));
                line(0,((9 * windowHeight) / 10 + windowHeight) / 2,windowWidth,((9 * windowHeight) / 10 + windowHeight) / 2);

                for (int i = 0; i < 9; ++i)
                {
                    desenButon(i * width / 9, ((9 * height) / 10 + height) / 2, width / 9, height - ((9 * height) / 10 + height) / 2, numeButoane[i]);
                }
                setcolor(COLOR(3, 244, 252));
                for(int i = 1; i < 9 ; i++)
                    line(i * width / 9, ((9 * height) / 10 + height) / 2, i * width / 9, height);
                line(width / 2, 0, width / 2, 9 * windowHeight / 10);
                int ok=1;
                while(1)
                {
                    if (ismouseclick(WM_LBUTTONDOWN))
                    {
                        int m1,m2;
                        getmouseclick(WM_LBUTTONDOWN, m1, m2);
                        if (isMouseOverButton(0, ((9 * height) / 10 + height) / 2, width / 9, height - ((9 * height) / 10 + height) / 2, m1, m2))
                        {
                            ok=0;
                            cleardevice();
                            goto start;
                        }//1.Menu
                        if (isMouseOverButton(width / 9, ((9 * height) / 10 + height) / 2, width / 9, height - ((9 * height) / 10 + height) / 2, m1, m2))
                        {
                            ok=0;
                            break;
                        }//2.Open
                        if (isMouseOverButton(2 * width / 9, ((9 * height) / 10 + height) / 2, width / 9, height - ((9 * height) / 10 + height) / 2, m1, m2))
                        {
                            ok=0;
                            break;
                        }//3.Back
                        if (isMouseOverButton(3 * width / 9, ((9 * height) / 10 + height) / 2, width / 9, height - ((9 * height) / 10 + height) / 2, m1, m2))
                        {
                            ok=0;
                            break;
                        }//4.Rename
                        if (isMouseOverButton(4 * width / 9, ((9 * height) / 10 + height) / 2, width / 9, height - ((9 * height) / 10 + height) / 2, m1, m2))
                        {
                            ok=0;
                            break;
                        }//5.Create
                        if (isMouseOverButton(5 * width / 9, ((9 * height) / 10 + height) / 2, width / 9, height - ((9 * height) / 10 + height) / 2, m1, m2))
                        {
                            ok=0;
                            break;
                        }//6.Copy
                        if (isMouseOverButton(6 * width / 9, ((9 * height) / 10 + height) / 2, width / 9, height - ((9 * height) / 10 + height) / 2, m1, m2))
                        {
                            ok=0;
                            break;
                        }//7.Move
                        if (isMouseOverButton(7 * width / 9, ((9 * height) / 10 + height) / 2, width / 9, height - ((9 * height) / 10 + height) / 2, m1, m2))
                        {
                            ok=0;
                            break;
                        }//8.Delete
                        if (isMouseOverButton(8 * width / 9, ((9 * height) / 10 + height) / 2, width / 9, height - ((9 * height) / 10 + height) / 2, m1, m2))
                        {
                            ok=0;
                            break;
                        }//9.Quit
                    }
                }
                if(ok==0)//pentru a inchide programul de tot (ar trebui sa fie strict pentru butonul 9.Quit)
                    break;
            }

            if (isMouseOverButton((windowWidth - 80) / 2, (windowHeight - 30) / 2 + 70, 80, 30, mx, my))//click pe Exit
            {
                break;
            }
        }
    }

    //getch();
    closegraph();
    return 0;
}
Leave a Comment