如何在循环中绘制东西(fltk/c )

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

本文关键字:fltk 循环 绘制      更新时间:2023-10-16

我有一个问题绘制多个行,它仅显示一行我使用

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

,但似乎没有任何作用

我尝试这样的事情

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;
    }

我使用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();
}

我希望看到for是否有助于绘制多个形状或找到相同的替代方案

此处的代码是一个声明:它根本不调用代码

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;
}

如果您想调用常规使用

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;
}

您是否在某处定义了std名称空间?