Hi. When I copy file in program fltk is stopped. Progressbar stay in 0. Why GUI 
don't respond(answer?)?

Link to program: http://adamchyla.pl/kopiuj.zip
<i>(kopiuj - in english: copy)</i>

<b>include/czytaj.hpp</b>
<i>/*
Kopiuj v. 1.0
Copyright (C) 2008 Adam Chyła

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

//  CZYTAJ

#ifndef CZYTAJ_HPP
#define CZYTAJ_HPP

#include <iostream>
#include <fstream>

using namespace std;

void czytaj(char nazwa[])
{
        ifstream plik;
        plik.open(nazwa, ios::binary);

        string str;

        int line_in_file;
        while(getline(plik, str))
        {line_in_file++;}

        Group1_ProgressBar1->range(0, line_in_file);

        plik.close();
}

#endif
<i/>

<br><br><b>include/kopiowanie.hpp</b><br><i>/*
Kopiuj v. 1.0
Copyright (C) 2008 Adam Chyła

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

//  KOPIOWANIE

#ifndef KOPIOWANIE_HPP
#define KOPIOWANIE_HPP

#include <cstdio>
#include "kopiuj.hpp"
#include "czytaj.hpp"

void kopiowanie()
{   // SOURCE FILE
        char 
zrodlo[]="C:\\Users\\Adam\\Downloads\\OOo_2.4.1_Win32Intel_install_wJRE_pl.exe";

        int rozmiar_zrodla = sizeof(zrodlo);
        for(int i; i<rozmiar_zrodla; i++)
        {
                if (zrodlo[i] == '\\')
                zrodlo[i] = '/';
        }

        czytaj(zrodlo);

        kopiuj(zrodlo, "C:/asd.exe");
}

#endif
</i><br><br>
<b>include/kopiuj.hpp</b>
<br><i>/*
Kopiuj v. 1.0
Copyright (C) 2008 Adam Chyła

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

//  KOPIUJ

#ifndef KOPIUJ_HPP
#define KOPIUJ_HPP

#include <iostream>
#include <fstream>

using namespace std;

void dodaj()
{
Group1_ProgressBar1->position(Group1_ProgressBar1->position() + 1);
}

void kopiuj(char nazwa[], char nazwa2[])
{
        ifstream plik;
        plik.open(nazwa, ios::binary);

        ofstream plik2;
        plik2.open(nazwa2, ios::binary);

        string str;

        while(getline(plik, str))
        {
                plik2 << str << "\n";
                dodaj();
                // I'm try there this 
Group1_ProgressBar1->position(Group1_ProgressBar1->position() + 1); but efect 
this same
        }

        plik.close();
        plik2.close();
}

#endif
</i><br><br>
<b>include/szczegoly.hpp<b/>
<i>/*
Kopiuj v. 1.0
Copyright (C) 2008 Adam Chyła

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

//  SZCZEGÓŁY

#ifndef SZCZEGOLY_HPP
#define SZCZEGOLY_HPP

void szczegoly(Widget *, void *)
{
        if (szczegoly_bool == 0)
        {

                szczegoly_bool = 1;
                Button1->label("@-990>; Widok podstawowy");

                MainWindowHeight += 50;
                MainWindow->resize(MainWindowWeight, MainWindowHeight);
                MainWindow->redraw();

                Group1->show();

        }
        else
        {

                szczegoly_bool = 0;
                Button1->label("@-9270>; Widok szczegółowy");

                MainWindowHeight -= 50;
                MainWindow->resize(MainWindowWeight, MainWindowHeight);
                MainWindow->redraw();

                Group1->hide();

        }
}

#endif
<i/>
<b>main.cxx</b>
<i>/*
Kopiuj v. 1.0
Copyright (C) 2008 Adam Chyła

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

//  MAIN


#include <fltk/Button.h>
#include <fltk/ProgressBar.h>
#include <fltk/run.h>
#include <fltk/Widget.h>
#include <fltk/Window.h>
#include <fltk/Group.h>

using namespace fltk;

Window *MainWindow;
Button *Button1;
Group *Group1;
ProgressBar *Group1_ProgressBar1, *ProgressBar1;

int MainWindowHeight = 159;
int MainWindowWeight = 400;

int align_i = ALIGN_LEFT + ALIGN_INSIDE;
bool szczegoly_bool = 0;

#include "include/szczegoly.hpp"
#include "include/kopiowanie.hpp"

void anuluj(Widget *, void *);
//int a;
//#include <iostream>
void test(Widget *, void*)
{
//Group1_ProgressBar1->range(0,100);
//for (int i=0; i<100; i++)
//{
//a++;
//std::cout <<a<<"\n";
//Group1_ProgressBar1->position(Group1_ProgressBar1->position() + 1);
//}
kopiowanie();
}

int main(int argc, char **argv)
{
        Window MainWindow(MainWindowWeight, MainWindowHeight, "Kopiuj v.1.0");
        ::MainWindow = &MainWindow;
        MainWindow.begin();

                Widget Widget1(5, 40, 390, 2);

                Widget Widget2(20, 0, 380, 40, "Przygotowywanie do 
kopiowania...");
                Widget2.color(MainWindow.color());
                Widget2.box(FLAT_BOX);
                Widget2.align(align_i);

                Widget Widget3(20, 50, 15, 15, "Z:");
                Widget3.color(MainWindow.color());
                Widget3.box(FLAT_BOX);
                Widget3.align(align_i);

                Widget Widget4(40, 50, 340, 15, "Oczekiwanie...");
                Widget4.color(MainWindow.color());
                Widget4.box(FLAT_BOX);
                Widget4.align(align_i);

                Widget Widget5(20, 65, 20, 15, "Do:");
                Widget5.color(MainWindow.color());
                Widget5.box(FLAT_BOX);
                Widget5.align(align_i);

                Widget Widget6(40, 65, 340, 15, "Oczekiwanie...");
                Widget6.color(MainWindow.color());
                Widget6.box(FLAT_BOX);
                Widget6.align(align_i);

                ProgressBar ProgressBar1(20, 87, 360, 14);
                ProgressBar1.range(0, 100);
                ProgressBar1.position(0);
                ProgressBar1.box(THIN_DOWN_BOX);
                ProgressBar1.textcolor(BLACK);
                ProgressBar1.selection_color(DARK_BLUE);
                ProgressBar1.color(MainWindow.color());
                ProgressBar1.showtext(0);
                ::ProgressBar1 = &ProgressBar1;

                Button Button1(20, 125, 130, 23, "@-9270>; Widok 
szczegółowy");
                Button1.box(FLAT_BOX);
                Button1.callback(szczegoly);
                ::Button1 = &Button1;

                Button Button2(300, 125, 75, 23, "Anuluj");
                Button2.callback(test);//anuluj);

                Group Group1(0, 160, 400, 40);
                Group1.color(MainWindow.color());
                ::Group1 = &Group1;
                Group1.begin();

                        Widget Group1_Widget1(20, 4, 125, 15, "Postęp 
kopiowania pliku:");
                        Group1_Widget1.color(MainWindow.color());
                        Group1_Widget1.align(align_i);
                        Group1_Widget1.box(FLAT_BOX);

                        ProgressBar Group1_ProgressBar1(20, 24, 360, 14);
                        Group1_ProgressBar1.range(0, 100);
                        Group1_ProgressBar1.position(0);
                        Group1_ProgressBar1.box(THIN_DOWN_BOX);
                        Group1_ProgressBar1.textcolor(BLACK);
                        Group1_ProgressBar1.selection_color(DARK_BLUE);
                        Group1_ProgressBar1.color(MainWindow.color());
                        Group1_ProgressBar1.showtext(0);
                        ::Group1_ProgressBar1 = &Group1_ProgressBar1;

                Group1.end();

        MainWindow.end();
        MainWindow.show();
        run();
        return 0;
}

void anuluj(Widget *, void *)
{
        MainWindow->hide();
}
<i/>
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to