简体   繁体   English

如何画一个循环的东西(FLTK / C ++)?

[英]How to draw things in a loop (FLTK/C++)?

I have a problem drawing more than one line, it only show one line i use 我在绘制多条线时遇到问题,它仅显示我使用的一条线

void fl_push_clip(int x, int y, int w, int h);

but nothing seems to work 但似乎没有任何作用

I try something like this 我尝试这样的事情

for (int i = 1; i < 10; i++) {
        int x = 10 * i, y = 10 * i;
        int w = 70 * i, h = 70 * i;
        void fl_push_clip(int x, int y, int w, int h);

        cout << "TEST" << endl;
    }

i use cout to see if the for works 我使用cout来查看是否适用

#include <FL/Fl.H>
#include <FL/Fl_Widget.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Int_Input.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Color_Chooser.H>

int main(int argc, char ** argv)
{
    int width = 90, height = 80;
    int rowmax = 4, colmax = 7;

    window = new Fl_Window(colmax * width + 20, rowmax * height + 240);
    window->color(FL_DARK_GREEN);

    Fl_Int_Input input = new Fl_Int_Input(140, rowmax * height + 20, colmax * width - 160, 20, "test1");
    input->labelfont(FL_BOLD + FL_ITALIC);

    for (int i = 1; i < 10; i++) {
        int x = 10 * i, y = 10 * i;
        int w = 70 * i, h = 70 * i;
        void fl_push_clip(int x, int y, int w, int h);

        cout << "TEST" << endl;
    }   
    window->end();
    window->show(argc, argv);
    return Fl::run();
}

I expect to see if the for is useful to draw multiple shapes or find an alternative to do the same 我希望看看for是否对绘制多个形状或找到其他替代方法有用

The code here is a declaration: it does not call the code at all 这里的代码是一个声明:它根本不调用代码

for (int i = 1; i < 10; i++) {
    int x = 10 * i, y = 10 * i;
    int w = 70 * i, h = 70 * i;
    void fl_push_clip(int x, int y, int w, int h); // This is a declaration

    cout << "TEST" << endl;
}

If you wish to call the routine use 如果您想致电常规使用

for (int i = 1; i < 10; i++) {
    int x = 10 * i, y = 10 * i;
    int w = 70 * i, h = 70 * i;
    fl_push_clip(x, y, w, h); // This is a call

    cout << "TEST" << endl;
}

Do you have std namespace defined somewhere? 您在某处定义了std名称空间吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM