diff options
| author | maxim nikonov <maxim.nikonov@hqo.co> | 2026-02-06 18:12:40 +0500 |
|---|---|---|
| committer | maxim nikonov <maxim.nikonov@hqo.co> | 2026-02-06 18:12:40 +0500 |
| commit | b4995f979d127cea667b4e2b71c91e9db4ab52ef (patch) | |
| tree | fbebc775e10932bace8d6a7c3481b1ba200c64db | |
| parent | 9575eb0a1ffa8150f70f88b5f6b55f342c3c0088 (diff) | |
wip
137 files changed, 2382 insertions, 1819 deletions
diff --git a/2026-02-06-claudemd.txt b/2026-02-06-claudemd.txt index 7598bc471..de80cf3e4 100644 --- a/2026-02-06-claudemd.txt +++ b/2026-02-06-claudemd.txt @@ -12,978 +12,985 @@ │ ~/Desktop/fltk │ │ ╰──────────────────────────────────────────────────────────────────────────────╯ ══════════════════ Conversation compacted · ctrl+o for history ═════════════════ - ⎿ Read test/threads.cxx (240 lines) - ⎿ Read test/penpal.cxx (316 lines) - ⎿ Read test/clipboard.cxx (277 lines) - ⎿ Referenced file test/utf8.cxx - ⎿ Read test/group.cxx (149 lines) + ⎿ Referenced file Makefile + ⎿ Read xlibs/fetch_headers.sh (95 lines) + ⎿ Read xlibs/README.md (64 lines) + ⎿ Read src/Fl_Cairo.cxx (214 lines) + ⎿ Read src/Fl_Private.H (73 lines) ⎿ Todo list read (4 items) ⎿ Plan file referenced (~/.claude/plans/compiled-petting-babbage.md) -⏺ Продолжаю работу над Фазой 6 — удаление std:: из test/. Сначала проверю, какие - файлы используют std::. +⏺ Продолжаю с Фазы 8: Cairo/Pango стратегия. -⏺ Search(pattern: "std::", path: "test", output_mode: "content") - ⎿ Found 25 lines (ctrl+o to expand) + Согласно плану, Cairo+Pango+glib слишком велики для бандлинга (~1M строк). + Нужно: + 1. Оставить как системные зависимости + 2. Добавить режим USE_CAIRO=0 для чистого Xlib+Xft рендеринга + 3. Задокументировать зависимости -⏺ Вижу 5 файлов с std::. Начну с простых случаев. + Начну с анализа использования Cairo в проекте. -⏺ Read(test/adjuster.cxx) - ⎿ Read 53 lines - -⏺ Read(test/ask.cxx) - ⎿ Read 154 lines - -⏺ Проверю, какие C-style альтернативы доступны для этих функций. - -⏺ Search(pattern: "format\(", path: "FL/Fl_Valuator.H", output_mode: "content") - ⎿ Found 1 line (ctrl+o to expand) - -⏺ Search(pattern: "fl_input\(", path: "FL/fl_ask.H", output_mode: "content") - ⎿ Found 0 lines - -⏺ Read(FL/Fl_Valuator.H) - ⎿ Read 16 lines - -⏺ Search(pattern: "fl_input|fl_password", path: "FL/fl_ask.H", output_mode: - "content") - ⎿ Found 4 lines (ctrl+o to expand) - -⏺ Отлично, есть C-style альтернативы. Исправляю оба файла. - -⏺ Update(test/adjuster.cxx) - ⎿ Added 3 lines, removed 2 lines - 23 void adjcb(Fl_Widget *o, void *v) { - 24 Fl_Adjuster *a = (Fl_Adjuster*)o; - 25 Fl_Box *b = (Fl_Box *)v; - 26 - std::string new_label = a->format_str(); - 27 - b->copy_label(new_label.c_str()); - 26 + char new_label[64]; - 27 + a->format(new_label); - 28 + b->copy_label(new_label); - 29 b->redraw(); - 30 } - 31 - -⏺ Update(test/ask.cxx) - ⎿ Added 5 lines, removed 6 lines - 34 - 35 void rename_button(Fl_Widget *o, void *v) { - 36 int what = fl_int(v); - 37 - int ret = 0; - 38 - std::string input; - 37 + const char *input; - 38 if (what == 0) { - 39 fl_message_icon_label("§"); - 41 - input = fl_input_str(ret, 0, "Input (no size limit, use ctr - -l/j for newline):", o->label()); - 40 + input = fl_input("Input (no size limit, use ctrl/j for newl - +ine):", o->label()); - 41 } else { - 42 fl_message_icon_label("€"); - 44 - input = fl_password_str(ret, 20, "Enter password (max. 20 c - -haracters):", o->label()); - 43 + input = fl_password(20, "Enter password (max. 20 characters - +):", o->label()); - 44 } - 46 - if (ret == 0) { - 47 - o->copy_label(input.c_str()); - 45 + if (input) { - 46 + o->copy_label(input); - 47 o->redraw(); - 48 } - 49 } - ⎿ Found 10 new diagnostic issues in 1 file (ctrl+o to expand) - -⏺ Теперь исправлю utf8.cxx. - -⏺ Read(test/utf8.cxx) - ⎿ Read 40 lines - ⎿ Found 10 new diagnostic issues in 1 file (ctrl+o to expand) - -⏺ Read(test/utf8.cxx) - ⎿ Read 70 lines - -⏺ Вижу также override на строке 508. Исправлю весь блок. - -⏺ Update(test/utf8.cxx) - ⎿ Added 15 lines, removed 19 lines - 505 "Only the first Unicode code point will be display - ed.\n" - 506 "Example: U+1F308 '🌈' 0x{f0,9f,8c,88}"); - 507 } - 508 - int handle(int event) override { - 508 + int handle(int event) { - 509 switch (event) { - 510 case FL_DND_ENTER: return 1; - 511 case FL_DND_DRAG: return 1; - ... - 513 case FL_PASTE: { - 514 int i, n; - 515 const char *t = Fl::event_text(); - 516 - char temp[10]; - 516 unsigned int ucode = fl_utf8decode(t, t + Fl::event_le - ngth(), &n); - 517 if (n == 0) { - 518 value(""); - ... - 523 // - length = 30: "U+1F308 '🌈' 0x{f0,9f,8c,88}" -- UT - F-8 encoding = 4 bytes - 524 // - length = 31: "U+10FFFF '' 0x{f4,8f,bf,bf}" -- UT - F-8 encoding = 4 bytes - 525 // - 527 - static const size_t max_size = 32; - 526 // begin with first Unicode code point of Fl::event_te - xt() in single quotes - 527 int tl = fl_utf8len(t[0]); - 528 if (tl < 1) - 529 tl = 1; - 532 - std::string buffer; - 533 - buffer.reserve(max_size); - 530 + char buffer[64]; - 531 + char *p = buffer; - 532 // add Unicode code point: "U+0000" - "U+10FFFF" (4-6 - hex digits) - 535 - buffer += "U+"; - 536 - snprintf(temp, 9, "%04X", ucode); - 537 - buffer += temp; - 533 + p += sprintf(p, "U+%04X '", ucode); - 534 // add Unicode character in quotes - 539 - buffer += " '"; - 540 - buffer += std::string(t, tl); - 541 - buffer += "'"; - 535 + memcpy(p, t, tl); - 536 + p += tl; - 537 + *p++ = '\''; - 538 // add hex UTF-8 codes, format: "0xab" or "0x{de,ad,be - ,ef}" - 543 - buffer += " 0x"; - 539 + p += sprintf(p, " 0x"); - 540 if (n > 1) - 545 - buffer += "{"; - 541 + *p++ = '{'; - 542 for (i = 0; i < n; i++) { - 543 if (i > 0) - 548 - buffer += ','; - 549 - snprintf(temp, 9, "%02x", (unsigned char)t[i]); - 550 - buffer += temp; - 544 + *p++ = ','; - 545 + p += sprintf(p, "%02x", (unsigned char)t[i]); - 546 } - 547 if (n > 1) - 553 - buffer += "}"; - 554 - value(buffer.c_str()); - 555 - printf("size: %lu\n", buffer.size()); fflush(stdout); - 548 + *p++ = '}'; - 549 + *p = '\0'; - 550 + value(buffer); - 551 + printf("size: %lu\n", (unsigned long)(p - buffer)); ff - +lush(stdout); - 552 } - 553 return 1; - 554 } - -⏺ Теперь threads.cxx с std::vector. Посмотрю контекст использования. - -⏺ Read(test/threads.cxx) - ⎿ Read 130 lines - -⏺ Read(test/threads.cxx) - ⎿ Read 35 lines - -⏺ Заменю std::vector на ручной динамический массив. - -⏺ Update(test/threads.cxx) - ⎿ Added 23 lines, removed 2 lines - 25 # include "threads.h" - 26 # include <stdio.h> - 27 # include <math.h> - 28 -# include <vector> - 28 +# include <stdlib.h> - 29 - 30 // min. time in seconds before calling Fl::awake(...) - 31 #define DELTA 0.25 - ... - 39 Fl_Terminal *terminal; // widget to write outp - ut to - 40 unsigned long max_prime; // highest prime found - so far - 41 Fl_Output *value; // highest prime output - widget - 42 - std::vector<unsigned long> primes; // collected primes wit - -hin time frame - 42 + unsigned long *primes; // collected primes wit - +hin time frame - 43 + size_t primes_count; // number of collected - +primes - 44 + size_t primes_alloc; // allocated size - 45 }; - 46 - 47 +static void primes_init(struct prime *pr) { - 48 + pr->primes = 0; - 49 + pr->primes_count = 0; - 50 + pr->primes_alloc = 0; - 51 +} - 52 + - 53 +static void primes_push(struct prime *pr, unsigned long n) { - 54 + if (pr->primes_count >= pr->primes_alloc) { - 55 + size_t new_alloc = pr->primes_alloc ? pr->primes_alloc * 2 - +: 64; - 56 + pr->primes = (unsigned long *)realloc(pr->primes, new_alloc - + * sizeof(unsigned long)); - 57 + pr->primes_alloc = new_alloc; - 58 + } - 59 + pr->primes[pr->primes_count++] = n; - 60 +} - 61 + - 62 +static void primes_clear(struct prime *pr) { - 63 + pr->primes_count = 0; - 64 +} - 65 + - 66 Fl_Thread prime_thread; - 67 - 68 Fl_Terminal *tty1, *tty2; - -⏺ Теперь обновлю использования. - -⏺ Update(test/threads.cxx) - ⎿ Added 1 line, removed 1 line - 83 char max_buf[32]; - 84 struct prime *pr = (struct prime *)v; - 85 size_t i; - 86 - for (i = 0; i < pr->primes.size(); i++) { - 86 + for (i = 0; i < pr->primes_count; i++) { - 87 unsigned long n = pr->primes[i]; - 88 pr->terminal->printf("prime: %10lu\n", n); - 89 if (n > pr->max_prime) - ⎿ Found 10 new diagnostic issues in 1 file (ctrl+o to expand) - -⏺ Update(test/threads.cxx) - ⎿ Added 2 lines, removed 2 lines - 126 pr[0].terminal = pr[1].terminal = terminal; - 127 pr[0].max_prime = pr[1].max_prime = 0; - 128 pr[0].value = pr[1].value = value; - 129 - pr[0].primes.clear(); - 130 - pr[1].primes.clear(); - 129 + primes_init(&pr[0]); - 130 + primes_init(&pr[1]); - 131 int pi = 0; // prime buffer index - 132 - 133 Fl_Timestamp last = Fl::now(); - ⎿ Found 1 new diagnostic issue in 1 file (ctrl+o to expand) - -⏺ Search(pattern: "primes\.", path: "test/threads.cxx", output_mode: "content") +⏺ Search(pattern: "FLTK_HAVE_CAIRO|USE_CAIRO|cairo", path: "~/Desktop/fltk", + glob: "Makefile", output_mode: "content") ⎿ Found 2 lines (ctrl+o to expand) -⏺ Update(test/threads.cxx) - ⎿ Added 1 line, removed 1 line - 152 - 153 if (pp > hn) { // n is a prime - 154 - 155 - pr[pi].primes.push_back(n); - 155 + primes_push(&pr[pi], n); - 156 - 157 // Send a message to the main thread, at which point it - will - 158 // process any pending updates. - -⏺ Update(test/threads.cxx) - ⎿ Added 1 line, removed 1 line - 163 last = Fl::now(); - 164 Fl::awake(update_handler, (void *)(&pr[pi])); - 165 pi = 1 - pi; // switch to a - lternate buffer - 166 - pr[pi].primes.clear(); // clear prime - -s - 166 + primes_clear(&pr[pi]); // clear prime - +s - 167 } - 168 - 169 if (n > max_value) { - -⏺ Теперь unittest_core.cxx. Этот файл тестирует API функции FLTK, возвращающие - std::string. Посмотрю его содержимое. - -⏺ Read(test/unittest_core.cxx) - ⎿ Read 228 lines - -⏺ Вижу, что большинство тестов уже отключены с помощью #if 0. Осталось - исправить: - 1. Строки 34-48: использование std::string с Fl_Preferences - 2. Строка 27: #include <string> - 3. Строка 214: FL_OVERRIDE — нужно проверить - -⏺ Search(pattern: "FL_OVERRIDE", path: "FL", output_mode: "content", head_limit: - 5) - ⎿ Found 3 lines (ctrl+o to expand) - -⏺ FL_OVERRIDE уже пустой макрос. Проверю API Fl_Preferences для C-строк. - -⏺ Search(pattern: "void set\(const char", path: "FL/Fl_Preferences.H", - output_mode: "content") - ⎿ Found 0 lines - -⏺ Search(pattern: "char get\(const char", path: "FL/Fl_Preferences.H", - output_mode: "content") - ⎿ Found 0 lines +⏺ Search(pattern: "#include.*cairo", path: "src", output_mode: "content") + ⎿ Found 9 lines (ctrl+o to expand) -⏺ Search(pattern: "set\(.*,.*\)", path: "FL/Fl_Preferences.H", output_mode: - "content") - ⎿ Found 11 lines (ctrl+o to expand) +⏺ Search(pattern: "FLTK_HAVE_CAIRO", path: "FL") + ⎿ Found 0 files -⏺ Search(pattern: "get\(.*char\*", path: "FL/Fl_Preferences.H", output_mode: - "content") - ⎿ Found 0 lines +⏺ Read(FL/fl_config.h) + ⎿ Read 95 lines -⏺ Search(pattern: "char get\(", path: "FL/Fl_Preferences.H", output_mode: - "content") - ⎿ Found 8 lines (ctrl+o to expand) - -⏺ Этот тест тестирует std::string API для Fl_Preferences, который по плану - должен быть удалён. Отключу его аналогично другим тестам. - -⏺ Update(test/unittest_core.cxx) - ⎿ Added 1 line, removed 26 lines - 24 #include <FL/filename.H> - 25 #include <FL/fl_utf8.h> - 26 - 27 -#include <string> - 28 - - 29 - - 30 -/* Test additions to Fl_Preferences. */ - 31 -TEST(Fl_Preferences, Strings) { - 32 - { - 33 - Fl_Preferences prefs(Fl_Preferences::USER_L, "fltk.org", "u - -nittests"); - 34 - prefs.set("a", std::string()); - 35 - prefs.set("b", std::string("Hello")); - 36 - prefs.set("c", std::string("Hel\\l\nö")); - 37 - } - 38 - { - 39 - Fl_Preferences prefs(Fl_Preferences::USER_L, "fltk.org", "u - -nittests"); - 40 - std::string r; - 41 - prefs.get("a", r, "x"); - 42 - EXPECT_STREQ(r.c_str(), ""); - 43 - prefs.get("b", r, "x"); - 44 - EXPECT_STREQ(r.c_str(), "Hello"); - 45 - prefs.get("c", r, "x"); - 46 - EXPECT_STREQ(r.c_str(), "Hel\\l\nö"); - 47 - prefs.get("d", r, "x"); - 48 - EXPECT_STREQ(r.c_str(), "x"); - 49 - } - 50 - return true; - 51 -} - 52 - - 27 +// std::string tests disabled - API to be removed - 28 #if 0 - 29 - 30 TEST(fl_filename, ext) { - -⏺ Проверю, остались ли ещё std:: в test/. - -⏺ Search(pattern: "std::", path: "test", output_mode: "content") - ⎿ Found 17 lines (ctrl+o to expand) - ⎿ Found 10 new diagnostic issues in 1 file (ctrl+o to expand) +⏺ Search(pattern: "FLTK_HAVE_CAIRO|CAIRO", path: "src", glob: "*.cxx") + ⎿ Found 13 files (ctrl+o to expand) -⏺ Все оставшиеся std:: находятся внутри #if 0 блока (уже отключены). Проверю - сборку. +⏺ Read(Makefile) + ⎿ Read 200 lines -⏺ Bash(make -j4 2>&1 | tail -50) - ⎿ make: Nothing to be done for `all'. - /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni - k01/Desktop/hobby/emsdk/emsdk_env.sh +⏺ Read(Makefile) + ⎿ Read 200 lines +⏺ Search(pattern: "src/drivers/Xlib/*.cxx") + ⎿ Found 11 files (ctrl+o to expand) -⏺ Сборка уже актуальна. Пересоберу изменённые тестовые файлы. +⏺ Search(pattern: "src/drivers/Xlib/*.H") + ⎿ Found 0 files -⏺ Bash(rm -f build/test/adjuster.o build/test/ask.o build/test/utf8.o - build/test/threads.o build/test/unittest_core.o 2>/dev/null; make -j4 2>&1 - | tail -60) - ⎿ make: Nothing to be done for `all'. - /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni - k01/Desktop/hobby/emsdk/emsdk_env.sh +⏺ Read(src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx) + ⎿ Read 80 lines +⏺ Read(src/drivers/X11/fl_X11_platform_init.cxx) + ⎿ Read 82 lines -⏺ Bash(find . -name "adjuster.o" -o -name "threads.o" 2>/dev/null) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni - k01/Desktop/hobby/emsdk/emsdk_env.sh +⏺ Read(config.h) + ⎿ Read 341 lines +⏺ Search(pattern: "src/drivers/Xlib/*.H", path: "~/Desktop/fltk") + ⎿ Found 4 files (ctrl+o to expand) -⏺ Search(pattern: "adjuster", path: "Makefile", output_mode: "content") - ⎿ Found 0 lines +⏺ Read(src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H) + ⎿ Read 60 lines -⏺ Search(pattern: "test", path: "Makefile", output_mode: "content") - ⎿ Found 0 lines +⏺ Теперь добавлю опцию USE_CAIRO в Makefile. При USE_CAIRO=0 будет + использоваться чистый Xlib+Xft рендеринг. ⏺ Read(Makefile) - ⎿ Read 80 lines - -⏺ Makefile не включает сборку тестов. Проверю компиляцию вручную. + ⎿ Read 40 lines -⏺ Bash(g++ -c -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src - -I/opt/X11/include $(pkg-config --cflags cairo pangocairo pango) - test/adjuster.cxx -o /tmp/adjuster.o…) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni - k01/Desktop/hobby/emsdk/emsdk_env.sh +⏺ Update(Makefile) + ⎿ Added 5 lines + 40 # Set USE_BUNDLED_X11=1 to use headers from xlibs/include (run + xlibs/fetch_headers.sh first) + 41 USE_BUNDLED_X11 ?= 0 + 42 + 43 +# Cairo rendering option + 44 +# Set USE_CAIRO=0 for pure Xlib+Xft rendering (no Cairo/Pango d + +ependency) + 45 +# Set USE_CAIRO=1 (default) for Cairo+Pango rendering + 46 +USE_CAIRO ?= 1 + 47 + + 48 UNAME_S := $(shell uname -s) + 49 ifeq ($(USE_BUNDLED_X11),1) + 50 # Use bundled X11 headers, still link system libraries + +⏺ Update(Makefile) + ⎿ Added 10 lines, removed 2 lines + 64 X11_LIBS = $(shell pkg-config --libs x11 xext xft xinera + ma xcursor xfixes xrender) + 65 endif + 66 + 67 -CAIRO_CFLAGS = $(shell pkg-config --cflags cairo pangocairo pan + -go) + 68 -CAIRO_LIBS = $(shell pkg-config --libs cairo pangocairo pango + - gobject-2.0) + 67 +# Cairo/Pango configuration (only when USE_CAIRO=1) + 68 +ifeq ($(USE_CAIRO),1) + 69 + CAIRO_CFLAGS = $(shell pkg-config --cflags cairo pangocairo + + pango) + 70 + CAIRO_LIBS = $(shell pkg-config --libs cairo pangocairo p + +ango gobject-2.0) + 71 + CAIRO_DEFINES = -DFLTK_USE_CAIRO=1 -DFLTK_HAVE_CAIRO=1 -DUS + +E_PANGO=1 + 72 +else + 73 + CAIRO_CFLAGS = + 74 + CAIRO_LIBS = + 75 + CAIRO_DEFINES = -DFLTK_USE_CAIRO=0 -DFLTK_HAVE_CAIRO=0 -DUS + +E_PANGO=0 + 76 +endif + 77 + 78 # OpenGL configuration (separate from X11 bundling) + 79 ifeq ($(UNAME_S),Darwin) + +⏺ Update(Makefile) + ⎿ Added 2 lines, removed 2 lines + 95 JPEG_LIBS = + 96 + 97 # Combined flags + 98 -ALL_CFLAGS = $(CFLAGS) $(DEFINES) $(INCLUDES) $(X11_CFLAGS) + -$(CAIRO_CFLAGS) + 99 -ALL_CXXFLAGS = $(CXXFLAGS) $(DEFINES) $(INCLUDES) $(X11_CFLAGS + -) $(CAIRO_CFLAGS) + 98 +ALL_CFLAGS = $(CFLAGS) $(DEFINES) $(INCLUDES) $(X11_CFLAGS) + +$(CAIRO_CFLAGS) $(CAIRO_DEFINES) + 99 +ALL_CXXFLAGS = $(CXXFLAGS) $(DEFINES) $(INCLUDES) $(X11_CFLAGS + +) $(CAIRO_CFLAGS) $(CAIRO_DEFINES) + 100 + 101 # Libraries for linking + 102 FLTK_LDLIBS = $(X11_LIBS) $(CAIRO_LIBS) -lm -ldl -lpthread +⏺ Read(Makefile) + ⎿ Read 40 lines -⏺ Bash(g++ -c -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src - -I/opt/X11/include $(pkg-config --cflags cairo pangocairo pango) - test/ask.cxx -o /tmp/ask.o 2>&1) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni - k01/Desktop/hobby/emsdk/emsdk_env.sh +⏺ Update(Makefile) + ⎿ Added 24 lines, removed 3 lines + 261 src/print_button.cxx \ + 262 src/screen_xywh.cxx + 263 + 264 -# X11 driver files + 265 -DRIVER_SRCS = \ + 264 +# X11 driver files (common) + 265 +DRIVER_SRCS_COMMON = \ + 266 src/Fl_x.cxx \ + 267 src/fl_dnd_x.cxx \ + 268 src/Fl_get_key.cxx \ + ... + 278 src/drivers/X11/Fl_X11_Window_Driver.cxx \ + 279 src/drivers/X11/fl_X11_platform_init.cxx \ + 280 src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx \ + 281 - src/drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx \ + 281 + src/drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx + 282 + + 283 +# Cairo graphics driver (USE_CAIRO=1) + 284 +DRIVER_SRCS_CAIRO = \ + 285 src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx \ + 286 src/drivers/Cairo/Fl_X11_Cairo_Graphics_Driver.cxx + 287 + 288 +# Xlib graphics driver (USE_CAIRO=0) - pure Xlib+Xft rendering + 289 +DRIVER_SRCS_XLIB = \ + 290 + src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx \ + 291 + src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx \ + 292 + src/drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx \ + 293 + src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx \ + 294 + src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx \ + 295 + src/drivers/Xlib/Fl_Xlib_Graphics_Driver_line_style.cxx \ + 296 + src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx \ + 297 + src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx + 298 + + 299 +# Select driver based on USE_CAIRO + 300 +ifeq ($(USE_CAIRO),1) + 301 + DRIVER_SRCS = $(DRIVER_SRCS_COMMON) $(DRIVER_SRCS_CAIRO) + 302 +else + 303 + DRIVER_SRCS = $(DRIVER_SRCS_COMMON) $(DRIVER_SRCS_XLIB) + 304 +endif + 305 + + 306 # PostScript driver + 307 PS_SRCS = \ + 308 src/drivers/PostScript/Fl_PostScript.cxx \ + +⏺ Read(FL/fl_config.h) + ⎿ Read 95 lines + +⏺ Нужно обновить fl_config.h для поддержки переопределений через командную + строку. + +⏺ Update(FL/fl_config.h) + ⎿ Added 3 lines + 46 * FLTK_HAVE_CAIRO + 47 * + 48 * Do we have Fl_Cairo_Window support? + 49 + * Can be overridden via -DFLTK_HAVE_CAIRO=0 for pure Xlib+Xft + +build. + 50 */ + 51 + 52 +#ifndef FLTK_HAVE_CAIRO + 53 #define FLTK_HAVE_CAIRO 1 + 54 +#endif + 55 + 56 /* + 57 * FLTK_HAVE_CAIROEXT + +⏺ Update(FL/fl_config.h) + ⎿ Added 3 lines + 82 * FLTK_USE_CAIRO + 83 * + 84 * Do we use Cairo to draw to the display? + 85 + * Can be overridden via -DFLTK_USE_CAIRO=0 for pure Xlib+Xft b + +uild. + 86 */ + 87 + 88 +#ifndef FLTK_USE_CAIRO + 89 #define FLTK_USE_CAIRO 1 + 90 +#endif + 91 + 92 /* + 93 * FLTK_USE_SVG + +⏺ Update(config.h) + ⎿ Added 3 lines + 105 * USE_PANGO + 106 * + 107 * Use the pango library to draw UTF-8 text. + 108 + * Can be overridden via -DUSE_PANGO=0 for pure Xlib+Xft build + +. + 109 */ + 110 + 111 +#ifndef USE_PANGO + 112 #define USE_PANGO 1 + 113 +#endif + 114 + 115 /* + 116 * HAVE_XFIXES: + +⏺ Проверю сборку с USE_CAIRO=0. + +⏺ Bash(make clean 2>&1 | tail -5) + ⎿ rm -f src/fl_images_core.o src/fl_write_png.o src/Fl_BMP_Image.o src/Fl + _File_Icon2.o src/Fl_GIF_Image.o src/Fl_Anim_GIF_Image.o src/Fl_Help_Di + alog.o src/Fl_ICO_Image.o src/Fl_JPEG_Image.o src/Fl_PNG_Image.o src/Fl + … +53 lines (ctrl+o to expand) -⏺ Bash(g++ -c -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src - -I/opt/X11/include $(pkg-config --cflags cairo pangocairo pango) - test/threads.cxx -o /tmp/threads.o 2…) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni - k01/Desktop/hobby/emsdk/emsdk_env.sh + ⎿ Found 1 new diagnostic issue in 1 file (ctrl+o to expand) -⏺ Bash(g++ -c -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src - -I/opt/X11/include $(pkg-config --cflags cairo pangocairo pango) - test/utf8.cxx -o /tmp/utf8.o 2>&1) - ⎿ test/utf8.cxx:533:14: warning: 'sprintf' is deprecated: This function i - s provided for compatibility reasons only. Due to security concerns in - herent in the design of sprintf(3), it is highly recommended that you u - … +51 lines (ctrl+o to expand) +⏺ Bash(make USE_CAIRO=0 lib/libfltk.a 2>&1 | head -50) timeout: 3m 0s + ⎿ g++ -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src -I./jpeg -I./pn + g -I./zlib -I./fluid -I/opt/X11/include -DFLTK_USE_CAIRO=0 -DFLTK_HAVE + _CAIRO=0 -DUSE_PANGO=0 -c -o src/Fl.o src/Fl.cxx + … +10 lines (ctrl+o to expand) +⏺ Read(FL/Fl_Cairo.H) + ⎿ Read 101 lines -⏺ Все файлы скомпилированы успешно! Только предупреждения о deprecated sprintf - на macOS. +⏺ Проблема в том, что #ifndef проверяет наличие макроса, а -DFLTK_HAVE_CAIRO=0 + его определяет (как 0). Нужно использовать #if !defined(...). -⏺ Проверю оставшиеся нарушения в test/. +⏺ Update(FL/fl_config.h) + ⎿ Added 1 line, removed 1 line + 49 * Can be overridden via -DFLTK_HAVE_CAIRO=0 for pure Xlib+Xft + build. + 50 */ + 51 + 52 -#ifndef FLTK_HAVE_CAIRO + 52 +#if !defined(FLTK_HAVE_CAIRO) + 53 #define FLTK_HAVE_CAIRO 1 + 54 #endif + 55 -⏺ Bash(echo "=== override ===" && grep -r '\boverride\b' test/*.cxx 2>/dev/null - | grep -v "\.cxx:\/\/" | grep -v "override_" | head -5 - echo "=== nullptr ===" && grep -…) - ⎿ === override === - test/clipboard.cxx: void draw() override { - test/clipboard.cxx: int handle(int event) override { - … +16 lines (ctrl+o to expand) +⏺ Update(FL/Fl_Cairo.H) + ⎿ Added 1 line, removed 1 line + 35 + 36 #include <FL/Fl.H> + 37 + 38 -# ifdef FLTK_HAVE_CAIRO + 38 +# if FLTK_HAVE_CAIRO + 39 + 40 # include <cairo.h> + 41 -⏺ Остались override и nullptr в test/. Исправлю их. +⏺ Search(pattern: "#ifdef FLTK_HAVE_CAIRO|#if defined\(FLTK_HAVE_CAIRO\)", + output_mode: "content") + ⎿ Found 9 lines (ctrl+o to expand) + ⎿ Found 1 new diagnostic issue in 1 file (ctrl+o to expand) -⏺ Bash(sed -i '' 's/ override\b//g' test/clipboard.cxx test/color_chooser.cxx - test/menubar.cxx 2>&1) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni - k01/Desktop/hobby/emsdk/emsdk_env.sh +⏺ Search(pattern: "#ifdef FLTK_USE_CAIRO|#if defined\(FLTK_USE_CAIRO\)", + output_mode: "content") + ⎿ Found 0 lines +⏺ Search(pattern: "FLTK_USE_CAIRO", output_mode: "content") + ⎿ Found 105 lines (ctrl+o to expand) -⏺ Bash(sed -i '' 's/\bnullptr\b/0/g' test/clipboard.cxx test/color_chooser.cxx - test/group.cxx 2>&1) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni +⏺ Bash(sed -i '' 's/#ifdef FLTK_HAVE_CAIRO/#if FLTK_HAVE_CAIRO/g' + examples/cairo-draw-x.cxx src/Fl_Cairo.cxx src/Fl_Private.H FL/Fl.H + test/cairo_test.cxx && echo "Done…) + ⎿ Done replacing #ifdef FLTK_HAVE_CAIRO + /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni k01/Desktop/hobby/emsdk/emsdk_env.sh -⏺ Bash(echo "=== override ===" && grep -r '\boverride\b' test/*.cxx 2>/dev/null - | grep -v "\.cxx:\/\/" | grep -v "override_" | grep -v "\.cxx:" | head -5 - echo "=== nul…) - ⎿ Error: Exit code 1 - /Users/mnik01/.zprofile:source:3: no such file or directory: - /Users/mnik01/Desktop/hobby/emsdk/emsdk_env.sh - head: echo: No such file or directory - head: === nullptr ===: No such file or directory +⏺ Bash(make USE_CAIRO=0 lib/libfltk.a 2>&1 | head -80) timeout: 3m 0s + ⎿ g++ -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src -I./jpeg -I./pn + g -I./zlib -I./fluid -I/opt/X11/include -DFLTK_USE_CAIRO=0 -DFLTK_HAVE + _CAIRO=0 -DUSE_PANGO=0 -c -o src/Fl.o src/Fl.cxx + … +274 lines (ctrl+o to expand) - === override === -⏺ Bash(grep -rn '\boverride\b' test/*.cxx 2>/dev/null | grep -v "\/\/" | grep -v - "override_" | head -10; echo "---"; grep -rn '\bnullptr\b' test/*.cxx - 2>/dev/null | he…) - ⎿ test/clipboard.cxx:62: void draw() override { - test/clipboard.cxx:107: int handle(int event) override { - test/color_chooser.cxx:92: int handle(int event) override { - … +24 lines (ctrl+o to expand) -⏺ sed не сработал. Исправлю файлы напрямую. +⏺ Bash(make USE_CAIRO=0 lib/libfltk.a 2>&1 | tail -50) timeout: 3m 0s + ⎿ g++ -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src -I./jpeg -I./pn + g -I./zlib -I./fluid -I/opt/X11/include -DFLTK_USE_CAIRO=0 -DFLTK_HAVE + _CAIRO=0 -DUSE_PANGO=0 -c -o src/fl_font.o src/fl_font.cxx + … +160 lines (ctrl+o to expand) -⏺ Bash(sed -i '' 's/) override {/) {/g' test/clipboard.cxx - test/color_chooser.cxx test/menubar.cxx test/penpal.cxx && sed -i '' - 's/override { }/{ }/g' test/penpal.cxx…) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni - k01/Desktop/hobby/emsdk/emsdk_env.sh -⏺ Search(pattern: "\boverride\b", path: "test", glob: "*.cxx", output_mode: - "content") - ⎿ Found 4 lines (ctrl+o to expand) +⏺ Xft требует FreeType. Нужно добавить FreeType include path в Makefile. -⏺ Bash(sed -i '' 's/) override {/) {/g' test/color_chooser.cxx && sed -i '' - 's/) override;/);/g' test/utf8.cxx && sed -i '' 's/) override {/) {/g' - test/utf8.cxx 2>&1) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni - k01/Desktop/hobby/emsdk/emsdk_env.sh +⏺ Read(Makefile) + ⎿ Read 50 lines + +⏺ Update(Makefile) + ⎿ Added 3 lines, removed 3 lines + 55 X11_LIBS = $(shell pkg-config --libs x11 xext xft xi + nerama xcursor xfixes xrender) + 56 endif + 57 else ifeq ($(UNAME_S),Darwin) + 58 - # macOS with XQuartz + 59 - X11_CFLAGS = -I/opt/X11/include + 60 - X11_LIBS = -L/opt/X11/lib -lX11 -lXext -lXft -lXinerama + --lXcursor -lXfixes -lXrender + 58 + # macOS with XQuartz (include freetype2 for Xft) + 59 + X11_CFLAGS = -I/opt/X11/include -I/opt/X11/include/freetyp + +e2 + 60 + X11_LIBS = -L/opt/X11/lib -lX11 -lXext -lXft -lXinerama + +-lXcursor -lXfixes -lXrender -lfontconfig -lfreetype + 61 else + 62 # Linux - use pkg-config + 63 X11_CFLAGS = $(shell pkg-config --cflags x11 xext xft xine + rama xcursor xfixes xrender) + +⏺ Update(Makefile) + ⎿ Added 3 lines, removed 3 lines + 59 X11_CFLAGS = -I/opt/X11/include -I/opt/X11/include/freetyp + e2 + 60 X11_LIBS = -L/opt/X11/lib -lX11 -lXext -lXft -lXinerama + -lXcursor -lXfixes -lXrender -lfontconfig -lfreetype + 61 else + 62 - # Linux - use pkg-config + 63 - X11_CFLAGS = $(shell pkg-config --cflags x11 xext xft xine + -rama xcursor xfixes xrender) + 64 - X11_LIBS = $(shell pkg-config --libs x11 xext xft xinera + -ma xcursor xfixes xrender) + 62 + # Linux - use pkg-config (include freetype2 for Xft) + 63 + X11_CFLAGS = $(shell pkg-config --cflags x11 xext xft xine + +rama xcursor xfixes xrender freetype2 fontconfig) + 64 + X11_LIBS = $(shell pkg-config --libs x11 xext xft xinera + +ma xcursor xfixes xrender freetype2 fontconfig) + 65 endif + 66 + 67 # Cairo/Pango configuration (only when USE_CAIRO=1) + +⏺ Update(Makefile) + ⎿ Added 2 lines, removed 1 line + 52 ifeq ($(UNAME_S),Darwin) + 53 X11_LIBS = -L/opt/X11/lib -lX11 -lXext -lXft -lXiner + ama -lXcursor -lXfixes -lXrender + 54 else + 55 - X11_LIBS = $(shell pkg-config --libs x11 xext xft xi + -nerama xcursor xfixes xrender) + 55 + X11_CFLAGS += $(shell pkg-config --cflags freetype2 fon + +tconfig) + 56 + X11_LIBS = $(shell pkg-config --libs x11 xext xft xi + +nerama xcursor xfixes xrender freetype2 fontconfig) + 57 endif + 58 else ifeq ($(UNAME_S),Darwin) + 59 # macOS with XQuartz (include freetype2 for Xft) + +⏺ Bash(rm -f src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.o && timeout: + make USE_CAIRO=0 lib/libfltk.a 2>&1 | tail -30) 3m 0s + ⎿ 83 | # define strlcpy fl_strlcpy + | ^ + /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/secure/ + … +113 lines (ctrl+o to expand) + + +⏺ libfltk.a собрана успешно с USE_CAIRO=0. Теперь соберу остальные библиотеки и + fluid. + +⏺ Bash(make USE_CAIRO=0 all 2>&1 | tail -30) timeout: 5m 0s + ⎿ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/cde + fs.h:218:48: note: expanded from macro '__deprecated_msg' + 218 | #define __deprecated_msg(_msg) __attribute__((__depreca + … +119 lines (ctrl+o to expand) + + + +⏺ Сборка с USE_CAIRO=0 завершена успешно. Проверю результат. + +⏺ Bash(ls -la lib/*.a && ls -la bin/fluid && bin/fluid -v) + ⎿ -rw-r--r--@ 1 mnik01 staff 2291608 Feb 6 13:14 lib/libfltk.a + -rw-r--r--@ 1 mnik01 staff 32888 Feb 6 13:15 lib/libfltk_forms.a + -rw-r--r--@ 1 mnik01 staff 212664 Feb 6 13:15 lib/libfltk_gl.a + … +8 lines (ctrl+o to expand) + +⏺ Теперь задокументирую зависимости и опции сборки. + +⏺ Search(pattern: "BUILDING*") + ⎿ Found 0 files + +⏺ Search(pattern: "README*") + ⎿ Found 27 files (ctrl+o to expand) + +⏺ Read(README.Unix.txt) + ⎿ Read 441 lines + +⏺ Update(README.Unix.txt) + ⎿ Added 2 lines, removed 3 lines + 32 + 33 + 34 --------------------------------------------------------------- + ---- + 35 - Note: usage of autotools, configure, and included Makefiles t + -o + 36 - build the FLTK library is no longer available since FLTK 1.5. + -0. + 37 - You must use CMake instead, see below and/or README.CMake.txt + -. + 35 + Note: This fork uses a simple Makefile-based build system. + 36 + CMake is no longer used. See section 3 for build instructions + +. + 37 --------------------------------------------------------------- + ---- + 38 + 39 + +⏺ Update(README.Unix.txt) + ⎿ Added 4 lines, removed 2 lines + 40 1 Introduction + 41 ================= + 42 + 43 +This FLTK fork uses a simple Makefile-based build system. It su + +pports + 44 +X11-only builds with either Cairo+Pango or pure Xlib+Xft render + +ing. + 45 + + 46 FLTK currently supports the following development environments + on most Unix + 47 and Linux platforms: + 48 + 46 - - CMake + the build system of your choice (see README.CMake + -.txt) + 47 - - gcc command line tools + 49 + - make + gcc command line tools + 50 - Code::Blocks + 51 - ... + 52 + +⏺ Update(README.Unix.txt) + ⎿ Added 23 lines, removed 20 lines + 293 3.2 Configuration and Building + 294 --------------------------------- + 295 + 296 -Since FLTK 1.5 the only build system (generator) used by FLTK + -is CMake. + 297 -CMake can be used to create the build system of your choice, f + -or instance + 298 -Makefiles, Ninja build files, Xcode, or Visual Studio IDE proj + -ects etc.. + 296 +This fork uses a simple Makefile. No CMake or autoconf require + +d. + 297 + 300 -Note: The "classic" build system with autoconf, configure, and + - Makefiles + 301 -is no longer available. + 298 +Build options are controlled via make variables: + 299 + - USE_CAIRO=1 (default): Cairo+Pango rendering + 300 + - USE_CAIRO=0: Pure Xlib+Xft rendering (no Cairo/Pango depen + +dency) + 301 + - USE_BUNDLED_X11=1: Use bundled X11 headers from xlibs/incl + +ude + 302 + 303 -Please see README.CMake.txt for how to build FLTK and your app + -lication + 304 -programs using CMake. + 303 + 306 -You can, of course, build FLTK with CMake and your own applica + -tion(s) + 307 -with your existing and well-known build system. + 308 - + 309 - + 304 3.3 Building FLTK in a Nutshell + 305 ---------------------------------- + 306 + 313 -Following are only basic commands, please see details in READM + -E.CMake.txt. + 307 +Building FLTK with default parameters (Cairo+Pango): + 308 + 315 -Building FLTK with all default parameters on your platform is + -easy. + 316 -Stay in your FLTK source-code directory and type: + 309 + make # Build all libraries and fluid + 310 + make test/hello # Build a test program + 311 + 318 - cmake . -B build -D [ CMAKE_BUILD_TYPE=Debug ... more option + -s ] + 319 - cmake --build build + 312 +Building without Cairo (pure Xlib+Xft): + 313 + 321 -The entire FLTK toolkit including many test programs will be b + -uilt for you + 322 -in the subdirectory `build`. No warnings should appear. If som + -e do, please + 323 -let the FLTK developer team know via the mailing list "fltk.ge + -neral" or + 324 -view the bug reporting guidelines at https://www.fltk.org/bugs + -.php . + 314 + make USE_CAIRO=0 # Build with Xlib+Xft rendering + 315 + 316 +Using bundled X11 headers (first run xlibs/fetch_headers.sh): + 317 + 318 + ./xlibs/fetch_headers.sh + 319 + make USE_BUNDLED_X11=1 + 320 + + 321 +The libraries are built in lib/: + 322 + - libfltk.a Core library + 323 + - libfltk_images.a Image support (PNG, JPEG, GIF, etc.) + 324 + - libfltk_gl.a OpenGL support + 325 + - libfltk_forms.a XForms compatibility + 326 + + 327 +The fluid GUI builder is built in bin/fluid. + 328 + + 329 + + 330 3.4 Testing FLTK + 331 ------------------- + 332 + +⏺ Update(README.Unix.txt) + ⎿ Added 17 lines, removed 21 lines + 80 + 81 Open a shell and install some development software: + 82 + 83 - sudo apt-get install g++ + 84 - sudo apt-get install gdb + 85 - sudo apt-get install git + 86 - sudo apt-get install make # if used + 87 - sudo apt-get install cmake + 88 - sudo apt-get install libx11-dev + 89 - sudo apt-get install libglu1-mesa-dev + 90 - sudo apt-get install libxft-dev + 91 - sudo apt-get install libxcursor-dev + 83 + sudo apt-get install g++ make gdb git + 84 + 93 -# These packages are optional but recommended: + 85 +# Core X11 dependencies (always required): + 86 + 95 - sudo apt-get install libasound2-dev + 96 - sudo apt-get install freeglut3-dev + 97 - sudo apt-get install libcairo2-dev + 98 - sudo apt-get install libfontconfig1-dev + 99 - sudo apt-get install libglew-dev + 100 - sudo apt-get install libjpeg-dev + 101 - sudo apt-get install libpng-dev + 102 - sudo apt-get install libpango1.0-dev + 103 - sudo apt-get install libxinerama-dev + 87 + sudo apt-get install libx11-dev libxext-dev libxft-dev + 88 + sudo apt-get install libxinerama-dev libxcursor-dev + 89 + sudo apt-get install libxfixes-dev libxrender-dev + 90 + sudo apt-get install libfontconfig1-dev libfreetype-dev + 91 + 105 -If you want to build FLTK for Wayland (the supposed successor + -of X) you need + 106 -some more packages. Please refer to README.Wayland.txt for mor + -e information. + 92 +# For Cairo+Pango rendering (USE_CAIRO=1, default): + 93 + 94 + sudo apt-get install libcairo2-dev libpango1.0-dev + 95 + + 96 +# For OpenGL support: + 97 + + 98 + sudo apt-get install libglu1-mesa-dev + 99 + + 100 +# Optional packages: + 101 + + 102 + sudo apt-get install libasound2-dev # audio support + 103 + + 104 If you are planning to use the Code::Blocks IDE, also install + this + 105 + 106 sudo apt-get install codeblocks + +⏺ Update(README.Unix.txt) + ⎿ Added 10 lines, removed 13 lines + 335 3.5 Installing FLTK + 336 ---------------------- + 337 + 338 -If you did not change any of the configuration settings, FLTK + -will be installed + 339 -in "/usr/local/include" and "/usr/local/lib" by typing + 338 +FLTK can be installed to /usr/local by typing: + 339 + 341 - sudo cmake --install . + 340 + sudo make install + 341 + 343 -in your build folder. Note the trailing '.' . + 342 +This will copy: + 343 + - Headers to /usr/local/include/FL + 344 + - Libraries to /usr/local/lib + 345 + - fluid to /usr/local/bin + 346 + 345 -It is possible to install FLTK without superuser privileges by + - changing the + 346 -installation path to a location within the user account by add + -ing the + 347 -"-D CMAKE_INSTALL_PREFIX=<path>" parameters to the "cmake" com + -mand. + 347 +To change the installation prefix, edit PREFIX in Makefile or + +type: + 348 + 349 + sudo make PREFIX=/opt/fltk install + 350 + + 351 Note: installing FLTK is optional. You can build your own soft + ware by using + 352 the FLTK build tree directly. This is recommended if you link + your application + 351 -statically (which is recommended as well). This is particularl + -y important if you + 352 -consider using different FLTK versions on a development system + - to avoid mixing + 353 -FLTK versions when building (a well-known problem) or running + -FLTK applications + 354 -with installed shared libraries of a different FLTK version. O + -TOH, if you build + 355 -shared FLTK libraries you may want to install FLTK, particular + -ly on a production + 356 -system. + 353 +statically (which is recommended as well). + 354 + 355 + 356 3.6 Creating Your Own Projects + +⏺ Проверю, что сборка с Cairo (по умолчанию) тоже работает. + +⏺ Bash(make clean 2>&1 | tail -3 && make lib/libfltk.a 2>&1 | tail timeout: 3m + -10) 0s + + ⎿ rm -f jpeg/jaricom.o jpeg/jcapimin.o jpeg/jcapistd.o jpeg/jcarith.o jpe + g/jccoefct.o jpeg/jccolor.o jpeg/jcdctmgr.o jpeg/jchuff.o jpeg/jcinit.o + jpeg/jcmainct.o jpeg/jcmarker.o jpeg/jcmaster.o jpeg/jcomapi.o jpeg/jc + … +172 lines (ctrl+o to expand) + + + + +⏺ Bash(make all 2>&1 | tail -5) timeout: 5m 0s + ⎿ g++ -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src -I./jpeg -I./pn + g -I./zlib -I./fluid -I/opt/X11/include -I/opt/X11/include/freetype2 -I + /opt/homebrew/Cellar/pango/1.56.4/include/pango-1.0 -I/opt/homebrew/Cel + … +62 lines (ctrl+o to expand) -⏺ Bash(grep -rn '\boverride\b' test/*.cxx 2>/dev/null | grep -v "\/\/" | head - -5) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni - k01/Desktop/hobby/emsdk/emsdk_env.sh -⏺ Bash(sed -i '' 's/nullptr/0/g' test/clipboard.cxx test/color_chooser.cxx - test/group.cxx test/menubar.cxx 2>&1) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni - k01/Desktop/hobby/emsdk/emsdk_env.sh +⏺ Bash(ls -la lib/*.a && bin/fluid -v) + ⎿ -rw-r--r--@ 1 mnik01 staff 2237200 Feb 6 13:17 lib/libfltk.a + -rw-r--r--@ 1 mnik01 staff 32888 Feb 6 13:17 lib/libfltk_forms.a + -rw-r--r--@ 1 mnik01 staff 212440 Feb 6 13:17 lib/libfltk_gl.a + … +7 lines (ctrl+o to expand) +⏺ Фаза 8 (Cairo/Pango стратегия) завершена. -⏺ Bash(grep -rn '\bnullptr\b' test/*.cxx 2>/dev/null | head -5) - ⎿ test/penpal.cxx:40:Fl_Widget *cv1 { nullptr }; - test/penpal.cxx:41:Fl_Window *cvwin { nullptr }; - test/penpal.cxx:49: Fl_Widget *widget_ { nullptr }; - … +6 lines (ctrl+o to expand) + Итог работы: -⏺ Bash(sed -i '' 's/nullptr/0/g' test/penpal.cxx 2>&1 && grep -rn '\bnullptr\b' - test/*.cxx 2>/dev/null | head -5) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni - k01/Desktop/hobby/emsdk/emsdk_env.sh + Фаза 7 (Bundling Xlib) - завершена: + - Создана директория xlibs/ с скриптом fetch_headers.sh + - Скрипт скачивает X11 заголовки из freedesktop.org + - Опция USE_BUNDLED_X11=1 позволяет собирать без системных X11-dev пакетов + (нужны только библиотеки) + Фаза 8 (Cairo/Pango) - завершена: + - Добавлена опция USE_CAIRO в Makefile: + - USE_CAIRO=1 (по умолчанию): Cairo+Pango рендеринг + - USE_CAIRO=0: Чистый Xlib+Xft рендеринг (без зависимости от + Cairo/Pango/glib) + - Обновлены fl_config.h и config.h для поддержки переопределений + - Исправлены все #ifdef FLTK_HAVE_CAIRO на #if FLTK_HAVE_CAIRO + - Добавлены файлы Xlib графического драйвера для режима без Cairo + - Обновлена документация в README.Unix.txt -⏺ Search(pattern: "\{ 0 \}", path: "test/penpal.cxx", output_mode: "content") - ⎿ Found 7 lines (ctrl+o to expand) + Результаты сборки: + USE_CAIRO=1: libfltk.a = 2.2 MB (Cairo+Pango) + USE_CAIRO=0: libfltk.a = 2.3 MB (Xlib+Xft) -⏺ Заменю C++11 инициализацию { 0 } на обычную. + Оставшаяся задача (отложена): + - Фаза 4b: Конвертация namespace Fl в class Fl - требует значительной + переработки API -⏺ Read(test/penpal.cxx) - ⎿ Read 25 lines +✻ Brewed for 15m 23s -⏺ Update(test/penpal.cxx) - ⎿ Added 2 lines, removed 2 lines - 37 - 38 extern Fl_Menu_Item app_menu[]; - 39 extern int popup_app_menu(); - 40 -Fl_Widget *cv1 { 0 }; - 41 -Fl_Window *cvwin { 0 }; - 40 +Fl_Widget *cv1 = 0; - 41 +Fl_Window *cvwin = 0; - 42 - 43 // - 44 // The canvas interface implements incremental drawing and hand - les draw events. - -⏺ Update(test/penpal.cxx) - ⎿ Added 14 lines, removed 10 lines - 46 // And it implements an overlay plane that visualizes pen event - data. - 47 // - 48 class CanvasInterface { - 49 - Fl_Widget *widget_ { 0 }; - 50 - bool in_window_ { false }; - 51 - bool first_draw_ { true }; - 52 - Fl_Offscreen offscreen_ { 0 }; - 53 - Fl_Color color_ { 1 }; - 54 - enum { NONE, HOVER, DRAW, PEN_HOVER, PEN_DRAW } overlay_ { NO - -NE }; - 55 - int ov_x_ { 0 }; - 56 - int ov_y_ { 0 }; - 49 + Fl_Widget *widget_; - 50 + bool in_window_; - 51 + bool first_draw_; - 52 + Fl_Offscreen offscreen_; - 53 + Fl_Color color_; - 54 + enum { NONE, HOVER, DRAW, PEN_HOVER, PEN_DRAW } overlay_; - 55 + int ov_x_; - 56 + int ov_y_; - 57 public: - 58 - CanvasInterface(Fl_Widget *w) : widget_(w) { } - 59 - CanvasInterface(Fl_Window *w) : widget_(w), in_window_(true) - -{ } - 58 + CanvasInterface(Fl_Widget *w) - 59 + : widget_(w), in_window_(false), first_draw_(true), offscre - +en_(0), - 60 + color_(1), overlay_(NONE), ov_x_(0), ov_y_(0) { } - 61 + CanvasInterface(Fl_Window *w) - 62 + : widget_(w), in_window_(true), first_draw_(true), offscree - +n_(0), - 63 + color_(1), overlay_(NONE), ov_x_(0), ov_y_(0) { } - 64 ~CanvasInterface() { - 65 if (offscreen_) fl_delete_offscreen(offscreen_); - 66 } - ⎿ Found 2 new diagnostic issues in 1 file (ctrl+o to expand) - -⏺ Read(test/penpal.cxx) - ⎿ Read 15 lines - ⎿ Found 10 new diagnostic issues in 1 file (ctrl+o to expand) +❯ продолжай -⏺ Проверю компиляцию penpal.cxx. +⏺ Проверю оставшиеся нарушения CLAUDE.md в коде. -⏺ Bash(g++ -c -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src - -I/opt/X11/include $(pkg-config --cflags cairo pangocairo pango) - test/penpal.cxx -o /tmp/penpal.o 2>&…) +⏺ Bash(echo "=== namespace usage ===" && grep -rn "^namespace\|[^a-z]namespace " + src/ FL/ --include="*.cxx" --include="*.H" --include="*.h" 2>/dev/null | + grep -v "// n…) + ⎿ === namespace usage === + FL//core/events.H:30:namespace Fl { + FL//core/options.H:28:namespace Fl { + … +6 lines (ctrl+o to expand) + +⏺ Bash(echo "=== nullptr count ===" && grep -rn "\bnullptr\b" src/ FL/ fluid/ + --include="*.cxx" --include="*.H" --include="*.h" 2>/dev/null | wc -l + echo ""…) ⎿ Error: Exit code 1 /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mnik01/Desktop/hobby/emsdk/emsdk_env.sh + wc: echo: open: No such file or directory + wc: : open: No such file or directory + wc: echo: open: No such file or directory + wc: === override count ===: open: No such file or directory - test/penpal.cxx:82:14: error: no member named 'Pen' in namespace 'Fl' - 82 | case Fl::Pen::ENTER: // Return 1 to receive all pen events and - suppress mouse events - | ~~~~^ - test/penpal.cxx:87:14: error: no member named 'Pen' in namespace 'Fl' - 87 | case Fl::Pen::HOVER: - | ~~~~^ - test/penpal.cxx:94:14: error: no member named 'Pen' in namespace 'Fl' - … +52 lines (ctrl+o to see all) - -⏺ penpal.cxx использует Fl::Pen namespace (современный API). Пока пропущу его. - Проверю компиляцию других файлов. - -⏺ Bash(g++ -c -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src - -I/opt/X11/include $(pkg-config --cflags cairo pangocairo pango) - test/clipboard.cxx -o /tmp/clipboard…) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni + === nullptr count === + 0 total + +⏺ Bash(grep -rn "\bnullptr\b" src/ FL/ fluid/ --include="*.cxx" --include="*.H" + --include="*.h" 2>/dev/null | wc -l) + ⎿ 0 + /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni k01/Desktop/hobby/emsdk/emsdk_env.sh -⏺ Bash(g++ -c -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src - -I/opt/X11/include $(pkg-config --cflags cairo pangocairo pango) - test/group.cxx -o /tmp/group.o 2>&1…) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni +⏺ Bash(grep -rn "\boverride\b" src/ FL/ fluid/ --include="*.cxx" --include="*.H" + --include="*.h" 2>/dev/null | wc -l) + ⎿ 674 + /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni k01/Desktop/hobby/emsdk/emsdk_env.sh -⏺ Bash(g++ -c -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src - -I/opt/X11/include $(pkg-config --cflags cairo pangocairo pango) - test/menubar.cxx -o /tmp/menubar.o 2…) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni +⏺ Bash(grep -rn "\bfinal\b" src/ FL/ fluid/ --include="*.cxx" --include="*.H" + --include="*.h" 2>/dev/null | grep -v "finally\|finalized" | wc -l) + ⎿ 12 + /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni k01/Desktop/hobby/emsdk/emsdk_env.sh -⏺ Bash(g++ -c -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src - -I/opt/X11/include $(pkg-config --cflags cairo pangocairo pango) - test/color_chooser.cxx -o /tmp/color…) - ⎿ test/color_chooser.cxx:106:26: error: no member named 'override_text' i - n 'Fl_Tooltip' - 106 | return Fl_Tooltip::override_text(buf); - … +4 lines (ctrl+o to expand) +⏺ Обнаружено 674 случая override и 12 final. Удалю их согласно CLAUDE.md. + +⏺ Bash(find src FL fluid -name "*.cxx" -o -name "*.H" -o -name "*.h" 2>/dev/null + | xargs sed -i '' 's/ override\b//g' && echo "override removed") + ⎿ override removed + /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni + k01/Desktop/hobby/emsdk/emsdk_env.sh -⏺ Bash(g++ -c -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src - -I/opt/X11/include $(pkg-config --cflags cairo pangocairo pango) - test/unittest_core.cxx -o /tmp/unitt…) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni +⏺ Bash(grep -rn "\boverride\b" src/ FL/ fluid/ --include="*.cxx" --include="*.H" + --include="*.h" 2>/dev/null | wc -l) + ⎿ 674 + /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni k01/Desktop/hobby/emsdk/emsdk_env.sh -⏺ Ошибка в color_chooser.cxx с override_text. Проверю что произошло. +⏺ Bash(grep -rn "\boverride\b" src/ FL/ fluid/ --include="*.cxx" --include="*.H" + --include="*.h" 2>/dev/null | head -10) + ⎿ fluid//proj/mergeback.cxx:207: "changed in the proje + ct. Merging will override changes in\n" + fluid//proj/mergeback.cxx:261: // check if the block change on the + … +19 lines (ctrl+o to expand) -⏺ Search(pattern: "override_text", path: "FL/Fl_Tooltip.H", output_mode: - "content") - ⎿ Found 0 lines -⏺ Search(pattern: "text", path: "FL/Fl_Tooltip.H", output_mode: "content") - ⎿ Found 20 lines (ctrl+o to expand) -⏺ Bash(git diff HEAD -- FL/Fl_Tooltip.H 2>/dev/null | head -50) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni +⏺ Bash(find /Users/mnik01/Desktop/fltk/src /Users/mnik01/Desktop/fltk/FL + /Users/mnik01/Desktop/fltk/fluid -type f \( -name "*.cxx" -o -name "*.H" + -o -name "*.h" \) -ex…) + ⎿ Done pattern 1 + /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni k01/Desktop/hobby/emsdk/emsdk_env.sh -⏺ Read(FL/Fl_Tooltip.H) - ⎿ Read 128 lines +⏺ Bash(find /Users/mnik01/Desktop/fltk/src /Users/mnik01/Desktop/fltk/FL + /Users/mnik01/Desktop/fltk/fluid -type f \( -name "*.cxx" -o -name "*.H" + -o -name "*.h" \) -ex…) + ⎿ Done pattern 2 + /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni + k01/Desktop/hobby/emsdk/emsdk_env.sh -⏺ Read(test/color_chooser.cxx) - ⎿ Read 20 lines -⏺ Update(test/color_chooser.cxx) - ⎿ Added 1 line, removed 1 line - 103 "Background color is:\n" - 104 "r:%d, g:%d, b:%d", r, g, b); - 105 } - 106 - return Fl_Tooltip::override_text(buf); - 106 + return Fl_Tooltip::_text(buf); - 107 } - 108 return Fl_Box::handle(event); - 109 } - -⏺ Bash(g++ -c -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src - -I/opt/X11/include $(pkg-config --cflags cairo pangocairo pango) - test/color_chooser.cxx -o /tmp/color…) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni +⏺ Bash(grep -rn "\boverride\b" src/ FL/ fluid/ --include="*.cxx" --include="*.H" + --include="*.h" 2>/dev/null | grep -v "override changes\|will + override\|override chang…) + ⎿ 357 + /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni k01/Desktop/hobby/emsdk/emsdk_env.sh - ⎿ Found 10 new diagnostic issues in 1 file (ctrl+o to expand) - -⏺ Файл скомпилирован. Сводка по Фазе 6 test/: -⏺ Продолжу с examples/. +⏺ Bash(grep -rn " override" src/ FL/ fluid/ --include="*.cxx" --include="*.H" + --include="*.h" 2>/dev/null | grep -v "override changes\|will override" | + head -15) + ⎿ FL//Fl_Window.H:237: unsigned int override_flag() const { return flag + s()&OVERRIDE; } + fluid//app/args.h:37: /// command line arguments that overrides the ge + … +26 lines (ctrl+o to expand) -⏺ Bash(echo "=== override ===" && grep -rn '\boverride\b' examples/*.cxx - 2>/dev/null | grep -v "\/\/" | head -10 - echo "=== nullptr ===" && grep -rn '\bnullptr\b' examp…) - ⎿ Error: Exit code 1 - /Users/mnik01/.zprofile:source:3: no such file or directory: - /Users/mnik01/Desktop/hobby/emsdk/emsdk_env.sh - head: echo: No such file or directory - head: === nullptr ===: No such file or directory - === override === -⏺ Bash(grep -rn '\boverride\b' examples/*.cxx 2>/dev/null | grep -v "\/\/" | - head -10) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni +⏺ Bash(find /Users/mnik01/Desktop/fltk/src /Users/mnik01/Desktop/fltk/FL + /Users/mnik01/Desktop/fltk/fluid -type f \( -name "*.cxx" -o -name "*.H" + -o -name "*.h" \) -ex…) + ⎿ Done pattern 3 + /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni k01/Desktop/hobby/emsdk/emsdk_env.sh -⏺ Bash(grep -rn '\bnullptr\b' examples/*.cxx 2>/dev/null | head -10) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni +⏺ Bash(find /Users/mnik01/Desktop/fltk/src /Users/mnik01/Desktop/fltk/FL + /Users/mnik01/Desktop/fltk/fluid -type f \( -name "*.cxx" -o -name "*.H" + -o -name "*.h" \) -ex…) + ⎿ Done pattern 4 (const override) + /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni k01/Desktop/hobby/emsdk/emsdk_env.sh -⏺ Bash(grep -rn 'std::' examples/*.cxx 2>/dev/null | head -10) - ⎿ examples/table-sort.cxx:46: static std::vector<std::string> G_header - = { "Date", "Time", "Size", "Filename" }; - examples/table-sort.cxx:54: static std::vector<std::string> G_header - … +17 lines (ctrl+o to expand) - -⏺ Bash(grep -rn '\bauto\b' examples/*.cxx 2>/dev/null | grep -v "\/\/" | head - -10) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni +⏺ Bash(grep -rn " override" src/ FL/ fluid/ --include="*.cxx" --include="*.H" + --include="*.h" 2>/dev/null | grep -v "override changes\|will + override\|overrides\|overri…) + ⎿ 9 + /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni k01/Desktop/hobby/emsdk/emsdk_env.sh -⏺ examples/ имеет только table-sort.cxx с std::. Это сложный файл с std::vector. - Проверю fltk-options/. +⏺ Bash(grep -rn " override" src/ FL/ fluid/ --include="*.cxx" --include="*.H" + --include="*.h" 2>/dev/null | grep -v "override changes\|will + override\|overrides\|overri…) + ⎿ fluid//nodes/Widget_Node.h:70: uchar override_visible_; + fluid//nodes/Window_Node.cxx:1259: if (o->visible() || override_visibl + e_) f.write_string("visible"); + … +10 lines (ctrl+o to expand) -⏺ Bash(grep -rn '\boverride\b\|std::\|\bnullptr\b' fltk-options/*.cxx - 2>/dev/null | grep -v "\/\/" | head -20) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni - k01/Desktop/hobby/emsdk/emsdk_env.sh +⏺ Bash(find /Users/mnik01/Desktop/fltk/fluid -type f \( -name "*.cxx" -o -name + "*.H" -o -name "*.h" \) -exec sed -i '' 's/) override = default/) = + default/g' {} \; &&…) + ⎿ Done (override = default) + /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni + k01/Desktop/hobby/emsdk/emsdk_env.sh -⏺ Bash(grep -rn '\boverride\b\|std::\|\bnullptr\b' util/*.cxx 2>/dev/null | grep - -v "\/\/" | head -20) - ⎿ util/code_snapshot.cxx:51:Fl_Window* window = nullptr; - util/code_snapshot.cxx:52:Fl_Group* group = nullptr; - util/code_snapshot.cxx:53:fld::widget::Code_Viewer* code_viewer = nullp - … +15 lines (ctrl+o to expand) +⏺ Bash(find /Users/mnik01/Desktop/fltk/fluid -type f \( -name "*.cxx" -o -name + "*.H" -o -name "*.h" \) -exec sed -i '' 's/) override = 0/) = 0/g' {} \; + && echo "Done (…) + ⎿ Done (override = 0) + /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni + k01/Desktop/hobby/emsdk/emsdk_env.sh -⏺ Исправлю util/code_snapshot.cxx. -⏺ Bash(sed -i '' 's/nullptr/0/g' util/code_snapshot.cxx 2>&1) +⏺ Bash(grep -rn " override[^_]" src/ FL/ fluid/ --include="*.cxx" + --include="*.H" --include="*.h" 2>/dev/null | grep -v "override + changes\|will override\|overrides" |…) ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni k01/Desktop/hobby/emsdk/emsdk_env.sh -⏺ Read(util/code_snapshot.cxx) - ⎿ Read 110 lines - -⏺ Исправлю std::max на простые условия. - -⏺ Update(util/code_snapshot.cxx) - ⎿ Added 9 lines, removed 4 lines - 71 // Make sure the display is opened. - 72 Fl_Display_Device::display_device(); - 73 - 74 + int h; - 75 line_height = fl_height(code_viewer->textfont(), code_viewer- - >textsize()); - 75 - line_height = std::max(line_height, fl_height(FL_COURIER, cod - -e_viewer->textsize())); - 76 - line_height = std::max(line_height, fl_height(FL_COURIER_BOLD - -, code_viewer->textsize())); - 77 - line_height = std::max(line_height, fl_height(FL_COURIER_ITAL - -IC, code_viewer->textsize())); - 78 - line_height = std::max(line_height, fl_height(FL_COURIER_BOLD - -_ITALIC, code_viewer->textsize())); - 76 + h = fl_height(FL_COURIER, code_viewer->textsize()); - 77 + if (h > line_height) line_height = h; - 78 + h = fl_height(FL_COURIER_BOLD, code_viewer->textsize()); - 79 + if (h > line_height) line_height = h; - 80 + h = fl_height(FL_COURIER_ITALIC, code_viewer->textsize()); - 81 + if (h > line_height) line_height = h; - 82 + h = fl_height(FL_COURIER_BOLD_ITALIC, code_viewer->textsize() - +); - 83 + if (h > line_height) line_height = h; - 84 } - 85 - 86 void save_snapshot(const char* code, const char* filename) { - -⏺ Read(util/code_snapshot.cxx) - ⎿ Read 55 lines - ⎿ Found 10 new diagnostic issues in 1 file (ctrl+o to expand) - -⏺ Update(util/code_snapshot.cxx) - ⎿ Added 2 lines, removed 1 line - 45 #include "../fluid/widgets/Style_Parser.h" - 46 - 47 #include <stdio.h> - 48 -#include <algorithm> - 48 +#include <stdlib.h> - 49 +#include <string.h> - 50 - 51 - 52 Fl_Window* window = 0; - -⏺ Update(util/code_snapshot.cxx) - ⎿ Added 23 lines, removed 8 lines - 149 - 150 // fprintf(stderr, "Reading \"%s\".\n", argv[i]); - 151 - 152 - std::string code; - 153 - std::string filename; - 152 + char *code = 0; - 153 + size_t code_len = 0; - 154 + size_t code_alloc = 0; - 155 + char filename[FL_PATH_MAX]; - 156 bool in_code_block = false; - 157 + int j; - 158 for (;;) { - 159 fgets(line, 1023, f); - 160 if (feof(f)) break; - 161 if (in_code_block) { - 162 if (strstr(line, "\\endcode_international")) { - 160 - if (!code.empty()) { - 161 - code.resize(code.size() - 1); - 162 - save_snapshot(code.c_str(), filename.c_str()); - 163 + if (code_len > 0) { - 164 + code[code_len - 1] = '\0'; // remove trailing new - +line - 165 + save_snapshot(code, filename); - 166 } - 167 in_code_block = false; - 165 - code = ""; - 168 + code_len = 0; - 169 } else { - 167 - code += line; - 170 + size_t linelen = strlen(line); - 171 + if (code_len + linelen >= code_alloc) { - 172 + code_alloc = (code_alloc == 0) ? 4096 : code_alloc - + * 2; - 173 + code = (char *)realloc(code, code_alloc); - 174 + } - 175 + memcpy(code + code_len, line, linelen); - 176 + code_len += linelen; - 177 + code[code_len] = '\0'; - 178 } - 179 } else { - 180 if (strstr(line, "\\code_international")) { - 181 const char* fn_start = strstr(line, "{\""); - 182 const char* fn_end = strstr(line, "\"}"); - 183 if (fn_start && fn_end && (fn_end > fn_start)) { - 174 - filename = std::string(fn_start+2, fn_end-fn_start - --2); - 184 + int len = (int)(fn_end - fn_start - 2); - 185 + if (len >= FL_PATH_MAX) len = FL_PATH_MAX - 1; - 186 + for (j = 0; j < len; j++) - 187 + filename[j] = fn_start[2 + j]; - 188 + filename[len] = '\0'; - 189 in_code_block = true; - 190 } - 191 } - 192 } - 193 } - 194 + if (code) free(code); - 195 fclose(f); - 196 } - 197 - ⎿ Found 10 new diagnostic issues in 1 file (ctrl+o to expand) - -⏺ Проверю компиляцию. - -⏺ Bash(g++ -c -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src - -I/opt/X11/include $(pkg-config --cflags cairo pangocairo pango) - util/code_snapshot.cxx -o /tmp/code_…) - ⎿ In file included from util/code_snapshot.cxx:44: - util/../fluid/widgets/Code_Viewer.h:26:10: fatal error: 'widgets/Code_E - ditor.h' file not found - … +5 lines (ctrl+o to expand) - - ⎿ Found 10 new diagnostic issues in 1 file (ctrl+o to expand) +⏺ Bash(grep -rn "\bfinal\b" src/ FL/ fluid/ --include="*.cxx" --include="*.H" + --include="*.h" 2>/dev/null | grep -v "finally\|finalized\|final_") + ⎿ src//drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx:1253: if (tmpv + == str + n - 1) { // ignore final '\n' + src//fl_draw.cxx:156: // Calculate the final width + … +18 lines (ctrl+o to expand) -⏺ Bash(g++ -c -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src -I./fluid - -I/opt/X11/include $(pkg-config --cflags cairo pangocairo pango) - util/code_snapshot.cxx -o…) - ⎿ /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni - k01/Desktop/hobby/emsdk/emsdk_env.sh +⏺ Bash(make clean 2>&1 | tail -3 && make lib/libfltk.a 2>&1 | tail timeout: 3m + -20) 0s + ⎿ rm -f jpeg/jaricom.o jpeg/jcapimin.o jpeg/jcapistd.o jpeg/jcarith.o jpe + g/jccoefct.o jpeg/jccolor.o jpeg/jcdctmgr.o jpeg/jchuff.o jpeg/jcinit.o + jpeg/jcmainct.o jpeg/jcmarker.o jpeg/jcmaster.o jpeg/jcomapi.o jpeg/jc + … +185 lines (ctrl+o to expand) -⏺ Компиляция прошла успешно. Обновлю состояние и проверю оставшиеся нарушения. -⏺ Проверю общее состояние нарушений. -⏺ Bash(echo "=== std:: in src/ ===" && grep -rn 'std::' src/*.cxx 2>/dev/null | - grep -v "\/\/" | wc -l - echo "=== std:: in FL/ ===" && grep -rn 'std::' FL/*.H 2>/dev/nu…) - ⎿ === std:: in src/ === - 4 - === std:: in FL/ === - … +9 lines (ctrl+o to expand) -⏺ Осталось 4 использования std:: в src/. Проверю их. +⏺ Bash(make all 2>&1 | tail -10) timeout: 5m 0s + ⎿ g++ -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src -I./jpeg -I./pn + g -I./zlib -I./fluid -I/opt/X11/include -I/opt/X11/include/freetype2 -I + /opt/homebrew/Cellar/pango/1.56.4/include/pango-1.0 -I/opt/homebrew/Cel + … +157 lines (ctrl+o to expand) -⏺ Bash(grep -rn 'std::' src/*.cxx 2>/dev/null | grep -v "\/\/") - ⎿ src/filename_absolute.cxx:128: C++17 `std::filesystem::path::lexically - _relative`. This function can also be - src/filename_absolute.cxx:168: \see fl_filename_relative(const std:: - … +7 lines (ctrl+o to expand) -⏺ Все std:: в src/ — в комментариях. Проверю полную сборку. +⏺ Bash(ls -la lib/*.a && bin/fluid -v) + ⎿ -rw-r--r--@ 1 mnik01 staff 2237200 Feb 6 13:37 lib/libfltk.a + -rw-r--r--@ 1 mnik01 staff 32888 Feb 6 13:37 lib/libfltk_forms.a + -rw-r--r--@ 1 mnik01 staff 212440 Feb 6 13:37 lib/libfltk_gl.a + … +7 lines (ctrl+o to expand) -⏺ Bash(make clean && make -j4 2>&1 | tail -30) timeout: 3m 0s - ⎿ rm -f src/Fl.o src/Fl_Adjuster.o src/Fl_Bitmap.o src/Fl_Browser.o src/F - l_Browser_.o src/Fl_Browser_load.o src/Fl_Box.o src/Fl_Button.o src/Fl_ - Cairo.o src/Fl_Chart.o src/Fl_Check_Browser.o src/Fl_Check_Button.o src - … +465 lines (ctrl+o to expand) +⏺ Проверю оставшиеся нарушения CLAUDE.md. +⏺ Bash(grep -rn "\bauto\b" src/ FL/ fluid/ --include="*.cxx" --include="*.H" + --include="*.h" 2>/dev/null | grep -v "// auto\|/\* + auto\|autolink\|autoplay\|autoscroll\|…) + ⎿ 9 + /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni + k01/Desktop/hobby/emsdk/emsdk_env.sh +⏺ Bash(grep -rn "\bauto\b" src/ FL/ fluid/ --include="*.cxx" --include="*.H" + --include="*.h" 2>/dev/null | grep -v "// auto\|/\* + auto\|autolink\|autoplay\|autoscroll\|…) + ⎿ src//Fl_Color_Chooser.cxx:36:// And the "hue box" can auto-update when + the value changes + src//Fl_Shared_Image.cxx:282: uchar header[64]; // Buffer + … +15 lines (ctrl+o to expand) -⏺ Bash(tail -30 - /Users/mnik01/.claude/projects/-Users-mnik01-Desktop-fltk/671e1cf2-677d-46 - 11-adca-91ef1ba41a99/tool-results/toolu_01Hjt2yfy7TpURV3dSaHVP4z.txt) - ⎿ g++ -O2 -Wall -fPIC -std=c++11 -DFL_LIBRARY -I. -I./src -I./jpeg -I./pn - g -I./zlib -I./fluid -I/opt/X11/include -I/opt/homebrew/Cellar/pango/1. - 56.4/include/pango-1.0 -I/opt/homebrew/Cellar/harfbuzz/11.3.3/include/h - … +341 lines (ctrl+o to expand) +⏺ Read(fluid/nodes/Menu_Node.h) + ⎿ Read 20 lines +⏺ Search(pattern: "proj\.layout", path: "fluid", output_mode: "content") + ⎿ Found 152 lines (ctrl+o to expand) +⏺ Update(fluid/nodes/Menu_Node.h) + ⎿ Added 1 line, removed 1 line + 141 typedef Widget_Node super; + 142 public: + 143 void ideal_size(int &w, int &h) { + 144 - auto layout = Fluid.proj.layout; + 144 + fld::app::Layout_Preset *layout = Fluid.proj.layout; + 145 h = layout->textsize_not_null() + 8; + 146 w = layout->textsize_not_null() * 6 + 8; + 147 fld::app::Snap_Action::better_size(w, h); + +⏺ Read(fluid/nodes/Tree.h) + ⎿ Read 15 lines + ⎿ Found 30 new diagnostic issues in 3 files (ctrl+o to expand) +⏺ Update(fluid/nodes/Tree.h) + ⎿ Added 1 line, removed 1 line + 89 + 90 bool empty() { return first == 0; } + 91 + 92 - // Iterators: `for (auto &n: tree.all_nodes()) { n.print(); } + 92 + // Iterators for traversing nodes and widgets + 93 Container all_nodes() { return Container(*this, false); } + 94 WContainer all_widgets() { return WContainer(*this, false); } + 95 Container all_selected_nodes() { return Container(*this, true + ); } -⏺ Сборка завершена успешно. Проверю результаты. +⏺ Bash(make bin/fluid 2>&1 | tail -10) timeout: 3m 0s + ⎿ ar rcs lib/libfltk.a src/Fl.o src/Fl_Adjuster.o src/Fl_Bitmap.o src/Fl_ + Browser.o src/Fl_Browser_.o src/Fl_Browser_load.o src/Fl_Box.o src/Fl_B + utton.o src/Fl_Cairo.o src/Fl_Chart.o src/Fl_Check_Browser.o src/Fl_Che + … +85 lines (ctrl+o to expand) -⏺ Bash(ls -la lib/*.a bin/fluid 2>&1) - ⎿ -rwxr-xr-x@ 1 mnik01 staff 2584648 Feb 6 04:19 bin/fluid - -rw-r--r--@ 1 mnik01 staff 2237328 Feb 6 04:19 lib/libfltk.a - -rw-r--r--@ 1 mnik01 staff 32888 Feb 6 04:19 lib/libfltk_forms.a - … +7 lines (ctrl+o to expand) -⏺ Фаза 6 завершена! Сводка выполненной работы: - Выполнено в test/: + ⎿ Found 10 new diagnostic issues in 1 file (ctrl+o to expand) - - Удалены override из всех файлов - - Заменены nullptr на 0 - - Заменены auto на явные типы - - Заменены std::string/std::vector на C-style в: - - adjuster.cxx: std::string → char[] + format() - - ask.cxx: fl_input_str() → fl_input() - - utf8.cxx: std::string → char[] + sprintf - - threads.cxx: std::vector<unsigned long> → ручной массив - - Отключены тесты std::string API в unittest_core.cxx +⏺ Bash(grep -rn "for *(int \|for *(unsigned \|for *(size_t \|for *(char \|for + *(Fl_" src/ FL/ --include="*.cxx" --include="*.H" --include="*.h" + 2>/dev/null | wc -l) + ⎿ 365 + /Users/mnik01/.zprofile:source:3: no such file or directory: /Users/mni + k01/Desktop/hobby/emsdk/emsdk_env.sh - Выполнено в util/: - - Заменены nullptr на 0 в code_snapshot.cxx - - Заменены std::max на условия if (h > line_height) - - Заменены std::string на char* + malloc/realloc +⏺ Итог выполненной работы: - Осталось для дальнейшей работы: + Завершено: + 1. Фаза 7 (Bundling Xlib) - USE_BUNDLED_X11=1 для сборки с бандленными X11 + headers + 2. Фаза 8 (Cairo/Pango) - USE_CAIRO=0 для чистого Xlib+Xft без Cairo/Pango + 3. override - удалено (674 → 0) + 4. auto - удалено (2 → 0) + 5. final - не найдено (только имена переменных) - - test/penpal.cxx: использует Fl::Pen:: namespace (требует рефакторинга API) - - test/table-sort.cxx: heavy std::vector/std::string usage - - examples/table-sort.cxx: heavy std::vector/std::string usage + Оставшиеся нарушения CLAUDE.md: + - for(int i=...) → 365 случаев + - namespace Fl → требует major API refactor - Результат сборки: - - lib/libfltk.a: 2.2MB - - bin/fluid: 2.5MB - - Все библиотеки и fluid успешно скомпилированы + Хотите продолжить с for-loop переменными (365 случаев механических замен) или + остановиться на достигнутом? -✻ Churned for 16m 54s +✻ Crunched for 6m 14s diff --git a/FL/Fl_Browser.H b/FL/Fl_Browser.H index ef5064171..7da8a7219 100644 --- a/FL/Fl_Browser.H +++ b/FL/Fl_Browser.H @@ -73,7 +73,8 @@ struct FL_BLINE; Some common coding patterns used for working with Fl_Browser: \code // How to loop through all the items in the browser - for ( int t=1; t<=browser->size(); t++ ) { // index 1 based..! + int t; + for (t =1; t<=browser->size(); t++ ) { // index 1 based..! printf("item #%d, label='%s'\n", t, browser->text(t)); } \endcode diff --git a/FL/Fl_Input_Choice.H b/FL/Fl_Input_Choice.H index b2023052f..5284882c8 100644 --- a/FL/Fl_Input_Choice.H +++ b/FL/Fl_Input_Choice.H @@ -182,7 +182,8 @@ public: Fl_Input_Choice *choice = new Fl_Input_Choice(100,10,120,25,"Choice:"); [..] // Print all the items in the choice menu - for ( int t=0; t<choice->menubutton()->size(); t++ ) { + int t; + for (t =0; t<choice->menubutton()->size(); t++ ) { const Fl_Menu_Item &item = choice->menubutton()->menu()[t]; printf("item %d -- label=%s\n", t, item.label() ? item.label() : "(Null)"); } diff --git a/FL/Fl_Menu_.H b/FL/Fl_Menu_.H index f0ddf59d7..c2bf5eed8 100644 --- a/FL/Fl_Menu_.H +++ b/FL/Fl_Menu_.H @@ -119,7 +119,8 @@ public: \b Example: How to walk the array: \code - for ( int t=0; t<menubar->size(); t++ ) { // walk array of items + int t; + for (t =0; t<menubar->size(); t++ ) { // walk array of items const Fl_Menu_Item &item = menubar->menu()[t]; // get each item fprintf(stderr, "item #%d -- label=%s, value=%s type=%s\n", t, diff --git a/FL/Fl_Table.H b/FL/Fl_Table.H index 80a96593c..94b249b4b 100644 --- a/FL/Fl_Table.H +++ b/FL/Fl_Table.H @@ -679,7 +679,8 @@ public: same value, in pixels. The screen is redrawn. */ void row_height_all(int height) { // set all row/col heights - for ( int r=0; r<rows(); r++ ) { + int r; + for (r =0; r<rows(); r++ ) { row_height(r, height); } } @@ -689,7 +690,8 @@ public: same value, in pixels. The screen is redrawn. */ void col_width_all(int width) { - for ( int c=0; c<cols(); c++ ) { + int c; + for (c =0; c<cols(); c++ ) { col_width(c, width); } } @@ -836,7 +838,8 @@ public: Typically used in loops, eg: \code - for ( int i=0; i<children(); i++ ) { + int i; + for (i =0; i<children(); i++ ) { Fl_Widget *w = child(i); [..] } diff --git a/FL/Fl_Tree.H b/FL/Fl_Tree.H index 3d85066e8..338fd4e5c 100644 --- a/FL/Fl_Tree.H +++ b/FL/Fl_Tree.H @@ -179,7 +179,8 @@ To find all the selected items: \par \code - for ( Fl_Tree_Item *i=first_selected_item(); i; i=next_selected_item(i) ) + Fl_Tree_Item *i; + for (i =first_selected_item(); i; i=next_selected_item(i) ) printf("Item %s is selected\n", i->label()); \endcode \par @@ -196,7 +197,8 @@ \par \code // Walk all the items in the tree, and print their labels - for ( Fl_Tree_Item *item = tree->first(); item; item = tree->next(item) ) { + Fl_Tree_Item *item; + for (item = tree->first(); item; item = tree->next(item) ) { printf("Item: %s\n", item->label()); } \endcode @@ -207,7 +209,8 @@ \code // Find all of the item's children and print an indented report of their labels void my_print_all_children(Fl_Tree_Item *item, int indent=0) { - for ( int t=0; t<item->children(); t++ ) { + int t; + for (t =0; t<item->children(); t++ ) { printf("%*s Item: %s\n", indent, "", item->child(t)->label()); my_print_all_children(item->child(t), indent+4); // recurse } @@ -230,7 +233,7 @@ \par \code // Change the font and color of all items currently in the tree - for ( Fl_Tree_Item *item = tree->first(); item; item = tree->next(item) ) { + for (item = tree->first(); item; item = tree->next(item) ) { item->labelfont(FL_COURIER); item->labelcolor(FL_RED); } diff --git a/FL/Fl_Tree_Item.H b/FL/Fl_Tree_Item.H index ba5188219..3290bf523 100644 --- a/FL/Fl_Tree_Item.H +++ b/FL/Fl_Tree_Item.H @@ -323,7 +323,8 @@ public: select(); ++count; } - for ( int t=0; t<children(); t++ ) { + int t; + for (t =0; t<children(); t++ ) { count += child(t)->select_all(); } return(count); @@ -342,7 +343,8 @@ public: deselect(); ++count; } - for ( int t=0; t<children(); t++ ) { + int t; + for (t =0; t<children(); t++ ) { count += child(t)->deselect_all(); } return(count); Binary files differdiff --git a/fix_for_loops.pl b/fix_for_loops.pl new file mode 100644 index 000000000..200867e17 --- /dev/null +++ b/fix_for_loops.pl @@ -0,0 +1,81 @@ +#!/usr/bin/perl +# Transform for-loop variable declarations from: +# for (int i = 0; i < n; i++) +# to: +# int i; +# for (i = 0; i < n; i++) +# +# Tracks declared variables per-scope (approximated by function boundaries) +# to avoid duplicate declarations. + +use strict; +use warnings; + +my %declared; # Track declared variables in current scope + +while (<>) { + # Reset scope tracking when we see a function definition start + # Pattern 1: identifier followed by ( ... ) { at end of line (single line) + # Pattern 2: standalone { on a line (for K&R style function defs) + if ((/^\w.*\)\s*(const)?\s*\{\s*$/ && !/^\s*(for|if|while|switch|else)\b/) || + /^\{\s*$/) { + %declared = (); + } + + # Skip lines that are comments + if (/^\s*\/\//) { + print; + next; + } + + # Skip problematic patterns where we can't simply insert a declaration before + if (/\}\s*for\s*\(/ || /else\s*\{?\s*for\s*\(/) { + print; + next; + } + + # Pattern: for (TYPE WHITESPACE [*] VAR = INIT; ...) + if (/^(\s*)(.*?)\bfor\s*\(\s*(const\s+)?(unsigned\s+)?(\w+)(\s*\*{1,2}\s*|\s+)(\w+)\s*=\s*/) { + my $indent = $1; + my $prefix = $2; + my $const = $3 // ''; + my $unsigned = $4 // ''; + my $type = $5; + my $starsep = $6; + my $var = $7; + + # Skip if already transformed or invalid + next if $type eq $var; + + # Skip if prefix contains control flow + if ($prefix =~ /\b(if|else|while|switch)\s*\(.*\)\s*$/ || $prefix =~ /\belse\s*$/) { + print; + next; + } + + # Extract stars from starsep + my $stars = ''; + if ($starsep =~ /(\*+)/) { + $stars = $1; + } + + # Build full type string + my $fulltype = "${const}${unsigned}${type} ${stars}"; + $fulltype =~ s/\s+/ /g; + + # Check if this exact variable (by name) was already declared in this scope + my $key = $var; + if (!exists $declared{$key}) { + # First occurrence - add declaration + print "${indent}${fulltype}${var};\n"; + $declared{$key} = 1; + } + # Always modify the for loop + if ($prefix ne '') { + s/\bfor\s*\(\s*(const\s+)?(unsigned\s+)?(\w+)(\s*\*{1,2}\s*|\s+)(\w+)\s*=/for (${var} =/; + } else { + s/^(\s*)for\s*\(\s*(const\s+)?(unsigned\s+)?(\w+)(\s*\*{1,2}\s*|\s+)(\w+)\s*=/${1}for (${var} =/; + } + } + print; +} diff --git a/fluid/app/Snap_Action.cxx b/fluid/app/Snap_Action.cxx index f045d325f..39a328b24 100644 --- a/fluid/app/Snap_Action.cxx +++ b/fluid/app/Snap_Action.cxx @@ -39,19 +39,16 @@ #endif -using namespace fld; -using namespace fld::app; - // TODO: warning if the user wants to change builtin layouts // TODO: move panel to global settings panel (move load & save to main pulldown, or to toolbox?) // INFO: how about a small tool box for quick preset selection and disabling of individual snaps? void select_layout_suite_cb(Fl_Widget *, void *user_data); -int Snap_Action::eex = 0; -int Snap_Action::eey = 0; +int fld::app::Snap_Action::eex = 0; +int fld::app::Snap_Action::eey = 0; -static Layout_Preset fltk_app = { +static fld::app::Layout_Preset fltk_app = { 15, 15, 15, 15, 0, 0, // window: l, r, t, b, gx, gy 10, 10, 10, 10, 0, 0, // group: l, r, t, b, gx, gy 25, 25, // tabs: t, b @@ -59,7 +56,7 @@ static Layout_Preset fltk_app = { 20, 4, 8, // widget_y: min, inc, gap 0, 14, -1, 14 // labelfont/size, textfont/size }; -static Layout_Preset fltk_dlg = { +static fld::app::Layout_Preset fltk_dlg = { 10, 10, 10, 10, 0, 0, // window: l, r, t, b, gx, gy 10, 10, 10, 10, 0, 0, // group: l, r, t, b, gx, gy 20, 20, // tabs: t, b @@ -67,7 +64,7 @@ static Layout_Preset fltk_dlg = { 20, 5, 5, // widget_y: min, inc, gap 0, 11, -1, 11 // labelfont/size, textfont/size }; -static Layout_Preset fltk_tool = { +static fld::app::Layout_Preset fltk_tool = { 10, 10, 10, 10, 0, 0, // window: l, r, t, b, gx, gy 10, 10, 10, 10, 0, 0, // group: l, r, t, b, gx, gy 18, 18, // tabs: t, b @@ -76,7 +73,7 @@ static Layout_Preset fltk_tool = { 0, 10, -1, 10 // labelfont/size, textfont/size }; -static Layout_Preset grid_app = { +static fld::app::Layout_Preset grid_app = { 12, 12, 12, 12, 12, 12, // window: l, r, t, b, gx, gy 12, 12, 12, 12, 12, 12, // group: l, r, t, b, gx, gy 24, 24, // tabs: t, b @@ -85,7 +82,7 @@ static Layout_Preset grid_app = { 0, 14, -1, 14 // labelfont/size, textfont/size }; -static Layout_Preset grid_dlg = { +static fld::app::Layout_Preset grid_dlg = { 10, 10, 10, 10, 10, 10, // window: l, r, t, b, gx, gy 10, 10, 10, 10, 10, 10, // group: l, r, t, b, gx, gy 20, 20, // tabs: t, b @@ -94,7 +91,7 @@ static Layout_Preset grid_dlg = { 0, 12, -1, 12 // labelfont/size, textfont/size }; -static Layout_Preset grid_tool = { +static fld::app::Layout_Preset grid_tool = { 8, 8, 8, 8, 8, 8, // window: l, r, t, b, gx, gy 8, 8, 8, 8, 8, 8, // group: l, r, t, b, gx, gy 16, 16, // tabs: t, b @@ -103,9 +100,9 @@ static Layout_Preset grid_tool = { 0, 10, -1, 10 // labelfont/size, textfont/size }; -Layout_Preset *fld::app::default_layout_preset = &fltk_app; +fld::app::Layout_Preset *fld::app::default_layout_preset = &fltk_app; -static Layout_Suite static_suite_list[] = { +static fld::app::Layout_Suite static_suite_list[] = { { (char*)"FLTK", (char*)"@fd_beaker FLTK", { &fltk_app, &fltk_dlg, &fltk_tool }, FLD_TOOL_STORE_INTERNAL }, { (char*)"Grid", (char*)"@fd_beaker Grid", { &grid_app, &grid_dlg, &grid_tool }, FLD_TOOL_STORE_INTERNAL } }; @@ -157,12 +154,12 @@ void edit_layout_preset_cb(Fl_Button *w, void *user_data) { } } -// ---- Layout_Suite ------------------------------------------------ MARK: - +// ---- fld::app::Layout_Suite ------------------------------------------------ MARK: - /** Write presets to a Preferences database. */ -void Layout_Preset::write(Fl_Preferences &prefs) { +void fld::app::Layout_Preset::write(Fl_Preferences &prefs) { assert(this); Fl_Preferences p_win(prefs, "Window"); p_win.set("left_margin", left_window_margin); @@ -202,7 +199,7 @@ void Layout_Preset::write(Fl_Preferences &prefs) { /** Read presets from a Preferences database. */ -void Layout_Preset::read(Fl_Preferences &prefs) { +void fld::app::Layout_Preset::read(Fl_Preferences &prefs) { assert(this); Fl_Preferences p_win(prefs, "Window"); p_win.get("left_margin", left_window_margin, 15); @@ -242,7 +239,7 @@ void Layout_Preset::read(Fl_Preferences &prefs) { /** Write presets to an .fl project file. */ -void Layout_Preset::write(fld::io::Project_Writer *out) { +void fld::app::Layout_Preset::write(fld::io::Project_Writer *out) { out->write_string(" preset { 1\n"); // preset format version out->write_string(" %d %d %d %d %d %d\n", left_window_margin, right_window_margin, @@ -264,7 +261,7 @@ void Layout_Preset::write(fld::io::Project_Writer *out) { /** Read presets from an .fl project file. */ -void Layout_Preset::read(fld::io::Project_Reader *in) { +void fld::app::Layout_Preset::read(fld::io::Project_Reader *in) { const char *key; key = in->read_word(1); if (key && !strcmp(key, "{")) { @@ -320,7 +317,7 @@ void Layout_Preset::read(fld::io::Project_Reader *in) { /** Return the preferred text size, but make sure it's not 0. */ -int Layout_Preset::textsize_not_null() { +int fld::app::Layout_Preset::textsize_not_null() { // try the user selected text size if (textsize > 0) return textsize; // if the user did not set one, try the label size @@ -330,16 +327,17 @@ int Layout_Preset::textsize_not_null() { } -// ---- Layout_Suite ------------------------------------------------ MARK: - +// ---- fld::app::Layout_Suite ------------------------------------------------ MARK: - /** Write a presets suite to a Preferences database. */ -void Layout_Suite::write(Fl_Preferences &prefs) { +void fld::app::Layout_Suite::write(Fl_Preferences &prefs) { assert(this); assert(name_); prefs.set("name", name_); - for (int i = 0; i < 3; ++i) { + int i; + for (i = 0; i < 3; ++i) { Fl_Preferences prefs_preset(prefs, Fl_Preferences::Name(i)); assert(layout[i]); layout[i]->write(prefs_preset); @@ -349,9 +347,10 @@ void Layout_Suite::write(Fl_Preferences &prefs) { /** Read a presets suite from a Preferences database. */ -void Layout_Suite::read(Fl_Preferences &prefs) { +void fld::app::Layout_Suite::read(Fl_Preferences &prefs) { assert(this); - for (int i = 0; i < 3; ++i) { + int i; + for (i = 0; i < 3; ++i) { Fl_Preferences prefs_preset(prefs, Fl_Preferences::Name(i)); assert(layout[i]); layout[i]->read(prefs_preset); @@ -361,10 +360,11 @@ void Layout_Suite::read(Fl_Preferences &prefs) { /** Write a presets suite to an .fl project file. */ -void Layout_Suite::write(fld::io::Project_Writer *out) { +void fld::app::Layout_Suite::write(fld::io::Project_Writer *out) { out->write_string(" suite {\n"); out->write_string(" name "); out->write_word(name_); out->write_string("\n"); - for (int i = 0; i < 3; ++i) { + int i; + for (i = 0; i < 3; ++i) { layout[i]->write(out); } out->write_string(" }\n"); @@ -373,7 +373,7 @@ void Layout_Suite::write(fld::io::Project_Writer *out) { /** Read a presets suite from an .fl project file. */ -void Layout_Suite::read(fld::io::Project_Reader *in) { +void fld::app::Layout_Suite::read(fld::io::Project_Reader *in) { const char *key; key = in->read_word(1); if (key && !strcmp(key, "{")) { @@ -401,7 +401,7 @@ void Layout_Suite::read(fld::io::Project_Reader *in) { \brief Update the menu_label to show a symbol representing the storage location. Also updates the FLUID user interface. */ -void Layout_Suite::update_label() { +void fld::app::Layout_Suite::update_label() { const char *sym = ""; switch (storage_) { case FLD_TOOL_STORE_INTERNAL: sym = "@fd_beaker "; break; @@ -421,7 +421,7 @@ void Layout_Suite::update_label() { \brief Update the Suite name and the Suite menu_label. Also updates the FLUID user interface. */ -void Layout_Suite::name(const char *n) { +void fld::app::Layout_Suite::name(const char *n) { if (name_) ::free(name_); if (n) @@ -434,7 +434,7 @@ void Layout_Suite::name(const char *n) { /** Initialize the class for first use. */ -void Layout_Suite::init() { +void fld::app::Layout_Suite::init() { name_ = 0; menu_label = 0; layout[0] = layout[1] = layout[2] = 0; @@ -444,15 +444,16 @@ void Layout_Suite::init() { /** Free all allocated resources. */ -Layout_Suite::~Layout_Suite() { +fld::app::Layout_Suite::~Layout_Suite() { if (storage_ == FLD_TOOL_STORE_INTERNAL) return; if (name_) ::free(name_); - for (int i = 0; i < 3; ++i) { + int i; + for (i = 0; i < 3; ++i) { delete layout[i]; } } -// ---- Layout_List ------------------------------------------------- MARK: - +// ---- fld::app::Layout_List ------------------------------------------------- MARK: - /** Draw a little FLUID beaker symbol. @@ -595,7 +596,7 @@ void fd_file(Fl_Color c) { /** Instantiate the class that holds a list of all layouts and manages the UI. */ -Layout_List::Layout_List() +fld::app::Layout_List::Layout_List() : main_menu_(main_layout_submenu_), choice_menu_(static_choice_menu), list_(static_suite_list), @@ -614,15 +615,16 @@ Layout_List::Layout_List() /** Release allocated resources. */ -Layout_List::~Layout_List() { +fld::app::Layout_List::~Layout_List() { assert(this); if (!list_is_static_) { ::free(main_menu_); ::free(choice_menu_); - for (int i = 0; i < list_size_; i++) { - Layout_Suite &suite = list_[i]; + int i; + for (i = 0; i < list_size_; i++) { + fld::app::Layout_Suite &suite = list_[i]; if (suite.storage_ != FLD_TOOL_STORE_INTERNAL) - suite.~Layout_Suite(); + suite.fld::app::Layout_Suite::~Layout_Suite(); } ::free(list_); } @@ -631,7 +633,7 @@ Layout_List::~Layout_List() { /** Update the Setting dialog and menus to reflect the current Layout selection state. */ -void Layout_List::update_dialogs() { +void fld::app::Layout_List::update_dialogs() { static Fl_Menu_Item *preset_menu = 0; if (!preset_menu) { preset_menu = (Fl_Menu_Item*)Fluid.main_menubar->find_item(select_layout_preset_cb); @@ -655,8 +657,9 @@ void Layout_List::update_dialogs() { /** Refresh the label pointers for both pulldown menus. */ -void Layout_List::update_menu_labels() { - for (int i=0; i<list_size_; i++) { +void fld::app::Layout_List::update_menu_labels() { + int i; + for (i =0; i<list_size_; i++) { main_menu_[i].label(list_[i].menu_label); choice_menu_[i].label(list_[i].menu_label); } @@ -665,7 +668,7 @@ void Layout_List::update_menu_labels() { /** Load all user layouts from the FLUID user preferences. */ -int Layout_List::load(const char *filename) { +int fld::app::Layout_List::load(const char *filename) { remove_all(FLD_TOOL_STORE_FILE); Fl_Preferences prefs(filename, "layout.fluid.fltk.org", 0, Fl_Preferences::C_LOCALE); read(prefs, FLD_TOOL_STORE_FILE); @@ -675,7 +678,7 @@ int Layout_List::load(const char *filename) { /** Save all user layouts to the FLUID user preferences. */ -int Layout_List::save(const char *filename) { +int fld::app::Layout_List::save(const char *filename) { assert(this); Fl_Preferences prefs(filename, "layout.fluid.fltk.org", 0, (Fl_Preferences::Root)(Fl_Preferences::C_LOCALE|Fl_Preferences::CLEAR)); prefs.clear(); @@ -686,14 +689,15 @@ int Layout_List::save(const char *filename) { /** Write Suite and Layout selection and selected layout data to Preferences database. */ -void Layout_List::write(Fl_Preferences &prefs, fld::Tool_Store storage) { +void fld::app::Layout_List::write(Fl_Preferences &prefs, fld::Tool_Store storage) { Fl_Preferences prefs_list(prefs, "Layouts"); prefs_list.clear(); prefs_list.set("current_suite", list_[current_suite()].name_); prefs_list.set("current_preset", current_preset()); int n = 0; - for (int i = 0; i < list_size_; ++i) { - Layout_Suite &suite = list_[i]; + int i; + for (i = 0; i < list_size_; ++i) { + fld::app::Layout_Suite &suite = list_[i]; if (suite.storage_ == storage) { Fl_Preferences prefs_suite(prefs_list, Fl_Preferences::Name(n++)); suite.write(prefs_suite); @@ -704,7 +708,7 @@ void Layout_List::write(Fl_Preferences &prefs, fld::Tool_Store storage) { /** Read Suite and Layout selection and selected layout data to Preferences database. */ -void Layout_List::read(Fl_Preferences &prefs, fld::Tool_Store storage) { +void fld::app::Layout_List::read(Fl_Preferences &prefs, fld::Tool_Store storage) { Fl_Preferences prefs_list(prefs, "Layouts"); char *cs_ptr = 0; int cp = 0; @@ -733,11 +737,12 @@ void Layout_List::read(Fl_Preferences &prefs, fld::Tool_Store storage) { /** Write Suite and Layout selection and project layout data to an .fl project file. */ -void Layout_List::write(fld::io::Project_Writer *out) { +void fld::app::Layout_List::write(fld::io::Project_Writer *out) { // Don't write the Snap field if no custom layout was used + int i; if ((current_suite()==0) && (current_preset()==0)) { int nSuite = 0; - for (int i=0; i<list_size_; i++) { + for (i =0; i<list_size_; i++) { if (list_[i].storage_ == FLD_TOOL_STORE_PROJECT) nSuite++; } if (nSuite == 0) return; @@ -745,8 +750,8 @@ void Layout_List::write(fld::io::Project_Writer *out) { out->write_string("\nsnap {\n ver 1\n"); out->write_string(" current_suite "); out->write_word(list_[current_suite()].name_); out->write_string("\n"); out->write_string(" current_preset %d\n", current_preset()); - for (int i=0; i<list_size_; i++) { - Layout_Suite &suite = list_[i]; + for (i =0; i<list_size_; i++) { + fld::app::Layout_Suite &suite = list_[i]; if (suite.storage_ == FLD_TOOL_STORE_PROJECT) suite.write(out); } @@ -756,7 +761,7 @@ void Layout_List::write(fld::io::Project_Writer *out) { /** Read Suite and Layout selection and project layout data from an .fl project file. */ -void Layout_List::read(fld::io::Project_Reader *in) { +void fld::app::Layout_List::read(fld::io::Project_Reader *in) { const char *key; key = in->read_word(1); if (key && !strcmp(key, "{")) { @@ -793,7 +798,7 @@ void Layout_List::read(fld::io::Project_Reader *in) { Set the current Suite. \param[in] ix index into list of suites */ -void Layout_List::current_suite(int ix) { +void fld::app::Layout_List::current_suite(int ix) { assert(ix >= 0); assert(ix < list_size_); current_suite_ = ix; @@ -805,11 +810,11 @@ void Layout_List::current_suite(int ix) { \param[in] arg_name name of the selected suite \return if no name is given or the name is not found, keep the current suite selected */ -void Layout_List::current_suite(const char *arg_name) { +void fld::app::Layout_List::current_suite(const char *arg_name) { if (!arg_name || !arg_name[0]) return; int i; for (i = 0; i < list_size_; ++i) { - Layout_Suite &suite = list_[i]; + fld::app::Layout_Suite &suite = list_[i]; if (suite.name_ && (strcmp(suite.name_, arg_name) == 0)) { current_suite(i); break; @@ -821,7 +826,7 @@ void Layout_List::current_suite(const char *arg_name) { Select a Preset within the current Suite. \param[in] ix 0 = application, 1 = dialog, 2 = toolbox */ -void Layout_List::current_preset(int ix) { +void fld::app::Layout_List::current_preset(int ix) { assert(ix >= 0); assert(ix < 3); current_preset_ = ix; @@ -831,7 +836,7 @@ void Layout_List::current_preset(int ix) { /** Allocate enough space for n entries in the list. */ -void Layout_List::capacity(int n) { +void fld::app::Layout_List::capacity(int n) { static Fl_Menu_Item *suite_menu = 0; if (!suite_menu) suite_menu = (Fl_Menu_Item*)Fluid.main_menubar->find_item(layout_suite_marker); @@ -839,7 +844,7 @@ void Layout_List::capacity(int n) { int old_n = list_size_; int i; - Layout_Suite *new_list = (Layout_Suite*)::calloc(n, sizeof(Layout_Suite)); + fld::app::Layout_Suite *new_list = (fld::app::Layout_Suite*)::calloc(n, sizeof(fld::app::Layout_Suite)); for (i = 0; i < old_n; i++) new_list[i] = list_[i]; if (!list_is_static_) ::free(list_); @@ -867,18 +872,19 @@ void Layout_List::capacity(int n) { \brief Clone the currently selected suite and append it to the list. Selects the new layout and updates the UI. */ -int Layout_List::add(const char *name) { +int fld::app::Layout_List::add(const char *name) { if (list_size_ == list_capacity_) { capacity(list_capacity_ * 2); } int n = list_size_; - Layout_Suite &old_suite = list_[current_suite_]; - Layout_Suite &new_suite = list_[n]; + fld::app::Layout_Suite &old_suite = list_[current_suite_]; + fld::app::Layout_Suite &new_suite = list_[n]; new_suite.init(); new_suite.name(name); - for (int i=0; i<3; ++i) { - new_suite.layout[i] = new Layout_Preset; - ::memcpy(new_suite.layout[i], old_suite.layout[i], sizeof(Layout_Preset)); + int i; + for (i =0; i<3; ++i) { + new_suite.layout[i] = new fld::app::Layout_Preset; + ::memcpy(new_suite.layout[i], old_suite.layout[i], sizeof(fld::app::Layout_Preset)); } fld::Tool_Store new_storage = old_suite.storage_; if (new_storage == FLD_TOOL_STORE_INTERNAL) @@ -897,7 +903,7 @@ int Layout_List::add(const char *name) { /** Rename the current Suite. */ -void Layout_List::rename(const char *name) { +void fld::app::Layout_List::rename(const char *name) { int n = current_suite(); list_[n].name(name); main_menu_[n].label(list_[n].menu_label); @@ -908,10 +914,11 @@ void Layout_List::rename(const char *name) { Remove the given suite. \param[in] ix index into list of suites */ -void Layout_List::remove(int ix) { +void fld::app::Layout_List::remove(int ix) { int tail = list_size_-ix-1; if (tail) { - for (int i = ix; i < list_size_-1; i++) + int i; + for (i = ix; i < list_size_-1; i++) list_[i] = list_[i+1]; } ::memmove(main_menu_+ix, main_menu_+ix+1, (tail+1) * sizeof(Fl_Menu_Item)); @@ -925,8 +932,9 @@ void Layout_List::remove(int ix) { Remove all Suites that use the given storage attribute. \param[in] storage storage attribute, see FLD_TOOL_STORE_INTERNAL, etc. */ -void Layout_List::remove_all(fld::Tool_Store storage) { - for (int i=list_size_-1; i>=0; --i) { +void fld::app::Layout_List::remove_all(fld::Tool_Store storage) { + int i; + for (i =list_size_-1; i>=0; --i) { if (list_[i].storage_ == storage) remove(i); } @@ -951,19 +959,19 @@ static int nearest(int x, int left, int grid, int right=0x7fff) { return grid_x; } -static bool in_window(Snap_Data &d) { +static bool in_window(fld::app::Snap_Data &d) { return (d.wgt && d.wgt->parent == d.win); } -static bool in_group(Snap_Data &d) { +static bool in_group(fld::app::Snap_Data &d) { return (d.wgt && d.wgt->parent && d.wgt->parent->is_a(FLD_NODE_TYPE_Group) && d.wgt->parent != d.win); } -static bool in_tabs(Snap_Data &d) { +static bool in_tabs(fld::app::Snap_Data &d) { return (d.wgt && d.wgt->parent && d.wgt->parent->is_a(FLD_NODE_TYPE_Tabs)); } -static Fl_Group *parent(Snap_Data &d) { +static Fl_Group *parent(fld::app::Snap_Data &d) { return (d.wgt->o->parent()); } @@ -994,7 +1002,7 @@ static Fl_Group *parent(Snap_Data &d) { \return -1 if this point is closer than any previous check, and this is the new distance to beat. */ -int Snap_Action::check_x_(Snap_Data &d, int x_ref, int x_snap) { +int fld::app::Snap_Action::check_x_(fld::app::Snap_Data &d, int x_ref, int x_snap) { int dd = x_ref + d.dx - x_snap; int d2 = abs(dd); if (d2 > d.x_dist) return 1; @@ -1007,9 +1015,9 @@ int Snap_Action::check_x_(Snap_Data &d, int x_ref, int x_snap) { /** \brief Check if a snap action has reached a preferred y position. - \see Snap_Action::check_x_(Snap_Data &d, int x_ref, int x_snap) + \see fld::app::Snap_Action::check_x_(fld::app::Snap_Data &d, int x_ref, int x_snap) */ -int Snap_Action::check_y_(Snap_Data &d, int y_ref, int y_snap) { +int fld::app::Snap_Action::check_y_(fld::app::Snap_Data &d, int y_ref, int y_snap) { int dd = y_ref + d.dy - y_snap; int d2 = abs(dd); if (d2 > d.y_dist) return 1; @@ -1022,9 +1030,9 @@ int Snap_Action::check_y_(Snap_Data &d, int y_ref, int y_snap) { /** \brief Check if a snap action has reached a preferred x and y position. - \see Snap_Action::check_x_(Snap_Data &d, int x_ref, int x_snap) + \see fld::app::Snap_Action::check_x_(fld::app::Snap_Data &d, int x_ref, int x_snap) */ -void Snap_Action::check_x_y_(Snap_Data &d, int x_ref, int x_snap, int y_ref, int y_snap) { +void fld::app::Snap_Action::check_x_y_(fld::app::Snap_Data &d, int x_ref, int x_snap, int y_ref, int y_snap) { int ddx = x_ref + d.dx - x_snap; int d2x = abs(ddx); int ddy = y_ref + d.dy - y_snap; @@ -1045,7 +1053,7 @@ void Snap_Action::check_x_y_(Snap_Data &d, int x_ref, int x_snap, int y_ref, int should be drawn. \param[inout] d current event data */ -bool Snap_Action::matches(Snap_Data &d) { +bool fld::app::Snap_Action::matches(fld::app::Snap_Data &d) { switch (type) { case 1: return (d.drag & mask) && (eex == ex) && (d.dx == dx); case 2: return (d.drag & mask) && (eey == ey) && (d.dy == dy); @@ -1058,8 +1066,9 @@ bool Snap_Action::matches(Snap_Data &d) { \brief Run through all possible snap actions and store the winning coordinates in eex and eey. \param[inout] d current event data */ -void Snap_Action::check_all(Snap_Data &data) { - for (int i=0; list[i]; i++) { +void fld::app::Snap_Action::check_all(fld::app::Snap_Data &data) { + int i; + for (i =0; list[i]; i++) { if (list[i]->mask & data.drag) list[i]->check(data); } @@ -1074,16 +1083,17 @@ void Snap_Action::check_all(Snap_Data &data) { coordinate, all of them will be drawn. \param[inout] d current event data */ -void Snap_Action::draw_all(Snap_Data &data) { - for (int i=0; list[i]; i++) { +void fld::app::Snap_Action::draw_all(fld::app::Snap_Data &data) { + int i; + for (i =0; list[i]; i++) { if (list[i]->matches(data)) list[i]->draw(data); } } /** Return a sensible step size for resizing a widget. */ -void Snap_Action::get_resize_stepsize(int &x_step, int &y_step) { - Layout_Preset *layout = Fluid.proj.layout; +void fld::app::Snap_Action::get_resize_stepsize(int &x_step, int &y_step) { + fld::app::Layout_Preset *layout = Fluid.proj.layout; if ((layout->widget_inc_w > 1) && (layout->widget_inc_h > 1)) { x_step = layout->widget_inc_w; y_step = layout->widget_inc_h; @@ -1097,8 +1107,8 @@ void Snap_Action::get_resize_stepsize(int &x_step, int &y_step) { } /** Return a sensible step size for moving a widget. */ -void Snap_Action::get_move_stepsize(int &x_step, int &y_step) { - Layout_Preset *layout = Fluid.proj.layout; +void fld::app::Snap_Action::get_move_stepsize(int &x_step, int &y_step) { + fld::app::Layout_Preset *layout = Fluid.proj.layout; if ((layout->group_grid_x > 1) && (layout->group_grid_y > 1)) { x_step = layout->group_grid_x; y_step = layout->group_grid_y; @@ -1112,8 +1122,8 @@ void Snap_Action::get_move_stepsize(int &x_step, int &y_step) { } /** Fix the given size to the same or next bigger snap position. */ -void Snap_Action::better_size(int &w, int &h) { - Layout_Preset *layout = Fluid.proj.layout; +void fld::app::Snap_Action::better_size(int &w, int &h) { + fld::app::Layout_Preset *layout = Fluid.proj.layout; int x_min = 1, y_min = 1, x_inc = 1, y_inc = 1; get_resize_stepsize(x_inc, y_inc); if (x_inc < 1) x_inc = 1; @@ -1138,7 +1148,7 @@ void Snap_Action::better_size(int &w, int &h) { /** Base class for all actions that drag the left side or the entire widget. */ -class Fd_Snap_Left : public Snap_Action { +class Fd_Snap_Left : public fld::app::Snap_Action { public: Fd_Snap_Left() { type = 1; mask = FD_LEFT|FD_DRAG; } }; @@ -1146,7 +1156,7 @@ public: /** Base class for all actions that drag the right side or the entire widget. */ -class Fd_Snap_Right : public Snap_Action { +class Fd_Snap_Right : public fld::app::Snap_Action { public: Fd_Snap_Right() { type = 1; mask = FD_RIGHT|FD_DRAG; } }; @@ -1154,7 +1164,7 @@ public: /** Base class for all actions that drag the top side or the entire widget. */ -class Fd_Snap_Top : public Snap_Action { +class Fd_Snap_Top : public fld::app::Snap_Action { public: Fd_Snap_Top() { type = 2; mask = FD_TOP|FD_DRAG; } }; @@ -1162,7 +1172,7 @@ public: /** Base class for all actions that drag the bottom side or the entire widget. */ -class Fd_Snap_Bottom : public Snap_Action { +class Fd_Snap_Bottom : public fld::app::Snap_Action { public: Fd_Snap_Bottom() { type = 2; mask = FD_BOTTOM|FD_DRAG; } }; @@ -1174,8 +1184,8 @@ public: */ class Fd_Snap_Left_Window_Edge : public Fd_Snap_Left { public: - void check(Snap_Data &d) { clr(); check_x_(d, d.bx, 0); } - void draw(Snap_Data &d) { draw_left_brace(d.win->o); } + void check(fld::app::Snap_Data &d) { clr(); check_x_(d, d.bx, 0); } + void draw(fld::app::Snap_Data &d) { draw_left_brace(d.win->o); } }; Fd_Snap_Left_Window_Edge snap_left_window_edge; @@ -1184,8 +1194,8 @@ Fd_Snap_Left_Window_Edge snap_left_window_edge; */ class Fd_Snap_Right_Window_Edge : public Fd_Snap_Right { public: - void check(Snap_Data &d) { clr(); check_x_(d, d.br, d.win->o->w()); } - void draw(Snap_Data &d) { draw_right_brace(d.win->o); } + void check(fld::app::Snap_Data &d) { clr(); check_x_(d, d.br, d.win->o->w()); } + void draw(fld::app::Snap_Data &d) { draw_right_brace(d.win->o); } }; Fd_Snap_Right_Window_Edge snap_right_window_edge; @@ -1194,8 +1204,8 @@ Fd_Snap_Right_Window_Edge snap_right_window_edge; */ class Fd_Snap_Top_Window_Edge : public Fd_Snap_Top { public: - void check(Snap_Data &d) { clr(); check_y_(d, d.by, 0); } - void draw(Snap_Data &d) { draw_top_brace(d.win->o); } + void check(fld::app::Snap_Data &d) { clr(); check_y_(d, d.by, 0); } + void draw(fld::app::Snap_Data &d) { draw_top_brace(d.win->o); } }; Fd_Snap_Top_Window_Edge snap_top_window_edge; @@ -1204,8 +1214,8 @@ Fd_Snap_Top_Window_Edge snap_top_window_edge; */ class Fd_Snap_Bottom_Window_Edge : public Fd_Snap_Bottom { public: - void check(Snap_Data &d) { clr(); check_y_(d, d.bt, d.win->o->h()); } - void draw(Snap_Data &d) { draw_bottom_brace(d.win->o); } + void check(fld::app::Snap_Data &d) { clr(); check_y_(d, d.bt, d.win->o->h()); } + void draw(fld::app::Snap_Data &d) { draw_bottom_brace(d.win->o); } }; Fd_Snap_Bottom_Window_Edge snap_bottom_window_edge; @@ -1214,11 +1224,11 @@ Fd_Snap_Bottom_Window_Edge snap_bottom_window_edge; */ class Fd_Snap_Left_Window_Margin : public Fd_Snap_Left { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_window(d)) check_x_(d, d.bx, Fluid.proj.layout->left_window_margin); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_h_arrow(d.bx, (d.by+d.bt)/2, 0); } }; @@ -1226,11 +1236,11 @@ Fd_Snap_Left_Window_Margin snap_left_window_margin; class Fd_Snap_Right_Window_Margin : public Fd_Snap_Right { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_window(d)) check_x_(d, d.br, d.win->o->w()-Fluid.proj.layout->right_window_margin); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_h_arrow(d.br, (d.by+d.bt)/2, d.win->o->w()-1); } }; @@ -1238,11 +1248,11 @@ Fd_Snap_Right_Window_Margin snap_right_window_margin; class Fd_Snap_Top_Window_Margin : public Fd_Snap_Top { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_window(d)) check_y_(d, d.by, Fluid.proj.layout->top_window_margin); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_v_arrow((d.bx+d.br)/2, d.by, 0); } }; @@ -1250,11 +1260,11 @@ Fd_Snap_Top_Window_Margin snap_top_window_margin; class Fd_Snap_Bottom_Window_Margin : public Fd_Snap_Bottom { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_window(d)) check_y_(d, d.bt, d.win->o->h()-Fluid.proj.layout->bottom_window_margin); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_v_arrow((d.bx+d.br)/2, d.bt, d.win->o->h()-1); } }; @@ -1267,11 +1277,11 @@ Fd_Snap_Bottom_Window_Margin snap_bottom_window_margin; */ class Fd_Snap_Left_Group_Edge : public Fd_Snap_Left { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_group(d)) check_x_(d, d.bx, parent(d)->x()); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_left_brace(parent(d)); } }; @@ -1279,11 +1289,11 @@ Fd_Snap_Left_Group_Edge snap_left_group_edge; class Fd_Snap_Right_Group_Edge : public Fd_Snap_Right { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_group(d)) check_x_(d, d.br, parent(d)->x() + parent(d)->w()); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_right_brace(parent(d)); } }; @@ -1291,11 +1301,11 @@ Fd_Snap_Right_Group_Edge snap_right_group_edge; class Fd_Snap_Top_Group_Edge : public Fd_Snap_Top { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_group(d)) check_y_(d, d.by, parent(d)->y()); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_top_brace(parent(d)); } }; @@ -1303,11 +1313,11 @@ Fd_Snap_Top_Group_Edge snap_top_group_edge; class Fd_Snap_Bottom_Group_Edge : public Fd_Snap_Bottom { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_group(d)) check_y_(d, d.bt, parent(d)->y() + parent(d)->h()); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_bottom_brace(parent(d)); } }; @@ -1319,11 +1329,11 @@ Fd_Snap_Bottom_Group_Edge snap_bottom_group_edge; */ class Fd_Snap_Left_Group_Margin : public Fd_Snap_Left { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_group(d)) check_x_(d, d.bx, parent(d)->x() + Fluid.proj.layout->left_group_margin); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_left_brace(parent(d)); draw_h_arrow(d.bx, (d.by+d.bt)/2, parent(d)->x()); } @@ -1332,11 +1342,11 @@ Fd_Snap_Left_Group_Margin snap_left_group_margin; class Fd_Snap_Right_Group_Margin : public Fd_Snap_Right { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_group(d)) check_x_(d, d.br, parent(d)->x()+parent(d)->w()-Fluid.proj.layout->right_group_margin); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_right_brace(parent(d)); draw_h_arrow(d.br, (d.by+d.bt)/2, parent(d)->x()+parent(d)->w()-1); } @@ -1345,11 +1355,11 @@ Fd_Snap_Right_Group_Margin snap_right_group_margin; class Fd_Snap_Top_Group_Margin : public Fd_Snap_Top { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_group(d) && !in_tabs(d)) check_y_(d, d.by, parent(d)->y()+Fluid.proj.layout->top_group_margin); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_top_brace(parent(d)); draw_v_arrow((d.bx+d.br)/2, d.by, parent(d)->y()); } @@ -1358,11 +1368,11 @@ Fd_Snap_Top_Group_Margin snap_top_group_margin; class Fd_Snap_Bottom_Group_Margin : public Fd_Snap_Bottom { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_group(d) && !in_tabs(d)) check_y_(d, d.bt, parent(d)->y()+parent(d)->h()-Fluid.proj.layout->bottom_group_margin); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_bottom_brace(parent(d)); draw_v_arrow((d.bx+d.br)/2, d.bt, parent(d)->y()+parent(d)->h()-1); } @@ -1376,7 +1386,7 @@ Fd_Snap_Bottom_Group_Margin snap_bottom_group_margin; */ class Fd_Snap_Top_Tabs_Margin : public Fd_Snap_Top_Group_Margin { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_tabs(d)) check_y_(d, d.by, parent(d)->y()+Fluid.proj.layout->top_tabs_margin); } @@ -1385,7 +1395,7 @@ Fd_Snap_Top_Tabs_Margin snap_top_tabs_margin; class Fd_Snap_Bottom_Tabs_Margin : public Fd_Snap_Bottom_Group_Margin { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_tabs(d)) check_y_(d, d.bt, parent(d)->y()+parent(d)->h()-Fluid.proj.layout->bottom_tabs_margin); } @@ -1397,12 +1407,12 @@ Fd_Snap_Bottom_Tabs_Margin snap_bottom_tabs_margin; /** Base class for grid based snapping. */ -class Fd_Snap_Grid : public Snap_Action { +class Fd_Snap_Grid : public fld::app::Snap_Action { protected: int nearest_x, nearest_y; public: Fd_Snap_Grid() { type = 3; mask = FD_LEFT|FD_TOP|FD_DRAG; } - void check_grid(Snap_Data &d, int left, int grid_x, int right, int top, int grid_y, int bottom) { + void check_grid(fld::app::Snap_Data &d, int left, int grid_x, int right, int top, int grid_y, int bottom) { if ((grid_x <= 1) || (grid_y <= 1)) return; int suggested_x = d.bx + d.dx; nearest_x = nearest(suggested_x, left, grid_x, right); @@ -1415,7 +1425,7 @@ public: else check_x_y_(d, d.bx, nearest_x, d.by, nearest_y); } - bool matches(Snap_Data &d) { + bool matches(fld::app::Snap_Data &d) { if (d.drag == FD_LEFT) return (eex == ex); if (d.drag == FD_TOP) return (eey == ey) && (d.dx == dx); return (d.drag & mask) && (eex == ex) && (d.dx == dx) && (eey == ey) && (d.dy == dy); @@ -1427,14 +1437,14 @@ public: */ class Fd_Snap_Window_Grid : public Fd_Snap_Grid { public: - void check(Snap_Data &d) { - Layout_Preset *layout = Fluid.proj.layout; + void check(fld::app::Snap_Data &d) { + fld::app::Layout_Preset *layout = Fluid.proj.layout; clr(); if (in_window(d)) check_grid(d, layout->left_window_margin, layout->window_grid_x, d.win->o->w()-layout->right_window_margin, layout->top_window_margin, layout->window_grid_y, d.win->o->h()-layout->bottom_window_margin); } - void draw(Snap_Data &d) { - Layout_Preset *layout = Fluid.proj.layout; + void draw(fld::app::Snap_Data &d) { + fld::app::Layout_Preset *layout = Fluid.proj.layout; draw_grid(nearest_x, nearest_y, layout->window_grid_x, layout->window_grid_y); } }; @@ -1445,17 +1455,17 @@ Fd_Snap_Window_Grid snap_window_grid; */ class Fd_Snap_Group_Grid : public Fd_Snap_Grid { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { if (in_group(d)) { - Layout_Preset *layout = Fluid.proj.layout; + fld::app::Layout_Preset *layout = Fluid.proj.layout; clr(); Fl_Widget *g = parent(d); check_grid(d, g->x()+layout->left_group_margin, layout->group_grid_x, g->x()+g->w()-layout->right_group_margin, g->y()+layout->top_group_margin, layout->group_grid_y, g->y()+g->h()-layout->bottom_group_margin); } } - void draw(Snap_Data &d) { - Layout_Preset *layout = Fluid.proj.layout; + void draw(fld::app::Snap_Data &d) { + fld::app::Layout_Preset *layout = Fluid.proj.layout; draw_grid(nearest_x, nearest_y, layout->group_grid_x, layout->group_grid_y); } }; @@ -1466,13 +1476,13 @@ Fd_Snap_Group_Grid snap_group_grid; /** Base class the check distance to other widgets in the same group. */ -class Fd_Snap_Sibling : public Snap_Action { +class Fd_Snap_Sibling : public fld::app::Snap_Action { protected: Fl_Widget *best_match; public: Fd_Snap_Sibling() : best_match(0) { } - virtual int sibling_check(Snap_Data &d, Fl_Widget *s) = 0; - void check(Snap_Data &d) { + virtual int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) = 0; + void check(fld::app::Snap_Data &d) { clr(); best_match = 0; if (!d.wgt) return; @@ -1481,7 +1491,8 @@ public: Group_Node *gt = (Group_Node*)d.wgt->parent; Fl_Group *g = (Fl_Group*)gt->o; Fl_Widget *w = d.wgt->o; - for (int i=0; i<g->children(); i++) { + int i; + for (i =0; i<g->children(); i++) { Fl_Widget *c = g->child(i); if (c == w) continue; int sret = sibling_check(d, c); @@ -1506,10 +1517,10 @@ public: class Fd_Snap_Siblings_Left_Same : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Left_Same() { type = 1; mask = FD_LEFT|FD_DRAG; } - int sibling_check(Snap_Data &d, Fl_Widget *s) { + int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { return check_x_(d, d.bx, s->x()); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { if (best_match) draw_left_brace(best_match); } }; @@ -1521,11 +1532,11 @@ Fd_Snap_Siblings_Left_Same snap_siblings_left_same; class Fd_Snap_Siblings_Left : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Left() { type = 1; mask = FD_LEFT|FD_DRAG; } - int sibling_check(Snap_Data &d, Fl_Widget *s) { + int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { return MIN(check_x_(d, d.bx, s->x()+s->w()), check_x_(d, d.bx, s->x()+s->w()+Fluid.proj.layout->widget_gap_x) ); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { if (best_match) draw_right_brace(best_match); } }; @@ -1534,10 +1545,10 @@ Fd_Snap_Siblings_Left snap_siblings_left; class Fd_Snap_Siblings_Right_Same : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Right_Same() { type = 1; mask = FD_RIGHT|FD_DRAG; } - int sibling_check(Snap_Data &d, Fl_Widget *s) { + int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { return check_x_(d, d.br, s->x()+s->w()); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { if (best_match) draw_right_brace(best_match); } }; @@ -1546,11 +1557,11 @@ Fd_Snap_Siblings_Right_Same snap_siblings_right_same; class Fd_Snap_Siblings_Right : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Right() { type = 1; mask = FD_RIGHT|FD_DRAG; } - int sibling_check(Snap_Data &d, Fl_Widget *s) { + int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { return MIN(check_x_(d, d.br, s->x()), check_x_(d, d.br, s->x()-Fluid.proj.layout->widget_gap_x)); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { if (best_match) draw_left_brace(best_match); } }; @@ -1559,10 +1570,10 @@ Fd_Snap_Siblings_Right snap_siblings_right; class Fd_Snap_Siblings_Top_Same : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Top_Same() { type = 2; mask = FD_TOP|FD_DRAG; } - int sibling_check(Snap_Data &d, Fl_Widget *s) { + int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { return check_y_(d, d.by, s->y()); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { if (best_match) draw_top_brace(best_match); } }; @@ -1571,11 +1582,11 @@ Fd_Snap_Siblings_Top_Same snap_siblings_top_same; class Fd_Snap_Siblings_Top : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Top() { type = 2; mask = FD_TOP|FD_DRAG; } - int sibling_check(Snap_Data &d, Fl_Widget *s) { + int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { return MIN(check_y_(d, d.by, s->y()+s->h()), check_y_(d, d.by, s->y()+s->h()+Fluid.proj.layout->widget_gap_y)); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { if (best_match) draw_bottom_brace(best_match); } }; @@ -1584,10 +1595,10 @@ Fd_Snap_Siblings_Top snap_siblings_top; class Fd_Snap_Siblings_Bottom_Same : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Bottom_Same() { type = 2; mask = FD_BOTTOM|FD_DRAG; } - int sibling_check(Snap_Data &d, Fl_Widget *s) { + int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { return check_y_(d, d.bt, s->y()+s->h()); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { if (best_match) draw_bottom_brace(best_match); } }; @@ -1596,11 +1607,11 @@ Fd_Snap_Siblings_Bottom_Same snap_siblings_bottom_same; class Fd_Snap_Siblings_Bottom : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Bottom() { type = 2; mask = FD_BOTTOM|FD_DRAG; } - int sibling_check(Snap_Data &d, Fl_Widget *s) { + int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { return MIN(check_y_(d, d.bt, s->y()), check_y_(d, d.bt, s->y()-Fluid.proj.layout->widget_gap_y)); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { if (best_match) draw_top_brace(best_match); } }; @@ -1612,11 +1623,11 @@ Fd_Snap_Siblings_Bottom snap_siblings_bottom; /** Snap horizontal resizing to min_w or min_w and a multiple of inc_w. */ -class Fd_Snap_Widget_Ideal_Width : public Snap_Action { +class Fd_Snap_Widget_Ideal_Width : public fld::app::Snap_Action { public: Fd_Snap_Widget_Ideal_Width() { type = 1; mask = FD_LEFT|FD_RIGHT; } - void check(Snap_Data &d) { - Layout_Preset *layout = Fluid.proj.layout; + void check(fld::app::Snap_Data &d) { + fld::app::Layout_Preset *layout = Fluid.proj.layout; clr(); if (!d.wgt) return; int iw = 15, ih = 15; @@ -1633,17 +1644,17 @@ public: check_x_(d, d.bx, d.br-iw); } } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_width(d.bx, d.bt+7, d.br, 0); } }; Fd_Snap_Widget_Ideal_Width snap_widget_ideal_width; -class Fd_Snap_Widget_Ideal_Height : public Snap_Action { +class Fd_Snap_Widget_Ideal_Height : public fld::app::Snap_Action { public: Fd_Snap_Widget_Ideal_Height() { type = 2; mask = FD_TOP|FD_BOTTOM; } - void check(Snap_Data &d) { - Layout_Preset *layout = Fluid.proj.layout; + void check(fld::app::Snap_Data &d) { + fld::app::Layout_Preset *layout = Fluid.proj.layout; clr(); if (!d.wgt) return; int iw, ih; @@ -1660,7 +1671,7 @@ public: check_y_(d, d.by, d.bt-ih); } } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_height(d.br+7, d.by, d.bt, 0); } }; @@ -1675,7 +1686,7 @@ Fd_Snap_Widget_Ideal_Height snap_widget_ideal_height; action in the list wins. All snap actions with the same distance and same winning coordinates are drawn in the overlay plane. */ -Snap_Action *Snap_Action::list[] = { +fld::app::Snap_Action *fld::app::Snap_Action::list[] = { &snap_left_window_edge, &snap_right_window_edge, &snap_top_window_edge, @@ -1834,8 +1845,10 @@ void draw_width(int x, int y, int r, Fl_Align a) { static void draw_grid(int x, int y, int dx, int dy) { int dx2 = 1, dy2 = 1; const int n = 2; - for (int i=-n; i<=n; i++) { - for (int j=-n; j<=n; j++) { + int i; + for (i =-n; i<=n; i++) { + int j; + for (j =-n; j<=n; j++) { if (abs(i)+abs(j) < 4) { int xx = x + i*dx , yy = y + j*dy; fl_xyline(xx-dx2, yy, xx+dx2); diff --git a/fluid/app/templates.cxx b/fluid/app/templates.cxx index 8b9b69f2a..9b2253001 100644 --- a/fluid/app/templates.cxx +++ b/fluid/app/templates.cxx @@ -28,9 +28,6 @@ #include <FL/Fl_PNG_Image.H> #include "../src/flstring.h" -using namespace fld; -using namespace fld::app; - /** Save a design template. \todo We should document the concept of templates. diff --git a/fluid/io/Code_Writer.cxx b/fluid/io/Code_Writer.cxx index f451d187e..ffa63514a 100644 --- a/fluid/io/Code_Writer.cxx +++ b/fluid/io/Code_Writer.cxx @@ -31,9 +31,6 @@ #include <stdlib.h> #include <string.h> -using namespace fld; -using namespace fld::io; - // ---- Fd_Id_Map implementation ---- void Fd_Id_Map::clear() { @@ -144,7 +141,7 @@ int is_id(char c) { \param[in] label else if label is set, it is appended, skipping non-keyword characters \return buffer to a unique identifier, managed by Code_Writer, so caller must NOT free() it */ -const char* Code_Writer::unique_id(void* o, const char* type, const char* name, const char* label) { +const char* fld::io::Code_Writer::unique_id(void* o, const char* type, const char* name, const char* label) { char buffer[128]; char* q = buffer; char* q_end = q + 128 - 8 - 1; // room for hex number and NUL @@ -189,7 +186,7 @@ const char* Code_Writer::unique_id(void* o, const char* type, const char* name, \param[in] set generate this indent depth \return pointer to a static string */ -const char *Code_Writer::indent(int set) { +const char *fld::io::Code_Writer::indent(int set) { static const char* spaces = " "; int i = set * 2; if (i>64) i = 64; @@ -201,7 +198,7 @@ const char *Code_Writer::indent(int set) { Return a C string that indents code to the current source file depth. \return pointer to a static string */ -const char *Code_Writer::indent() { +const char *fld::io::Code_Writer::indent() { return indent(indentation); } @@ -211,7 +208,7 @@ const char *Code_Writer::indent() { change the `indentation` variable; offset can be negative \return pointer to a static string */ -const char *Code_Writer::indent_plus(int offset) { +const char *fld::io::Code_Writer::indent_plus(int offset) { return indent(indentation+offset); } @@ -222,7 +219,7 @@ const char *Code_Writer::indent_plus(int offset) { \param[in] format printf-style formatting text, followed by a vararg list \return 1 if the text was written to the file, 0 if it was previously written. */ -int Code_Writer::write_h_once(const char *format, ...) { +int fld::io::Code_Writer::write_h_once(const char *format, ...) { va_list args; char buf[1024]; va_start(args, format); @@ -242,7 +239,7 @@ int Code_Writer::write_h_once(const char *format, ...) { \param[in] format printf-style formatting text, followed by a vararg list \return 1 if the text was written to the file, 0 if it was previously written. */ -int Code_Writer::write_c_once(const char *format, ...) { +int fld::io::Code_Writer::write_c_once(const char *format, ...) { va_list args; char buf[1024]; va_start(args, format); @@ -267,7 +264,7 @@ int Code_Writer::write_c_once(const char *format, ...) { \param[in] pp ay pointer \return true if found in the tree, false if added to the tree */ -bool Code_Writer::c_contains(void *pp) { +bool fld::io::Code_Writer::c_contains(void *pp) { if (ptr_in_code.contains(pp)) { return true; } @@ -292,7 +289,7 @@ bool Code_Writer::c_contains(void *pp) { \see f.write_cstring(const char*) */ -void Code_Writer::write_cstring(const char *s, int length) { +void fld::io::Code_Writer::write_cstring(const char *s, int length) { const char *next_line = "\"\n\""; if (varused_test) { varused = 1; @@ -373,7 +370,7 @@ void Code_Writer::write_cstring(const char *s, int length) { \param[in] s write this string \see f.write_cstring(const char*, int) */ -void Code_Writer::write_cstring(const char *s) { +void fld::io::Code_Writer::write_cstring(const char *s) { write_cstring(s, (int)strlen(s)); } @@ -385,7 +382,7 @@ void Code_Writer::write_cstring(const char *s) { \param[in] s a block of binary data, interpreted as unsigned bytes \param[in] length size of the block in bytes */ -void Code_Writer::write_cdata(const char *s, int length) { +void fld::io::Code_Writer::write_cdata(const char *s, int length) { if (varused_test) { varused = 1; return; @@ -423,7 +420,7 @@ void Code_Writer::write_cdata(const char *s, int length) { \param[in] format printf-style formatting text \param[in] args list of arguments */ -void Code_Writer::vwrite_c(const char* format, va_list args) { +void fld::io::Code_Writer::vwrite_c(const char* format, va_list args) { if (varused_test) { varused = 1; return; @@ -435,7 +432,7 @@ void Code_Writer::vwrite_c(const char* format, va_list args) { Print a formatted line to the source file. \param[in] format printf-style formatting text, followed by a vararg list */ -void Code_Writer::write_c(const char* format,...) { +void fld::io::Code_Writer::write_c(const char* format,...) { va_list args; va_start(args, format); vwrite_c(format, args); @@ -450,7 +447,7 @@ void Code_Writer::write_c(const char* format,...) { \param[in] c line of code \param[in] com optional commentary */ -void Code_Writer::write_cc(const char *indent, int n, const char *c, const char *com) { +void fld::io::Code_Writer::write_cc(const char *indent, int n, const char *c, const char *com) { write_c("%s%.*s", indent, n, c); char cc = c[n-1]; if (cc!='}' && cc!=';') @@ -464,7 +461,7 @@ void Code_Writer::write_cc(const char *indent, int n, const char *c, const char Print a formatted line to the header file. \param[in] format printf-style formatting text, followed by a vararg list */ -void Code_Writer::write_h(const char* format,...) { +void fld::io::Code_Writer::write_h(const char* format,...) { if (varused_test) return; va_list args; va_start(args, format); @@ -480,7 +477,7 @@ void Code_Writer::write_h(const char* format,...) { \param[in] c line of code \param[in] com optional commentary */ -void Code_Writer::write_hc(const char *indent, int n, const char* c, const char *com) { +void fld::io::Code_Writer::write_hc(const char *indent, int n, const char* c, const char *com) { write_h("%s%.*s", indent, n, c); char cc = c[n-1]; if (cc!='}' && cc!=';') @@ -497,7 +494,7 @@ void Code_Writer::write_hc(const char *indent, int n, const char* c, const char \param[in] inTrailWith append this character if the last line did not end with a newline, usually 0 or newline. */ -void Code_Writer::write_c_indented(const char *textlines, int inIndent, char inTrailWith) { +void fld::io::Code_Writer::write_c_indented(const char *textlines, int inIndent, char inTrailWith) { if (textlines) { indentation += inIndent; for (;;) { @@ -570,7 +567,7 @@ bool is_comment_before_class_member(Node *q) { \param[in] p write this type and all its children \return pointer to the next sibling */ -Node* Code_Writer::write_static(Node* p) { +Node* fld::io::Code_Writer::write_static(Node* p) { if (write_codeview) p->header_static_start = (int)ftell(header_file); if (write_codeview) p->code_static_start = (int)ftell(code_file); p->write_static(*this); @@ -592,7 +589,7 @@ Node* Code_Writer::write_static(Node* p) { \param[in] p write this node and all its children \return pointer to the next sibling */ -Node* Code_Writer::write_code(Node* p) { +Node* fld::io::Code_Writer::write_code(Node* p) { // write all code that comes before the children code // (but don't write the last comment until the very end) if (!(p==Fluid.proj.tree.last && p->is_a(FLD_NODE_TYPE_Comment))) { @@ -661,7 +658,7 @@ Node* Code_Writer::write_code(Node* p) { \param[in] t filename of the header file \return 0 if the operation failed, 1 if it was successful */ -int Code_Writer::write_code(const char *s, const char *t, bool to_codeview) { +int fld::io::Code_Writer::write_code(const char *s, const char *t, bool to_codeview) { write_codeview = to_codeview; unique_id_list.clear(); indentation = 0; @@ -835,7 +832,8 @@ int Code_Writer::write_code(const char *s, const char *t, bool to_codeview) { write_c("#endif\n"); } } - for (Node* p = first_node; p;) { + Node *p; + for (p = first_node; p;) { // write all static data for this & all children first write_static(p); // then write the nested code: @@ -875,7 +873,7 @@ int Code_Writer::write_code(const char *s, const char *t, bool to_codeview) { This avoids repeating these words if the mode is already set. \param[in] state 0 for private, 1 for public, 2 for protected */ -void Code_Writer::write_public(int state) { +void fld::io::Code_Writer::write_public(int state) { if (!current_class && !current_widget_class) return; if (current_class && current_class->write_public_state == state) return; if (current_widget_class && current_widget_class->write_public_state == state) return; @@ -891,7 +889,7 @@ void Code_Writer::write_public(int state) { /** Create and initialize a new C++ source code writer. */ -Code_Writer::Code_Writer(Project &proj) +fld::io::Code_Writer::Code_Writer(Project &proj) : proj_ { proj } { block_crc_ = crc32(0, 0, 0); @@ -900,7 +898,7 @@ Code_Writer::Code_Writer(Project &proj) /** Release all resources. */ -Code_Writer::~Code_Writer() +fld::io::Code_Writer::~Code_Writer() { if (block_buffer_) ::free(block_buffer_); } @@ -913,7 +911,7 @@ Code_Writer::~Code_Writer() \param[in] type FD_TAG_GENERIC, FD_TAG_CODE, FD_TAG_MENU_CALLBACK, or FD_TAG_WIDGET_CALLBACK \param[in] uid the unique id of the current type */ -void Code_Writer::tag(Mergeback::Tag prev_type, Mergeback::Tag next_type, unsigned short uid) { +void fld::io::Code_Writer::tag(Mergeback::Tag prev_type, Mergeback::Tag next_type, unsigned short uid) { if (proj_.write_mergeback_data) { ::Mergeback::print_tag(code_file, prev_type, next_type, uid, (uint32_t)block_crc_); } @@ -931,7 +929,7 @@ void Code_Writer::tag(Mergeback::Tag prev_type, Mergeback::Tag next_type, unsign if we are the start of a line, used to find leading whitespace \return the new CRC */ -unsigned long Code_Writer::block_crc(const void *data, int n, unsigned long in_crc, bool *inout_line_start) { +unsigned long fld::io::Code_Writer::block_crc(const void *data, int n, unsigned long in_crc, bool *inout_line_start) { if (!data) return 0; if (n==-1) n = (int)strlen((const char*)data); bool line_start = true; @@ -958,7 +956,7 @@ unsigned long Code_Writer::block_crc(const void *data, int n, unsigned long in_c \param[in] data a pointer to the data block \param[in] n the size of the data in bytes, or -1 to use strlen() */ -void Code_Writer::crc_add(const void *data, int n) { +void fld::io::Code_Writer::crc_add(const void *data, int n) { block_crc_ = block_crc(data, n, block_crc_, &block_line_start_); } @@ -967,7 +965,7 @@ void Code_Writer::crc_add(const void *data, int n) { \param[in] format printf style formatting string \return see fprintf(FILE *, *const char*, ...) */ -int Code_Writer::crc_printf(const char *format, ...) { +int fld::io::Code_Writer::crc_printf(const char *format, ...) { va_list args; va_start(args, format); int ret = crc_vprintf(format, args); @@ -981,7 +979,7 @@ int Code_Writer::crc_printf(const char *format, ...) { \param[in] args list of arguments \return see fprintf(FILE *, *const char*, ...) */ -int Code_Writer::crc_vprintf(const char *format, va_list args) { +int fld::io::Code_Writer::crc_vprintf(const char *format, va_list args) { if (proj_.write_mergeback_data) { int n = vsnprintf(block_buffer_, block_buffer_size_, format, args); if (n > block_buffer_size_) { @@ -1002,7 +1000,7 @@ int Code_Writer::crc_vprintf(const char *format, va_list args) { \param[in] text any text, no requirements to end in a newline or such \return see fputs(const char*, FILE*) */ -int Code_Writer::crc_puts(const char *text) { +int fld::io::Code_Writer::crc_puts(const char *text) { if (proj_.write_mergeback_data) { crc_add(text); } @@ -1011,11 +1009,11 @@ int Code_Writer::crc_puts(const char *text) { /** Write a single ASCII character to the code file. If MergeBack is enabled, the CRC calculation is continued. - \note to write UTF-8 characters, use Code_Writer::crc_puts(const char *text) + \note to write UTF-8 characters, use fld::io::Code_Writer::crc_puts(const char *text) \param[in] c any character between 0 and 127 inclusive \return see fputc(int, FILE*) */ -int Code_Writer::crc_putc(int c) { +int fld::io::Code_Writer::crc_putc(int c) { if (proj_.write_mergeback_data) { uchar uc = (uchar)c; crc_add(&uc, 1); diff --git a/fluid/io/Project_Reader.cxx b/fluid/io/Project_Reader.cxx index 3bf9608a3..54baa9a85 100644 --- a/fluid/io/Project_Reader.cxx +++ b/fluid/io/Project_Reader.cxx @@ -41,9 +41,6 @@ /// \defgroup flfile .fl Project File Operations /// \{ -using namespace fld; -using namespace fld::io; - // This file contains code to read and write .fl files. /// If set, we read an old fdesign file and widget y coordinates need to be flipped. @@ -85,7 +82,7 @@ static int hexdigit(int x) { Oh how I wish sometimes we would upgrade to modern C++. \param[in] length minimum length in bytes */ -void Project_Reader::expand_buffer(int length) { +void fld::io::Project_Reader::expand_buffer(int length) { if (length >= buflen) { if (!buflen) { buflen = length+1; @@ -99,13 +96,13 @@ void Project_Reader::expand_buffer(int length) { } /** \brief Construct local project reader. */ -Project_Reader::Project_Reader(Project &proj) +fld::io::Project_Reader::Project_Reader(Project &proj) : proj_(proj) { } /** \brief Release project reader resources. */ -Project_Reader::~Project_Reader() +fld::io::Project_Reader::~Project_Reader() { // fname is not copied, so do not free it if (buffer) @@ -117,7 +114,7 @@ Project_Reader::~Project_Reader() \param[in] s filename, if 0, read from stdin instead \return 0 if the operation failed, 1 if it succeeded */ -int Project_Reader::open_read(const char *s) { +int fld::io::Project_Reader::open_read(const char *s) { lineno = 1; if (!s) { fin = stdin; @@ -136,7 +133,7 @@ int Project_Reader::open_read(const char *s) { Close the .fl file. \return 0 if the operation failed, 1 if it succeeded */ -int Project_Reader::close_read() { +int fld::io::Project_Reader::close_read() { if (fin != stdin) { int x = fclose(fin); fin = 0; @@ -149,7 +146,7 @@ int Project_Reader::close_read() { Return the name part of the current filename and path. \return a pointer into a string that is not owned by this class */ -const char *Project_Reader::filename_name() { +const char *fld::io::Project_Reader::filename_name() { return fl_filename_name(fname); } @@ -159,7 +156,7 @@ const char *Project_Reader::filename_name() { values, and \\o### octal values. \return a character in the ASCII range */ -int Project_Reader::read_quoted() { // read whatever character is after a \ . +int fld::io::Project_Reader::read_quoted() { // read whatever character is after a \ . int c,d,x; switch(c = nextchar()) { case '\n': lineno++; return -1; @@ -204,7 +201,7 @@ int Project_Reader::read_quoted() { // read whatever character is after a \ a previous call, and there is no need to waste time searching for them. \return the last node that was created */ -Node *Project_Reader::read_children(Node *p, int merge, Strategy strategy, char skip_options) { +Node *fld::io::Project_Reader::read_children(Node *p, int merge, Strategy strategy, char skip_options) { Fluid.proj.tree.current = p; Node *last_child_read = 0; Node *t = 0; @@ -388,7 +385,7 @@ Node *Project_Reader::read_children(Node *p, int merge, Strategy strategy, char \param[in] strategy add new nodes after current or as last child \return 0 if the operation failed, 1 if it succeeded */ -int Project_Reader::read_project(const char *filename, int merge, Strategy strategy) { +int fld::io::Project_Reader::read_project(const char *filename, int merge, Strategy strategy) { Node *o; proj_.undo.suspend(); read_version = 0.0; @@ -438,7 +435,7 @@ int Project_Reader::read_project(const char *filename, int merge, Strategy strat operations. \param[in] format printf style format string, followed by an argument list */ -void Project_Reader::read_error(const char *format, ...) { +void fld::io::Project_Reader::read_error(const char *format, ...) { va_list args; va_start(args, format); if (!fin) { // FIXME: this line suppresses any error messages in interactive mode @@ -471,7 +468,7 @@ void Project_Reader::read_error(const char *format, ...) { overwrite this buffer. If wantbrace is not set, but we read a leading '{', the returned string will be stripped of its leading and trailing braces. */ -const char *Project_Reader::read_word(int wantbrace) { +const char *fld::io::Project_Reader::read_word(int wantbrace) { int x; // skip all the whitespace before it: @@ -541,7 +538,7 @@ const char *Project_Reader::read_word(int wantbrace) { /** Read a word and interpret it as an integer value. \return integer value, or 0 if the word is not an integer */ -int Project_Reader::read_int() { +int fld::io::Project_Reader::read_int() { const char *word = read_word(); if (word) { return atoi(word); @@ -557,7 +554,7 @@ int Project_Reader::read_int() { \param[out] value string \return 0 if end of file, else 1 */ -int Project_Reader::read_fdesign_line(const char*& name, const char*& value) { +int fld::io::Project_Reader::read_fdesign_line(const char*& name, const char*& value) { int length = 0; int x; // find a colon: @@ -646,6 +643,7 @@ static const char *class_matcher[] = { static void forms_end(Fl_Group *g, int flip) { // set the dimensions of a group to surround its contents const int nc = g->children(); + int i; if (nc && !g->w()) { Fl_Widget*const* a = g->array(); Fl_Widget* o = *a++; @@ -653,7 +651,7 @@ static void forms_end(Fl_Group *g, int flip) { int ry = o->y(); int rw = rx+o->w(); int rh = ry+o->h(); - for (int i = nc - 1; i--;) { + for (i = nc - 1; i--;) { o = *a++; if (o->x() < rx) rx = o->x(); if (o->y() < ry) ry = o->y(); @@ -667,7 +665,7 @@ static void forms_end(Fl_Group *g, int flip) { Fl_Widget* o = (g->as_window()) ? g : g->window(); int Y = o->h(); Fl_Widget*const* a = g->array(); - for (int i = nc; i--;) { + for (i = nc; i--;) { Fl_Widget* ow = *a++; int newy = Y - ow->y() - ow->h(); ow->Fl_Widget::resize(ow->x(), newy, ow->w(), ow->h()); @@ -683,7 +681,7 @@ static void forms_end(Fl_Group *g, int flip) { FLTK widgets. \see http://xforms-toolkit.org */ -void Project_Reader::read_fdesign() { +void fld::io::Project_Reader::read_fdesign() { int fdesign_magic = atoi(read_word()); fdesign_flip = (fdesign_magic < 13000); Widget_Node *window = 0; @@ -721,7 +719,8 @@ void Project_Reader::read_fdesign() { group = widget = 0; Fluid.proj.tree.current = window; } else { - for (int i = 0; class_matcher[i]; i += 2) + int i; + for (i = 0; class_matcher[i]; i += 2) if (!strcmp(value,class_matcher[i])) { value = class_matcher[i+1]; break;} widget = (Widget_Node*)add_new_widget_from_file(value, Strategy::FROM_FILE_AS_LAST_CHILD); diff --git a/fluid/io/Project_Writer.cxx b/fluid/io/Project_Writer.cxx index 9af369c93..e2f670f8f 100644 --- a/fluid/io/Project_Writer.cxx +++ b/fluid/io/Project_Writer.cxx @@ -32,9 +32,6 @@ /// \defgroup flfile .fl Project File Operations /// \{ -using namespace fld; -using namespace fld::io; - /** \brief Write an .fl design description file. The .fl file format is documented in `fluid/README_fl.txt`. @@ -52,13 +49,13 @@ int fld::io::write_file(Project &proj, const char *filename, int selected_only, // ---- Project_Writer ---------------------------------------------- MARK: - /** \brief Construct local project writer. */ -Project_Writer::Project_Writer(Project &proj) +fld::io::Project_Writer::Project_Writer(Project &proj) : proj_(proj) { } /** \brief Release project writer resources. */ -Project_Writer::~Project_Writer() +fld::io::Project_Writer::~Project_Writer() { } @@ -68,7 +65,7 @@ Project_Writer::~Project_Writer() \param[in] s the filename or 0 for stdout \return 1 if successful. 0 if the operation failed */ -int Project_Writer::open_write(const char *s) { +int fld::io::Project_Writer::open_write(const char *s) { if (!s) { fout = stdout; } else { @@ -84,7 +81,7 @@ int Project_Writer::open_write(const char *s) { Don't close, if data was sent to stdout. \return 1 if succeeded, 0 if fclose failed */ -int Project_Writer::close_write() { +int fld::io::Project_Writer::close_write() { if (fout != stdout) { int x = fclose(fout); fout = stdout; @@ -100,7 +97,7 @@ int Project_Writer::close_write() { \param[in] sv if set, this file will be used by codeview \return 0 if the operation failed, 1 if it succeeded */ -int Project_Writer::write_project(const char *filename, int selected_only, bool sv) { +int fld::io::Project_Writer::write_project(const char *filename, int selected_only, bool sv) { write_codeview_ = sv; proj_.undo.suspend(); if (!open_write(filename)) { @@ -131,7 +128,8 @@ int Project_Writer::write_project(const char *filename, int selected_only, bool write_string("\nmergeback %d", proj_.write_mergeback_data); } - for (Node *p = proj_.tree.first; p;) { + Node *p; + for (p = proj_.tree.first; p;) { if (!selected_only || p->selected) { p->write(*this); write_string("\n"); @@ -150,7 +148,7 @@ int Project_Writer::write_project(const char *filename, int selected_only, bool Write a string to the .fl file, quoting characters if necessary. \param[in] w NUL terminated text */ -void Project_Writer::write_word(const char *w) { +void fld::io::Project_Writer::write_word(const char *w) { if (needspace) putc(' ', fout); needspace = 1; if (!w || !*w) {fprintf(fout,"{}"); return;} @@ -188,7 +186,7 @@ void Project_Writer::write_word(const char *w) { unless the format starts with a newline character \\n. \param[in] format printf style formatting string followed by a list of arguments */ -void Project_Writer::write_string(const char *format, ...) { +void fld::io::Project_Writer::write_string(const char *format, ...) { va_list args; va_start(args, format); if (needspace && *format != '\n') fputc(' ',fout); @@ -201,7 +199,7 @@ void Project_Writer::write_string(const char *format, ...) { Start a new line in the .fl file and indent it for a given nesting level. \param[in] n indent level */ -void Project_Writer::write_indent(int n) { +void fld::io::Project_Writer::write_indent(int n) { fputc('\n',fout); while (n--) {fputc(' ',fout); fputc(' ',fout);} needspace = 0; @@ -210,7 +208,7 @@ void Project_Writer::write_indent(int n) { /** Write a '{' to the .fl file at the given indenting level. */ -void Project_Writer::write_open() { +void fld::io::Project_Writer::write_open() { if (needspace) fputc(' ',fout); fputc('{',fout); needspace = 0; @@ -220,7 +218,7 @@ void Project_Writer::write_open() { Write a '}' to the .fl file at the given indenting level. \param[in] n indent level */ -void Project_Writer::write_close(int n) { +void fld::io::Project_Writer::write_close(int n) { if (needspace) write_indent(n); fputc('}',fout); needspace = 1; diff --git a/fluid/io/String_Writer.cxx b/fluid/io/String_Writer.cxx index 97245697b..891fc5a25 100644 --- a/fluid/io/String_Writer.cxx +++ b/fluid/io/String_Writer.cxx @@ -21,9 +21,6 @@ #include "nodes/Window_Node.h" #include "nodes/Function_Node.h" -using namespace fld; -using namespace fld::io; - /** Write a string to a file, replacing all non-ASCII characters with octal codes. \param[in] out output file @@ -33,7 +30,8 @@ using namespace fld::io; static int write_escaped_strings(FILE *out, const char *text) { int ret = 0; const unsigned char *utf8_text = (const unsigned char *)text; - for (const unsigned char *s = utf8_text; *s; ++s) { + const unsigned char *s; + for (s = utf8_text; *s; ++s) { unsigned char c = *s; // escape control characters, delete, all utf-8, and the double quotes // note: we should have an option in the project settings to allow utf-8 diff --git a/fluid/nodes/Function_Node.cxx b/fluid/nodes/Function_Node.cxx index de3706eb3..daf5822c0 100644 --- a/fluid/nodes/Function_Node.cxx +++ b/fluid/nodes/Function_Node.cxx @@ -37,9 +37,6 @@ extern void open_panel(); -using namespace fld; -using namespace fld::io; -using namespace fld::proj; /// Set a current class, so that the code of the children is generated correctly. Class_Node *current_class = 0; diff --git a/fluid/nodes/Grid_Node.cxx b/fluid/nodes/Grid_Node.cxx index d38bbd1ca..6759c33f2 100644 --- a/fluid/nodes/Grid_Node.cxx +++ b/fluid/nodes/Grid_Node.cxx @@ -225,7 +225,8 @@ void Fl_Grid_Proxy::transient_make_room_(int n) { \param[in] w remove the transient cell for this widget */ void Fl_Grid_Proxy::transient_remove_(Fl_Widget *w) { - for (int i=0; i<num_transient_; i++) { + int i; + for (i =0; i<num_transient_; i++) { if (transient_[i].widget==w) { if (transient_[i].cell) { ::free(transient_[i].cell); @@ -254,7 +255,8 @@ Fl_Grid_Proxy::Cell *Fl_Grid_Proxy::any_cell(Fl_Widget *widget) const { \return the transient cell, or 0 if it was not found. */ Fl_Grid_Proxy::Cell *Fl_Grid_Proxy::transient_cell(Fl_Widget *widget) const { - for (int i=0; i<num_transient_; i++) { + int i; + for (i =0; i<num_transient_; i++) { if (transient_[i].widget == widget) return transient_[i].cell; } @@ -316,13 +318,15 @@ void Grid_Node::copy_properties() s->gap(&rg, &cg); d->gap(rg, cg); // copy col widths, heights, and gaps - for (int c=0; c<s->cols(); c++) { + int c; + for (c =0; c<s->cols(); c++) { d->col_width(c, s->col_width(c)); d->col_gap(c, s->col_gap(c)); d->col_weight(c, s->col_weight(c)); } // copy row widths, heights, and gaps - for (int r=0; r<s->rows(); r++) { + int r; + for (r =0; r<s->rows(); r++) { d->row_height(r, s->row_height(r)); d->row_gap(r, s->row_gap(r)); d->row_weight(r, s->row_weight(r)); @@ -331,7 +335,8 @@ void Grid_Node::copy_properties() void Grid_Node::copy_properties_for_children() { Fl_Grid *d = (Fl_Grid*)live_widget, *s =(Fl_Grid*)o; - for (int i=0; i<s->children(); i++) { + int i; + for (i =0; i<s->children(); i++) { Fl_Grid::Cell *cell = s->cell(s->child(i)); if (cell && i<d->children()) { d->widget(d->child(i), @@ -411,6 +416,7 @@ void Grid_Node::write_properties(fld::io::Project_Writer &f) void Grid_Node::read_property(fld::io::Project_Reader &f, const char *c) { Fl_Grid* grid = (Fl_Grid*)o; + int i; if (!strcmp(c,"dimensions")) { int rows = 3, cols = 3; if (sscanf(f.read_word(),"%d %d", &rows, &cols) == 2) @@ -426,32 +432,32 @@ void Grid_Node::read_property(fld::io::Project_Reader &f, const char *c) } else if (!strcmp(c,"rowheights")) { int rows = grid->rows(); f.read_word(1); // "{" - for (int i=0; i<rows; i++) grid->row_height(i, f.read_int()); + for (i =0; i<rows; i++) grid->row_height(i, f.read_int()); f.read_word(1); // "}" } else if (!strcmp(c,"rowweights")) { int rows = grid->rows(); f.read_word(1); // "{" - for (int i=0; i<rows; i++) grid->row_weight(i, f.read_int()); + for (i =0; i<rows; i++) grid->row_weight(i, f.read_int()); f.read_word(1); // "}" } else if (!strcmp(c,"rowgaps")) { int rows = grid->rows(); f.read_word(1); // "{" - for (int i=0; i<rows; i++) grid->row_gap(i, f.read_int()); + for (i =0; i<rows; i++) grid->row_gap(i, f.read_int()); f.read_word(1); // "}" } else if (!strcmp(c,"colwidths")) { int cols = grid->cols(); f.read_word(1); // "{" - for (int i=0; i<cols; i++) grid->col_width(i, f.read_int()); + for (i =0; i<cols; i++) grid->col_width(i, f.read_int()); f.read_word(1); // "}" } else if (!strcmp(c,"colweights")) { int cols = grid->cols(); f.read_word(1); // "{" - for (int i=0; i<cols; i++) grid->col_weight(i, f.read_int()); + for (i =0; i<cols; i++) grid->col_weight(i, f.read_int()); f.read_word(1); // "}" } else if (!strcmp(c,"colgaps")) { int cols = grid->cols(); f.read_word(1); // "{" - for (int i=0; i<cols; i++) grid->col_gap(i, f.read_int()); + for (i =0; i<cols; i++) grid->col_gap(i, f.read_int()); f.read_word(1); // "}" } else { super::read_property(f, c); @@ -612,7 +618,8 @@ void Grid_Node::write_code2(fld::io::Code_Writer& f) { const char *var = name() ? name() : "o"; Fl_Grid* grid = (Fl_Grid*)o; bool first_cell = true; - for (int i=0; i<grid->children(); i++) { + int i; + for (i =0; i<grid->children(); i++) { Fl_Widget *c = grid->child(i); Fl_Grid::Cell *cell = grid->cell(c); if (cell) { @@ -694,14 +701,16 @@ void Grid_Node::insert_child_at(Fl_Widget *child, int x, int y) { int x0 = grid->x() + Fl::box_dx(grid->box()) + ml; int y0 = grid->y() + Fl::box_dy(grid->box()) + mt; - for (int r = 0; r < grid->rows(); r++) { + int r; + for (r = 0; r < grid->rows(); r++) { if (y>y0) row = r; int gap = grid->row_gap(r)>=0 ? grid->row_gap(r) : grg; y0 += grid->computed_row_height(r); y0 += gap; } - for (int c = 0; c < grid->cols(); c++) { + int c; + for (c = 0; c < grid->cols(); c++) { if (x>x0) col = c; int gap = grid->col_gap(c)>=0 ? grid->col_gap(c) : gcg; x0 += grid->computed_col_width(c); @@ -732,8 +741,10 @@ void Grid_Node::insert_child_at_next_free_cell(Fl_Widget *child) { // c = current_cell->col(); // } // } - for (int r = 0; r < grid->rows(); r++) { - for (int c = 0; c < grid->cols(); c++) { + int r; + for (r = 0; r < grid->rows(); r++) { + int c; + for (c = 0; c < grid->cols(); c++) { if (!grid->cell(r, c)) { grid->move_cell(child, r, c); return; diff --git a/fluid/nodes/Group_Node.cxx b/fluid/nodes/Group_Node.cxx index 8ff3b9cdf..d4dc93780 100644 --- a/fluid/nodes/Group_Node.cxx +++ b/fluid/nodes/Group_Node.cxx @@ -79,7 +79,8 @@ void fix_group_size(Node *tt) { int Y = t->o->y(); int R = X+t->o->w(); int B = Y+t->o->h(); - for (Node *nn = t->next; nn && nn->level > t->level; nn = nn->next) { + Node *nn; + for (nn = t->next; nn && nn->level > t->level; nn = nn->next) { if (nn->is_true_widget()) { Widget_Node* n = (Widget_Node*)nn; int x = n->o->x(); if (x < X) X = x; @@ -122,7 +123,8 @@ void group_cb(Fl_Widget *, void *) { Group_Node *n = (Group_Node*)(Group_Node::prototype.make(Strategy::AS_LAST_CHILD)); n->move_before(q); n->o->resize(q->o->x(),q->o->y(),q->o->w(),q->o->h()); - for (Node *t = qq->next; t && (t->level > qq->level);) { + Node *t; + for (t = qq->next; t && (t->level > qq->level);) { if (t->level != n->level || t == n || !t->selected) { t = t->next; continue; @@ -166,7 +168,8 @@ void ungroup_cb(Fl_Widget *, void *) { Fluid.proj.undo.checkpoint(); Fluid.proj.undo.suspend(); Fluid.proj.tree.current = qq; - for (Node *t = qq->next; t && (t->level > qq->level);) { + Node *t; + for (t = qq->next; t && (t->level > qq->level);) { if (t->level != q_level || !t->selected) { t = t->next; continue; @@ -319,7 +322,8 @@ Fl_Widget *Flex_Node::enter_live_mode(int) { Fl_Flex *d = grp, *s =(Fl_Flex*)o; int nc = s->children(), nd = d->children(); if (nc>nd) nc = nd; - for (int i=0; i<nc; i++) { + int i; + for (i =0; i<nc; i++) { if (s->fixed(s->child(i))) { Fl_Widget *dc = d->child(i); d->fixed(d->child(i), s->horizontal() ? dc->w() : dc->h()); @@ -340,7 +344,8 @@ void Flex_Node::copy_properties() void Flex_Node::copy_properties_for_children() { Fl_Flex *d = (Fl_Flex*)live_widget, *s =(Fl_Flex*)o; - for (int i=0; i<s->children(); i++) { + int i; + for (i =0; i<s->children(); i++) { if (s->fixed(s->child(i)) && i<d->children()) { if (s->horizontal()) { d->fixed(d->child(i), d->child(i)->w()); @@ -363,12 +368,13 @@ void Flex_Node::write_properties(fld::io::Project_Writer &f) if (flex->gap()) f.write_string("gap %d", flex->gap()); int nSet = 0; - for (int i=0; i<flex->children(); i++) + int i; + for (i =0; i<flex->children(); i++) if (flex->fixed(flex->child(i))) nSet++; if (nSet) { f.write_string("fixed_size_tuples {%d", nSet); - for (int i=0; i<flex->children(); i++) { + for (i =0; i<flex->children(); i++) { Fl_Widget *ci = flex->child(i); if (flex->fixed(ci)) f.write_string(" %d %d", i, flex->horizontal() ? ci->w() : ci->h()); @@ -394,7 +400,8 @@ void Flex_Node::read_property(fld::io::Project_Reader &f, const char *c) const char *nStr = f.read_word(1); // number of indices in table fixedSizeTupleSize = atoi(nStr); fixedSizeTuple = new int[fixedSizeTupleSize*2]; - for (int i=0; i<fixedSizeTupleSize; i++) { + int i; + for (i =0; i<fixedSizeTupleSize; i++) { const char *ix = f.read_word(1); // child at that index is fixed in size fixedSizeTuple[i*2] = atoi(ix); const char *size = f.read_word(1); // fixed size of that child @@ -410,7 +417,8 @@ void Flex_Node::postprocess_read() { Fl_Flex* flex = (Fl_Flex*)o; if (fixedSizeTupleSize>0) { - for (int i=0; i<fixedSizeTupleSize; i++) { + int i; + for (i =0; i<fixedSizeTupleSize; i++) { int ix = fixedSizeTuple[2*i]; int size = fixedSizeTuple[2*i+1]; if (ix>=0 && ix<flex->children()) { @@ -434,7 +442,8 @@ void Flex_Node::write_code2(fld::io::Code_Writer& f) { f.write_c("%s%s->margin(%d, %d, %d, %d);\n", f.indent(), var, lm, tm, rm, bm); if (flex->gap()) f.write_c("%s%s->gap(%d);\n", f.indent(), var, flex->gap()); - for (int i=0; i<flex->children(); ++i) { + int i; + for (i =0; i<flex->children(); ++i) { Fl_Widget *ci = flex->child(i); if (flex->fixed(ci)) f.write_c("%s%s->fixed(%s->child(%d), %d);\n", f.indent(), var, var, i, @@ -489,15 +498,16 @@ void Flex_Node::change_subtype_to(int n) { int fh = f->h()-dh-tm-bm-(nc*gap); if (fh<=nc) fh = nc; // avoid division by zero + int i; if (f->type()==Fl_Flex::HORIZONTAL && n==Fl_Flex::VERTICAL) { float scl = (float)fh/(float)fw; - for (int i=0; i<nc; i++) { + for (i =0; i<nc; i++) { Fl_Widget* c = f->child(i); c->size(f->w(), (int)(c->w()*scl)); } } else if (f->type()==Fl_Flex::VERTICAL && n==Fl_Flex::HORIZONTAL) { float scl = (float)fw/(float)fh; - for (int i=0; i<nc; i++) { + for (i =0; i<nc; i++) { Fl_Widget* c = f->child(i); c->size((int)(c->h()*scl), f->h()); } @@ -658,8 +668,9 @@ public: Fl_Table_Proxy(int x, int y, int w, int h, const char *l=0) : Fl_Table(x, y, w, h, l) { end(); - for ( int r=0; r<MAX_ROWS; r++ ) - for ( int c=0; c<MAX_COLS; c++ ) + int r, c; + for (r =0; r<MAX_ROWS; r++ ) + for (c =0; c<MAX_COLS; c++ ) data[r][c] = 1000+(r*1000)+c; // Rows rows(MAX_ROWS); // how many rows diff --git a/fluid/nodes/Menu_Node.cxx b/fluid/nodes/Menu_Node.cxx index 8075c9c60..6f837a9ba 100644 --- a/fluid/nodes/Menu_Node.cxx +++ b/fluid/nodes/Menu_Node.cxx @@ -44,8 +44,6 @@ #include <stdio.h> #include <stdlib.h> -using namespace fld; -using namespace fld::proj; Fl_Menu_Item menu_item_type_menu[] = { {"Normal",0,0,(void*)0}, @@ -210,7 +208,8 @@ void group_selected_menuitems() { Fluid.proj.undo.checkpoint(); Fluid.proj.undo.suspend(); Widget_Node *n = (Widget_Node*)(q->make(FL_SUBMENU, Strategy::AFTER_CURRENT)); - for (Node *t = qq->next; t && (t->level > qq->level);) { + Node *t; + for (t = qq->next; t && (t->level > qq->level);) { if (t->level != n->level || t == n || !t->selected) { t = t->next; continue; @@ -236,7 +235,8 @@ void ungroup_selected_menuitems() { Fluid.proj.undo.checkpoint(); Fluid.proj.undo.suspend(); Fluid.proj.tree.current = qq; - for (Node *t = qq->next; t && (t->level > qq->level);) { + Node *t; + for (t = qq->next; t && (t->level > qq->level);) { if (t->level != q_level || !t->selected) { t = t->next; continue; @@ -325,7 +325,8 @@ void Menu_Item_Node::write_static(fld::io::Code_Writer& f) { if (callback() && is_name(callback()) && !user_defined(callback())) f.write_h_once("extern void %s(Fl_Menu_*, %s);", callback(), user_data_type() ? user_data_type() : "void*"); - for (int n=0; n < NUM_EXTRA_CODE; n++) { + int n; + for (n =0; n < NUM_EXTRA_CODE; n++) { if (extra_code(n) && extra_code(n)[0] && isdeclare(extra_code(n))) f.write_h_once("%s", extra_code(n)); } @@ -426,7 +427,8 @@ void Menu_Item_Node::write_static(fld::io::Code_Writer& f) { f.write_c("\nFl_Menu_Item %s[] = {\n", menu_name(f, i)); } Node* t = prev; while (t && t->is_a(FLD_NODE_TYPE_Menu_Item)) t = t->prev; - for (Node* q = t->next; q && q->is_a(FLD_NODE_TYPE_Menu_Item); q = q->next) { + Node *q; + for (q = t->next; q && q->is_a(FLD_NODE_TYPE_Menu_Item); q = q->next) { ((Menu_Item_Node*)q)->write_item(f); int thislevel = q->level; if (q->can_have_children()) thislevel++; int nextlevel = @@ -438,7 +440,7 @@ void Menu_Item_Node::write_static(fld::io::Code_Writer& f) { if (k) { // Write menu item variables... t = prev; while (t && t->is_a(FLD_NODE_TYPE_Menu_Item)) t = t->prev; - for (Node* q = t->next; q && q->is_a(FLD_NODE_TYPE_Menu_Item); q = q->next) { + for (q = t->next; q && q->is_a(FLD_NODE_TYPE_Menu_Item); q = q->next) { Menu_Item_Node *m = (Menu_Item_Node*)q; const char *c = array_name(m); if (c) { @@ -637,7 +639,8 @@ void Menu_Item_Node::write_code1(fld::io::Code_Writer& f) { } } } - for (int n=0; n < NUM_EXTRA_CODE; n++) { + int n; + for (n =0; n < NUM_EXTRA_CODE; n++) { if (extra_code(n) && extra_code(n)[0] && !isdeclare(extra_code(n))) { start_menu_initialiser(f, menuItemInitialized, mname, i); f.write_c("%s%s\n", f.indent(), extra_code(n)); diff --git a/fluid/nodes/Node.cxx b/fluid/nodes/Node.cxx index 8e0041f3c..79bd04b3b 100644 --- a/fluid/nodes/Node.cxx +++ b/fluid/nodes/Node.cxx @@ -133,8 +133,10 @@ Node *in_this_only; // set if menu popped-up in window */ void print_project_tree() { fprintf(stderr, "---- %s --->\n", Fluid.proj.projectfile_name().c_str()); - for (Node *t = Fluid.proj.tree.first; t; t = t->next) { - for (int i = t->level; i > 0; i--) + Node *t; + for (t = Fluid.proj.tree.first; t; t = t->next) { + int i; + for (i = t->level; i > 0; i--) fprintf(stderr, ". "); fprintf(stderr, "%s\n", subclassname(t).c_str()); } @@ -180,7 +182,8 @@ bool validate_project_tree() { bool validate_independent_branch(class Node *root) { // Make sure that `first` and `last` do not point at any node in this branch if (Fluid.proj.tree.first) { - for (Node *t = root; t; t = t->next) { + Node *t; + for (t = root; t; t = t->next) { if (Fluid.proj.tree.first == t) { fprintf(stderr, "ERROR: Branch is not independent, `first` is pointing to branch member!\n"); return false; @@ -188,7 +191,7 @@ bool validate_independent_branch(class Node *root) { } } if (Fluid.proj.tree.last) { - for (Node *t = root; t; t = t->next) { + for (t = root; t; t = t->next) { if (Fluid.proj.tree.last == t) { fprintf(stderr, "ERROR: Branch is not independent, `last` is pointing to branch member!\n"); return false; @@ -216,7 +219,8 @@ bool validate_branch(class Node *root) { return false; } // Check relation between this and next node - for (Node *t = root; t; t = t->next) { + Node *t; + for (t = root; t; t = t->next) { if (t->level < root->level) { fprintf(stderr, "ERROR: Node in tree is above root level!\n"); return false; @@ -241,7 +245,8 @@ bool validate_branch(class Node *root) { } } // Validate the `parent` entry - for (Node *p = t->prev; ; p = p->prev) { + Node *p; + for (p = t->prev; ; p = p->prev) { if (p == 0) { if (t->parent != 0) { fprintf(stderr, "ERROR: `parent` pointer should be 0!\n"); @@ -270,16 +275,17 @@ void select_all_cb(Fl_Widget *,void *) { for (; t && t != in_this_only; t = t->parent) {/*empty*/} if (t != in_this_only) p = in_this_only; } + Node *t; for (;;) { if (p) { int foundany = 0; - for (Node *t = p->next; t && t->level>p->level; t = t->next) { + for (t = p->next; t && t->level>p->level; t = t->next) { if (!t->new_selected) {widget_browser->select(t,1,0); foundany = 1;} } if (foundany) break; p = p->parent; } else { - for (Node *t = Fluid.proj.tree.first; t; t = t->next) + for (t = Fluid.proj.tree.first; t; t = t->next) widget_browser->select(t,1,0); break; } @@ -294,16 +300,17 @@ void select_none_cb(Fl_Widget *,void *) { for (; t && t != in_this_only; t = t->parent) {/*empty*/} if (t != in_this_only) p = in_this_only; } + Node *t; for (;;) { if (p) { int foundany = 0; - for (Node *t = p->next; t && t->level>p->level; t = t->next) { + for (t = p->next; t && t->level>p->level; t = t->next) { if (t->new_selected) {widget_browser->select(t,0,0); foundany = 1;} } if (foundany) break; p = p->parent; } else { - for (Node *t = Fluid.proj.tree.first; t; t = t->next) + for (t = Fluid.proj.tree.first; t; t = t->next) widget_browser->select(t,0,0); break; } @@ -388,7 +395,8 @@ void delete_all(int selected_only) { widget_browser->save_scroll_position(); widget_browser->new_list(); } - for (Node *f = Fluid.proj.tree.first; f;) { + Node *f; + for (f = Fluid.proj.tree.first; f;) { if (f->selected || !selected_only) { delete_children(f); Node *g = f->next; @@ -590,7 +598,8 @@ const char* Node::title() { Window_Node *Node::window() { if (!is_widget()) return 0; - for (Node *t = this; t; t=t->parent) + Node *t; + for (t = this; t; t=t->parent) if (t->is_a(FLD_NODE_TYPE_Window)) return (Window_Node*)t; return 0; @@ -603,7 +612,8 @@ Window_Node *Node::window() { Group_Node *Node::group() { if (!is_widget()) return 0; - for (Node *t = this; t; t=t->parent) + Node *t; + for (t = this; t; t=t->parent) if (t->is_a(FLD_NODE_TYPE_Group)) return (Group_Node*)t; return 0; @@ -677,7 +687,8 @@ void Node::add(Node *anchor, Strategy strategy) { // Walk the tree to update parent pointers and levels int source_level = level; - for (Node *t = this; t; t = t->next) { + Node *t; + for (t = this; t; t = t->next) { t->level += (target_level-source_level); if (t->level == target_level) t->parent = target_parent; @@ -708,7 +719,7 @@ void Node::add(Node *anchor, Strategy strategy) { } // Give the widgets in our tree a chance to update themselves - for (Node *t = this; t && t!=end->next; t = t->next) { + for (t = this; t && t!=end->next; t = t->next) { if (target_parent && (t->level == target_level)) target_parent->add_child(t, 0); update_visibility_flag(t); @@ -744,7 +755,8 @@ void Node::insert(Node *g) { // run the list again to set the future node levels int newlevel = g->level; visible = g->visible; - for (Node *t = this->next; t; t = t->next) t->level += newlevel-level; + Node *t; + for (t = this->next; t; t = t->next) t->level += newlevel-level; level = newlevel; // insert this in the list before g prev = g->prev; @@ -1186,7 +1198,8 @@ void Node::copy_properties() { the parameter types match. */ int Node::user_defined(const char* cbname) const { - for (Node* p = Fluid.proj.tree.first; p ; p = p->next) + Node *p; + for (p = Fluid.proj.tree.first; p ; p = p->next) if (p->is_a(FLD_NODE_TYPE_Function) && p->name() != 0) if (strncmp(p->name(), cbname, strlen(cbname)) == 0) if (p->name()[strlen(cbname)] == '(') diff --git a/fluid/nodes/Tree.cxx b/fluid/nodes/Tree.cxx index d437b5bd3..e11c399e2 100644 --- a/fluid/nodes/Tree.cxx +++ b/fluid/nodes/Tree.cxx @@ -19,11 +19,7 @@ #include "Project.h" -using namespace fld; -using namespace fld::node; - - -Tree::Iterator::Iterator(Node *t, bool only_selected) +fld::node::Tree::Iterator::Iterator(Node *t, bool only_selected) : type_(t) , only_selected_(only_selected) { @@ -36,7 +32,7 @@ Tree::Iterator::Iterator(Node *t, bool only_selected) } } -Tree::Iterator &Tree::Iterator::operator++() { +fld::node::Tree::Iterator &fld::node::Tree::Iterator::operator++() { if (only_selected_) { do { type_ = type_->next; @@ -47,7 +43,7 @@ Tree::Iterator &Tree::Iterator::operator++() { return *this; } -Tree::WIterator::WIterator(Node *t, bool only_selected) +fld::node::Tree::WIterator::WIterator(Node *t, bool only_selected) : type_(t) , only_selected_(only_selected) { @@ -64,7 +60,7 @@ Tree::WIterator::WIterator(Node *t, bool only_selected) } } -Tree::WIterator& Tree::WIterator::operator++() { +fld::node::Tree::WIterator& fld::node::Tree::WIterator::operator++() { if (only_selected_) { do { type_ = type_->next; @@ -78,7 +74,7 @@ Tree::WIterator& Tree::WIterator::operator++() { } -Tree::Tree(Project &proj) +fld::node::Tree::Tree(Project &proj) : proj_(proj) { (void)proj_; } @@ -91,7 +87,7 @@ Tree::Tree(Project &proj) \param[in] uid any number between 0 and 65535 \return the node with this uid, or 0 if not found */ -Node *Tree::find_by_uid(unsigned short uid) { +Node *fld::node::Tree::find_by_uid(unsigned short uid) { for (Node *tp: all_nodes()) { if (tp->get_uid() == uid) return tp; } @@ -105,7 +101,7 @@ Node *Tree::find_by_uid(unsigned short uid) { \param[in] crsr cursor position in text \return the node we found or 0 */ -Node *Tree::find_in_text(int text_type, int crsr) { +Node *fld::node::Tree::find_in_text(int text_type, int crsr) { for (Node *node: all_nodes()) { switch (text_type) { case 0: diff --git a/fluid/nodes/Widget_Node.cxx b/fluid/nodes/Widget_Node.cxx index d5d256dbe..757155335 100644 --- a/fluid/nodes/Widget_Node.cxx +++ b/fluid/nodes/Widget_Node.cxx @@ -51,8 +51,6 @@ #define MAX(a,b) ((a)>=(b) ? (a) : (b)) #endif -using namespace fld; -using namespace fld::proj; extern void redraw_browser(); @@ -386,7 +384,8 @@ void name_public_cb(Fl_Choice* i, void* v) { i->show(); } else { int mod = 0; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { ((Widget_Node*)o)->public_ = i->value(); mod = 1; @@ -433,7 +432,8 @@ void label_cb(Fl_Input* i, void* v) { if (i->changed()) { Fluid.proj.undo.suspend(); int mod = 0; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { if (!mod) { if (first_change) { @@ -724,7 +724,8 @@ Fl_Menu_Item boxmenu[] = { const char* boxname(int i) { if (!i) i = ZERO_ENTRY; - for (int j = 0; j < int(sizeof(boxmenu)/sizeof(*boxmenu)); j++) + int j; + for (j = 0; j < int(sizeof(boxmenu)/sizeof(*boxmenu)); j++) if (boxmenu[j].argument() == i) return boxmenu[j].label(); return 0; @@ -733,7 +734,8 @@ const char* boxname(int i) { int boxnumber(const char* i) { if (i[0]=='F' && i[1]=='L' && i[2]=='_') i += 3; - for (int j = 0; j < int(sizeof(boxmenu)/sizeof(*boxmenu)); j++) + int j; + for (j = 0; j < int(sizeof(boxmenu)/sizeof(*boxmenu)); j++) if (boxmenu[j].label() && !strcmp(boxmenu[j].label(), i)) { return int(boxmenu[j].argument()); } @@ -896,7 +898,8 @@ void labeltype_cb(Fl_Choice* i, void* v) { if (v == LOAD) { int n = current_widget->o->labeltype(); i->when(FL_WHEN_RELEASE); - for (int j = 0; j < int(sizeof(labeltypemenu)/sizeof(*labeltypemenu)); j++) { + int j; + for (j = 0; j < int(sizeof(labeltypemenu)/sizeof(*labeltypemenu)); j++) { if (labeltypemenu[j].argument() == n) { i->value(j); break; @@ -908,7 +911,8 @@ void labeltype_cb(Fl_Choice* i, void* v) { int n = int(labeltypemenu[m].argument()); if (n<0) return; // should not happen - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { Widget_Node* p = (Widget_Node*)o; p->o->labeltype((Fl_Labeltype)n); @@ -943,7 +947,8 @@ Fl_Menu_Item colormenu[] = { void color_common(Fl_Color c) { int mod = 0; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { Widget_Node* q = (Widget_Node*)o; q->o->color(c); q->o->redraw(); @@ -963,7 +968,8 @@ void color_common(Fl_Color c) { void color2_common(Fl_Color c) { int mod = 0; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { Widget_Node* q = (Widget_Node*)o; q->o->selection_color(c); q->o->redraw(); @@ -978,7 +984,8 @@ void color2_common(Fl_Color c) { void labelcolor_common(Fl_Color c) { int mod = 0; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { Widget_Node* q = (Widget_Node*)o; q->o->labelcolor(c); q->redraw(); @@ -1029,7 +1036,8 @@ void align_cb(Fl_Button* i, void* v) { } else { int mod = 0; Fluid.proj.undo.checkpoint(); - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { Widget_Node* q = (Widget_Node*)o; Fl_Align x = q->o->align(); @@ -1079,7 +1087,8 @@ void align_position_cb(Fl_Choice* i, void* v) { Fl_Align b = Fl_Align(fl_uintptr_t(mi->user_data())); int mod = 0; Fluid.proj.undo.checkpoint(); - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { Widget_Node* q = (Widget_Node*)o; Fl_Align x = q->o->align(); @@ -1114,7 +1123,8 @@ void align_text_image_cb(Fl_Choice* i, void* v) { Fl_Align b = Fl_Align(fl_uintptr_t(mi->user_data())); int mod = 0; Fluid.proj.undo.checkpoint(); - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { Widget_Node* q = (Widget_Node*)o; Fl_Align x = q->o->align(); @@ -1156,7 +1166,8 @@ int Widget_Node::textstuff(int, Fl_Font&, int&, Fl_Color&) { void textcolor_common(Fl_Color c) { Fl_Font n; int s; int mod = 0; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { Widget_Node* q = (Widget_Node*)o; q->textstuff(3,n,s,c); q->o->redraw(); @@ -1245,7 +1256,8 @@ Fl_Menu_Item* Widget_Node::subtypes() { return 0; } void propagate_load(Fl_Group* g, void* v) { if (v == LOAD) { Fl_Widget*const* a = g->array(); - for (int i=g->children(); i--;) { + int i; + for (i =g->children(); i--;) { Fl_Widget* o = *a++; o->do_callback(o, LOAD, FL_REASON_USER); } @@ -1255,7 +1267,8 @@ void propagate_load(Fl_Group* g, void* v) { void set_cb(Fl_Button*, void*) { haderror = 0; Fl_Widget*const* a = the_panel->array(); - for (int i=the_panel->children(); i--;) { + int i; + for (i =the_panel->children(); i--;) { Fl_Widget* o = *a++; if (o->changed()) { o->do_callback(); @@ -1391,7 +1404,8 @@ void load_panel() { current_node = 0; if (Fluid.proj.tree.current->is_widget()) current_widget=(Widget_Node*)Fluid.proj.tree.current; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->is_widget() && o->selected) { numselected++; if (!current_widget) current_widget = (Widget_Node*)o; @@ -1468,12 +1482,13 @@ extern void update_codeview_position(); // old panel in that case, as the object may no longer exist) void selection_changed(Node* p) { // store all changes to the current selected objects: + Node *o; if (p && the_panel && the_panel->visible()) { set_cb(0,0); // if there was an error, we try to leave the selected set unchanged: if (haderror) { Node* q = 0; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + for (o = Fluid.proj.tree.first; o; o = o->next) { o->new_selected = o->selected; if (!q && o->selected) q = o; } @@ -1485,7 +1500,7 @@ void selection_changed(Node* p) { } // update the selected flags to new set: Node* q = 0; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + for (o = Fluid.proj.tree.first; o; o = o->next) { o->selected = o->new_selected; if (!q && o->selected) q = o; } @@ -1626,7 +1641,8 @@ void Widget_Node::write_static(fld::io::Code_Writer& f) { f.write_c("void %s::%s(%s* o, %s v) {\n", k, cn, t, ut); f.write_c("%s((%s*)(o", f.indent(1), k); Node* q = 0; - for (Node* p = parent; p && p->is_widget(); q = p, p = p->parent) + Node *p; + for (p = parent; p && p->is_widget(); q = p, p = p->parent) f.write_c("->parent()"); if (!q || !q->is_a(FLD_NODE_TYPE_Widget_Class)) f.write_c("->user_data()"); @@ -2018,7 +2034,8 @@ void Widget_Node::write_widget_code(fld::io::Code_Writer& f) { } void Widget_Node::write_extra_code(fld::io::Code_Writer& f) { - for (int n=0; n < NUM_EXTRA_CODE; n++) + int n; + for (n =0; n < NUM_EXTRA_CODE; n++) if (extra_code(n) && extra_code(n)[0] && !isdeclare(extra_code(n))) f.write_c("%s%s\n", f.indent(), extra_code(n)); } @@ -2158,7 +2175,8 @@ void Widget_Node::write_properties(fld::io::Project_Writer &f) { if (resizable()) f.write_string("resizable"); if (hotspot()) f.write_string(is_a(FLD_NODE_TYPE_Menu_Item) ? "divider" : "hotspot"); if (menu_headline()) f.write_string("headline"); - for (int n=0; n < NUM_EXTRA_CODE; n++) if (extra_code(n) && extra_code(n)[0]) { + int n; + for (n =0; n < NUM_EXTRA_CODE; n++) if (extra_code(n) && extra_code(n)[0]) { f.write_indent(level+1); f.write_string("code%d",n); f.write_word(extra_code(n)); diff --git a/fluid/nodes/Window_Node.cxx b/fluid/nodes/Window_Node.cxx index 9a53d2ecb..5cdda615d 100644 --- a/fluid/nodes/Window_Node.cxx +++ b/fluid/nodes/Window_Node.cxx @@ -163,8 +163,9 @@ void Overlay_Window::draw() { if ((damage()&FL_DAMAGE_ALL) && (!box() || (box()>=4&&!(box()&2)) || box()>=FL_ROUNDED_BOX)) { // if so, draw checkerboard so user can see what areas are clear: - for (int Y = 0; Y < h(); Y += CHECKSIZE) - for (int X = 0; X < w(); X += CHECKSIZE) { + int Y, X; + for (Y = 0; Y < h(); Y += CHECKSIZE) + for (X = 0; X < w(); X += CHECKSIZE) { fl_color(((Y/(2*CHECKSIZE))&1) != ((X/(2*CHECKSIZE))&1) ? FL_WHITE : FL_BLACK); fl_rectf(X,Y,CHECKSIZE,CHECKSIZE); @@ -402,7 +403,8 @@ void Window_Node::newdx() { if (Fluid.show_guides && (drag & (FD_DRAG|FD_TOP|FD_LEFT|FD_BOTTOM|FD_RIGHT))) { Node *selection = 0; // special power for the first selected widget - for (Node *q=next; q && q->level>level; q = q->next) { + Node *q; + for (q =next; q && q->level>level; q = q->next) { if (q->selected && q->is_true_widget()) { selection = q; break; @@ -492,7 +494,8 @@ void fd_hatch(int x, int y, int w, int h, int size=6, int offset=0, int pad=3) { \param[in] x, y, w, h bounding box of this group */ void Window_Node::draw_out_of_bounds(Widget_Node *group, int x, int y, int w, int h) { - for (Node *p = group->next; p && p->level>group->level; p = p->next) { + Node *p; + for (p = group->next; p && p->level>group->level; p = p->next) { if (p->level == group->level+1 && p->is_true_widget()) { Fl_Widget *o = ((Widget_Node*)p)->o; if (o->x() < x) fd_hatch(o->x(), o->y(), x-o->x(), o->h()); @@ -510,7 +513,8 @@ void Window_Node::draw_out_of_bounds() { // get every group in the hierarchy, then draw any overlap of a direct child with that group fl_color(FL_DARK_RED); draw_out_of_bounds(this, 0, 0, o->w(), o->h()); - for (Node *q=next; q && q->level>level; q = q->next) { + Node *q; + for (q =next; q && q->level>level; q = q->next) { // don't do this for Fl_Scroll (which we currently can't handle in FLUID anyway) if (q->is_a(FLD_NODE_TYPE_Group) && !q->is_a(FLD_NODE_TYPE_Scroll)) { Widget_Node *w = (Widget_Node*)q; @@ -526,7 +530,8 @@ void Window_Node::draw_out_of_bounds() { void Window_Node::draw_overlaps() { fl_color(FL_DARK_YELLOW); // loop through all widgets in this window - for (Node *q=next; q && q->level>level; q = q->next) { + Node *q; + for (q =next; q && q->level>level; q = q->next) { // is it a valid widget if (q->is_true_widget()) { Widget_Node *w = (Widget_Node*)q; @@ -534,7 +539,8 @@ void Window_Node::draw_overlaps() { if (w->o->visible()) { int x = w->o->x(), y = w->o->y(); int r = x + w->o->w(), b = y + w->o->h(); - for (Node *p=q->next; p && p->level>=q->level; p = p->next) { + Node *p; + for (p =q->next; p && p->level>=q->level; p = p->next) { if (p->level==q->level && p->is_true_widget()) { Widget_Node *wp = (Widget_Node*)p; if (wp->o->visible()) { @@ -557,10 +563,11 @@ void Window_Node::draw_overlaps() { } void Window_Node::draw_overlay() { + Node *q; if (recalc) { bx = o->w(); by = o->h(); br = 0; bt = 0; numselected = 0; - for (Node *q=next; q && q->level>level; q=q->next) + for (q =next; q && q->level>level; q=q->next) if (q->selected && q->is_true_widget()) { numselected++; Widget_Node* myo = (Widget_Node*)q; @@ -592,7 +599,7 @@ void Window_Node::draw_overlay() { int mysx,mysy,mysr,myst; mybx = mysx = o->w(); myby = mysy = o->h(); mybr = mysr = 0; mybt = myst = 0; Node *selection = 0; // special power for the first selected widget - for (Node *q=next; q && q->level>level; q = q->next) + for (q =next; q && q->level>level; q = q->next) if (q->selected && q->is_true_widget()) { if (!selection) selection = q; Widget_Node* myo = (Widget_Node*)q; @@ -674,7 +681,8 @@ void Window_Node::fix_overlay() { void check_redraw_corresponding_parent(Node *s) { Widget_Node * prev_parent = 0; if( !s || !s->selected || !s->is_widget()) return; - for (Node *i=s; i && i->parent; i=i->parent) { + Node *i; + for (i =s; i && i->parent; i=i->parent) { if (i->is_a(FLD_NODE_TYPE_Group) && prev_parent) { if (i->is_a(FLD_NODE_TYPE_Tabs)) { ((Fl_Tabs*)((Widget_Node*)i)->o)->value(prev_parent->o); @@ -692,7 +700,8 @@ void check_redraw_corresponding_parent(Node *s) { // do that for every window (when selected set changes): void redraw_overlays() { - for (Node *o=Fluid.proj.tree.first; o; o=o->next) + Node *o; + for (o =Fluid.proj.tree.first; o; o=o->next) if (o->is_a(FLD_NODE_TYPE_Window)) ((Window_Node*)o)->fix_overlay(); } @@ -707,7 +716,8 @@ void toggle_overlays(Fl_Widget *,void *) { if (overlay_button) overlay_button->label("Hide &Overlays"); } - for (Node *o=Fluid.proj.tree.first; o; o=o->next) + Node *o; + for (o =Fluid.proj.tree.first; o; o=o->next) if (o->is_a(FLD_NODE_TYPE_Window)) { Widget_Node* w = (Widget_Node*)o; ((Overlay_Window*)(w->o))->redraw_overlay(); @@ -730,7 +740,8 @@ void toggle_guides(Fl_Widget *,void *) { if (guides_button) guides_button->value(Fluid.show_guides); - for (Node *o=Fluid.proj.tree.first; o; o=o->next) { + Node *o; + for (o =Fluid.proj.tree.first; o; o=o->next) { if (o->is_a(FLD_NODE_TYPE_Window)) { Widget_Node* w = (Widget_Node*)o; ((Overlay_Window*)(w->o))->redraw_overlay(); @@ -762,7 +773,8 @@ void toggle_restricted(Fl_Widget *,void *) { if (restricted_button) restricted_button->value(Fluid.show_restricted); - for (Node *o=Fluid.proj.tree.first; o; o=o->next) { + Node *o; + for (o =Fluid.proj.tree.first; o; o=o->next) { if (o->is_a(FLD_NODE_TYPE_Window)) { Widget_Node* w = (Widget_Node*)o; ((Overlay_Window*)(w->o))->redraw_overlay(); @@ -776,7 +788,8 @@ void toggle_restricted(Fl_Widget *,void *) { void toggle_ghosted_outline_cb(Fl_Check_Button *,void *) { Fluid.show_ghosted_outline = !Fluid.show_ghosted_outline; Fluid.preferences.set("Fluid.show_ghosted_outline", Fluid.show_ghosted_outline); - for (Node *o=Fluid.proj.tree.first; o; o=o->next) { + Node *o; + for (o =Fluid.proj.tree.first; o; o=o->next) { if (o->is_a(FLD_NODE_TYPE_Window)) { Widget_Node* w = (Widget_Node*)o; ((Overlay_Window*)(w->o))->redraw(); @@ -914,6 +927,8 @@ int Window_Node::popupy = 0x7FFFFFFF; int Window_Node::handle(int event) { static Node* selection = 0; + Node *i; + Fl_Widget *o1; switch (event) { case FL_DND_ENTER: // printf("DND enter\n"); @@ -922,7 +937,7 @@ int Window_Node::handle(int event) { { // find the innermost item clicked on: selection = this; - for (Node* i=next; i && i->level>level; i=i->next) + for (i =next; i && i->level>level; i=i->next) if (i->is_a(FLD_NODE_TYPE_Group)) { Widget_Node* myo = (Widget_Node*)i; if (Fl::event_inside(myo->o) && myo->o->visible_r()) { @@ -974,7 +989,7 @@ int Window_Node::handle(int event) { // ok, so it is an image - now add it as image() or deimage() to the widget // printf("DND check for target %s\n", fn); Widget_Node *tgt = 0; - for (Node* i=next; i && i->level>level; i=i->next) { + for (i =next; i && i->level>level; i=i->next) { if (i->is_widget()) { Widget_Node* myo = (Widget_Node*)i; if (Fl::event_inside(myo->o) && myo->o->visible_r()) @@ -1044,10 +1059,10 @@ int Window_Node::handle(int event) { } // find the innermost item clicked on: selection = this; - {for (Node* i=next; i && i->level>level; i=i->next) + {for (i =next; i && i->level>level; i=i->next) if (i->is_true_widget()) { Widget_Node* myo = (Widget_Node*)i; - for (Fl_Widget *o1 = myo->o; o1; o1 = o1->parent()) + for (o1 = myo->o; o1; o1 = o1->parent()) if (!o1->visible()) goto CONTINUE2; if (Fl::event_inside(myo->o)) { selection = myo; @@ -1107,10 +1122,10 @@ int Window_Node::handle(int event) { // clear selection on everything: if (!toggle) deselect(); else Fl::event_is_click(0); // select everything in box: - for (Node*i=next; i&&i->level>level; i=i->next) + for (i =next; i&&i->level>level; i=i->next) if (i->is_true_widget()) { Widget_Node* myo = (Widget_Node*)i; - for (Fl_Widget *o1 = myo->o; o1; o1 = o1->parent()) + for (o1 = myo->o; o1; o1 = o1->parent()) if (!o1->visible()) goto CONTINUE; if (Fl::event_inside(myo->o)) selection = myo; if (myo && myo->o && myo->o->x()>=x1 && myo->o->y()>y1 && diff --git a/fluid/nodes/factory.cxx b/fluid/nodes/factory.cxx index 7e6726a41..c901c9945 100644 --- a/fluid/nodes/factory.cxx +++ b/fluid/nodes/factory.cxx @@ -158,7 +158,8 @@ public: // Avoid this when compiling so it works w/o a display: if (!Fluid.batch_mode) { char buffer[20]; - for (int i = 1; i <= 20; i++) { + int i; + for (i = 1; i <= 20; i++) { sprintf(buffer,"Browser Line %d",i); b->add(buffer); } @@ -193,7 +194,8 @@ public: // Avoid this when compiling so it works w/o a display: if (!Fluid.batch_mode) { char buffer[20]; - for (int i = 1; i <= 20; i++) { + int i; + for (i = 1; i <= 20; i++) { sprintf(buffer,"Browser Line %d",i); b->add(buffer); } @@ -1560,7 +1562,8 @@ static void make_iconlabel(Fl_Menu_Item *mi, Fl_Image *ic, const char *txt) Names and icons are taken from the referenced prototypes. */ void fill_in_New_Menu() { - for (unsigned i = 0; i < sizeof(New_Menu)/sizeof(*New_Menu); i++) { + unsigned i; + for (i = 0; i < sizeof(New_Menu)/sizeof(*New_Menu); i++) { Fl_Menu_Item *m = New_Menu+i; if (m->user_data()) { Node *t = (Node*)m->user_data(); @@ -1586,7 +1589,8 @@ Node *typename_to_prototype(const char *inName) { if (inName==0 || *inName==0) return 0; - for (unsigned i = 0; i < sizeof(known_types)/sizeof(*known_types); i++) { + unsigned i; + for (i = 0; i < sizeof(known_types)/sizeof(*known_types); i++) { Node *prototype = known_types[i]; if (fl_ascii_strcasecmp(inName, prototype->type_name())==0) return prototype; @@ -1774,7 +1778,8 @@ static symbol table[] = { int lookup_symbol(const char *name, int &v, int numberok) { if ((name[0]=='F') && (name[1]=='L') && (name[2]=='_')) name += 3; - for (int i=0; i < int(sizeof(table)/sizeof(*table)); i++) { + int i; + for (i =0; i < int(sizeof(table)/sizeof(*table)); i++) { if (!fl_ascii_strcasecmp(name,table[i].name)) { v = table[i].value; return 1; diff --git a/fluid/panels/settings_panel.cxx b/fluid/panels/settings_panel.cxx index 04aa8e900..66df11816 100644 --- a/fluid/panels/settings_panel.cxx +++ b/fluid/panels/settings_panel.cxx @@ -545,13 +545,14 @@ Fl_Menu_Button *w_layout_menu=(Fl_Menu_Button *)0; static void cb_w_layout_menu(Fl_Menu_Button*, void* v) { if (v == LOAD) { fld::app::Layout_Suite &suite = (*Fluid.layout_list)[Fluid.layout_list->current_suite()]; + int i; if (suite.storage_ == FLD_TOOL_STORE_INTERNAL) { w_layout_menu_rename->deactivate(); - for (int i=1; i<4; i++) w_layout_menu_storage[i]->deactivate(); + for (i =1; i<4; i++) w_layout_menu_storage[i]->deactivate(); w_layout_menu_delete->deactivate(); } else { w_layout_menu_rename->activate(); - for (int i=1; i<4; i++) w_layout_menu_storage[i]->activate(); + for (i =1; i<4; i++) w_layout_menu_storage[i]->activate(); w_layout_menu_delete->activate(); } w_layout_menu_storage[(int)(suite.storage_)]->setonly(menu_w_layout_menu); @@ -889,7 +890,8 @@ static void cb_w_settings_shell_list(Fl_Browser* o, void* v) { if (g_shell_config) { o->clear(); w_settings_shell_list_selected = 0; - for (int i=0; i<g_shell_config->list_size; i++) { + int i; + for (i =0; i<g_shell_config->list_size; i++) { Fd_Shell_Command *cmd = g_shell_config->list[i]; o->add(cmd->name); if (cmd->storage == FLD_TOOL_STORE_USER) diff --git a/fluid/panels/widget_panel.cxx b/fluid/panels/widget_panel.cxx index 1f60bc178..33720b5ac 100644 --- a/fluid/panels/widget_panel.cxx +++ b/fluid/panels/widget_panel.cxx @@ -101,7 +101,8 @@ static void cb_image_panel_imagew(fld::widget::Formula_Input* o, void* v) { } } else { int mod = 0; - for (Node *t = Fluid.proj.tree.first; t; t = t->next) { + Node *t; + for (t = Fluid.proj.tree.first; t; t = t->next) { if (t->selected && t->is_widget()) { Widget_Node* wt = ((Widget_Node*)t); wt->scale_image_w_ = o->value(); @@ -133,7 +134,8 @@ static void cb_image_panel_imageh(fld::widget::Formula_Input* o, void* v) { } } else { int mod = 0; - for (Node *t = Fluid.proj.tree.first; t; t = t->next) { + Node *t; + for (t = Fluid.proj.tree.first; t; t = t->next) { if (t->selected && t->is_widget()) { Widget_Node* wt = ((Widget_Node*)t); wt->scale_image_h_ = o->value(); @@ -241,7 +243,8 @@ static void cb_image_panel_deimagew(fld::widget::Formula_Input* o, void* v) { } } else { int mod = 0; - for (Node *t = Fluid.proj.tree.first; t; t = t->next) { + Node *t; + for (t = Fluid.proj.tree.first; t; t = t->next) { if (t->selected && t->is_widget()) { Widget_Node* wt = ((Widget_Node*)t); wt->scale_deimage_w_ = o->value(); @@ -273,7 +276,8 @@ static void cb_image_panel_deimageh(fld::widget::Formula_Input* o, void* v) { } } else { int mod = 0; - for (Node *t = Fluid.proj.tree.first; t; t = t->next) { + Node *t; + for (t = Fluid.proj.tree.first; t; t = t->next) { if (t->selected && t->is_widget()) { Widget_Node* wt = ((Widget_Node*)t); wt->scale_deimage_h_ = o->value(); @@ -555,7 +559,8 @@ void flex_margin_cb(Fl_Value_Input* i, void* v, void (*load_margin)(Fl_Flex*,Fl_ } else { int mod = 0; int new_value = (int)i->value(); - for (Node *o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_a(FLD_NODE_TYPE_Flex)) { Flex_Node* q = (Flex_Node*)o; Fl_Flex* w = (Fl_Flex*)q->o; @@ -1654,7 +1659,8 @@ static void cb_Hotspot(Fl_Light_Button* o, void* v) { Node *p = current_widget->parent; if (!p || !p->is_widget()) return; while (!p->is_a(FLD_NODE_TYPE_Window)) p = p->parent; - for (Node *q = p->next; q && q->level > p->level; q = q->next) { + Node *q; + for (q = p->next; q && q->level > p->level; q = q->next) { if (q->is_widget() && q != current_widget) ((Widget_Node*)q)->hotspot(0); } @@ -1771,7 +1777,8 @@ static void cb_7(Fl_Choice* o, void* v) { if (current_widget->is_a(FLD_NODE_TYPE_Menu_Item)) {o->deactivate(); return;} else o->activate(); int n = current_widget->o->box(); if (!n) n = ZERO_ENTRY; - for (int j = 0; j < 72 /*int(sizeof(boxmenu)/sizeof(*boxmenu))*/; j++) + int j; + for (j = 0; j < 72 /*int(sizeof(boxmenu)/sizeof(*boxmenu))*/; j++) if (boxmenu[j].argument() == n) {o->value(j); break;} } else { int mod = 0; @@ -1846,7 +1853,8 @@ static void cb_9(Fl_Choice* o, void* v) { } o->activate(); if (!n) n = ZERO_ENTRY; - for (int j = 0; j < 72 /*int(sizeof(boxmenu)/sizeof(*boxmenu))*/; j++) + int j; + for (j = 0; j < 72 /*int(sizeof(boxmenu)/sizeof(*boxmenu))*/; j++) if (boxmenu[j].argument() == n) {o->value(j); break;} } else { int mod = 0; @@ -2711,7 +2719,8 @@ static void cb_comment_predefined_2(Fl_Menu_Button* o, void* v) { "My Comment"); if (xname) { char *name = fl_strdup(xname); - for (char*s=name;*s;s++) if (*s==':') *s = ';'; + char *s; + for (s =name;*s;s++) if (*s==':') *s = ';'; int n; Fl_Preferences db(Fl_Preferences::USER_L, "fltk.org", "fluid_comments"); db.set(name, comment_tabs_name->buffer()->text()); diff --git a/fluid/proj/align_widget.cxx b/fluid/proj/align_widget.cxx index 8056de429..0877c35f0 100644 --- a/fluid/proj/align_widget.cxx +++ b/fluid/proj/align_widget.cxx @@ -52,7 +52,8 @@ void align_widget_cb(Fl_Widget*, void *user_data) BREAK_ON_FIRST; } if (left!=max) - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -82,7 +83,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) if (left!=max) { int center2 = left+right; - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -109,7 +110,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) BREAK_ON_FIRST; } if (right!=min) - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -135,7 +136,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) BREAK_ON_FIRST; } if (top!=max) - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -165,7 +166,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) if (top!=max) { int center2 = top+bot; - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -192,7 +193,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) BREAK_ON_FIRST; } if (bot!=min) - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -227,7 +228,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) { wdt = wdt/n*n; // make sure that all gaps are the same, possibly moving the rightmost widget int cnt = 0, wsum = 0; - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -264,7 +265,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) { hgt = hgt/n*n; // make sure that all gaps are the same, possibly moving the rightmost widget int cnt = 0, hsum = 0; - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -294,7 +295,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) BREAK_ON_FIRST; } if (wdt!=min) - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -320,7 +321,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) BREAK_ON_FIRST; } if (hgt!=min) - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -348,7 +349,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) BREAK_ON_FIRST; } if (hgt!=min) - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { diff --git a/fluid/proj/mergeback.cxx b/fluid/proj/mergeback.cxx index bb7ef5504..2d553aedb 100644 --- a/fluid/proj/mergeback.cxx +++ b/fluid/proj/mergeback.cxx @@ -304,7 +304,8 @@ void Mergeback::analyse_code(unsigned long code_crc, unsigned long tag_crc, int */ uint32_t Mergeback::decode_trichar32(const char *text) { uint32_t word = 0; - for (int i=30; i>=0; i-=3) { + int i; + for (i =30; i>=0; i-=3) { char a = *text++; if (a==0) break; char b = *text++; @@ -335,7 +336,8 @@ uint32_t Mergeback::decode_trichar32(const char *text) { */ void Mergeback::print_trichar32(FILE *out, uint32_t value) { static const char *lut[] = { "--", "-~", "~-", "~~", "-=", "=-", "~=", "=~" }; - for (int i=30; i>=0; i-=3) fputs(lut[(value>>i)&7], out); + int i; + for (i =30; i>=0; i-=3) fputs(lut[(value>>i)&7], out); } /** @@ -365,7 +367,8 @@ bool Mergeback::read_tag(const char *tag, Tag *prev_type, uint16_t *uid, uint32_ if (strncmp(tag, "▼", 3)==0) tag += 3; // E2 96 BC if (*tag==' ') tag += 1; uint32_t w1 = decode_trichar32(tag); // Read the first word - for (int i=0; i<32; i++) if (*tag++ == 0) return false; + int i; + for (i =0; i<32; i++) if (*tag++ == 0) return false; uint32_t w2 = decode_trichar32(tag); // Read the second word // Return the decoded values *prev_type = static_cast<Tag>((w1>>16) & 0xff); diff --git a/fluid/proj/undo.cxx b/fluid/proj/undo.cxx index e4ee89bf6..d3444c91a 100644 --- a/fluid/proj/undo.cxx +++ b/fluid/proj/undo.cxx @@ -47,15 +47,11 @@ extern Fl_Window* the_panel; -using namespace fld; -using namespace fld::proj; - - -Undo::Undo(Project &p) +fld::proj::Undo::Undo(fld::Project &p) : proj_( p ) { } -Undo::~Undo() { +fld::proj::Undo::~Undo() { // TODO: delete old undo files when calling the destructor. } @@ -64,7 +60,7 @@ Undo::~Undo() { // The filename is constructed in a static internal buffer and // this buffer is overwritten by every call of this function. // The return value is a pointer to this internal string. -char *Undo::filename(int level) { +char *fld::proj::Undo::filename(int level) { if (!path_len_) { Fluid.preferences.getUserdataPath(path_, sizeof(path_)); path_len_ = (unsigned int)strlen(path_); @@ -79,7 +75,7 @@ char *Undo::filename(int level) { // Redo menu callback -void Undo::redo() { +void fld::proj::Undo::redo() { // int undo_item = main_menubar->find_index(undo_cb); // int redo_item = main_menubar->find_index(redo_cb); once_type_ = FLD_UNDO_ONCETYPE_ALWAYS; @@ -123,7 +119,7 @@ void Undo::redo() { } // Undo menu callback -void Undo::undo() { +void fld::proj::Undo::undo() { // int undo_item = main_menubar->find_index(undo_cb); // int redo_item = main_menubar->find_index(redo_cb); once_type_ = FLD_UNDO_ONCETYPE_ALWAYS; @@ -155,7 +151,8 @@ void Undo::undo() { return; } if (reload_panel) { - for (Node *t = Fluid.proj.tree.first; t; t=t->next) { + Node *t; + for (t = Fluid.proj.tree.first; t; t=t->next) { if (t->is_widget() && t->selected) { t->open(); break; @@ -183,7 +180,7 @@ void Undo::undo() { \param[in] type set a new type, or set to 0 to clear the once_type without setting a checkpoint \return 1 if the checkpoint was set, 0 if this is a repeating event */ -int Undo::checkpoint(OnceType type) { +int fld::proj::Undo::checkpoint(OnceType type) { if (type == FLD_UNDO_ONCETYPE_ALWAYS) { once_type_ = FLD_UNDO_ONCETYPE_ALWAYS; return 0; @@ -200,7 +197,7 @@ int Undo::checkpoint(OnceType type) { } // Save current file to undo buffer -void Undo::checkpoint() { +void fld::proj::Undo::checkpoint() { // printf("checkpoint(): current_=%d, paused_=%d, modflag=%d\n", // current_, paused_, modflag); @@ -234,11 +231,12 @@ void Undo::checkpoint() { } // Clear undo buffer -void Undo::clear() { +void fld::proj::Undo::clear() { // int undo_item = main_menubar->find_index(undo_cb); // int redo_item = main_menubar->find_index(redo_cb); // Remove old checkpoint files... - for (int i = 0; i <= max_; i ++) { + int i; + for (i = 0; i <= max_; i ++) { fl_unlink(filename(i)); } @@ -253,19 +251,19 @@ void Undo::clear() { } // Resume undo checkpoints -void Undo::resume() { +void fld::proj::Undo::resume() { paused_--; } // Suspend undo checkpoints -void Undo::suspend() { +void fld::proj::Undo::suspend() { paused_++; } -void Undo::undo_cb(Fl_Widget *, void *) { +void fld::proj::Undo::undo_cb(Fl_Widget *, void *) { Fluid.proj.undo.undo(); } -void Undo::redo_cb(Fl_Widget *, void *) { +void fld::proj::Undo::redo_cb(Fl_Widget *, void *) { Fluid.proj.undo.redo(); } diff --git a/fluid/tools/ExternalCodeEditor_UNIX.cxx b/fluid/tools/ExternalCodeEditor_UNIX.cxx index 1d1efc462..f848e8158 100644 --- a/fluid/tools/ExternalCodeEditor_UNIX.cxx +++ b/fluid/tools/ExternalCodeEditor_UNIX.cxx @@ -23,8 +23,6 @@ #include <stdlib.h> /* free().. */ #include <stdio.h> /* snprintf().. */ -using namespace fld; - // Static local data static int L_editors_open = 0; // keep track of #editors open static Fl_Timeout_Handler L_update_timer_cb = 0; // app's update timer callback diff --git a/fluid/tools/autodoc.cxx b/fluid/tools/autodoc.cxx index a59e08ab9..aaa61486e 100644 --- a/fluid/tools/autodoc.cxx +++ b/fluid/tools/autodoc.cxx @@ -125,10 +125,12 @@ void blend_alpha_left(const Fl_RGB_Image *img, int dx) { int max_x = dx, max_y = img->h(); int ld = img->ld(); if (ld == 0) ld = img->w() * img->d(); float a = 255.0f/static_cast<float>(max_x); - for (int i = 0; i < max_x; i++) { + int i; + for (i = 0; i < max_x; i++) { uchar *rgba = (uchar*)img->data()[0] + i * img->d(); uchar alpha = static_cast<uchar>(i * a); - for (int j = 0; j < max_y; j++) { + int j; + for (j = 0; j < max_y; j++) { rgba[3] = fl_min(alpha, rgba[3]); rgba += ld; } @@ -150,10 +152,12 @@ void blend_alpha_top(const Fl_RGB_Image *img, int dy) { int max_x = img->w(), max_y = dy; int ld = img->ld(); if (ld == 0) ld = img->w() * img->d(); float a = 255.0f/static_cast<float>(max_y); - for (int i = 0; i < max_y; i++) { + int i; + for (i = 0; i < max_y; i++) { uchar *rgba = (uchar*)img->data()[0] + i * ld; uchar alpha = static_cast<uchar>(i * a); - for (int j = 0; j < max_x; j++) { + int j; + for (j = 0; j < max_x; j++) { rgba[3] = fl_min(alpha, rgba[3]); rgba += 4; } @@ -175,10 +179,12 @@ void blend_alpha_right(const Fl_RGB_Image *img, int dx) { int max_x = dx, max_y = img->h(); int ld = img->ld(); if (ld == 0) ld = img->w() * img->d(); float a = 255.0f/static_cast<float>(max_x); - for (int i = 0; i < max_x; i++) { + int i; + for (i = 0; i < max_x; i++) { uchar *rgba = (uchar*)img->data()[0] + (img->w()-i-1) * img->d(); uchar alpha = static_cast<uchar>(i * a); - for (int j = 0; j < max_y; j++) { + int j; + for (j = 0; j < max_y; j++) { rgba[3] = fl_min(alpha, rgba[3]); rgba += ld; } @@ -200,10 +206,12 @@ void blend_alpha_bottom(const Fl_RGB_Image *img, int dy) { int max_x = img->w(), max_y = dy; int ld = img->ld(); if (ld == 0) ld = img->w() * img->d(); float a = 255.0f/static_cast<float>(max_y); - for (int i = 0; i < max_y; i++) { + int i; + for (i = 0; i < max_y; i++) { uchar *rgba = (uchar*)img->data()[0] + (img->h()-i-1) * ld; uchar alpha = static_cast<uchar>(i * a); - for (int j = 0; j < max_x; j++) { + int j; + for (j = 0; j < max_x; j++) { rgba[3] = fl_min(alpha, rgba[3]); rgba += 4; } diff --git a/fluid/widgets/App_Menu_Bar.cxx b/fluid/widgets/App_Menu_Bar.cxx index 9cb3e2d15..cb0dae33f 100644 --- a/fluid/widgets/App_Menu_Bar.cxx +++ b/fluid/widgets/App_Menu_Bar.cxx @@ -23,8 +23,8 @@ #include "Fluid.h" #include "Project.h" -using namespace fld; -using namespace fld::widget; + + extern void mergeback_cb(Fl_Widget *, void *); @@ -33,7 +33,7 @@ extern void mergeback_cb(Fl_Widget *, void *); \param[in] X, Y, W, H position and size of the widget \param[in] L optional label */ -App_Menu_Bar::App_Menu_Bar(int X, int Y, int W, int H, const char *L) +fld::widget::App_Menu_Bar::App_Menu_Bar(int X, int Y, int W, int H, const char *L) : Fl_Menu_Bar(X, Y, W, H, L) { } @@ -41,7 +41,7 @@ App_Menu_Bar::App_Menu_Bar(int X, int Y, int W, int H, const char *L) /** Set menu item visibility and active state before menu pops up. */ -int App_Menu_Bar::handle(int event) +int fld::widget::App_Menu_Bar::handle(int event) { Fl_Menu_Item *mi = 0; if (event == FL_BEFORE_MENU) { diff --git a/fluid/widgets/Bin_Button.cxx b/fluid/widgets/Bin_Button.cxx index 728bcc8ed..1a14433e2 100644 --- a/fluid/widgets/Bin_Button.cxx +++ b/fluid/widgets/Bin_Button.cxx @@ -24,8 +24,8 @@ #include <FL/Fl_Button.H> #include <FL/Fl_Window.H> -using namespace fld; -using namespace fld::widget; + + /** \class fld::widget::Bin_Button diff --git a/fluid/widgets/Code_Editor.cxx b/fluid/widgets/Code_Editor.cxx index 583d07c5b..1551ed3e2 100644 --- a/fluid/widgets/Code_Editor.cxx +++ b/fluid/widgets/Code_Editor.cxx @@ -24,8 +24,8 @@ #include <ctype.h> #include "widgets/Code_Editor.h" -using namespace fld; -using namespace fld::widget; + + // ---- Code_Editor implementation @@ -33,7 +33,7 @@ using namespace fld::widget; Lookup table for all supported styles. Every table entry describes a rendering style for the corresponding text. */ -Fl_Text_Display::Style_Table_Entry Code_Editor::styletable[] = { // Style table +Fl_Text_Display::Style_Table_Entry fld::widget::Code_Editor::styletable[] = { // Style table { FL_FOREGROUND_COLOR, FL_COURIER, 11 }, // A - Plain { FL_DARK_GREEN, FL_COURIER_ITALIC, 11 }, // B - Line comments { FL_DARK_GREEN, FL_COURIER_ITALIC, 11 }, // C - Block comments @@ -51,7 +51,7 @@ Fl_Text_Display::Style_Table_Entry Code_Editor::styletable[] = { // Style tabl \param[in] in_len byte length to parse \param[in] in_style starting style letter */ -void Code_Editor::style_parse(const char *in_tbuff, // text buffer to parse +void fld::widget::Code_Editor::style_parse(const char *in_tbuff, // text buffer to parse char *in_sbuff, // style buffer we modify int in_len, // byte length to parse char in_style) { // starting style letter @@ -104,7 +104,7 @@ void Code_Editor::style_parse(const char *in_tbuff, // text buffer to pa /** Update unfinished styles. */ -void Code_Editor::style_unfinished_cb(int, void*) { +void fld::widget::Code_Editor::style_unfinished_cb(int, void*) { } /** @@ -114,7 +114,7 @@ void Code_Editor::style_unfinished_cb(int, void*) { \param[in] nDeleted number of bytes deleted \param[in] cbArg pointer back to the code editor */ -void Code_Editor::style_update(int pos, int nInserted, int nDeleted, +void fld::widget::Code_Editor::style_update(int pos, int nInserted, int nDeleted, int /*nRestyled*/, const char * /*deletedText*/, void *cbArg) { Code_Editor *editor = (Code_Editor*)cbArg; @@ -165,7 +165,7 @@ void Code_Editor::style_update(int pos, int nInserted, int nDeleted, Find the right indentation depth after pressing the Enter key. \param[in] e pointer back to the code editor */ -int Code_Editor::auto_indent(int, Code_Editor* e) { +int fld::widget::Code_Editor::auto_indent(int, Code_Editor* e) { if (e->buffer()->selected()) { e->insert_position(e->buffer()->primary_selection()->start()); e->buffer()->remove_selection(); @@ -203,7 +203,7 @@ int Code_Editor::auto_indent(int, Code_Editor* e) { \param[in] X, Y, W, H position and size of the widget \param[in] L optional label */ -Code_Editor::Code_Editor(int X, int Y, int W, int H, const char *L) : +fld::widget::Code_Editor::Code_Editor(int X, int Y, int W, int H, const char *L) : Fl_Text_Editor(X, Y, W, H, L) { buffer(new Fl_Text_Buffer); @@ -231,7 +231,7 @@ Code_Editor::Code_Editor(int X, int Y, int W, int H, const char *L) : /** Destroy a Code_Editor widget. */ -Code_Editor::~Code_Editor() { +fld::widget::Code_Editor::~Code_Editor() { Fl_Text_Buffer *buf = mStyleBuffer; mStyleBuffer = 0; delete buf; @@ -246,11 +246,12 @@ Code_Editor::~Code_Editor() { This works by updating the fontsizes in the style table. \param[in] s the new general height of the text font */ -void Code_Editor::textsize(Fl_Fontsize s) { +void fld::widget::Code_Editor::textsize(Fl_Fontsize s) { Fl_Text_Editor::textsize(s); // call base class method // now attempt to update our styletable to honor the new size... int entries = sizeof(styletable) / sizeof(styletable[0]); - for(int iter = 0; iter < entries; iter++) { + int iter; + for (iter = 0; iter < entries; iter++) { styletable[iter].size = s; } } // textsize diff --git a/fluid/widgets/Code_Viewer.cxx b/fluid/widgets/Code_Viewer.cxx index fdbfdc626..978ed178e 100644 --- a/fluid/widgets/Code_Viewer.cxx +++ b/fluid/widgets/Code_Viewer.cxx @@ -22,15 +22,15 @@ #include "widgets/Code_Viewer.h" -using namespace fld; -using namespace fld::widget; + + /** Create a fld::widget::Code_Viewer widget. \param[in] X, Y, W, H position and size of the widget \param[in] L optional label */ -Code_Viewer::Code_Viewer(int X, int Y, int W, int H, const char *L) +fld::widget::Code_Viewer::Code_Viewer(int X, int Y, int W, int H, const char *L) : Code_Editor(X, Y, W, H, L) { default_key_function(kf_ignore); @@ -41,7 +41,7 @@ Code_Viewer::Code_Viewer(int X, int Y, int W, int H, const char *L) /** Tricking Fl_Text_Display into using bearable colors for this specific task. */ -void Code_Viewer::draw() +void fld::widget::Code_Viewer::draw() { Fl_Color c = Fl::get_color(FL_SELECTION_COLOR); Fl::set_color(FL_SELECTION_COLOR, fl_color_average(FL_BACKGROUND_COLOR, FL_FOREGROUND_COLOR, 0.9f)); diff --git a/fluid/widgets/Formula_Input.cxx b/fluid/widgets/Formula_Input.cxx index 16bc2310a..06f5e3672 100644 --- a/fluid/widgets/Formula_Input.cxx +++ b/fluid/widgets/Formula_Input.cxx @@ -23,8 +23,8 @@ #include <ctype.h> #include <string.h> -using namespace fld; -using namespace fld::widget; + + /** \class fld::widget::Formula_Input The Formula_Input widget is an input field for entering widget coordinates @@ -36,18 +36,18 @@ using namespace fld::widget; /** Create an input field. */ -Formula_Input::Formula_Input(int x, int y, int w, int h, const char *l) +fld::widget::Formula_Input::Formula_Input(int x, int y, int w, int h, const char *l) : Fl_Input(x, y, w, h, l) { Fl_Input::callback((Fl_Callback*)callback_handler_cb); text("0"); } -void Formula_Input::callback_handler_cb(Formula_Input *This, void *v) { +void fld::widget::Formula_Input::callback_handler_cb(Formula_Input *This, void *v) { This->callback_handler(v); } -void Formula_Input::callback_handler(void *v) { +void fld::widget::Formula_Input::callback_handler(void *v) { if (user_callback_) (*user_callback_)(this, v); // do *not* update the value to show the evaluated formula here, because the @@ -63,7 +63,7 @@ void Formula_Input::callback_handler(void *v) { the last character of the variable name when returning. \return the integer value that was found or calculated */ -int Formula_Input::eval_var(uchar *&s) const { +int fld::widget::Formula_Input::eval_var(uchar *&s) const { if (!vars_) return 0; // find the end of the variable name @@ -71,7 +71,8 @@ int Formula_Input::eval_var(uchar *&s) const { while (isalpha(*s)) s++; int n = (int)(s-v); // find the variable in the list - for (Formula_Input_Vars *vars = vars_; vars->name_; vars++) { + Formula_Input_Vars *vars; + for (vars = vars_; vars->name_; vars++) { if (strncmp((char*)v, vars->name_, n)==0 && vars->name_[n]==0) return vars->callback_(this, vars_user_data_); } @@ -85,7 +86,7 @@ int Formula_Input::eval_var(uchar *&s) const { \param prio priority of current operation \return the value so far */ -int Formula_Input::eval(uchar *&s, int prio) const { +int fld::widget::Formula_Input::eval(uchar *&s, int prio) const { int v = 0, sgn = 1; uchar c = *s++; @@ -157,7 +158,7 @@ int Formula_Input::eval(uchar *&s, int prio) const { \param s formula as a C string \return the calculated value */ -int Formula_Input::eval(const char *s) const +int fld::widget::Formula_Input::eval(const char *s) const { // duplicate the text, so we can modify it uchar *buf = (uchar*)fl_strdup(s); @@ -179,14 +180,14 @@ int Formula_Input::eval(const char *s) const /** Evaluate the formula and return the result. */ -int Formula_Input::value() const { +int fld::widget::Formula_Input::value() const { return eval(text()); } /** Set the field to an integer value, replacing previous texts. */ -void Formula_Input::value(int v) { +void fld::widget::Formula_Input::value(int v) { char buf[32]; fl_snprintf(buf, sizeof(buf), "%d", v); text(buf); @@ -195,7 +196,7 @@ void Formula_Input::value(int v) { /** Allow vertical mouse dragging and mouse wheel to interactively change the value. */ -int Formula_Input::handle(int event) { +int fld::widget::Formula_Input::handle(int event) { switch (event) { case FL_MOUSEWHEEL: if (Fl::event_dy()) { @@ -211,7 +212,7 @@ int Formula_Input::handle(int event) { /** Set the list of the available variables \param vars array of variables, last entry `has name_` set to `0` \param user_data is forwarded to the Variable callback */ -void Formula_Input::variables(Formula_Input_Vars *vars, void *user_data) { +void fld::widget::Formula_Input::variables(Formula_Input_Vars *vars, void *user_data) { vars_ = vars; vars_user_data_ = user_data; } diff --git a/fluid/widgets/Node_Browser.cxx b/fluid/widgets/Node_Browser.cxx index 3343d6772..7482298b5 100644 --- a/fluid/widgets/Node_Browser.cxx +++ b/fluid/widgets/Node_Browser.cxx @@ -30,8 +30,8 @@ /// Global access to the widget browser. fld::widget::Node_Browser *widget_browser = 0; -using namespace fld; -using namespace fld::widget; + + /** @@ -49,18 +49,18 @@ using namespace fld::widget; // ---- static variables -Fl_Color Node_Browser::label_color = 72; -Fl_Font Node_Browser::label_font = FL_HELVETICA; -Fl_Color Node_Browser::class_color = FL_FOREGROUND_COLOR; -Fl_Font Node_Browser::class_font = FL_HELVETICA_BOLD; -Fl_Color Node_Browser::func_color = FL_FOREGROUND_COLOR; -Fl_Font Node_Browser::func_font = FL_HELVETICA; -Fl_Color Node_Browser::name_color = FL_FOREGROUND_COLOR; -Fl_Font Node_Browser::name_font = FL_HELVETICA; -Fl_Color Node_Browser::code_color = FL_FOREGROUND_COLOR; -Fl_Font Node_Browser::code_font = FL_HELVETICA; -Fl_Color Node_Browser::comment_color = FL_DARK_GREEN; -Fl_Font Node_Browser::comment_font = FL_HELVETICA; +Fl_Color fld::widget::Node_Browser::label_color = 72; +Fl_Font fld::widget::Node_Browser::label_font = FL_HELVETICA; +Fl_Color fld::widget::Node_Browser::class_color = FL_FOREGROUND_COLOR; +Fl_Font fld::widget::Node_Browser::class_font = FL_HELVETICA_BOLD; +Fl_Color fld::widget::Node_Browser::func_color = FL_FOREGROUND_COLOR; +Fl_Font fld::widget::Node_Browser::func_font = FL_HELVETICA; +Fl_Color fld::widget::Node_Browser::name_color = FL_FOREGROUND_COLOR; +Fl_Font fld::widget::Node_Browser::name_font = FL_HELVETICA; +Fl_Color fld::widget::Node_Browser::code_color = FL_FOREGROUND_COLOR; +Fl_Font fld::widget::Node_Browser::code_font = FL_HELVETICA; +Fl_Color fld::widget::Node_Browser::comment_color = FL_DARK_GREEN; +Fl_Font fld::widget::Node_Browser::comment_font = FL_HELVETICA; // ---- global functions @@ -75,7 +75,7 @@ void redraw_browser() { Shortcut to create the widget browser. */ Fl_Widget *make_widget_browser(int x,int y,int w,int h) { - return (widget_browser = new Node_Browser(x,y,w,h)); + return (widget_browser = new fld::widget::Node_Browser(x,y,w,h)); } /** @@ -213,7 +213,7 @@ static char *copy_trunc(char *p, const char *str, int maxl, int quote, int trunc \todo It would be nice to be able to grab one or more nodes and move them within the hierarchy. */ -Node_Browser::Node_Browser(int X,int Y,int W,int H,const char*l) : +fld::widget::Node_Browser::Node_Browser(int X,int Y,int W,int H,const char*l) : Fl_Browser_(X,Y,W,H,l) { type(FL_MULTI_BROWSER); @@ -225,7 +225,7 @@ Node_Browser::Node_Browser(int X,int Y,int W,int H,const char*l) : Override the method to find the first item in the list of elements. \return the first item */ -void *Node_Browser::item_first() const { +void *fld::widget::Node_Browser::item_first() const { return Fluid.proj.tree.first; } @@ -234,7 +234,7 @@ void *Node_Browser::item_first() const { \param l this item \return the next item, irregardless of tree depth, or 0 at the end */ -void *Node_Browser::item_next(void *l) const { +void *fld::widget::Node_Browser::item_next(void *l) const { return ((Node*)l)->next; } @@ -243,7 +243,7 @@ void *Node_Browser::item_next(void *l) const { \param l this item \return the previous item, irregardless of tree depth, or 0 at the start */ -void *Node_Browser::item_prev(void *l) const { +void *fld::widget::Node_Browser::item_prev(void *l) const { return ((Node*)l)->prev; } @@ -253,7 +253,7 @@ void *Node_Browser::item_prev(void *l) const { \return 1 if selected, 0 if not \todo what is the difference between selected and new_selected, and why do we do this? */ -int Node_Browser::item_selected(void *l) const { +int fld::widget::Node_Browser::item_selected(void *l) const { return ((Node*)l)->new_selected; } @@ -262,7 +262,7 @@ int Node_Browser::item_selected(void *l) const { \param l this item \param[in] v 1 if selecting, 0 if not */ -void Node_Browser::item_select(void *l,int v) { +void fld::widget::Node_Browser::item_select(void *l,int v) { ((Node*)l)->new_selected = v; } @@ -271,7 +271,7 @@ void Node_Browser::item_select(void *l,int v) { \param l this item \return height in FLTK units (used to be pixels before high res screens) */ -int Node_Browser::item_height(void *l) const { +int fld::widget::Node_Browser::item_height(void *l) const { Node *t = (Node*)l; if (t->visible) { if (Fluid.show_comments && t->comment()) @@ -286,7 +286,7 @@ int Node_Browser::item_height(void *l) const { Override the method to return the estimated height of all items. \return height in FLTK units */ -int Node_Browser::incr_height() const { +int fld::widget::Node_Browser::incr_height() const { return textsize() + 5 + linespacing(); } @@ -311,7 +311,7 @@ int Node_Browser::incr_height() const { \param X,Y these give the position in window coordinates of the top left corner of this line */ -void Node_Browser::item_draw(void *v, int X, int Y, int, int) const { +void fld::widget::Node_Browser::item_draw(void *v, int X, int Y, int, int) const { // cast to a more general type Node *l = (Node *)v; @@ -455,7 +455,7 @@ void Node_Browser::item_draw(void *v, int X, int Y, int, int) const { \param v this item \return width in FLTK units */ -int Node_Browser::item_width(void *v) const { +int fld::widget::Node_Browser::item_width(void *v) const { char buf[500]; // edit buffer: large enough to hold 80 UTF-8 chars + nul @@ -490,7 +490,7 @@ int Node_Browser::item_width(void *v) const { /** Callback to tell the Fluid UI when the list of selected items changed. */ -void Node_Browser::callback() { +void fld::widget::Node_Browser::callback() { selection_changed((Node*)selection()); } @@ -508,7 +508,7 @@ void Node_Browser::callback() { \param[in] e the incoming event type \return 0 if the event is not supported, and 1 if the event was "used up" */ -int Node_Browser::handle(int e) { +int fld::widget::Node_Browser::handle(int e) { static Node *title; Node *l; int X,Y,W,H; bbox(X,Y,W,H); @@ -549,13 +549,14 @@ int Node_Browser::handle(int e) { l = pushedtitle; title = pushedtitle = 0; if (l) { + Node *k; if (!l->folded_) { l->folded_ = 1; - for (Node*k = l->next; k&&k->level>l->level; k = k->next) + for (k = l->next; k&&k->level>l->level; k = k->next) k->visible = 0; } else { l->folded_ = 0; - for (Node*k=l->next; k&&k->level>l->level;) { + for (k =l->next; k&&k->level>l->level;) { k->visible = 1; if (k->can_have_children() && k->folded_) { Node *j; @@ -575,7 +576,7 @@ int Node_Browser::handle(int e) { /** Save the current scrollbar position during rebuild. */ -void Node_Browser::save_scroll_position() { +void fld::widget::Node_Browser::save_scroll_position() { saved_h_scroll_ = hposition(); saved_v_scroll_ = vposition(); } @@ -583,7 +584,7 @@ void Node_Browser::save_scroll_position() { /** Restore the previous scrollbar position after rebuild. */ -void Node_Browser::restore_scroll_position() { +void fld::widget::Node_Browser::restore_scroll_position() { hposition(saved_h_scroll_); vposition(saved_v_scroll_); } @@ -593,7 +594,7 @@ void Node_Browser::restore_scroll_position() { This clears internal caches, recalculates the scroll bar sizes, and sends a redraw() request to the widget. */ -void Node_Browser::rebuild() { +void fld::widget::Node_Browser::rebuild() { save_scroll_position(); new_list(); damage(FL_DAMAGE_SCROLL); @@ -605,7 +606,7 @@ void Node_Browser::rebuild() { Rebuild the browser layout and make sure that the given item is visible. \param[in] inNode pointer to a widget node derived from Node. */ -void Node_Browser::display(Node *inNode) { +void fld::widget::Node_Browser::display(Node *inNode) { if (!inNode) { // Alternative: find the first (last?) visible selected item. return; @@ -639,7 +640,7 @@ void Node_Browser::display(Node *inNode) { vposition(newV); } -void Node_Browser::load_prefs() { +void fld::widget::Node_Browser::load_prefs() { int c; Fl_Preferences p(Fluid.preferences, "widget_browser"); p.get("label_color", c, 72); label_color = c; @@ -656,7 +657,7 @@ void Node_Browser::load_prefs() { p.get("comment_font", c, FL_HELVETICA); comment_font = c; } -void Node_Browser::save_prefs() { +void fld::widget::Node_Browser::save_prefs() { Fl_Preferences p(Fluid.preferences, "widget_browser"); p.set("label_color", (int)label_color); p.set("label_font", (int)label_font); diff --git a/fluid/widgets/Style_Parser.cxx b/fluid/widgets/Style_Parser.cxx index 9929cc01a..9188e565e 100644 --- a/fluid/widgets/Style_Parser.cxx +++ b/fluid/widgets/Style_Parser.cxx @@ -22,9 +22,6 @@ #include <ctype.h> #include <stdlib.h> // bsearch() -using namespace fld; -using namespace fld::widget; - // Sorted list of C/C++ keywords... static const char * const code_keywords[] = { "and", @@ -133,7 +130,7 @@ static void* search_types(char *find) { // Applies the current style, advances to next text + style char. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_over_char(int handle_crlf) { +int fld::widget::Style_Parser::parse_over_char(int handle_crlf) { char c = *tbuff; // End of line? @@ -160,7 +157,7 @@ int Style_Parser::parse_over_char(int handle_crlf) { // Parse over white space using current style // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_over_white() { +int fld::widget::Style_Parser::parse_over_white() { while ( len > 0 && strchr(" \t", *tbuff)) { if ( !parse_over_char() ) return 0; } return 1; @@ -169,7 +166,7 @@ int Style_Parser::parse_over_white() { // Parse over non-white alphabetic text // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_over_alpha() { +int fld::widget::Style_Parser::parse_over_alpha() { while ( len > 0 && isalpha(*tbuff) ) { if ( !parse_over_char() ) return 0; } return 1; @@ -178,7 +175,7 @@ int Style_Parser::parse_over_alpha() { // Parse to end of line in specified style. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_to_eol(char s) { +int fld::widget::Style_Parser::parse_to_eol(char s) { char save = style; style = s; while ( *tbuff != '\n' ) @@ -190,7 +187,7 @@ int Style_Parser::parse_to_eol(char s) { // Parse a block comment until end of comment or buffer. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_block_comment() { +int fld::widget::Style_Parser::parse_block_comment() { char save = style; style = 'C'; // block comment style while ( len > 0 ) { @@ -206,10 +203,11 @@ int Style_Parser::parse_block_comment() { } // Copy keyword from tbuff -> keyword[] buffer -void Style_Parser::buffer_keyword() { +void fld::widget::Style_Parser::buffer_keyword() { char *key = keyword; char *kend = key + sizeof(keyword) - 1; // end of buffer - for ( const char *s=tbuff; + const char *s; + for (s =tbuff; (islower(*s) || *s=='_') && (key < kend); *key++ = *s++ ) { } *key = 0; // terminate @@ -218,7 +216,7 @@ void Style_Parser::buffer_keyword() { // Parse over specified 'key'word in specified style 's'. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_over_key(const char *key, char s) { +int fld::widget::Style_Parser::parse_over_key(const char *key, char s) { char save = style; style = s; // Parse over the keyword while applying style to sbuff @@ -232,7 +230,7 @@ int Style_Parser::parse_over_key(const char *key, char s) { // Parse over angle brackets <..> in specified style. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_over_angles(char s) { +int fld::widget::Style_Parser::parse_over_angles(char s) { if ( *tbuff != '<' ) return 1; // not <..>, early exit char save = style; style = s; @@ -248,7 +246,7 @@ int Style_Parser::parse_over_angles(char s) { // spi.keyword[] will contain parsed word. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_keyword() { +int fld::widget::Style_Parser::parse_keyword() { // Parse into 'keyword' buffer buffer_keyword(); char *key = keyword; @@ -265,7 +263,7 @@ int Style_Parser::parse_keyword() { // Style parse a quoted string, either "" or ''. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_quoted_string(char quote_char, // e.g. '"' or '\'' +int fld::widget::Style_Parser::parse_quoted_string(char quote_char, // e.g. '"' or '\'' char in_style) { // style for quoted text style = in_style; // start string style if ( !parse_over_char() ) return 0; // parse over opening quote @@ -292,7 +290,7 @@ int Style_Parser::parse_quoted_string(char quote_char, // e.g. '"' or '\'' // Style parse a directive (#include, #define..) // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_directive() { +int fld::widget::Style_Parser::parse_directive() { style = 'E'; // start directive style if ( !parse_over_char() ) return 0; // Parse over '#' if ( !parse_over_white() ) return 0; // Parse over any whitespace after '#' @@ -306,7 +304,7 @@ int Style_Parser::parse_directive() { // Style parse a line comment to end of line. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_line_comment() { +int fld::widget::Style_Parser::parse_line_comment() { return parse_to_eol('B'); } @@ -315,7 +313,7 @@ int Style_Parser::parse_line_comment() { // a continuation of a line, such as in a multiline #directive. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_escape() { +int fld::widget::Style_Parser::parse_escape() { const char no_crlf = 0; if ( !parse_over_char(no_crlf) ) return 0; // backslash if ( !parse_over_char(no_crlf) ) return 0; // char escaped @@ -325,7 +323,7 @@ int Style_Parser::parse_escape() { // Parse all other non-specific characters // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_all_else() { +int fld::widget::Style_Parser::parse_all_else() { last = isalnum(*tbuff) || *tbuff == '_' || *tbuff == '.'; return parse_over_char(); } diff --git a/fluid/widgets/Text_Viewer.cxx b/fluid/widgets/Text_Viewer.cxx index 310fa6919..3cd89d4d8 100644 --- a/fluid/widgets/Text_Viewer.cxx +++ b/fluid/widgets/Text_Viewer.cxx @@ -20,15 +20,15 @@ #include "widgets/Text_Viewer.h" -using namespace fld; -using namespace fld::widget; + + /** Create a fld::widget::Text_Viewer widget. \param[in] X, Y, W, H position and size of the widget \param[in] L optional label */ -Text_Viewer::Text_Viewer(int X, int Y, int W, int H, const char *L) +fld::widget::Text_Viewer::Text_Viewer(int X, int Y, int W, int H, const char *L) : Fl_Text_Display(X, Y, W, H, L) { buffer(new Fl_Text_Buffer); @@ -37,7 +37,7 @@ Text_Viewer::Text_Viewer(int X, int Y, int W, int H, const char *L) /** Avoid memory leaks. */ -Text_Viewer::~Text_Viewer() { +fld::widget::Text_Viewer::~Text_Viewer() { Fl_Text_Buffer *buf = mBuffer; buffer(0); delete buf; @@ -46,7 +46,7 @@ Text_Viewer::~Text_Viewer() { /** Tricking Fl_Text_Display into using bearable colors for this specific task. */ -void Text_Viewer::draw() +void fld::widget::Text_Viewer::draw() { Fl_Color c = Fl::get_color(FL_SELECTION_COLOR); Fl::set_color(FL_SELECTION_COLOR, fl_color_average(FL_BACKGROUND_COLOR, FL_FOREGROUND_COLOR, 0.9f)); diff --git a/lib/libfltk.a b/lib/libfltk.a Binary files differindex 7de0a4490..9c6174ab2 100644 --- a/lib/libfltk.a +++ b/lib/libfltk.a diff --git a/lib/libfltk_forms.a b/lib/libfltk_forms.a Binary files differindex 8439bdee4..d7cfbf6f2 100644 --- a/lib/libfltk_forms.a +++ b/lib/libfltk_forms.a diff --git a/lib/libfltk_gl.a b/lib/libfltk_gl.a Binary files differindex d336f6c8c..3c508cb29 100644 --- a/lib/libfltk_gl.a +++ b/lib/libfltk_gl.a diff --git a/lib/libfltk_images.a b/lib/libfltk_images.a Binary files differindex 1e762d6da..cca36a01d 100644 --- a/lib/libfltk_images.a +++ b/lib/libfltk_images.a diff --git a/lib/libfltk_jpeg.a b/lib/libfltk_jpeg.a Binary files differindex 22fc5ecfe..93154edd0 100644 --- a/lib/libfltk_jpeg.a +++ b/lib/libfltk_jpeg.a diff --git a/lib/libfltk_png.a b/lib/libfltk_png.a Binary files differindex ac75ae338..be74ef7da 100644 --- a/lib/libfltk_png.a +++ b/lib/libfltk_png.a diff --git a/lib/libfltk_z.a b/lib/libfltk_z.a Binary files differindex 62bb9749a..1c06eabbd 100644 --- a/lib/libfltk_z.a +++ b/lib/libfltk_z.a diff --git a/src/Fl.cxx b/src/Fl.cxx index 45509a0f6..2a110d935 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -510,7 +510,8 @@ void Fl::add_check(Fl_Timeout_Handler cb, void *argp) { callback that no longer exists. */ void Fl::remove_check(Fl_Timeout_Handler cb, void *argp) { - for (Check** p = &first_check; *p;) { + Check **p; + for (p = &first_check; *p;) { Check* t = *p; if (t->cb == cb && t->arg == argp) { if (next_check == t) next_check = t->next; @@ -527,7 +528,8 @@ void Fl::remove_check(Fl_Timeout_Handler cb, void *argp) { Returns 1 if the check exists and has not been called yet, 0 otherwise. */ int Fl::has_check(Fl_Timeout_Handler cb, void *argp) { - for (Check** p = &first_check; *p;) { + Check **p; + for (p = &first_check; *p;) { Check* t = *p; if (t->cb == cb && t->arg == argp) { return 1; @@ -869,7 +871,8 @@ void Fl::first_window(Fl_Window* window) { Redraws all widgets. */ void Fl::redraw() { - for (Fl_X* i = Fl_X::first; i; i = i->next) i->w->redraw(); + Fl_X *i; + for (i = Fl_X::first; i; i = i->next) i->w->redraw(); } /** @@ -886,7 +889,8 @@ void Fl::redraw() { void Fl::flush() { if (damage()) { damage_ = 0; - for (Fl_X* i = Fl_X::first; i; i = i->next) { + Fl_X *i; + for (i = Fl_X::first; i; i = i->next) { Fl_Window* wi = i->w; if (Fl_Window_Driver::driver(wi)->wait_for_expose_value) {damage_ = 1; continue;} if (!wi->visible_r()) continue; @@ -1006,7 +1010,8 @@ void Fl::remove_handler(Fl_Event_Handler ha) { int (*fl_local_grab)(int); // used by fl_dnd.cxx static int send_handlers(int e) { - for (const handler_link *hl = handlers; hl; hl = hl->next) + const handler_link *hl; + for (hl = handlers; hl; hl = hl->next) if (hl->handle(e)) return 1; return 0; } @@ -1082,7 +1087,8 @@ void Fl::remove_system_handler(Fl_System_Handler ha) { } int fl_send_system_handlers(void *e) { - for (const system_handler_link *hl = sys_handlers; hl; hl = hl->next) { + const system_handler_link *hl; + for (hl = sys_handlers; hl; hl = hl->next) { if (hl->handle(e, hl->data)) return 1; } @@ -1337,7 +1343,8 @@ static int send_event(int event, Fl_Widget* to, Fl_Window* window) { } else { dx = dy = 0; } - for (const Fl_Widget* w = to; w; w = w->parent()) { + const Fl_Widget *w; + for (w = to; w; w = w->parent()) { if (w->type() >= FL_WINDOW) { dx -= w->x(); dy -= w->y(); @@ -1903,7 +1910,8 @@ void Fl::delete_widget(Fl_Widget *wi) { if (win && win->shown()) win->hide(); // case of iconified window // don't add the same widget twice to the widget delete list - for (int i = 0; i < num_dwidgets; i++) { + int i; + for (i = 0; i < num_dwidgets; i++) { if (dwidgets[i]==wi) return; } @@ -1939,7 +1947,8 @@ void Fl::delete_widget(Fl_Widget *wi) { void Fl::do_widget_deletion() { if (!num_dwidgets) return; - for (int i = 0; i < num_dwidgets; i ++) + int i; + for (i = 0; i < num_dwidgets; i ++) delete dwidgets[i]; num_dwidgets = 0; @@ -2509,7 +2518,8 @@ void Fl::screen_scale(int n, float factor) { Fl_Screen_Driver::APP_SCALING_CAPABILITY capability = Fl::screen_driver()->rescalable(); if (!capability || n < 0 || n >= Fl::screen_count()) return; if (capability == Fl_Screen_Driver::SYSTEMWIDE_APP_SCALING) { - for (int s = 0; s < Fl::screen_count(); s++) { + int s; + for (s = 0; s < Fl::screen_count(); s++) { Fl::screen_driver()->rescale_all_windows_from_screen(s, factor, factor); } } else diff --git a/src/Fl_Anim_GIF_Image.cxx b/src/Fl_Anim_GIF_Image.cxx index f026d4961..048c8c580 100644 --- a/src/Fl_Anim_GIF_Image.cxx +++ b/src/Fl_Anim_GIF_Image.cxx @@ -193,7 +193,8 @@ double Fl_Anim_GIF_Image::FrameInfo::convert_delay(int d) const { void Fl_Anim_GIF_Image::FrameInfo::copy(const FrameInfo& fi) { // copy from source - for (int i = 0; i < fi.frames_size; i++) { + int i; + for (i = 0; i < fi.frames_size; i++) { if (!push_back_frame(fi.frames[i])) { break; } @@ -245,7 +246,8 @@ void Fl_Anim_GIF_Image::FrameInfo::dispose(int frame) { else { if ( px + pw > canvas_w ) pw = canvas_w - px; if ( py + ph > canvas_h ) ph = canvas_h - py; - for (int y = 0; y < ph; y++) { + int y; + for (y = 0; y < ph; y++) { memcpy(dst + ( y + py ) * canvas_w * 4 + px, src + y * frames[prev].w * 4, pw * 4); } } @@ -346,8 +348,9 @@ void Fl_Anim_GIF_Image::FrameInfo::on_frame_data(Fl_GIF_Image::GIF_FRAME &gf) { // copy image data to offscreen const uchar *bits = gf.bptr; const uchar *endp = offscreen + canvas_w * canvas_h * 4; - for (int y = frame.y; y < frame.y + frame.h; y++) { - for (int x = frame.x; x < frame.x + frame.w; x++) { + int y, x; + for (y = frame.y; y < frame.y + frame.h; y++) { + for (x = frame.x; x < frame.x + frame.w; x++) { uchar c = *bits++; if (c == gf.trans) continue; @@ -366,8 +369,8 @@ void Fl_Anim_GIF_Image::FrameInfo::on_frame_data(Fl_GIF_Image::GIF_FRAME &gf) { if (optimize_mem) { uchar *buf = new uchar[frame.w * frame.h * 4]; uchar *dest = buf; - for (int y = frame.y; y < frame.y + frame.h; y++) { - for (int x = frame.x; x < frame.x + frame.w; x++) { + for (y = frame.y; y < frame.y + frame.h; y++) { + for (x = frame.x; x < frame.x + frame.w; x++) { if (offscreen + y * canvas_w * 4 + x * 4 < endp) memcpy(dest, &offscreen[y * canvas_w * 4 + x * 4], 4); dest += 4; @@ -403,7 +406,8 @@ bool Fl_Anim_GIF_Image::FrameInfo::push_back_frame(const GifFrame &frame) { void Fl_Anim_GIF_Image::FrameInfo::resize(int W, int H) { double scale_factor_x = (double)W / (double)canvas_w; double scale_factor_y = (double)H / (double)canvas_h; - for (int i=0; i < frames_size; i++) { + int i; + for (i =0; i < frames_size; i++) { if (optimize_mem) { frames[i].x = (unsigned short)round(frames[i].x * scale_factor_x); frames[i].y = (unsigned short)round(frames[i].y * scale_factor_y); @@ -449,7 +453,8 @@ void Fl_Anim_GIF_Image::FrameInfo::set_to_background(int frame) { bg = tp; color.alpha = tp == bg ? T_FULL : tp < 0 ? T_FULL : T_NONE; DEBUG((" set to color %d/%d/%d alpha=%d\n", color.r, color.g, color.b, color.alpha)); - for (uchar *p = offscreen + canvas_w * canvas_h * 4 - 4; p >= offscreen; p -= 4) + uchar *p; + for (p = offscreen + canvas_w * canvas_h * 4 - 4; p >= offscreen; p -= 4) memcpy(p, &color, 4); } @@ -712,7 +717,8 @@ void Fl_Anim_GIF_Image::color_average(Fl_Color c, float i) /* */ { if (i < 0) { // immediate mode i = -i; - for (int f=0; f < frames(); f++) { + int f; + for (f =0; f < frames(); f++) { fi_->frames[f].rgb->color_average(c, i); } return; @@ -817,7 +823,8 @@ void Fl_Anim_GIF_Image::draw(int x, int y, int w, int h, while (f0 > 0 && !(fi_->frames[f0].x == 0 && fi_->frames[f0].y == 0 && fi_->frames[f0].w == this->w() && fi_->frames[f0].h == this->h())) --f0; - for (int f = f0; f <= frame_; f++) { + int f; + for (f = f0; f <= frame_; f++) { if (f < frame_ && fi_->frames[f].dispose == FrameInfo::DISPOSE_PREVIOUS) continue; if (f < frame_ && fi_->frames[f].dispose == FrameInfo::DISPOSE_BACKGROUND) continue; Fl_RGB_Image *rgb = fi_->frames[f].rgb; @@ -1057,7 +1064,8 @@ bool Fl_Anim_GIF_Image::load(const char *name, const unsigned char *imgdata /* = // we have to replicate the actions of the pixmap destructor here uncache(); if (alloc_data) { - for (int i = 0; i < count(); i ++) delete[] (char *)data()[i]; + int i; + for (i = 0; i < count(); i ++) delete[] (char *)data()[i]; delete[] (char **)data(); } alloc_data = 0; @@ -1278,7 +1286,8 @@ bool Fl_Anim_GIF_Image::next() { */ void Fl_Anim_GIF_Image::uncache() /* */ { Fl_GIF_Image::uncache(); - for (int i=0; i < fi_->frames_size; i++) { + int i; + for (i =0; i < fi_->frames_size; i++) { if (fi_->frames[i].rgb) fi_->frames[i].rgb->uncache(); } } diff --git a/src/Fl_BMP_Image.cxx b/src/Fl_BMP_Image.cxx index a0d3e00cc..b9c30fdae 100644 --- a/src/Fl_BMP_Image.cxx +++ b/src/Fl_BMP_Image.cxx @@ -254,7 +254,8 @@ void Fl_BMP_Image::load_bmp_(Fl_Image_Reader &rdr, int ico_height, int ico_width if (colors_used == 0 && depth <= 8) colors_used = 1 << depth; - for (int i = 0; i < colors_used; i++) { + int i; + for (i = 0; i < colors_used; i++) { // Read BGR color... colormap[i][0] = rdr.read_byte(); colormap[i][1] = rdr.read_byte(); diff --git a/src/Fl_Browser.cxx b/src/Fl_Browser.cxx index 9228529e2..b51397c08 100644 --- a/src/Fl_Browser.cxx +++ b/src/Fl_Browser.cxx @@ -58,7 +58,8 @@ struct FL_BLINE { // data is in a linked list of these Example of use: \code // Walk the browser from beginning to end - for ( void *i=item_first(); i; i=item_next(i) ) { + void *i; + for (i =item_first(); i; i=item_next(i) ) { printf("item label='%s'\n", item_text(i)); } \endcode @@ -88,7 +89,7 @@ void* Fl_Browser::item_prev(void* item) const {return ((FL_BLINE*)item)->prev;} Example of use: \code // Walk the browser in reverse, from end to start - for ( void *i=item_last(); i; i=item_prev(i) ) { + for (i =item_last(); i; i=item_prev(i) ) { printf("item label='%s'\n", item_text(i)); } \endcode @@ -372,7 +373,8 @@ int Fl_Browser::item_height(void *item) const { } else { const int* i = column_widths(); // do each column separately as they may all set different fonts: - for (char* str = l->txt; str && *str; str++) { + char *str; + for (str = l->txt; str && *str; str++) { Fl_Font font = textfont(); // default font int tsize = textsize(); // default size if ( format_char() ) { // can be NULL @@ -669,7 +671,8 @@ void Fl_Browser::textsize(Fl_Fontsize newSize) { new_list(); full_height_ = 0; if (lines == 0) return; - for (FL_BLINE* itm=(FL_BLINE *)item_first(); itm; itm=(FL_BLINE *)item_next(itm)) { + FL_BLINE *itm; + for (itm =(FL_BLINE *)item_first(); itm; itm=(FL_BLINE *)item_next(itm)) { full_height_ += item_height(itm) + linespacing(); } } @@ -679,7 +682,8 @@ void Fl_Browser::textsize(Fl_Fontsize newSize) { \see add(), insert(), remove(), swap(int,int), clear() */ void Fl_Browser::clear() { - for (FL_BLINE* l = first; l;) { + FL_BLINE *l; + for (l = first; l;) { FL_BLINE* n = l->next; free(l); l = n; diff --git a/src/Fl_Browser_.cxx b/src/Fl_Browser_.cxx index 56b751415..eee2369b0 100644 --- a/src/Fl_Browser_.cxx +++ b/src/Fl_Browser_.cxx @@ -227,7 +227,8 @@ void Fl_Browser_::hposition(int pos) { int Fl_Browser_::displayed(void* item) const { int X, Y, W, H; bbox(X, Y, W, H); int yy = H+offset_; - for (void* l = top_; l && yy > 0; l = item_next(l)) { + void *l; + for (l = top_; l && yy > 0; l = item_next(l)) { if (l == item) return 1; yy -= item_height(l) + linespacing(); } @@ -583,7 +584,8 @@ void* Fl_Browser_::find_item(int ypos) { update_top(); int X, Y, W, H; bbox(X, Y, W, H); int yy = Y-offset_; - for (void *l = top_; l; l = item_next(l)) { + void *l; + for (l = top_; l; l = item_next(l)) { int hh = item_height(l); if (hh <= 0) continue; yy += hh + linespacing(); if (ypos <= yy || yy>=(Y+H)) return l; @@ -649,7 +651,8 @@ int Fl_Browser_::select(void* item, int val, int docallbacks) { int Fl_Browser_::deselect(int docallbacks) { if (type() == FL_MULTI_BROWSER) { int change = 0; - for (void* p = item_first(); p; p = item_next(p)) + void *p; + for (p = item_first(); p; p = item_next(p)) change |= select(p, 0, docallbacks); return change; } else { @@ -673,7 +676,8 @@ int Fl_Browser_::select_only(void* item, int docallbacks) { int change = 0; Fl_Widget_Tracker wp(this); if (type() == FL_MULTI_BROWSER) { - for (void* p = item_first(); p; p = item_next(p)) { + void *p; + for (p = item_first(); p; p = item_next(p)) { if (p != item) change |= select(p, 0, docallbacks); if (wp.deleted()) return change; } @@ -833,19 +837,20 @@ J1: // see which of the new item or previous selection is earlier, // by searching from the previous forward for this one: int down; + void *m; if (!l) down = 1; - else {for (void* m = selection_; ; m = item_next(m)) { + else {for (m = selection_; ; m = item_next(m)) { if (m == l) {down = 1; break;} if (!m) {down = 0; break;} }} if (down) { - for (void* m = selection_; m != l; m = item_next(m)) { + for (m = selection_; m != l; m = item_next(m)) { select(m, whichway, when() & FL_WHEN_CHANGED); if (wp.deleted()) return 1; } } else { void* e = selection_; - for (void* m = item_next(l); m; m = item_next(m)) { + for (m = item_next(l); m; m = item_next(m)) { select(m, whichway, when() & FL_WHEN_CHANGED); if (wp.deleted()) return 1; if (m == e) break; @@ -1066,7 +1071,8 @@ int Fl_Browser_::incr_height() const { */ int Fl_Browser_::full_height() const { int t = 0; - for (void* p = item_first(); p; p = item_next(p)) + void *p; + for (p = item_first(); p; p = item_next(p)) t += item_quick_height(p); return t; } diff --git a/src/Fl_Button.cxx b/src/Fl_Button.cxx index 3df97875b..d22229ea4 100644 --- a/src/Fl_Button.cxx +++ b/src/Fl_Button.cxx @@ -59,7 +59,8 @@ void Fl_Button::setonly() { // set this radio button on, turn others off value(1); Fl_Group* g = parent(); Fl_Widget*const* a = g->array(); - for (int i = g->children(); i--;) { + int i; + for (i = g->children(); i--;) { Fl_Widget* o = *a++; if (o != this && o->type()==FL_RADIO_BUTTON) ((Fl_Button*)o)->value(0); } diff --git a/src/Fl_Chart.cxx b/src/Fl_Chart.cxx index 2baf632f5..a4aebad49 100644 --- a/src/Fl_Chart.cxx +++ b/src/Fl_Chart.cxx @@ -295,7 +295,8 @@ void Fl_Chart::draw() { if (min >= max) { min = max = 0.0; - for (int i = 0; i < numb; i++) { + int i; + for (i = 0; i < numb; i++) { if (entries[i].val < min) min = entries[i].val; if (entries[i].val > max) diff --git a/src/Fl_Check_Browser.cxx b/src/Fl_Check_Browser.cxx index e1ed61d7f..ca2b8a48b 100644 --- a/src/Fl_Check_Browser.cxx +++ b/src/Fl_Check_Browser.cxx @@ -108,7 +108,8 @@ void *Fl_Check_Browser::item_at(int index) const { // note: index is 1-based if (index < 1 || index > nitems()) return 0L; cb_item *item = (cb_item *)item_first(); - for (int i = 1; i < index; i++) + int i; + for (i = 1; i < index; i++) item = (cb_item *)(item_next(item)); return (void *)item; } diff --git a/src/Fl_Clock.cxx b/src/Fl_Clock.cxx index 15ac88d14..d77b4652e 100644 --- a/src/Fl_Clock.cxx +++ b/src/Fl_Clock.cxx @@ -95,7 +95,8 @@ void Fl_Clock_Output::draw(int X, int Y, int W, int H) { // draw the tick marks: fl_push_matrix(); fl_color(active_r() ? FL_FOREGROUND_COLOR : fl_inactive(FL_FOREGROUND_COLOR)); - for (int i=0; i<12; i++) { + int i; + for (i =0; i<12; i++) { if (i==6) rect(-0.5, 9, 1, 2); else if (i==3 || i==0 || i== 9) rect(-0.5, 9.5, 1, 1); else rect(-0.25, 9.5, .5, 1); diff --git a/src/Fl_Color_Chooser.cxx b/src/Fl_Color_Chooser.cxx index f219906f1..17bb67bc9 100644 --- a/src/Fl_Color_Chooser.cxx +++ b/src/Fl_Color_Chooser.cxx @@ -249,7 +249,8 @@ static void generate_image(void* vv, int X, int Y, int W, uchar* buf) { #else const double V = 1.0; #endif - for (int x = X; x < X+W; x++) { + int x; + for (x = X; x < X+W; x++) { double Xf = double(x)/iw; double H,S; tohs(Xf,Yf,H,S); double r=0, g=0, b=0; @@ -374,7 +375,8 @@ static void generate_vimage(void* vv, int X, int Y, int W, uchar* buf) { uchar r = uchar(tr*Yf+.5); uchar g = uchar(tg*Yf+.5); uchar b = uchar(tb*Yf+.5); - for (int x = X; x < X+W; x++) { + int x; + for (x = X; x < X+W; x++) { *buf++ = r; *buf++ = g; *buf++ = b; } } diff --git a/src/Fl_Counter.cxx b/src/Fl_Counter.cxx index be57c9f1f..059797b59 100644 --- a/src/Fl_Counter.cxx +++ b/src/Fl_Counter.cxx @@ -75,7 +75,8 @@ void Fl_Counter::draw() { if (tbt == FL_THIN_UP_BOX) tbt = FL_THIN_DOWN_BOX; // arrow boxes - for (int i = 0; i < 4; i++) { + int i; + for (i = 0; i < 4; i++) { if (mouseobj_ == i + 1) ab[i].boxtype = fl_down(box()); else @@ -116,7 +117,7 @@ void Fl_Counter::draw() { // draw arrow boxes int xo = x(); - for (int i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { if (ab[i].width > 0) { draw_box(ab[i].boxtype, xo, y(), ab[i].width, h(), color()); Fl_Rect bb(xo, y(), ab[i].width, h(), ab[i].boxtype); diff --git a/src/Fl_File_Chooser2.cxx b/src/Fl_File_Chooser2.cxx index 46e902c18..bcf22111d 100644 --- a/src/Fl_File_Chooser2.cxx +++ b/src/Fl_File_Chooser2.cxx @@ -1418,7 +1418,8 @@ Fl_File_Chooser::update_preview() This sample code loops through all selected files: \code // Get list of filenames user selected from a MULTI chooser - for ( int t=1; t<=chooser->count(); t++ ) { + int t; + for (t =1; t<=chooser->count(); t++ ) { const char *filename = chooser->value(t); ... } @@ -1588,7 +1589,8 @@ void Fl_File_Chooser::showHidden(int value) void Fl_File_Chooser::remove_hidden_files() { int count = fileList->size(); - for(int num = count; num >= 1; num--) { + int num; + for (num = count; num >= 1; num--) { const char *p = fileList->text(num); if (*p == '.' && strcmp(p, "../") != 0) fileList->remove(num); } diff --git a/src/Fl_File_Icon2.cxx b/src/Fl_File_Icon2.cxx index f81fa8af0..4fe66307b 100644 --- a/src/Fl_File_Icon2.cxx +++ b/src/Fl_File_Icon2.cxx @@ -301,7 +301,8 @@ Fl_File_Icon::load_fti(const char *fti) // I - File to read from #ifdef DEBUG printf("Icon File \"%s\":\n", fti); - for (int i = 0; i < num_data_; i ++) + int i; + for (i = 0; i < num_data_; i ++) printf(" %d,\n", data_[i]); #endif /* DEBUG */ diff --git a/src/Fl_Flex.cxx b/src/Fl_Flex.cxx index 20437783c..ebcdea4e0 100644 --- a/src/Fl_Flex.cxx +++ b/src/Fl_Flex.cxx @@ -212,7 +212,8 @@ void Fl_Flex::layout() { // Precalculate remaining space that can be distributed - for (int i = 0; i < nc; i++) { + int i; + for (i = 0; i < nc; i++) { Fl_Widget *c = child(i); if (c->visible()) { if (fixed(c)) { @@ -239,7 +240,7 @@ void Fl_Flex::layout() { sp++; } - for (int i = 0; i < nc; i++) { + for (i = 0; i < nc; i++) { Fl_Widget *c = child(i); if (!c->visible()) continue; @@ -304,7 +305,8 @@ void Fl_Flex::fixed(Fl_Widget *child, int size) { // find w in our fixed size list int idx = -1; - for (int i = 0; i < fixed_size_size_; i++) { + int i; + for (i = 0; i < fixed_size_size_; i++) { if (fixed_size_[i] == child) { idx = i; break; @@ -313,7 +315,7 @@ void Fl_Flex::fixed(Fl_Widget *child, int size) { // remove from array, if we want the widget to be flexible, but an entry was found if (size == 0 && idx >= 0) { - for (int i = idx; i < fixed_size_size_ - 1; i++) { + for (i = idx; i < fixed_size_size_ - 1; i++) { fixed_size_[i] = fixed_size_[i+1]; } fixed_size_size_--; @@ -352,7 +354,8 @@ void Fl_Flex::fixed(Fl_Widget *child, int size) { \retval 0 the widget resizes dynamically */ int Fl_Flex::fixed(Fl_Widget *w) const { - for (int i = 0; i < fixed_size_size_; i++) { + int i; + for (i = 0; i < fixed_size_size_; i++) { if (w == fixed_size_[i]) { return 1; } diff --git a/src/Fl_GIF_Image.cxx b/src/Fl_GIF_Image.cxx index 93fe22f36..074a4ea32 100644 --- a/src/Fl_GIF_Image.cxx +++ b/src/Fl_GIF_Image.cxx @@ -500,8 +500,9 @@ void Fl_GIF_Image::load_gif_(Fl_Image_Reader &rdr, bool anim/*=false*/) // printf("\nFl_GIF_Image::load_gif_ : %s\n", rdr.name()); + int i; {char b[6] = { 0 }; - for (int i=0; i<6; ++i) b[i] = rdr.read_byte(); + for (i =0; i<6; ++i) b[i] = rdr.read_byte(); if (b[0]!='G' || b[1]!='I' || b[2] != 'F') { Fl::error("Fl_GIF_Image: %s is not a GIF file.\n", rdr.name()); ld(ERR_FORMAT); @@ -539,7 +540,7 @@ void Fl_GIF_Image::load_gif_(Fl_Image_Reader &rdr, bool anim/*=false*/) int YPos = 0; struct ColorMap CMap; /* color map */ if (HasColormap) { - for (int i=0; i < ColorMapSize; i++) { + for (i =0; i < ColorMapSize; i++) { CMap.Red[i] = rdr.read_byte(); CMap.Green[i] = rdr.read_byte(); CMap.Blue[i] = rdr.read_byte(); @@ -658,7 +659,7 @@ void Fl_GIF_Image::load_gif_(Fl_Image_Reader &rdr, bool anim/*=false*/) ColorMapSize = 1 << BitsPerPixel; CMap.Red[0] = CMap.Green[0] = CMap.Blue[0] = 0; // black CMap.Red[1] = CMap.Green[1] = CMap.Blue[1] = 255; // white - for (int i = 2; i < ColorMapSize; i++) { + for (i = 2; i < ColorMapSize; i++) { CMap.Red[i] = CMap.Green[i] = CMap.Blue[i] = (uchar)(255 * i / (ColorMapSize - 1)); } } @@ -670,13 +671,14 @@ void Fl_GIF_Image::load_gif_(Fl_Image_Reader &rdr, bool anim/*=false*/) // Fix transparent pixel index outside ColorMap (Issue #271) if (has_transparent && transparent_pixel >= ColorMapSize) { - for (int k = ColorMapSize; k <= transparent_pixel; k++) + int k; + for (k = ColorMapSize; k <= transparent_pixel; k++) CMap.Red[k] = CMap.Green[k] = CMap.Blue[k] = 0xff; // white (color is irrelevant) ColorMapSize = transparent_pixel + 1; } #if (0) // TEST/DEBUG: fill color table to maximum size - for (int i = ColorMapSize; i < 256; i++) { + for (i = ColorMapSize; i < 256; i++) { CMap.Red[i] = CMap.Green[i] = CMap.Blue[i] = 0; // black } #endif @@ -726,7 +728,8 @@ void Fl_GIF_Image::load_gif_(Fl_Image_Reader &rdr, bool anim/*=false*/) int ystart = YPos; if (ystart < 0) ystart = 0; int xmax = XPos + Width; if (xmax > ScreenWidth) xmax = ScreenWidth; int ymax = YPos + Height; if (ymax > ScreenHeight) ymax = ScreenHeight; - for (int y = ystart; y<ymax; y++) { + int y; + for (y = ystart; y<ymax; y++) { uchar *src = Image + (y-YPos) * Width + (xstart-XPos); uchar *dst = moved_image + y*ScreenWidth + xstart; memcpy(dst, src, xmax-xstart); diff --git a/src/Fl_Gl_Window.cxx b/src/Fl_Gl_Window.cxx index 776ea3ff9..560fbe162 100644 --- a/src/Fl_Gl_Window.cxx +++ b/src/Fl_Gl_Window.cxx @@ -616,7 +616,8 @@ Fl_RGB_Image* Fl_Gl_Window_Driver::capture_gl_rectangle(int x, int y, int w, int uchar *tmp = new uchar[mByteWidth]; uchar *p = baseAddress ; uchar *q = baseAddress + (h-1)*mByteWidth; - for (int i = 0; i < h/2; i++, p += mByteWidth, q -= mByteWidth) { + int i; + for (i = 0; i < h/2; i++, p += mByteWidth, q -= mByteWidth) { memcpy(tmp, p, mByteWidth); memcpy(p, q, mByteWidth); memcpy(q, tmp, mByteWidth); diff --git a/src/Fl_Graphics_Driver.cxx b/src/Fl_Graphics_Driver.cxx index fe943d780..793a14d20 100644 --- a/src/Fl_Graphics_Driver.cxx +++ b/src/Fl_Graphics_Driver.cxx @@ -1066,15 +1066,17 @@ void Fl_Scalable_Graphics_Driver::draw_image_rescale(void *buf, Fl_Draw_Image_Cb if (L == 0) L = W*aD; int depth = mono ? (aD%2==0?2:1) : aD; uchar *tmp_buf = new uchar[W*H*depth]; + int i; if (cb) { - for (int i = 0; i < H; i++) { + for (i = 0; i < H; i++) { cb(buf, 0, i, W, tmp_buf + i * W * depth); } } else { uchar *q, *p = tmp_buf; - for (int i = 0; i < H; i++) { + for (i = 0; i < H; i++) { q = (uchar*)buf + i * L; - for (int j = 0; j < W; j++) { + int j; + for (j = 0; j < W; j++) { memcpy(p, q, depth); p += depth; q += D; } diff --git a/src/Fl_Grid.cxx b/src/Fl_Grid.cxx index 4a4d7afd0..f82d2c342 100644 --- a/src/Fl_Grid.cxx +++ b/src/Fl_Grid.cxx @@ -200,7 +200,8 @@ void Fl_Grid::layout(int rows, int cols, int margin, int gap) { if (cols != cols_) { Col *new_cols = new Col[cols]; - for (int c = 0; c < cols; c++) { + int c; + for (c = 0; c < cols; c++) { if (c < cols_) new_cols[c] = Cols_[c]; else @@ -215,7 +216,8 @@ void Fl_Grid::layout(int rows, int cols, int margin, int gap) { if (rows != rows_) { Row *new_rows = new Row[rows]; Row *row = Rows_; - for (int r = 0; r < rows; r++, row++) { + int r; + for (r = 0; r < rows; r++, row++) { if (r < rows_) { new_rows[r] = *row; row->cells_ = 0; @@ -257,7 +259,8 @@ void Fl_Grid::draw_grid() { // draw horizontal lines (gap = 0) or rectangles (gap > 0) - for (int r = 0; r < rows_ - 1; r++) { + int r; + for (r = 0; r < rows_ - 1; r++) { int gap = Rows_[r].gap_ >= 0 ? Rows_[r].gap_ : gap_row_; y0 += Rows_[r].h_; @@ -274,7 +277,8 @@ void Fl_Grid::draw_grid() { x0 = x() + Fl::box_dx(box()) + margin_left_; y0 = y() + Fl::box_dy(box()) + margin_top_; - for (int c = 0; c < cols_ - 1; c++) { + int c; + for (c = 0; c < cols_ - 1; c++) { int gap = Cols_[c].gap_ >= 0 ? Cols_[c].gap_ : gap_col_; x0 += Cols_[c].w_; @@ -345,21 +349,23 @@ void Fl_Grid::layout() { // initialize column widths and row heights col = Cols_; - for (int c = 0; c < cols_; c++, col++) { + int c; + for (c = 0; c < cols_; c++, col++) { col->w_ = col->minw_; } row = Rows_; - for (int r = 0; r < rows_; r++, row++) { + int r; + for (r = 0; r < rows_; r++, row++) { row->h_ = row->minh_; } // calculate minimal column widths and row heights (in one loop) row = Rows_; - for (int r = 0; r < rows_; r++, row++) { + for (r = 0; r < rows_; r++, row++) { col = Cols_; - for (int c = 0; c < cols_; c++, col++) { + for (c = 0; c < cols_; c++, col++) { cel = cell(r, c); if (cel) { Fl_Widget *wi = cel->widget_; @@ -384,7 +390,7 @@ void Fl_Grid::layout() { int irwe = 0; // index of row with highest weight col = Cols_; - for (int c = 0; c < cols_; c++, col++) { + for (c = 0; c < cols_; c++, col++) { tcwi += col->w_; tcwe += col->weight_; if (c < cols_ - 1) @@ -396,7 +402,7 @@ void Fl_Grid::layout() { } row = Rows_; - for (int r = 0; r < rows_; r++, row++) { + for (r = 0; r < rows_; r++, row++) { trhe += row->h_; trwe += row->weight_; if (r < rows_ - 1) @@ -417,7 +423,7 @@ void Fl_Grid::layout() { if (space > 0 && tcwe > 0) { remaining = space; col = Cols_; - for (int c = 0; c < cols_; c++, col++) { + for (c = 0; c < cols_; c++, col++) { if (col->weight_ > 0) { add_space = int(float(space * col->weight_) / tcwe + 0.5); col->w_ += add_space; @@ -433,7 +439,7 @@ void Fl_Grid::layout() { if (space > 0 && trwe > 0) { remaining = space; row = Rows_; - for (int r = 0; r < rows_; r++, row++) { + for (r = 0; r < rows_; r++, row++) { if (row->weight_ > 0) { add_space = int(float(space * row->weight_) / trwe + 0.5); row->h_ += add_space; @@ -451,10 +457,10 @@ void Fl_Grid::layout() { y0 = y() + Fl::box_dy(box()) + margin_top_; row = Rows_; - for (int r = 0; r < rows_; r++, row++) { + for (r = 0; r < rows_; r++, row++) { x0 = x() + Fl::box_dx(box()) + margin_left_; col = Cols_; - for (int c = 0; c < cols_; c++, col++) { + for (c = 0; c < cols_; c++, col++) { int wx = x0; // widget's x int wy = y0; // widget's y cel = cell(r, c); @@ -467,12 +473,13 @@ void Fl_Grid::layout() { int ww = col->w_; int wh = row->h_; - for (int i = 0; i < cel->colspan_ - 1; i++) { + int i; + for (i = 0; i < cel->colspan_ - 1; i++) { ww += (Cols_[c + i].gap_ >= 0) ? Cols_[c + i].gap_ : gap_col_; ww += Cols_[c + i + 1].w_; } - for (int i = 0; i < cel->rowspan_ - 1; i++) { + for (i = 0; i < cel->rowspan_ - 1; i++) { wh += (Rows_[r + i].gap_ >= 0) ? Rows_[r + i].gap_ : gap_row_; wh += Rows_[r + i + 1].h_; } @@ -609,7 +616,8 @@ void Fl_Grid::clear_layout() { delete[] Cols_; delete[] Rows_; init(); - for (int i = 0; i < children(); i++) { + int i; + for (i = 0; i < children(); i++) { child(i)->hide(); } need_layout(1); @@ -766,7 +774,8 @@ Fl_Grid::Cell* Fl_Grid::cell(int row, int col) const { */ Fl_Grid::Cell* Fl_Grid::cell(Fl_Widget *widget) const { Row *row = Rows_; - for (int r = 0; r < rows_; r++, row++) { + int r; + for (r = 0; r < rows_; r++, row++) { Cell *cel = row->cells_; while (cel) { if (cel->widget_ == widget) @@ -914,7 +923,8 @@ void Fl_Grid::col_width(int col, int value) { */ void Fl_Grid::col_width(const int *value, size_t size) { Col *c = Cols_; - for (int i = 0; i < cols_; i++, value++, c++) { + int i; + for (i = 0; i < cols_; i++, value++, c++) { if (i >= (int)size) break; if (*value >= 0) c->minw_ = *value; @@ -984,7 +994,8 @@ void Fl_Grid::col_weight(int col, int value) { */ void Fl_Grid::col_weight(const int *value, size_t size) { Col *c = Cols_; - for (int i = 0; i < cols_; i++, value++, c++) { + int i; + for (i = 0; i < cols_; i++, value++, c++) { if (i >= (int)size) break; if (*value >= 0) c->weight_ = *value; @@ -1020,7 +1031,8 @@ void Fl_Grid::col_gap(int col, int value) { */ void Fl_Grid::col_gap(const int *value, size_t size) { Col *c = Cols_; - for (int i = 0; i < cols_; i++, value++, c++) { + int i; + for (i = 0; i < cols_; i++, value++, c++) { if (i >= (int)size) break; if (*value >= 0) c->gap_ = *value; @@ -1056,7 +1068,8 @@ void Fl_Grid::row_height(int row, int value) { */ void Fl_Grid::row_height(const int *value, size_t size) { Row *r = Rows_; - for (int i = 0; i < rows_; i++, value++, r++) { + int i; + for (i = 0; i < rows_; i++, value++, r++) { if (i >= (int)size) break; if (*value >= 0) r->minh_ = *value; @@ -1092,7 +1105,8 @@ void Fl_Grid::row_weight(int row, int value) { */ void Fl_Grid::row_weight(const int *value, size_t size) { Row *r = Rows_; - for (int i = 0; i < rows_; i++, value++, r++) { + int i; + for (i = 0; i < rows_; i++, value++, r++) { if (i >= (int)size) break; if (*value >= 0) r->weight_ = *value; @@ -1129,7 +1143,8 @@ void Fl_Grid::row_gap(int row, int value) { */ void Fl_Grid::row_gap(const int *value, size_t size) { Row *r = Rows_; - for (int i = 0; i < rows_; i++, value++, r++) { + int i; + for (i = 0; i < rows_; i++, value++, r++) { if (i >= (int)size) break; if (*value >= 0) r->gap_ = *value; @@ -1177,7 +1192,8 @@ void Fl_Grid::debug(int level) { fprintf(stderr, " gaps: (%2d, %2d)\n", gap_row_, gap_col_); Row *row = Rows_; - for (int r = 0; r < rows_; r++, row++) { + int r; + for (r = 0; r < rows_; r++, row++) { fprintf(stderr, "Row %2d: minh = %d, weight = %d, gap = %d, h = %d\n", r, row->minh_, row->weight_, row->gap_, row->h_); Cell *cel = row->cells_; diff --git a/src/Fl_Group.cxx b/src/Fl_Group.cxx index 31fca05d8..1fb22d14f 100644 --- a/src/Fl_Group.cxx +++ b/src/Fl_Group.cxx @@ -290,7 +290,8 @@ int Fl_Group::handle(int event) { if (i >= children()) i = 0; if (children()) { - for (int j = i;;) { + int j; + for (j = i;;) { if (a[j]->takesevents()) if (send(a[j], event)) return 1; j++; if (j >= children()) j = 0; @@ -409,7 +410,8 @@ void Fl_Group::clear() { // child which is much faster than the other way around and // should be the "natural order" (last in, first out). - for (int i = children() - 1; i >= 0; i--) { + int i; + for (i = children() - 1; i >= 0; i--) { // some children may have been deleted, so check always if (i >= children()) continue; delete_child(i); @@ -517,11 +519,12 @@ void Fl_Group::insert(Fl_Widget &o, int index) { // now it's OK to move the child inside this group + int j; if (index > n) { // target > current position: move "up" and all other children "down" - for (int j = n; j < index; j++) + for (j = n; j < index; j++) child_[j] = child_[j + 1]; } else { // n > index: move "down" and all other children "up" - for (int j = n; j > index; j--) + for (j = n; j > index; j--) child_[j] = child_[j - 1]; } child_[index] = &o; @@ -766,7 +769,8 @@ Fl_Rect* Fl_Group::bounds() { // next is all the children's sizes: p += 2; Fl_Widget*const* a = array(); - for (int i = children(); i--;) { + int i; + for (i = children(); i--;) { *p++ = Fl_Rect(*a++); } } @@ -804,7 +808,8 @@ int* Fl_Group::sizes() { // allocate new sizes_ array and copy bounds_ over to sizes_ int* pi = sizes_ = new int[4*(children() + 2)]; Fl_Rect *rb = bounds(); - for (int i = 0; i < children() + 2; i++, rb++) { + int i; + for (i = 0; i < children() + 2; i++, rb++) { *pi++ = rb->x(); *pi++ = rb->r(); *pi++ = rb->y(); @@ -839,6 +844,7 @@ void Fl_Group::resize(int X, int Y, int W, int H) { // just move the children. // This case covers also window rescaling where dw == dh == 0. + int i; if (!resizable() || (dw==0 && dh==0)) { // top window and subwindows must not change the position of their children @@ -851,7 +857,7 @@ void Fl_Group::resize(int X, int Y, int W, int H) { if (Fl_Window::is_a_rescale() || dx || dy) { Fl_Widget*const* a = array(); - for (int i = children(); i--;) { + for (i = children(); i--;) { Fl_Widget* o = *a++; o->resize(o->x() + dx, o->y() + dy, o->w(), o->h()); } @@ -888,7 +894,7 @@ void Fl_Group::resize(int X, int Y, int W, int H) { // resize children Fl_Widget*const* a = array(); - for (int i = children(); i--; p++) { + for (i = children(); i--; p++) { Fl_Widget* o = *a++; int L = p->x(); @@ -929,14 +935,15 @@ void Fl_Group::draw_children() { h() - Fl::box_dh(box())); } + int i; if (damage() & ~FL_DAMAGE_CHILD) { // redraw the entire thing: - for (int i = children(); i--;) { + for (i = children(); i--;) { Fl_Widget& o = **a++; draw_child(o); draw_outside_label(o); } } else { // only redraw the children that need it: - for (int i = children(); i--;) + for (i = children(); i--;) update_child(**a++); } diff --git a/src/Fl_ICO_Image.cxx b/src/Fl_ICO_Image.cxx index 9de71737b..301dc86e6 100644 --- a/src/Fl_ICO_Image.cxx +++ b/src/Fl_ICO_Image.cxx @@ -96,7 +96,8 @@ void Fl_ICO_Image::load_ico_(Fl_Image_Reader &rdr, int id) icondirentry_ = new IconDirEntry[idcount()]; - for (int i = 0; i < idcount(); ++i) { + int i; + for (i = 0; i < idcount(); ++i) { icondirentry_[i].bWidth = (int)rdr.read_byte(); icondirentry_[i].bHeight = (int)rdr.read_byte(); icondirentry_[i].bColorCount = (int)rdr.read_byte(); @@ -120,7 +121,7 @@ void Fl_ICO_Image::load_ico_(Fl_Image_Reader &rdr, int id) if (id == -1) { // pick icon with highest resolution + highest bitcount int highestRes = 0, bitcount = 0; - for (int i = 0; i < idcount(); ++i) { + for (i = 0; i < idcount(); ++i) { int res = icondirentry_[i].bWidth * icondirentry_[i].bHeight; if (res > highestRes || (res == highestRes && icondirentry_[i].wBitCount > bitcount)) { highestRes = res; @@ -147,7 +148,7 @@ void Fl_ICO_Image::load_ico_(Fl_Image_Reader &rdr, int id) // Check for a PNG image resource uchar b[8]; - for (int i=0; i<8; ++i) b[i] = rdr.read_byte(); + for (i =0; i<8; ++i) b[i] = rdr.read_byte(); if (b[0]==0x89 && b[1]=='P' && b[2]=='N' && b[3]=='G' && b[4]=='\r' && b[5]=='\n' && b[6]==0x1A && b[7]=='\n') diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx index aa4837d26..00023bb17 100644 --- a/src/Fl_Image.cxx +++ b/src/Fl_Image.cxx @@ -637,24 +637,26 @@ Fl_RGB_Image *Fl_RGB_Image::copy_scale_down_2h_() const { if ((W==0) || (H==0) || (D==0)) return 0; uchar *data = (uchar*)malloc(W*H*D); uchar *dst = data; - for (int y = 0; y < H; y++) { + int y; + for (y = 0; y < H; y++) { const uchar *src = array + y*LD; switch (D) { case 1: - for (int x=0; x<W; ++x) { + int x; + for (x =0; x<W; ++x) { *dst++ = ((uchar) ( ( ((unsigned)src[0]) + ((unsigned)src[1]) ) >> 1 )); src += 2; } break; case 2: - for (int x=0; x<W; ++x) { + for (x =0; x<W; ++x) { *dst++ = ((uchar) ( ( ((unsigned)src[0]) + ((unsigned)src[2]) ) >> 1 )); *dst++ = ((uchar) ( ( ((unsigned)src[1]) + ((unsigned)src[3]) ) >> 1 )); src += 4; } break; case 3: - for (int x=0; x<W; ++x) { + for (x =0; x<W; ++x) { *dst++ = ((uchar) ( ( ((unsigned)src[0]) + ((unsigned)src[3]) ) >> 1 )); *dst++ = ((uchar) ( ( ((unsigned)src[1]) + ((unsigned)src[4]) ) >> 1 )); *dst++ = ((uchar) ( ( ((unsigned)src[2]) + ((unsigned)src[5]) ) >> 1 )); @@ -662,7 +664,7 @@ Fl_RGB_Image *Fl_RGB_Image::copy_scale_down_2h_() const { } break; case 4: - for (int x=0; x<W; ++x) { + for (x =0; x<W; ++x) { *dst++ = ((uchar) ( ( ((unsigned)src[0]) + ((unsigned)src[4]) ) >> 1 )); *dst++ = ((uchar) ( ( ((unsigned)src[1]) + ((unsigned)src[5]) ) >> 1 )); *dst++ = ((uchar) ( ( ((unsigned)src[2]) + ((unsigned)src[6]) ) >> 1 )); @@ -683,30 +685,32 @@ Fl_RGB_Image *Fl_RGB_Image::copy_scale_down_2v_() const { if ((W==0) || (H==0) || (D==0)) return 0; uchar *data = (uchar*)malloc(W*H*D); uchar *dst = data; - for (int y = 0; y < H; y++) { + int y; + for (y = 0; y < H; y++) { const uchar *s0 = array + 2*y*LD; const uchar *s1 = s0 + LD; switch (D) { case 1: - for (int x=0; x<W; ++x) { + int x; + for (x =0; x<W; ++x) { *dst++ = ((uchar) ( ( ((unsigned)*s0++) + ((unsigned)*s1++) ) >> 1 )); } break; case 2: - for (int x=0; x<W; ++x) { + for (x =0; x<W; ++x) { *dst++ = ((uchar) ( ( ((unsigned)*s0++) + ((unsigned)*s1++) ) >> 1 )); *dst++ = ((uchar) ( ( ((unsigned)*s0++) + ((unsigned)*s1++) ) >> 1 )); } break; case 3: - for (int x=0; x<W; ++x) { + for (x =0; x<W; ++x) { *dst++ = ((uchar) ( ( ((unsigned)*s0++) + ((unsigned)*s1++) ) >> 1 )); *dst++ = ((uchar) ( ( ((unsigned)*s0++) + ((unsigned)*s1++) ) >> 1 )); *dst++ = ((uchar) ( ( ((unsigned)*s0++) + ((unsigned)*s1++) ) >> 1 )); } break; case 4: - for (int x=0; x<W; ++x) { + for (x =0; x<W; ++x) { *dst++ = ((uchar) ( ( ((unsigned)*s0++) + ((unsigned)*s1++) ) >> 1 )); *dst++ = ((uchar) ( ( ((unsigned)*s0++) + ((unsigned)*s1++) ) >> 1 )); *dst++ = ((uchar) ( ( ((unsigned)*s0++) + ((unsigned)*s1++) ) >> 1 )); diff --git a/src/Fl_Image_Surface.cxx b/src/Fl_Image_Surface.cxx index 38cda73d9..cc65175fa 100644 --- a/src/Fl_Image_Surface.cxx +++ b/src/Fl_Image_Surface.cxx @@ -95,12 +95,14 @@ void Fl_Image_Surface_Driver::copy_with_mask(Fl_RGB_Image* mask, uchar *dib_dst, uchar *dib_src, int line_size, bool bottom_to_top) { int w = mask->data_w(), h = mask->data_h(); - for (int i = 0; i < h; i++) { + int i; + for (i = 0; i < h; i++) { const uchar* alpha = (const uchar*)mask->array + (bottom_to_top ? (h-i-1) : i) * w; uchar *src = dib_src + i * line_size; uchar *dst = dib_dst + i * line_size; - for (int j = 0; j < w; j++) { + int j; + for (j = 0; j < w; j++) { // mix src and dst into dst weighted by mask pixel's value uchar u = *alpha++, v = 255 - u; *dst = ((*dst) * v + (*src) * u)/255; @@ -269,7 +271,8 @@ static int count_offscreens = 0; static int find_slot(void) { // return an available slot to memorize an Fl_Image_Surface object static int max = 0; - for (int num = 0; num < count_offscreens; num++) { + int num; + for (num = 0; num < count_offscreens; num++) { if (!offscreen_api_surface[num]) return num; } if (count_offscreens >= max) { @@ -315,7 +318,8 @@ Fl_Offscreen fl_create_offscreen(int w, int h) { */ void fl_delete_offscreen(Fl_Offscreen ctx) { if (!ctx) return; - for (int i = 0; i < count_offscreens; i++) { + int i; + for (i = 0; i < count_offscreens; i++) { if (offscreen_api_surface[i] && offscreen_api_surface[i]->offscreen() == ctx) { delete offscreen_api_surface[i]; offscreen_api_surface[i] = NULL; @@ -329,7 +333,8 @@ void fl_delete_offscreen(Fl_Offscreen ctx) { \note The \p ctx argument must have been created by fl_create_offscreen(). */ void fl_begin_offscreen(Fl_Offscreen ctx) { - for (int i = 0; i < count_offscreens; i++) { + int i; + for (i = 0; i < count_offscreens; i++) { if (offscreen_api_surface[i] && offscreen_api_surface[i]->offscreen() == ctx) { Fl_Surface_Device::push_current(offscreen_api_surface[i]); return; diff --git a/src/Fl_Input_.cxx b/src/Fl_Input_.cxx index c052de10d..e06942539 100644 --- a/src/Fl_Input_.cxx +++ b/src/Fl_Input_.cxx @@ -109,7 +109,8 @@ public: void clear() { if (list_) { - for (int i=0; i<list_size_; i++) { + int i; + for (i =0; i<list_size_; i++) { delete list_[i]; } ::free(list_); @@ -581,7 +582,8 @@ int Fl_Input_::line_end(int i) const { while (j > 0 && index(j-1) != '\n') j--; // now measure lines until we get past i, end of that line is real eol: setfont(); - for (const char* p=value()+j; ;) { + const char *p; + for (p =value()+j; ;) { char buf[MAXBUF]; p = expand(p, buf); int k = (int) (p-value()); @@ -610,7 +612,8 @@ int Fl_Input_::line_start(int i) const { if (wrap()) { // now measure lines until we get past i, start of that line is real eol: setfont(); - for (const char* p=value()+j; ;) { + const char *p; + for (p =value()+j; ;) { char buf[MAXBUF]; const char* e = expand(p, buf); if ((int) (e-value()) >= i) return (int) (p-value()); diff --git a/src/Fl_Input_Choice.cxx b/src/Fl_Input_Choice.cxx index 59aeecfe9..6d9f7e05a 100644 --- a/src/Fl_Input_Choice.cxx +++ b/src/Fl_Input_Choice.cxx @@ -343,7 +343,8 @@ void Fl_Input_Choice::clear_changed() { */ int Fl_Input_Choice::update_menubutton() { // Find item in menu - for ( int i=0; i<menu_->size(); i++ ) { + int i; + for (i =0; i<menu_->size(); i++ ) { const Fl_Menu_Item &item = menu_->menu()[i]; if (item.flags & (FL_SUBMENU|FL_SUBMENU_POINTER)) continue; // ignore submenus const char *name = menu_->text(i); diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx index c574d32b1..acddc4e91 100644 --- a/src/Fl_Menu.cxx +++ b/src/Fl_Menu.cxx @@ -345,7 +345,8 @@ public: \return 1 if the coordinates are inside any of the menuwindows */ bool Menu_State::is_inside(int mx, int my) { - for (menu_index_t i=num_menus-1; i>=0; i--) { + menu_index_t i; + for (i =num_menus-1; i>=0; i--) { if (menu_window[i]->is_inside(mx, my)) { return true; } @@ -434,7 +435,8 @@ bool Menu_State::prev_item(menu_index_t menu) { // previous item in menu menu if \return 1 if the shortcut was found in the menu and handled. */ int Menu_State::handle_shortcut() { - for (menu_index_t mymenu = num_menus; mymenu--;) { + menu_index_t mymenu; + for (mymenu = num_menus; mymenu--;) { Menu_Window &mw = *(menu_window[mymenu]); int item; const Fl_Menu_Item* m = mw.menu->find_shortcut(&item); @@ -672,7 +674,8 @@ bool Menu_State::create_submenu(const Fl_Rect &r, Menu_Window& cw, const Fl_Menu int dx = n->x()-nX; int waX, waY, waW, waH; Fl_Window_Driver::driver(n)->menu_window_area(waX, waY, waW, waH, Fl::screen_num(r.x(), r.y())); - for (menu_index_t menu = 0; menu <= current_menu_ix; menu++) { + menu_index_t menu; + for (menu = 0; menu <= current_menu_ix; menu++) { Menu_Window* tt = menu_window[menu]; int nx = tt->x()+dx; if (nx < waX) {nx = waX; dx = -tt->x() + waX;} int ny = tt->y()+dy; if (ny < waY) {ny = waY; dy = -tt->y() + waY;} @@ -1411,7 +1414,8 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown( button = pbutton; if (pbutton && pbutton->window()) { Menu_Window::parent_ = pbutton->top_window(); - for (Fl_Window* w = pbutton->window(); w; w = w->window()) { + Fl_Window *w; + for (w = pbutton->window(); w; w = w->window()) { X += w->x(); Y += w->y(); } @@ -1464,7 +1468,8 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown( // make sure all the menus are shown: { - for (menu_index_t k = menubar ? 1 : 0; k < pp.num_menus; k++) { + menu_index_t k; + for (k = menubar ? 1 : 0; k < pp.num_menus; k++) { if (!pp.menu_window[k]->shown()) { if (pp.menu_window[k]->title) pp.menu_window[k]->title->show(); pp.menu_window[k]->show(); diff --git a/src/Fl_Menu_.cxx b/src/Fl_Menu_.cxx index bce89ef39..9d857c11c 100644 --- a/src/Fl_Menu_.cxx +++ b/src/Fl_Menu_.cxx @@ -74,7 +74,8 @@ int Fl_Menu_::item_pathname_(char *name, int level = 0; finditem = finditem ? finditem : mvalue(); menu = menu ? menu : this->menu(); - for ( int t=0; t<size(); t++ ) { + int t; + for (t =0; t<size(); t++ ) { const Fl_Menu_Item *m = menu + t; if (m->submenu()) { // submenu? descend if (m->flags & FL_SUBMENU_POINTER) { @@ -196,7 +197,8 @@ int Fl_Menu_::find_index(const Fl_Menu_Item *item) const { \see find_index(const char*) */ int Fl_Menu_::find_index(Fl_Callback *cb) const { - for ( int t=0; t < size(); t++ ) + int t; + for (t =0; t < size(); t++ ) if (menu_[t].callback_==cb) return(t); return(-1); @@ -217,7 +219,8 @@ int Fl_Menu_::find_index(Fl_Callback *cb) const { */ int Fl_Menu_::find_index(const char *pathname) const { char menupath[1024] = ""; // File/Export - for ( int t=0; t < size(); t++ ) { + int t; + for (t =0; t < size(); t++ ) { Fl_Menu_Item *m = menu_ + t; if (m->flags&FL_SUBMENU) { // IT'S A SUBMENU @@ -257,7 +260,8 @@ int Fl_Menu_::find_index(const char *pathname) const { \see find_item(const char*) */ const Fl_Menu_Item * Fl_Menu_::find_item(Fl_Callback *cb) { - for ( int t=0; t < size(); t++ ) { + int t; + for (t =0; t < size(); t++ ) { const Fl_Menu_Item *m = menu_ + t; if (m->callback_==cb) { return m; @@ -274,7 +278,8 @@ const Fl_Menu_Item * Fl_Menu_::find_item(Fl_Callback *cb) { \see find_item(const char*) */ const Fl_Menu_Item* Fl_Menu_::find_item_with_user_data(void *v) { - for ( int t=0; t < size(); t++ ) { + int t; + for (t =0; t < size(); t++ ) { const Fl_Menu_Item *m = menu_ + t; if (m->user_data_==v) { return m; @@ -291,7 +296,8 @@ const Fl_Menu_Item* Fl_Menu_::find_item_with_user_data(void *v) { \see find_item(const char*) */ const Fl_Menu_Item* Fl_Menu_::find_item_with_argument(long v) { - for ( int t=0; t < size(); t++ ) { + int t; + for (t =0; t < size(); t++ ) { const Fl_Menu_Item *m = menu_ + t; if (m->argument()==v) { return m; @@ -582,7 +588,8 @@ void Fl_Menu_::clear() { // not to free() images or Fl_Multi_Label's because they can // either be static or are allocated by operator new. - for (int i = size(); i--;) { + int i; + for (i = size(); i--;) { if (!menu_[i].text) continue; switch(menu_[i].labeltype_) { diff --git a/src/Fl_Menu_add.cxx b/src/Fl_Menu_add.cxx index 08a9153d9..1519602a4 100644 --- a/src/Fl_Menu_add.cxx +++ b/src/Fl_Menu_add.cxx @@ -498,7 +498,8 @@ void Fl_Menu_::remove(int i) { const Fl_Menu_Item* next_item = item->next(); // delete the text only if all items were created with add(): if (alloc > 1) { - for (Fl_Menu_Item* m = item; m < next_item; m++) + Fl_Menu_Item *m; + for (m = item; m < next_item; m++) if (m->text) free((void*)(m->text)); } // MRS: "n" is the menu size(), which includes the trailing NULL entry... diff --git a/src/Fl_Message.cxx b/src/Fl_Message.cxx index d3112c562..78cf03951 100644 --- a/src/Fl_Message.cxx +++ b/src/Fl_Message.cxx @@ -180,7 +180,8 @@ Fl_Message::Fl_Message(const char *iconlabel) // create the buttons (positions: right to left) // button 1 is a return button - for (int b = 0, x = 310; b < 3; b++, x -= 100) { + int b, x; + for (b = 0, x = 310; b < 3; b++, x -= 100) { if (b == 1) { button_[b] = new Fl_Return_Button(x, 70, 90, 23); } else { @@ -192,7 +193,7 @@ Fl_Message::Fl_Message(const char *iconlabel) // add the buttons left to right for tab navigation - for (int b = 2; b >= 0; b--) { + for (b = 2; b >= 0; b--) { window_->add(button_[b]); } diff --git a/src/Fl_Native_File_Chooser.cxx b/src/Fl_Native_File_Chooser.cxx index 2cafb019b..c5761f8c3 100644 --- a/src/Fl_Native_File_Chooser.cxx +++ b/src/Fl_Native_File_Chooser.cxx @@ -75,7 +75,8 @@ int Fl_Native_File_Chooser::options() const { \code if ( fnfc->show() == 0 ) { // Print all filenames user selected - for (int n=0; n<fnfc->count(); n++ ) { + int n; + for (n =0; n<fnfc->count(); n++ ) { printf("%d) '%s'\n", n, fnfc->filename(n)); } } @@ -103,7 +104,8 @@ const char *Fl_Native_File_Chooser::filename() const { \code if ( fnfc->show() == 0 ) { // Print all filenames user selected - for (int n=0; n<fnfc->count(); n++ ) { + int n; + for (n =0; n<fnfc->count(); n++ ) { printf("%d) '%s'\n", n, fnfc->filename(n)); } } diff --git a/src/Fl_Native_File_Chooser_Kdialog.cxx b/src/Fl_Native_File_Chooser_Kdialog.cxx index 68cb4729e..f4039366c 100644 --- a/src/Fl_Native_File_Chooser_Kdialog.cxx +++ b/src/Fl_Native_File_Chooser_Kdialog.cxx @@ -47,7 +47,8 @@ Fl_Kdialog_Native_File_Chooser_Driver::Fl_Kdialog_Native_File_Chooser_Driver(int Fl_Kdialog_Native_File_Chooser_Driver::~Fl_Kdialog_Native_File_Chooser_Driver() { - for (int i = 0; i < _tpathnames; i++) delete[] _pathnames[i]; + int i; + for (i = 0; i < _tpathnames; i++) delete[] _pathnames[i]; delete[] _pathnames; if (_preset_file) free(_preset_file); if (_directory) free(_directory); @@ -122,6 +123,7 @@ void Fl_Kdialog_Native_File_Chooser_Driver::build_command(char *command, int max int Fl_Kdialog_Native_File_Chooser_Driver::show() { + int i; if (_btype == Fl_Native_File_Chooser::BROWSE_MULTI_DIRECTORY) { // BROWSE_MULTI_DIRECTORY is not supported by kdialog, run GTK chooser instead Fl_Native_File_Chooser fnfc(Fl_Native_File_Chooser::BROWSE_MULTI_DIRECTORY); @@ -131,12 +133,12 @@ int Fl_Kdialog_Native_File_Chooser_Driver::show() { fnfc.filter(filter()); fnfc.options(options()); int retval = fnfc.show(); - for (int i = 0; i < _tpathnames; i++) delete[] _pathnames[i]; + for (i = 0; i < _tpathnames; i++) delete[] _pathnames[i]; delete[] _pathnames; _pathnames = NULL; _tpathnames = fnfc.count(); if (_tpathnames && retval == 0) { _pathnames = new char*[_tpathnames]; - for (int i = 0; i < _tpathnames; i++) { + for (i = 0; i < _tpathnames; i++) { _pathnames[i] = new char[strlen(fnfc.filename(i))+1]; strcpy(_pathnames[i], fnfc.filename(i)); } @@ -167,7 +169,7 @@ int Fl_Kdialog_Native_File_Chooser_Driver::show() { if (data.all_files) { // process text received from pipe if (data.all_files[strlen(data.all_files)-1] == '\n') data.all_files[strlen(data.all_files)-1] = 0; - for (int i = 0; i < _tpathnames; i++) delete[] _pathnames[i]; + for (i = 0; i < _tpathnames; i++) delete[] _pathnames[i]; delete[] _pathnames; char *p = data.all_files; int count = 1; diff --git a/src/Fl_Pack.cxx b/src/Fl_Pack.cxx index f28218c20..26e4f3ecb 100644 --- a/src/Fl_Pack.cxx +++ b/src/Fl_Pack.cxx @@ -75,11 +75,12 @@ void Fl_Pack::draw() { int maximum_position = current_position; uchar d = damage(); Fl_Widget*const* a = array(); + int i; if (horizontal()) { rw = -spacing_; rh = th; - for (int i = children(); i--;) + for (i = children(); i--;) if (child(i)->visible()) { if (child(i) != this->resizable()) rw += child(i)->w(); rw += spacing_; @@ -88,13 +89,13 @@ void Fl_Pack::draw() { rw = tw; rh = -spacing_; - for (int i = children(); i--;) + for (i = children(); i--;) if (child(i)->visible()) { if (child(i) != this->resizable()) rh += child(i)->h(); rh += spacing_; } } - for (int i = children(); i--;) { + for (i = children(); i--;) { Fl_Widget* o = *a++; if (o->visible()) { int X,Y,W,H; diff --git a/src/Fl_Pixmap.cxx b/src/Fl_Pixmap.cxx index 2b59a86ad..7a9f5f907 100644 --- a/src/Fl_Pixmap.cxx +++ b/src/Fl_Pixmap.cxx @@ -302,7 +302,8 @@ void Fl_Pixmap::color_average(Fl_Color c, float i) { void Fl_Pixmap::delete_data() { if (alloc_data) { - for (int i = 0; i < count(); i ++) delete[] (char *)data()[i]; + int i; + for (i = 0; i < count(); i ++) delete[] (char *)data()[i]; delete[] (char **)data(); } } diff --git a/src/Fl_Preferences.cxx b/src/Fl_Preferences.cxx index ca0b17916..56ed070a1 100644 --- a/src/Fl_Preferences.cxx +++ b/src/Fl_Preferences.cxx @@ -1000,7 +1000,8 @@ static void *decodeHex( const char *src, int &size ) { size = (int) strlen( src )/2; unsigned char *data = (unsigned char*)malloc( size ), *d = data; const char *s = src; - for ( int i=size; i>0; i-- ) { + int i; + for (i =size; i>0; i-- ) { int v; char x = tolower(*s++); if ( x >= 'a' ) v = x-'a'+10; else v = x-'0'; @@ -1517,7 +1518,8 @@ Fl_Preferences::Node::Node( const char *path ) { void Fl_Preferences::Node::deleteAllChildren() { Node *next_node = NULL; - for ( Node *current_node = first_child_; current_node; current_node = next_node ) { + Node *current_node; + for (current_node = first_child_; current_node; current_node = next_node ) { next_node = current_node->next_; delete current_node; } @@ -1528,7 +1530,8 @@ void Fl_Preferences::Node::deleteAllChildren() { void Fl_Preferences::Node::deleteAllEntries() { if ( entry_ ) { - for ( int i = 0; i < nEntry_; i++ ) { + int i; + for (i = 0; i < nEntry_; i++ ) { if ( entry_[i].name ) { ::free( entry_[i].name ); entry_[i].name = NULL; @@ -1583,7 +1586,8 @@ void Fl_Preferences::Node::clearDirtyFlags() { int Fl_Preferences::Node::write( FILE *f ) { if ( next_ ) next_->write( f ); fprintf( f, "\n[%s]\n\n", path_ ); - for ( int i = 0; i < nEntry_; i++ ) { + int i; + for (i = 0; i < nEntry_; i++ ) { char *src = entry_[i].value; if ( src ) { // hack it into smaller pieces if needed fprintf( f, "%s:", entry_[i].name ); @@ -1645,7 +1649,8 @@ Fl_Preferences::Node *Fl_Preferences::Node::addChild( const char *path ) { // create and set, or change an entry within this node void Fl_Preferences::Node::set( const char *name, const char *value ) { - for ( int i=0; i<nEntry_; i++ ) { + int i; + for (i =0; i<nEntry_; i++ ) { if ( strcmp( name, entry_[i].name ) == 0 ) { if ( !value ) return; // annotation if ( strcmp( value, entry_[i].value ) != 0 ) { @@ -1710,7 +1715,8 @@ const char *Fl_Preferences::Node::get( const char *name ) { // find the index of an entry, returns -1 if no such entry int Fl_Preferences::Node::getEntry( const char *name ) { - for ( int i=0; i<nEntry_; i++ ) { + int i; + for (i =0; i<nEntry_; i++ ) { if ( strcmp( name, entry_[i].name ) == 0 ) { return i; } @@ -1784,7 +1790,8 @@ Fl_Preferences::Node *Fl_Preferences::Node::search( const char *path, int offset if ( len > 0 && path[ len ] == 0 ) return this; if ( len <= 0 || path[ len ] == '/' ) { - for ( Node *nd = first_child_; nd; nd = nd->next_ ) { + Node *nd; + for (nd = first_child_; nd; nd = nd->next_ ) { Node *nn = nd->search( path, offset ); if ( nn ) return nn; } @@ -1800,7 +1807,8 @@ int Fl_Preferences::Node::nChildren() { return nIndex_; } else { int cnt = 0; - for ( Node *nd = first_child_; nd; nd = nd->next_ ) + Node *nd; + for (nd = first_child_; nd; nd = nd->next_ ) cnt++; return cnt; } diff --git a/src/Fl_Roller.cxx b/src/Fl_Roller.cxx index 03e665314..15067191f 100644 --- a/src/Fl_Roller.cxx +++ b/src/Fl_Roller.cxx @@ -100,11 +100,13 @@ void Fl_Roller::draw() { int offset = step() ? int(value()/step()) : 0; const double ARC = 1.5; // 1/2 the number of radians visible const double delta = .2; // radians per knurl + int i; + double yy; if (horizontal()) { // horizontal one // draw shaded ends of wheel: int h1 = W/4+1; // distance from end that shading starts fl_color(color()); fl_rectf(X+h1,Y,W-2*h1,H); - for (int i=0; h1; i++) { + for (i =0; h1; i++) { fl_color((Fl_Color)(FL_GRAY-i-1)); int h2 = FL_GRAY-i-1 > FL_DARK3 ? 2*h1/3+1 : 0; fl_rectf(X+h2,Y,h1-h2,H); @@ -114,7 +116,7 @@ void Fl_Roller::draw() { if (active_r()) { // draw ridges: double junk; - for (double yy = -ARC+modf(offset*sin(ARC)/(W/2)/delta,&junk)*delta;; + for (yy = -ARC+modf(offset*sin(ARC)/(W/2)/delta,&junk)*delta;; yy += delta) { int yy1 = int((sin(yy)/sin(ARC)+1)*W/2); if (yy1 <= 0) continue; else if (yy1 >= W-1) break; @@ -138,7 +140,7 @@ void Fl_Roller::draw() { // draw shaded ends of wheel: int h1 = H/4+1; // distance from end that shading starts fl_color(color()); fl_rectf(X,Y+h1,W,H-2*h1); - for (int i=0; h1; i++) { + for (i =0; h1; i++) { fl_color((Fl_Color)(FL_GRAY-i-1)); int h2 = FL_GRAY-i-1 > FL_DARK3 ? 2*h1/3+1 : 0; fl_rectf(X,Y+h2,W,h1-h2); @@ -148,7 +150,7 @@ void Fl_Roller::draw() { if (active_r()) { // draw ridges: double junk; - for (double yy = -ARC+modf(offset*sin(ARC)/(H/2)/delta,&junk)*delta; + for (yy = -ARC+modf(offset*sin(ARC)/(H/2)/delta,&junk)*delta; ; yy += delta) { int yy1 = int((sin(yy)/sin(ARC)+1)*H/2); if (yy1 <= 0) continue; else if (yy1 >= H-1) break; diff --git a/src/Fl_Scheme.cxx b/src/Fl_Scheme.cxx index 0f4b39fb2..ce5dc5387 100644 --- a/src/Fl_Scheme.cxx +++ b/src/Fl_Scheme.cxx @@ -126,7 +126,8 @@ int Fl_Scheme::add_scheme_name(const char *name) { if (nlen > 12) return (-2); - for (int i = 0; i < nlen; i++) { + int i; + for (i = 0; i < nlen; i++) { if ((name[i] >= 'a' && name[i] <= 'z') || (name[i] >= '0' && name[i] <= '9')) continue; @@ -139,7 +140,7 @@ int Fl_Scheme::add_scheme_name(const char *name) { // hence we can use the faster strcmp() for comparison. const char **s = names(); - for (int i = 0; i < num_schemes_; i++) { + for (i = 0; i < num_schemes_; i++) { if (strcmp(name, s[i]) == 0) return 0; } diff --git a/src/Fl_Screen_Driver.cxx b/src/Fl_Screen_Driver.cxx index 3a25f6ec7..a091cea62 100644 --- a/src/Fl_Screen_Driver.cxx +++ b/src/Fl_Screen_Driver.cxx @@ -145,7 +145,8 @@ int Fl_Screen_Driver::screen_num(int x, int y) int screen = 0; if (num_screens < 0) init(); - for (int i = 0; i < num_screens; i ++) { + int i; + for (i = 0; i < num_screens; i ++) { int sx, sy, sw, sh; screen_xywh(sx, sy, sw, sh, i); if ((x >= sx) && (x < (sx+sw)) && (y >= sy) && (y < (sy+sh))) { @@ -176,7 +177,8 @@ int Fl_Screen_Driver::screen_num(int x, int y, int w, int h) int best_screen = 0; float best_intersection = 0.; if (num_screens < 0) init(); - for (int i = 0; i < num_screens; i++) { + int i; + for (i = 0; i < num_screens; i++) { int sx = 0, sy = 0, sw = 0, sh = 0; screen_xywh(sx, sy, sw, sh, i); float sintersection = fl_intersection(x, y, w, h, sx, sy, sw, sh); @@ -234,10 +236,12 @@ Image depths can differ between "to" and "from". uchar *tobytes = (uchar*)to->array + to_y * to_ld + to_x * to->d(); const uchar *frombytes = from->array; int need_alpha = (from->d() == 3 && to->d() == 4); - for (int i = 0; i < from->h(); i++) { + int i; + for (i = 0; i < from->h(); i++) { if (from->d() == to->d()) memcpy(tobytes, frombytes, from->w() * from->d()); else { - for (int j = 0; j < from->w(); j++) { + int j; + for (j = 0; j < from->w(); j++) { memcpy(tobytes + j * to->d(), frombytes + j * from->d(), from->d()); if (need_alpha) *(tobytes + j * to->d() + 3) = 0xff; } @@ -281,7 +285,8 @@ Fl_RGB_Image *Fl_Screen_Driver::traverse_to_gl_subwindows(Fl_Group *g, int x, in if (!full_img) return NULL; float full_img_scale = (full_img && w > 0 ? float(full_img->data_w())/w : 1); int n = (captured_subwin ? 0 : g->children()); - for (int i = 0; i < n; i++) { + int i; + for (i = 0; i < n; i++) { Fl_Widget *c = g->child(i); if ( !c->visible() || !c->as_group()) continue; if ( c->as_window() ) { @@ -564,7 +569,8 @@ int Fl_Screen_Driver::scale_handler(int event) if (f == old_f) return 1; if (screen_dr->rescalable() == SYSTEMWIDE_APP_SCALING) { float old_f = screen_dr->scale(0); - for (int i = 0; i < Fl::screen_count(); i++) { + int i; + for (i = 0; i < Fl::screen_count(); i++) { screen_dr->rescale_all_windows_from_screen(i, f * initial_scale, old_f); } } else { @@ -587,11 +593,12 @@ void Fl_Screen_Driver::use_startup_scale_factor() if ((p = fl_getenv("FLTK_SCALING_FACTOR"))) { float factor = 1; sscanf(p, "%f", &factor); + int i; if (rescalable() == SYSTEMWIDE_APP_SCALING) { float new_val = factor * scale(0); - for (int i = 0; i < s_count; i++) scale(i, new_val); + for (i = 0; i < s_count; i++) scale(i, new_val); } else { - for (int i = 0; i < s_count; i++) scale(i, factor * scale(i)); + for (i = 0; i < s_count; i++) scale(i, factor * scale(i)); } } } diff --git a/src/Fl_Scroll.cxx b/src/Fl_Scroll.cxx index f64dbb952..951d5daae 100644 --- a/src/Fl_Scroll.cxx +++ b/src/Fl_Scroll.cxx @@ -169,7 +169,8 @@ void Fl_Scroll::draw_clip(void* v,int X, int Y, int W, int H) { // draw visible children Fl_Widget*const* a = s->array(); - for (int i=s->children()-2; i--;) { + int i; + for (i =s->children()-2; i--;) { Fl_Widget& o = **a++; s->draw_child(o); s->draw_outside_label(o); @@ -208,7 +209,8 @@ void Fl_Scroll::recalc_scrollbars(ScrollInfo &si) const { si.child.t = si.innerbox.y; int first = 1; Fl_Widget*const* a = array(); - for (int i=children(); i--;) { + int i; + for (i =children(); i--;) { Fl_Widget* o = *a++; if ( o==&scrollbar || o==&hscrollbar || o->visible()==0 ) continue; if ( first ) { @@ -340,6 +342,7 @@ void Fl_Scroll::draw() { draw_box(box(),x(),y(),w(),h(),color()); draw_clip(this, X, Y, W, H); } else { + int i; if (d & FL_DAMAGE_SCROLL) { // scroll the contents: fl_scroll(X, Y, W, H, oldx-xposition_, oldy-yposition_, draw_clip, this); @@ -351,7 +354,7 @@ void Fl_Scroll::draw() { R = 0; T = 999999; B = 0; - for (int i=children()-2; i--; a++) { + for (i =children()-2; i--; a++) { if ((*a)->x() < L) L = (*a)->x(); if (((*a)->x() + (*a)->w()) > R) R = (*a)->x() + (*a)->w(); if ((*a)->y() < T) T = (*a)->y(); @@ -365,7 +368,7 @@ void Fl_Scroll::draw() { if (d & FL_DAMAGE_CHILD) { // draw damaged children fl_push_clip(X, Y, W, H); Fl_Widget*const* a = array(); - for (int i=children()-2; i--;) update_child(**a++); + for (i =children()-2; i--;) update_child(**a++); fl_pop_clip(); } } @@ -454,7 +457,8 @@ void Fl_Scroll::resize(int X, int Y, int W, int H) { fix_scrollbar_order(); // move all the children: Fl_Widget*const* a = array(); - for (int i=children()-2; i--;) { + int i; + for (i =children()-2; i--;) { Fl_Widget* o = *a++; o->position(o->x()+dx, o->y()+dy); } @@ -493,7 +497,8 @@ void Fl_Scroll::scroll_to(int X, int Y) { xposition_ = X; yposition_ = Y; Fl_Widget*const* a = array(); - for (int i=children(); i--;) { + int i; + for (i =children(); i--;) { Fl_Widget* o = *a++; if (o == &hscrollbar || o == &scrollbar) continue; o->position(o->x()+dx, o->y()+dy); diff --git a/src/Fl_Shared_Image.cxx b/src/Fl_Shared_Image.cxx index 82e9be050..ae2bc859a 100644 --- a/src/Fl_Shared_Image.cxx +++ b/src/Fl_Shared_Image.cxx @@ -703,7 +703,8 @@ void Fl_Shared_Image::remove_handler(Fl_Shared_Handler f) { */ void Fl_Shared_Image::print_pool() { printf("Fl_Shared_Image: %d images stored in a pool of %d\n", num_images_, alloc_images_); - for (int i=0; i<num_images_; i++) { + int i; + for (i =0; i<num_images_; i++) { Fl_Shared_Image *img = images_[i]; printf("%3d: %3d(%c) %4dx%4d: %s\n", i, diff --git a/src/Fl_Slider.cxx b/src/Fl_Slider.cxx index f1d0444ac..52fcdaa94 100644 --- a/src/Fl_Slider.cxx +++ b/src/Fl_Slider.cxx @@ -227,7 +227,8 @@ void Fl_Slider::draw_ticks(const Fl_Rect& r, int /*S*/ /*, int min_spacing*/) fl_color(black); int n = num_ticks(); double nd = (double)(n-1); - for (int i=0; i<n; i++) { + int i; + for (i =0; i<n; i++) { double v = i / nd; if (scale() == LOG_SCALE) { v = position_to_value(1.0-v); diff --git a/src/Fl_System_Driver.cxx b/src/Fl_System_Driver.cxx index c93794711..980273443 100644 --- a/src/Fl_System_Driver.cxx +++ b/src/Fl_System_Driver.cxx @@ -252,7 +252,8 @@ int Fl_System_Driver::filename_expand(char *to,int tolen, const char *from) { int ret = 0; - for (char *a=temp; a<end; ) { // for each slash component + char *a; + for (a =temp; a<end; ) { // for each slash component char *e; for (e=a; e<end && *e != '/'; e++) {/*empty*/} // find next slash const char *value = 0; // this will point at substitute value switch (*a) { diff --git a/src/Fl_Table.cxx b/src/Fl_Table.cxx index e19fc2fbe..c238a8d1d 100644 --- a/src/Fl_Table.cxx +++ b/src/Fl_Table.cxx @@ -76,7 +76,8 @@ long Fl_Table::row_scroll_position(int row) { scroll = toprow_scrollpos; startrow = toprow; } - for ( int t=startrow; t<row; t++ ) { + int t; + for (t =startrow; t<row; t++ ) { scroll += row_height(t); } return(scroll); @@ -95,7 +96,8 @@ long Fl_Table::col_scroll_position(int col) { scroll = leftcol_scrollpos; startcol = leftcol; } - for ( int t=startcol; t<col; t++ ) { + int t; + for (t =startcol; t<col; t++ ) { scroll += col_width(t); } return(scroll); @@ -1339,8 +1341,10 @@ void Fl_Table::draw() { // Only redraw a few cells? if ( ! ( damage() & FL_DAMAGE_ALL ) && _redraw_leftcol != -1 ) { fl_push_clip(tix, tiy, tiw, tih); - for ( int c = _redraw_leftcol; c <= _redraw_rightcol; c++ ) { - for ( int r = _redraw_toprow; r <= _redraw_botrow; r++ ) { + int c; + for (c = _redraw_leftcol; c <= _redraw_rightcol; c++ ) { + int r; + for (r = _redraw_toprow; r <= _redraw_botrow; r++ ) { _redraw_cell(CONTEXT_CELL, r, c); } } @@ -1348,11 +1352,12 @@ void Fl_Table::draw() { } if ( damage() & FL_DAMAGE_ALL ) { int X,Y,W,H; + int r, c; // Draw row headers, if any if ( row_header() ) { get_bounds(CONTEXT_ROW_HEADER, X, Y, W, H); fl_push_clip(X,Y,W,H); - for ( int r = toprow; r <= botrow; r++ ) { + for (r = toprow; r <= botrow; r++ ) { _redraw_cell(CONTEXT_ROW_HEADER, r, 0); } fl_pop_clip(); @@ -1361,7 +1366,7 @@ void Fl_Table::draw() { if ( col_header() ) { get_bounds(CONTEXT_COL_HEADER, X, Y, W, H); fl_push_clip(X,Y,W,H); - for ( int c = leftcol; c <= rightcol; c++ ) { + for (c = leftcol; c <= rightcol; c++ ) { _redraw_cell(CONTEXT_COL_HEADER, 0, c); } fl_pop_clip(); @@ -1373,8 +1378,8 @@ void Fl_Table::draw() { // drawing over deadzones; prevent deadzones by sizing columns. // fl_push_clip(tix, tiy, tiw, tih); { - for ( int r = toprow; r <= botrow; r++ ) { - for ( int c = leftcol; c <= rightcol; c++ ) { + for (r = toprow; r <= botrow; r++ ) { + for (c = leftcol; c <= rightcol; c++ ) { _redraw_cell(CONTEXT_CELL, r, c); } } diff --git a/src/Fl_Table_Row.cxx b/src/Fl_Table_Row.cxx index d07db7ac7..9bf665eab 100644 --- a/src/Fl_Table_Row.cxx +++ b/src/Fl_Table_Row.cxx @@ -114,7 +114,8 @@ int Fl_Table_Row::select_row(int row, int flag) { case SELECT_SINGLE: { int oldval; - for ( int t=0; t<rows(); t++ ) { + int t; + for (t =0; t<rows(); t++ ) { if ( t == row ) { oldval = _rowselect[row]; if ( flag == 2 ) { _rowselect[row] ^= 1; } @@ -254,7 +255,8 @@ int Fl_Table_Row::handle(int event) { srow = _last_row; erow = R; } - for ( int row = srow; row <= erow; row++ ) { + int row; + for (row = srow; row <= erow; row++ ) { select_row(row, 1); } } @@ -320,7 +322,8 @@ int Fl_Table_Row::handle(int event) { srow = _last_row; erow = R; } - for ( int row = srow; row <= erow; row++ ) { + int row; + for (row = srow; row <= erow; row++ ) { select_row(row, 1); } } diff --git a/src/Fl_Tabs.cxx b/src/Fl_Tabs.cxx index 7d48d78d1..96ad87f90 100644 --- a/src/Fl_Tabs.cxx +++ b/src/Fl_Tabs.cxx @@ -260,7 +260,8 @@ int Fl_Tabs::tab_height() { int H = h(); int H2 = y(); Fl_Widget*const* a = array(); - for (int i=children(); i--;) { + int i; + for (i =children(); i--;) { Fl_Widget* o = *a++; if (o->y() < y()+H) H = o->y()-y(); if (o->y()+o->h() > H2) H2 = o->y()+o->h(); @@ -292,7 +293,8 @@ Fl_Widget *Fl_Tabs::which(int event_x, int event_y) { Fl_Widget *ret = 0L; const int nc = children(); tab_positions(); - for (int i=0; i<nc; i++) { + int i; + for (i =0; i<nc; i++) { if (event_x < x()+tab_pos[i+1]+tab_offset) { ret = child(i); break; @@ -314,7 +316,8 @@ Fl_Widget *Fl_Tabs::which(int event_x, int event_y) { */ int Fl_Tabs::hit_close(Fl_Widget *o, int event_x, int event_y) { (void)event_y; - for (int i=0; i<children(); i++) { + int i; + for (i =0; i<children(); i++) { if (child(i)==o) { // never hit the "close" button on a compressed tab unless it's the active one if (tab_flags[i] & 1) @@ -721,7 +724,8 @@ int Fl_Tabs::push(Fl_Widget *o) { Fl_Widget* Fl_Tabs::value() { Fl_Widget* v = 0; Fl_Widget*const* a = array(); - for (int i=children(); i--;) { + int i; + for (i =children(); i--;) { Fl_Widget* o = *a++; if (v) o->hide(); else if (o->visible()) v = o; @@ -746,7 +750,8 @@ int Fl_Tabs::value(Fl_Widget *newvalue) { Fl_Widget*const* a = array(); int ret = 0; int selected = -1; - for (int i=children(); i--;) { + int i; + for (i =children(); i--;) { Fl_Widget* o = *a++; if (o == newvalue) { if (!o->visible()) ret = 1; diff --git a/src/Fl_Terminal.cxx b/src/Fl_Terminal.cxx index ef57749cf..99ac7a6f2 100644 --- a/src/Fl_Terminal.cxx +++ b/src/Fl_Terminal.cxx @@ -743,7 +743,8 @@ void Fl_Terminal::RingBuffer::new_copy(int drows, int dcols, int hrows, const Ch while ((src_row >= src_stop_row) && (dst_row >= 0)) { Utf8Char *src = u8c_ring_row(src_row); Utf8Char *dst = new_ring_chars + (dst_row*dst_cols); - for (int col=0; col<tcols; col++ ) *dst++ = *src++; + int col; + for (col =0; col<tcols; col++ ) *dst++ = *src++; --src_row; --dst_row; } @@ -826,15 +827,18 @@ bool Fl_Terminal::RingBuffer::is_disp_ring_row(int grow) const { void Fl_Terminal::RingBuffer::move_disp_row(int src_row, int dst_row) { Utf8Char *src = u8c_disp_row(src_row); Utf8Char *dst = u8c_disp_row(dst_row); - for (int col=0; col<disp_cols(); col++) *dst++ = *src++; + int col; + for (col =0; col<disp_cols(); col++) *dst++ = *src++; } // Clear the display rows 'sdrow' thru 'edrow' inclusive using specified CharStyle 'style' void Fl_Terminal::RingBuffer::clear_disp_rows(int sdrow, int edrow, const CharStyle& style) { - for (int drow=sdrow; drow<=edrow; drow++) { + int drow; + for (drow =sdrow; drow<=edrow; drow++) { int row = hist_rows_ + drow + offset_; Utf8Char *u8c = u8c_ring_row(row); - for (int col=0; col<disp_cols(); col++) u8c++->clear(style); + int col; + for (col =0; col<disp_cols(); col++) u8c++->clear(style); } } @@ -896,7 +900,8 @@ void Fl_Terminal::RingBuffer::scroll(int rows, const CharStyle& style) { // Memory // move rows = clamp(-rows, 1, disp_rows()); // make rows positive + sane - for (int row=disp_rows()-1; row>=0; row--) { // start at end of disp and work up + int row; + for (row =disp_rows()-1; row>=0; row--) { // start at end of disp and work up int src_row = (row - rows); // src is offset #rows being scrolled int dst_row = row; // dst is display if (src_row >= 0) move_disp_row(src_row, dst_row); // ok to move row? move row down @@ -1086,9 +1091,11 @@ const Fl_Terminal::Utf8Char* Fl_Terminal::u8c_disp_row(int drow) const // For walking the terminal lines in order, see examples // for u8c_hist_use_row() and u8c_disp_row(). // - for (int row=0; row<ring_rows(); row++) { + int row; + for (row =0; row<ring_rows(); row++) { Utf8Char *u8c = u8c_ring_row(row); - for (int col=0; col<ring_cols(); col++,u8c++) { + int col; + for (col =0; col<ring_cols(); col++,u8c++) { ..make use of u8c->xxx() methods.. } } @@ -1118,9 +1125,9 @@ Fl_Terminal::Utf8Char* Fl_Terminal::u8c_hist_row(int hrow) Example to walk all "in use" lines of the history buffer: \code // Walk the entire screen history ("in use") and display to stdout - for (int row=0; row<hist_use(); row++) { + for (row =0; row<hist_use(); row++) { const Utf8Char *u8c = u8c_hist_use_row(row); // first char in row - for (int col=0; col<=hist_cols(); col++,u8c++) { // walk columns left-to-right + for (col =0; col<=hist_cols(); col++,u8c++) { // walk columns left-to-right // ..Do things here with each u8c char.. ::printf("%.*s", u8c->length(), u8c->text_utf8()); // show each utf8 char to stdout } @@ -1141,7 +1148,7 @@ Fl_Terminal::Utf8Char* Fl_Terminal::u8c_hist_use_row(int hurow) // Print all chars in first row of display (ASCII and UTF-8) Utf8Char *u8c = u8c_disp_row(0); // first char of first display row int scol = 0, ecol = disp_cols(); // start/end for column loop - for (int col=scol; col<ecol; col++,u8c++) { // loop from first char to last + for (col =scol; col<ecol; col++,u8c++) { // loop from first char to last char *text = u8c->text_utf8(); // text string for char int len = u8c->length(); // text string length for char ::printf("<%.*s>", len, text); // print potentially multibyte char @@ -1151,9 +1158,9 @@ Fl_Terminal::Utf8Char* Fl_Terminal::u8c_hist_use_row(int hurow) - This can also be used to walk all rows on the display screen up to the cursor row, e.g. \code // Write all chars in display up to cursor row to stdout - for (int row=0; row<disp_rows() && row<=cursor_row(); row++) { + for (row =0; row<disp_rows() && row<=cursor_row(); row++) { const Utf8Char *u8c = u8c_disp_row(row); // first char in row - for (int col=0; col<=display_cols(); col++,u8c++) { // walk columns left-to-right + for (col =0; col<=display_cols(); col++,u8c++) { // walk columns left-to-right // ..Do things here with each u8c char.. ::printf("%.*s", u8c->text_utf8(), u8c->length()); // write each utf8 char to stdout } @@ -1197,7 +1204,8 @@ void Fl_Terminal::init_tabstops(int newsize) { char *oldstops = tabstops_; // save old stops int oldsize = tabstops_size_; // save old size tabstops_ = (char*)malloc(newsize); // alloc new - for (int t=0; t<newsize; t++) { // init new tabstops: + int t; + for (t =0; t<newsize; t++) { // init new tabstops: tabstops_[t] = (oldstops && t<oldsize) ? oldstops[t] // copy old : ((t % 8) == 0) ? 1 : 0; // new defaults @@ -1212,7 +1220,8 @@ void Fl_Terminal::init_tabstops(int newsize) { // Reset all tabstops to default 8th char void Fl_Terminal::default_tabstops(void) { init_tabstops(ring_cols()); // issue #882 - for (int t=1; t<tabstops_size_; t++) // t=1: skip 0 + int t; + for (t =1; t<tabstops_size_; t++) // t=1: skip 0 tabstops_[t] = ((t % 8) == 0) ? 1 : 0; // every 8th char is a tabstop } @@ -1345,8 +1354,9 @@ void Fl_Terminal::refit_disp_to_screen(void) { scrollbar->value(0); // force scrollbar to bottom before refit if (drow_diff) { // change in display rows means shrink|enlarge + int i; if (is_enlarge) { // enlarging widget? - for (int i=0; i<drow_diff; i++) { // carefully loop thru each change + for (i =0; i<drow_diff; i++) { // carefully loop thru each change if (history_use() > 0) { // CASE 1: Drag lines down from history cursor_.scroll(-1); // cursor chases ring_.resize() } else { // CASE 2: add blank lines below cursor @@ -1356,7 +1366,7 @@ void Fl_Terminal::refit_disp_to_screen(void) { ring_.resize(display_rows()+1, dcols, hist_rows(), *current_style_); } } else { // shrinking widget? - for (int i=0; i<(-drow_diff); i++) { // carefully loop thru each row change + for (i =0; i<(-drow_diff); i++) { // carefully loop thru each row change int cur_row = cursor_.row(); // cursor row int below_cur = (drows > cur_row); // shrink is below cursor row? if (below_cur) { // CASE 3: shrinking below cursor? drop lines below @@ -1905,8 +1915,9 @@ void Fl_Terminal::clear(Fl_Color val) { */ void Fl_Terminal::clear_screen(bool scroll_to_hist) { if (scroll_to_hist) { scroll(disp_rows()); return; } - for (int drow=0; drow<disp_rows(); drow++) - for (int dcol=0; dcol<disp_cols(); dcol++) + int drow, dcol; + for (drow =0; drow<disp_rows(); drow++) + for (dcol =0; dcol<disp_cols(); dcol++) clear_char_at_disp(drow, dcol); clear_mouse_selection(); } @@ -1932,32 +1943,39 @@ void Fl_Terminal::clear_screen_home(bool scroll_to_hist) { /// Clear from cursor to Start Of Display (EOD), like \c "<ESC>[1J". void Fl_Terminal::clear_sod(void) { - for (int drow=0; drow <= cursor_.row(); drow++) - if (drow == cursor_.row()) - for (int dcol=0; dcol<=cursor_.col(); dcol++) + int drow, dcol; + for (drow =0; drow <= cursor_.row(); drow++) { + if (drow == cursor_.row()) { + for (dcol =0; dcol<=cursor_.col(); dcol++) plot_char(' ', drow, dcol); - else - for (int dcol=0; dcol<disp_cols(); dcol++) + } else { + for (dcol =0; dcol<disp_cols(); dcol++) plot_char(' ', drow, dcol); + } + } //TODO: Clear mouse selection? } /// Clear from cursor to End Of Display (EOD), like \c "<ESC>[J<ESC>[0J". void Fl_Terminal::clear_eod(void) { - for (int drow=cursor_.row(); drow<disp_rows(); drow++) - if (drow == cursor_.row()) - for (int dcol=cursor_.col(); dcol<disp_cols(); dcol++) + int drow, dcol; + for (drow =cursor_.row(); drow<disp_rows(); drow++) { + if (drow == cursor_.row()) { + for (dcol =cursor_.col(); dcol<disp_cols(); dcol++) plot_char(' ', drow, dcol); - else - for (int dcol=0; dcol<disp_cols(); dcol++) + } else { + for (dcol =0; dcol<disp_cols(); dcol++) plot_char(' ', drow, dcol); + } + } //TODO: Clear mouse selection? } /// Clear from cursor to End Of Line (EOL), like \c "<ESC>[K". void Fl_Terminal::clear_eol(void) { Utf8Char *u8c = u8c_disp_row(cursor_.row()) + cursor_.col(); // start at cursor - for (int col=cursor_.col(); col<disp_cols(); col++) // run from cursor to eol + int col; + for (col =cursor_.col(); col<disp_cols(); col++) // run from cursor to eol (u8c++)->clear(*current_style_); //TODO: Clear mouse selection? } @@ -1965,7 +1983,8 @@ void Fl_Terminal::clear_eol(void) { /// Clear from cursor to Start Of Line (SOL), like \c "<ESC>[1K". void Fl_Terminal::clear_sol(void) { Utf8Char *u8c = u8c_disp_row(cursor_.row()); // start at sol - for (int col=0; col<=cursor_.col(); col++) // run from sol to cursor + int col; + for (col =0; col<=cursor_.col(); col++) // run from sol to cursor (u8c++)->clear(*current_style_); //TODO: Clear mouse selection? } @@ -1973,7 +1992,8 @@ void Fl_Terminal::clear_sol(void) { /// Clear entire line for specified row. void Fl_Terminal::clear_line(int drow) { Utf8Char *u8c = u8c_disp_row(drow); // start at sol - for (int col=0; col<disp_cols(); col++) // run to eol + int col; + for (col =0; col<disp_cols(); col++) // run to eol (u8c++)->clear(*current_style_); //TODO: Clear mouse selection? } @@ -2045,12 +2065,14 @@ const Fl_Terminal::Utf8Char* Fl_Terminal::walk_selection( int srow,scol,erow,ecol; if (get_selection(srow,scol,erow,ecol)) { // mouse selection exists? // Walk entire selection from start to end - for (int row=srow; row<=erow; row++) { // walk rows of selection + int row; + for (row =srow; row<=erow; row++) { // walk rows of selection const Utf8Char *u8c = u8c_ring_row(row); // ptr to first character in row int col_start = (row==srow) ? scol : 0; // start row? start at scol int col_end = (row==erow) ? ecol : ring_cols(); // end row? end at ecol u8c += col_start; // include col offset (if any) - for (int col=col_start; col<=col_end; col++,u8c++) { // walk columns + int col; + for (col =col_start; col<=col_end; col++,u8c++) { // walk columns ..do something with each char at *u8c.. } } @@ -2235,15 +2257,16 @@ void Fl_Terminal::scroll(int rows) { void Fl_Terminal::insert_rows(int count) { int dst_drow = disp_rows()-1; // dst is bottom of display int src_drow = clamp((dst_drow-count), 1, (disp_rows()-1)); // src is count lines up from dst + int dcol; while (src_drow >= cursor_.row()) { // walk srcrow upwards to cursor row Utf8Char *src = u8c_disp_row(src_drow--); Utf8Char *dst = u8c_disp_row(dst_drow--); - for (int dcol=0; dcol<disp_cols(); dcol++) *dst++ = *src++; // move + for (dcol =0; dcol<disp_cols(); dcol++) *dst++ = *src++; // move } // Blank remaining rows upwards to and including cursor line while (dst_drow >= cursor_.row()) { // walk srcrow to curs line Utf8Char *dst = u8c_disp_row(dst_drow--); - for (int dcol=0; dcol<disp_cols(); dcol++) + for (dcol =0; dcol<disp_cols(); dcol++) dst++->clear(*current_style_); } clear_mouse_selection(); @@ -2257,16 +2280,17 @@ void Fl_Terminal::insert_rows(int count) { void Fl_Terminal::delete_rows(int count) { int dst_drow = cursor_.row(); // dst is cursor row int src_drow = clamp((dst_drow+count), 1, (disp_rows()-1)); // src is count rows below cursor + int dcol; while (src_drow < disp_rows()) { // walk srcrow to EOD Utf8Char *src = u8c_disp_row(src_drow++); Utf8Char *dst = u8c_disp_row(dst_drow++); - for (int dcol=0; dcol<disp_cols(); dcol++) + for (dcol =0; dcol<disp_cols(); dcol++) *dst++ = *src++; // move } // Blank remaining rows downwards to End Of Display while (dst_drow < disp_rows()) { // walk srcrow to EOD Utf8Char *dst = u8c_disp_row(dst_drow++); - for (int dcol=0; dcol<disp_cols(); dcol++) + for (dcol =0; dcol<disp_cols(); dcol++) dst++->clear(*current_style_); } clear_mouse_selection(); @@ -2298,7 +2322,8 @@ void Fl_Terminal::insert_char_eol(char c, int drow, int dcol, int rep) { const CharStyle &style = *current_style_; Utf8Char *src = u8c_disp_row(drow)+disp_cols()-1-rep; // start src at 'g' Utf8Char *dst = u8c_disp_row(drow)+disp_cols()-1; // start dst at 'j' - for (int col=(disp_cols()-1); col>=dcol; col--) { // loop col in reverse: eol -> dcol + int col; + for (col =(disp_cols()-1); col>=dcol; col--) { // loop col in reverse: eol -> dcol if (col >= (dcol+rep)) *dst-- = *src--; // let assignment do move else (dst--)->text_ascii(c,style);// assign chars displaced } @@ -2318,7 +2343,8 @@ void Fl_Terminal::delete_chars(int drow, int dcol, int rep) { if (rep == 0) return; const CharStyle &style = *current_style_; Utf8Char *u8c = u8c_disp_row(drow); - for (int col=dcol; col<disp_cols(); col++) // delete left-to-right + int col; + for (col =dcol; col<disp_cols(); col++) // delete left-to-right if (col+rep >= disp_cols()) u8c[col].text_ascii(' ', style); // blanks else u8c[col] = u8c[col+rep]; // move } @@ -2337,9 +2363,11 @@ void Fl_Terminal::clear_history(void) { ring_.clear_hist(); scrollbar->value(0); // zero scroll position // Clear entire history buffer - for (int hrow=0; hrow<hist_rows(); hrow++) { + int hrow; + for (hrow =0; hrow<hist_rows(); hrow++) { Utf8Char *u8c = u8c_hist_row(hrow); // walk history rows.. - for (int hcol=0; hcol<hist_cols(); hcol++) { // ..and history cols + int hcol; + for (hcol =0; hcol<hist_cols(); hcol++) { // ..and history cols (u8c++)->clear(*current_style_); } } @@ -2667,7 +2695,8 @@ void Fl_Terminal::handle_SGR(void) { // ESC[...m? int rgbcode = 0; // 0=none, 38=fg, 48=bg int rgbmode = 0; // 0=none, 1="2", 2=<r>, 3=<g>, 4=<b> int r=0,g=0,b=0; - for (int i=0; i<tot; i++) { // expect possibly many values + int i; + for (i =0; i<tot; i++) { // expect possibly many values int val = esc.val(i); // each val one at a time switch (rgbmode) { case 0: @@ -3602,7 +3631,8 @@ void Fl_Terminal::draw_row_bg(int grow, int X, int Y) const { int end_col = disp_cols(); const Utf8Char *u8c = u8c_ring_row(grow) + start_col; // start of spec'd row uchar lastattr = u8c->attrib(); - for (int gcol=start_col; gcol<end_col; gcol++,u8c++) { // walk columns + int gcol; + for (gcol =start_col; gcol<end_col; gcol++,u8c++) { // walk columns // Attribute changed since last char? if (gcol==0 || u8c->attrib() != lastattr) { u8c->fl_font_set(*current_style_); // pwidth_int() needs fl_font set @@ -3652,7 +3682,8 @@ void Fl_Terminal::draw_row(int grow, int Y) const { int start_col = hscrollbar->visible() ? hscrollbar->value() : 0; int end_col = disp_cols(); const Utf8Char *u8c = u8c_ring_row(grow) + start_col; - for (int gcol=start_col; gcol<end_col; gcol++,u8c++) { // walk the columns + int gcol; + for (gcol =start_col; gcol<end_col; gcol++,u8c++) { // walk the columns const int &dcol = gcol; // dcol and gcol are the same // Are we drawing the cursor? Only if inside display is_cursor = inside_display ? cursor_.is_rowcol(drow-scrollval, dcol) : 0; @@ -3711,7 +3742,8 @@ void Fl_Terminal::draw_buff(int Y) const { int srow = disp_srow() - scrollbar->value(); int erow = srow + disp_rows(); const int rowheight = current_style_->fontheight(); - for (int grow=srow; (grow<erow) && (Y<scrn_.b()); grow++) { + int grow; + for (grow =srow; (grow<erow) && (Y<scrn_.b()); grow++) { draw_row(grow, Y); // draw global row at Y Y += rowheight; // advance Y to bottom left corner of row } diff --git a/src/Fl_Text_Buffer.cxx b/src/Fl_Text_Buffer.cxx index 9aa099208..8411342d1 100644 --- a/src/Fl_Text_Buffer.cxx +++ b/src/Fl_Text_Buffer.cxx @@ -181,7 +181,8 @@ public: void clear() { if (locked_) return; if (list_) { - for (int i=0; i<list_size_; i++) { + int i; + for (i =0; i<list_size_; i++) { delete list_[i]; } ::free(list_); @@ -887,7 +888,8 @@ void Fl_Text_Buffer::add_modify_callback(Fl_Text_Modify_Cb bufModifiedCB, Fl_Text_Modify_Cb *newModifyProcs = new Fl_Text_Modify_Cb[mNModifyProcs + 1]; void **newCBArgs = new void *[mNModifyProcs + 1]; - for (int i = 0; i < mNModifyProcs; i++) { + int i; + for (i = 0; i < mNModifyProcs; i++) { newModifyProcs[i + 1] = mModifyProcs[i]; newCBArgs[i + 1] = mCbArgs[i]; } @@ -963,7 +965,8 @@ void Fl_Text_Buffer::add_predelete_callback(Fl_Text_Predelete_Cb bufPreDeleteCB, Fl_Text_Predelete_Cb *newPreDeleteProcs = new Fl_Text_Predelete_Cb[mNPredeleteProcs + 1]; void **newCBArgs = new void *[mNPredeleteProcs + 1]; - for (int i = 0; i < mNPredeleteProcs; i++) { + int i; + for (i = 0; i < mNPredeleteProcs; i++) { newPreDeleteProcs[i + 1] = mPredeleteProcs[i]; newCBArgs[i + 1] = mPredeleteCbArgs[i]; } @@ -1127,7 +1130,8 @@ int Fl_Text_Buffer::skip_displayed_characters(int lineStartPos, int nChars) int pos = lineStartPos; - for (int charCount = 0; charCount < nChars && pos < mLength; charCount++) { + int charCount; + for (charCount = 0; charCount < nChars && pos < mLength; charCount++) { unsigned int c = char_at(pos); if (c == '\n') return pos; @@ -1633,7 +1637,8 @@ void Fl_Text_Buffer::call_modify_callbacks(int pos, int nDeleted, int nInserted, int nRestyled, const char *deletedText) const { IS_UTF8_ALIGNED2(this, pos) - for (int i = 0; i < mNModifyProcs; i++) + int i; + for (i = 0; i < mNModifyProcs; i++) (*mModifyProcs[i]) (pos, nInserted, nDeleted, nRestyled, deletedText, mCbArgs[i]); } @@ -1644,7 +1649,8 @@ void Fl_Text_Buffer::call_modify_callbacks(int pos, int nDeleted, Unicode safe. */ void Fl_Text_Buffer::call_predelete_callbacks(int pos, int nDeleted) const { - for (int i = 0; i < mNPredeleteProcs; i++) + int i; + for (i = 0; i < mNPredeleteProcs; i++) (*mPredeleteProcs[i]) (pos, nDeleted, mPredeleteCbArgs[i]); } @@ -2078,7 +2084,8 @@ int Fl_Text_Buffer::prev_char_clipped(int pos) const const int l_t = 40; char t[l_t + 1]; t[l_t] = 0; int len = l_t, p = pos, ll; - for (int i = l_t; i > 0 && p > 0; i--) { + int i; + for (i = l_t; i > 0 && p > 0; i--) { t[--len] = byte_at(--p); ll = fl_utf8len(t[len]); if (ll == 1 || ll == 2) break; @@ -2123,7 +2130,8 @@ int Fl_Text_Buffer::next_char(int pos) const { t[len++] = b; ll = fl_utf8len1(b); count_points++; - for (int i = 1; i < ll && len < (int)sizeof(t); i++) t[len++] = byte_at(p++); + int i; + for (i = 1; i < ll && len < (int)sizeof(t); i++) t[len++] = byte_at(p++); if (count_points > 1 && (ll == 1 || ll == 2)) { // stop after short codepoint but not if it's the 1st codepoint which can be inside // emoji sequence (e.g. 9️⃣ "keycap 9") diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index 9e0aacc2f..650cf1b7d 100644 --- a/src/Fl_Text_Display.cxx +++ b/src/Fl_Text_Display.cxx @@ -131,7 +131,8 @@ Fl_Text_Display::Fl_Text_Display(int X, int Y, int W, int H, const char* l) mLineStarts = new int[mNVisibleLines]; #if VISIBLE_LINES_INIT > 1 { // Note: this code is unused unless mNVisibleLines is ever initialized > 1 - for (int i=1; i<mNVisibleLines; i++) mLineStarts[i] = -1; + int i; + for (i =1; i<mNVisibleLines; i++) mLineStarts[i] = -1; } #endif mLineStarts[0] = 0; @@ -462,7 +463,8 @@ void Fl_Text_Display::highlight_data(Fl_Text_Buffer *styleBuffer, */ int Fl_Text_Display::longest_vline() const { int longest = 0; - for (int i = 0; i < mNVisibleLines; i++) + int i; + for (i = 0; i < mNVisibleLines; i++) longest = max(longest, measure_vline(i)); return longest; } @@ -560,7 +562,8 @@ void Fl_Text_Display::recalc_display() { } // End of optimization, see comment above. - for (int again = 1; again;) { + int again; + for (again = 1; again;) { again = 0; /* In continuous wrap mode, a change in width affects the total number of lines in the buffer, and can leave the top line number incorrect, and @@ -2098,7 +2101,8 @@ int Fl_Text_Display::handle_vline( // In DRAW_LINE mode, the first iteration of the loop will draw all // backgrounds. The second iteration will draw the text, so that text // overlapping background color changes will not be clipped. - for (int loop=1; loop<=2; loop++) { + int loop; + for (loop =1; loop<=2; loop++) { int mask = (loop==1) ? BG_ONLY_MASK : TEXT_ONLY_MASK; startX = X; startIndex = 0; @@ -2623,7 +2627,8 @@ void Fl_Text_Display::draw_cursor( int X, int Y ) { } fl_color( mCursor_color ); - for ( int k = 0; k < nSegs; k++ ) { + int k; + for (k = 0; k < nSegs; k++ ) { fl_line( segs[ k ].x1, segs[ k ].y1, segs[ k ].x2, segs[ k ].y2 ); } diff --git a/src/Fl_Text_Editor.cxx b/src/Fl_Text_Editor.cxx index 205687c36..6bbb2a81d 100644 --- a/src/Fl_Text_Editor.cxx +++ b/src/Fl_Text_Editor.cxx @@ -147,7 +147,8 @@ static struct { /** Adds all of the default editor key bindings to the specified key binding list.*/ void Fl_Text_Editor::add_default_key_bindings(Key_Binding** list) { - for (int i = 0; default_key_bindings[i].key; i++) { + int i; + for (i = 0; default_key_bindings[i].key; i++) { add_key_binding(default_key_bindings[i].key, default_key_bindings[i].state, default_key_bindings[i].func, @@ -155,7 +156,7 @@ void Fl_Text_Editor::add_default_key_bindings(Key_Binding** list) { } Key_Binding *extra_key_bindings = Fl::screen_driver()->text_editor_extra_key_bindings; if (extra_key_bindings) { // add platform-specific key bindings, if any - for (int i = 0; extra_key_bindings[i].key; i++) { + for (i = 0; extra_key_bindings[i].key; i++) { add_key_binding(extra_key_bindings[i].key, extra_key_bindings[i].state, extra_key_bindings[i].function, diff --git a/src/Fl_Tile.cxx b/src/Fl_Tile.cxx index 0eb7e0a70..2f84a9a22 100644 --- a/src/Fl_Tile.cxx +++ b/src/Fl_Tile.cxx @@ -177,7 +177,8 @@ static int fl_max(int a, int b) { return a>b ? a : b; } void Fl_Tile::request_shrink_l(int old_l, int &new_l, Fl_Rect *final_size) { Fl_Rect *p = bounds(); int min_l = new_l; - for (int i=0; i<children(); i++) { + int i; + for (i =0; i<children(); i++) { Fl_Rect *ri = p+i+2; if (ri->x() == old_l) { if (ri->w() == 0) { @@ -224,7 +225,8 @@ void Fl_Tile::request_shrink_l(int old_l, int &new_l, Fl_Rect *final_size) { void Fl_Tile::request_shrink_r(int old_r, int &new_r, Fl_Rect *final_size) { Fl_Rect *p = bounds(); int min_r = new_r; - for (int i=0; i<children(); i++) { + int i; + for (i =0; i<children(); i++) { Fl_Rect *ri = p+i+2; if (ri->r() == old_r) { if (ri->w() == 0) { @@ -271,7 +273,8 @@ void Fl_Tile::request_shrink_r(int old_r, int &new_r, Fl_Rect *final_size) { void Fl_Tile::request_shrink_t(int old_t, int &new_t, Fl_Rect *final_size) { Fl_Rect *p = bounds(); int min_y = new_t; - for (int i=0; i<children(); i++) { + int i; + for (i =0; i<children(); i++) { Fl_Rect *ri = p+i+2; if (ri->y() == old_t) { if (ri->h() == 0) { @@ -318,7 +321,8 @@ void Fl_Tile::request_shrink_t(int old_t, int &new_t, Fl_Rect *final_size) { void Fl_Tile::request_shrink_b(int old_b, int &new_b, Fl_Rect *final_size) { Fl_Rect *p = bounds(); int min_b = new_b; - for (int i=0; i<children(); i++) { + int i; + for (i =0; i<children(); i++) { Fl_Rect *ri = p+i+2; if (ri->b() == old_b) { if (ri->h() == 0) { @@ -362,7 +366,8 @@ void Fl_Tile::request_shrink_b(int old_b, int &new_b, Fl_Rect *final_size) { */ void Fl_Tile::request_grow_l(int old_l, int &new_l, Fl_Rect *final_size) { Fl_Rect *p = bounds(); - for (int i=0; i<children(); i++) { + int i; + for (i =0; i<children(); i++) { Fl_Rect *ri = p+i+2; if (ri->x() == old_l) { final_size[i].w(final_size[i].r() - new_l); @@ -383,7 +388,8 @@ void Fl_Tile::request_grow_l(int old_l, int &new_l, Fl_Rect *final_size) { */ void Fl_Tile::request_grow_r(int old_r, int &new_r, Fl_Rect *final_size) { Fl_Rect *p = bounds(); - for (int i=0; i<children(); i++) { + int i; + for (i =0; i<children(); i++) { Fl_Rect *ri = p+i+2; if (ri->r() == old_r) { final_size[i].r(new_r); @@ -403,7 +409,8 @@ void Fl_Tile::request_grow_r(int old_r, int &new_r, Fl_Rect *final_size) { */ void Fl_Tile::request_grow_t(int old_t, int &new_t, Fl_Rect *final_size) { Fl_Rect *p = bounds(); - for (int i=0; i<children(); i++) { + int i; + for (i =0; i<children(); i++) { Fl_Rect *ri = p+i+2; if (ri->y() == old_t) { final_size[i].h(final_size[i].b() - new_t); @@ -424,7 +431,8 @@ void Fl_Tile::request_grow_t(int old_t, int &new_t, Fl_Rect *final_size) { */ void Fl_Tile::request_grow_b(int old_b, int &new_b, Fl_Rect *final_size) { Fl_Rect *p = bounds(); - for (int i=0; i<children(); i++) { + int i; + for (i =0; i<children(); i++) { Fl_Rect *ri = p+i+2; if (ri->b() == old_b) { final_size[i].b(new_b); @@ -458,7 +466,8 @@ void Fl_Tile::move_intersection(int oldx, int oldy, int newx, int newy) { Fl_Widget*const* a = array(); Fl_Rect *p = bounds(); p += 2; // skip group & resizable's saved size - for (int i=children(); i--; p++) { + int i; + for (i =children(); i--; p++) { Fl_Widget* o = *a++; if (o == resizable()) continue; int X = o->x(); @@ -564,7 +573,7 @@ void Fl_Tile::drag_intersection(int oldx, int oldy, int newx, int newy) { See the Fl_Tile class documentation about how the resizable() works. */ void Fl_Tile::resize(int X,int Y,int W,int H) { - + int i; if (size_range_) { // -- handle size_range style resizing int dx = X - x(); @@ -580,7 +589,7 @@ void Fl_Tile::resize(int X,int Y,int W,int H) { } // -- if the position changes, move all widgets first if ((dx!=0) || (dy!=0)) { - for (int i = 0; i < children(); i++) { + for (i = 0; i < children(); i++) { Fl_Widget *c = child(i); c->position(c->x()+dx, c->y()+dy); } @@ -589,7 +598,7 @@ void Fl_Tile::resize(int X,int Y,int W,int H) { init_sizes(); Fl_Rect *p = bounds(); int bbr = X, bbb = Y; - for (int i = 0; i < children(); i++) { + for (i = 0; i < children(); i++) { // find the current bounding box bbr = fl_max(bbr, p[i+2].r()); bbb = fl_max(bbb, p[i+2].b()); @@ -661,7 +670,7 @@ void Fl_Tile::resize(int X,int Y,int W,int H) { // move everything to be on correct side of new resizable: Fl_Widget*const* a = array(); p += 2; - for (int i=children(); i--; p++) { + for (i =children(); i--; p++) { Fl_Widget* o = *a++; int xx = o->x()+dx; int R = xx+o->w(); @@ -723,7 +732,8 @@ int Fl_Tile::handle(int event) { Fl_Widget*const* a = array(); Fl_Rect *q = bounds(); Fl_Rect *p = q+2; - for (int i=children(); i--; p++) { + int i; + for (i =children(); i--; p++) { Fl_Widget* o = *a++; if (!size_range_ && o == resizable()) continue; if (p->r() < q->r() && o->y()<=my+GRABAREA && o->y()+o->h()>=my-GRABAREA) { @@ -896,7 +906,8 @@ void Fl_Tile::init_size_range(int default_min_w, int default_min_h) { size_range_size_ = children(); size_range_capacity_ = (size_range_size_+8) & ~7; // allocate in steps of 8 size_range_ = (Size_Range*)::realloc(size_range_, sizeof(Size_Range)*size_range_capacity_); - for (int i=0; i<size_range_size_; i++) { + int i; + for (i =0; i<size_range_size_; i++) { size_range_[i].minw = default_min_w_; size_range_[i].minh = default_min_h_; size_range_[i].maxw = 0x7FFFFFFF; diff --git a/src/Fl_Tiled_Image.cxx b/src/Fl_Tiled_Image.cxx index 2ec62e79a..80846779f 100644 --- a/src/Fl_Tiled_Image.cxx +++ b/src/Fl_Tiled_Image.cxx @@ -185,9 +185,11 @@ Fl_Tiled_Image::draw(int X, // I - Starting X position if (cx > 0) iw -= cx; // crop image if (cy > 0) ih -= cy; - for (int yy = Y; yy < Y+H; yy += ih) { + int yy; + for (yy = Y; yy < Y+H; yy += ih) { if (fl_not_clipped(X,yy,W,ih)) { - for (int xx = X; xx < X+W; xx += iw) { + int xx; + for (xx = X; xx < X+W; xx += iw) { if (fl_not_clipped(xx,yy,iw,ih)) { image_->draw(xx,yy,iw,ih,cx,cy); } diff --git a/src/Fl_Timeout.cxx b/src/Fl_Timeout.cxx index 9aa89b839..eb3e6cccd 100644 --- a/src/Fl_Timeout.cxx +++ b/src/Fl_Timeout.cxx @@ -217,7 +217,8 @@ void Fl_Timeout::insert() { \see Fl::has_timeout(Fl_Timeout_Handler cb, void *data) */ int Fl_Timeout::has_timeout(Fl_Timeout_Handler cb, void *data) { - for (Fl_Timeout *t = first_timeout; t; t = t->next) { + Fl_Timeout *t; + for (t = first_timeout; t; t = t->next) { if (t->callback == cb && t->data == data) return 1; } @@ -289,7 +290,8 @@ void Fl_Timeout::repeat_timeout(double time, Fl_Timeout_Handler cb, void *data) \see Fl::remove_timeout(Fl_Timeout_Handler cb, void *data) */ void Fl_Timeout::remove_timeout(Fl_Timeout_Handler cb, void *data) { - for (Fl_Timeout** p = &first_timeout; *p;) { + Fl_Timeout **p; + for (p = &first_timeout; *p;) { Fl_Timeout* t = *p; if (t->callback == cb && (t->data == data || !data)) { *p = t->next; @@ -323,7 +325,8 @@ void Fl_Timeout::remove_timeout(Fl_Timeout_Handler cb, void *data) { */ int Fl_Timeout::remove_next_timeout(Fl_Timeout_Handler cb, void *data, void **data_return) { int ret = 0; - for (Fl_Timeout** p = &first_timeout; *p;) { // scan all timeouts + Fl_Timeout **p; + for (p = &first_timeout; *p;) { // scan all timeouts Fl_Timeout* t = *p; if (t->callback == cb && (t->data == data || !data)) { // timeout matches ret++; @@ -356,7 +359,8 @@ int Fl_Timeout::remove_next_timeout(Fl_Timeout_Handler cb, void *data, void **da void Fl_Timeout::make_current() { // printf("[%4d] Fl_Timeout::make_current(%p)\n", __LINE__, this); // remove the timer entry from the active timer queue - for (Fl_Timeout** p = &first_timeout; *p;) { + Fl_Timeout **p; + for (p = &first_timeout; *p;) { Fl_Timeout* t = *p; if (t == this) { *p = t->next; @@ -497,13 +501,14 @@ void Fl_Timeout::elapse_timeouts() { // active timers - for (Fl_Timeout* t = first_timeout; t; t = t->next) { + Fl_Timeout *t; + for (t = first_timeout; t; t = t->next) { t->time -= elapsed; } // "current" timers, i.e. timers being serviced - for (Fl_Timeout* t = current_timeout; t; t = t->next) { + for (t = current_timeout; t; t = t->next) { t->time -= elapsed; } } diff --git a/src/Fl_Tooltip.cxx b/src/Fl_Tooltip.cxx index cb85f520e..43ff1ea0f 100644 --- a/src/Fl_Tooltip.cxx +++ b/src/Fl_Tooltip.cxx @@ -101,7 +101,8 @@ void Fl_TooltipBox::layout() { oy = Fl::event_y_root()+13; } else { oy = currentTooltipY + currentTooltipH+2; - for (Fl_Widget* p = Fl_Tooltip::current(); p; p = p->window()) { + Fl_Widget *p; + for (p = Fl_Tooltip::current(); p; p = p->window()) { oy += p->y(); } } diff --git a/src/Fl_Tree.cxx b/src/Fl_Tree.cxx index 01ab99d33..d4f1be750 100644 --- a/src/Fl_Tree.cxx +++ b/src/Fl_Tree.cxx @@ -67,7 +67,8 @@ static void free_path(char **arr) { // static int find_total_children(Fl_Tree_Item *item, int count=0) { count++; - for ( int t=0; t<item->children(); t++ ) { + int t; + for (t =0; t<item->children(); t++ ) { count = find_total_children(item->child(t), count); } return(count); @@ -138,7 +139,8 @@ Fl_Tree::~Fl_Tree() { int Fl_Tree::extend_selection_dir(Fl_Tree_Item *from, Fl_Tree_Item *to, int dir, int val, bool visible ) { int changed = 0; - for (Fl_Tree_Item *item=from; item; item = next_item(item, dir, visible) ) { + Fl_Tree_Item *item; + for (item =from; item; item = next_item(item, dir, visible) ) { switch (val) { case 0: if ( deselect(item, when()) ) ++changed; @@ -193,8 +195,9 @@ int Fl_Tree::extend_selection(Fl_Tree_Item *from, Fl_Tree_Item *to, } return(changed); } + Fl_Tree_Item *item; char on = 0; - for ( Fl_Tree_Item *item = first(); item; item = item->next_visible(_prefs) ) { + for (item = first(); item; item = item->next_visible(_prefs) ) { if ( visible && !item->is_visible() ) continue; if ( on || (item == from) || (item == to) ) { switch (val) { @@ -1099,11 +1102,12 @@ Fl_Tree_Item* Fl_Tree::item_clicked() { \code : // Walk down the tree (forwards) - for ( Fl_Tree_Item *i=tree->first_visible_item(); i; i=tree->next_visible_item(i, FL_Down) ) + Fl_Tree_Item *i; + for (i =tree->first_visible_item(); i; i=tree->next_visible_item(i, FL_Down) ) printf("Item: %s\n", i->label()); // Walk up the tree (backwards) - for ( Fl_Tree_Item *i=tree->last_visible_item(); i; i=tree->next_visible_item(i, FL_Up) ) + for (i =tree->last_visible_item(); i; i=tree->next_visible_item(i, FL_Up) ) printf("Item: %s\n", i->label()); : \endcode @@ -1123,7 +1127,8 @@ Fl_Tree_Item *Fl_Tree::next_visible_item(Fl_Tree_Item *item, int dir) { \par \code : - for ( Fl_Tree_Item *item = tree->first(); item; item = tree->next(item) ) + Fl_Tree_Item *item; + for (item = tree->first(); item; item = tree->next(item) ) printf("Item: %s\n", item->label()); : \endcode @@ -1161,7 +1166,8 @@ Fl_Tree_Item* Fl_Tree::first_visible_item() { \par \code : - for ( Fl_Tree_Item *i = tree->first(); i; i = tree->next(i) ) + Fl_Tree_Item *i; + for (i = tree->first(); i; i = tree->next(i) ) printf("Item: %s\n", i->label()); : \endcode @@ -1180,7 +1186,8 @@ Fl_Tree_Item *Fl_Tree::next(Fl_Tree_Item *item) { \par \code : - for ( Fl_Tree_Item *item = tree->first(); item; item = tree->prev(item) ) + Fl_Tree_Item *item; + for (item = tree->first(); item; item = tree->prev(item) ) printf("Item: %s\n", item->label()); : \endcode @@ -1198,7 +1205,8 @@ Fl_Tree_Item *Fl_Tree::prev(Fl_Tree_Item *item) { This can be used to walk the tree in reverse, e.g. \par \code - for ( Fl_Tree_Item *item = tree->last(); item; item = tree->prev() ) + Fl_Tree_Item *item; + for (item = tree->last(); item; item = tree->prev() ) printf("Item: %s\n", item->label()); \endcode \returns Last item in the tree, or 0 if none (tree empty). @@ -1249,7 +1257,8 @@ Fl_Tree_Item* Fl_Tree::last_visible_item() { \code : // Walk tree forward, from top to bottom - for ( Fl_Tree_Item *i=tree->first_selected_item(); i; i=tree->next_selected_item(i) ) + Fl_Tree_Item *i; + for (i =tree->first_selected_item(); i; i=tree->next_selected_item(i) ) printf("Selected item: %s\n", i->label()); : \endcode @@ -1270,7 +1279,8 @@ Fl_Tree_Item *Fl_Tree::first_selected_item() { \code : // Walk tree in reverse, from bottom to top - for ( Fl_Tree_Item *i=tree->last_selected_item(); i; i=tree->next_selected_item(i, FL_Up) ) + Fl_Tree_Item *i; + for (i =tree->last_selected_item(); i; i=tree->next_selected_item(i, FL_Up) ) printf("Selected item: %s\n", i->label()); : \endcode @@ -1303,19 +1313,20 @@ Fl_Tree_Item *Fl_Tree::last_selected_item() { \code : // Walk down the tree showing open(), visible items - for ( Fl_Tree_Item *i=tree->first_visible_item(); i; i=tree->next_item(i, FL_Down, true) ) + Fl_Tree_Item *i; + for (i =tree->first_visible_item(); i; i=tree->next_item(i, FL_Down, true) ) printf("Item: %s\n", i->label()); // Walk up the tree showing open(), visible items - for ( Fl_Tree_Item *i=tree->last_visible_item(); i; i=tree->next_item(i, FL_Up, true) ) + for (i =tree->last_visible_item(); i; i=tree->next_item(i, FL_Up, true) ) printf("Item: %s\n", i->label()); // Walk down the tree showing all items (open or closed) - for ( Fl_Tree_Item *i=tree->first(); i; i=tree->next_item(i, FL_Down, false) ) + for (i =tree->first(); i; i=tree->next_item(i, FL_Down, false) ) printf("Item: %s\n", i->label()); // Walk up the tree showing all items (open or closed) - for ( Fl_Tree_Item *i=tree->last(); i; i=tree->next_item(i, FL_Up, false) ) + for (i =tree->last(); i; i=tree->next_item(i, FL_Up, false) ) printf("Item: %s\n", i->label()); : \endcode @@ -1365,11 +1376,12 @@ Fl_Tree_Item *Fl_Tree::next_item(Fl_Tree_Item *item, int dir, bool visible) { \code : // Walk down the tree (forwards) - for ( Fl_Tree_Item *i=tree->first_selected_item(); i; i=tree->next_selected_item(i, FL_Down) ) + Fl_Tree_Item *i; + for (i =tree->first_selected_item(); i; i=tree->next_selected_item(i, FL_Down) ) printf("Item: %s\n", i->label()); // Walk up the tree (backwards) - for ( Fl_Tree_Item *i=tree->last_selected_item(); i; i=tree->next_selected_item(i, FL_Up) ) + for (i =tree->last_selected_item(); i; i=tree->next_selected_item(i, FL_Up) ) printf("Item: %s\n", i->label()); : \endcode @@ -1419,7 +1431,8 @@ Fl_Tree_Item *Fl_Tree::next_selected_item(Fl_Tree_Item *item, int dir) { Fl_Tree_Item_Array items; tree->get_selected_items(items); // Manipulate the returned array - for ( int t=0; t<items.total(); t++ ) { + int t; + for (t =0; t<items.total(); t++ ) { Fl_Tree_Item &item = items[t]; ..do stuff with each selected item.. } @@ -1432,7 +1445,8 @@ Fl_Tree_Item *Fl_Tree::next_selected_item(Fl_Tree_Item *item, int dir) { */ int Fl_Tree::get_selected_items(Fl_Tree_Item_Array &ret_items) { ret_items.clear(); - for ( Fl_Tree_Item *i=first_selected_item(); i; i=next_selected_item(i) ) { + Fl_Tree_Item *i; + for (i =first_selected_item(); i; i=next_selected_item(i) ) { ret_items.add(i); } return ret_items.total(); @@ -1821,7 +1835,8 @@ int Fl_Tree::deselect_all(Fl_Tree_Item *item, int docallback) { if ( deselect(item, docallback) ) ++count; // Deselect its children - for ( int t=0; t<item->children(); t++ ) { + int t; + for (t =0; t<item->children(); t++ ) { count += deselect_all(item->child(t), docallback); // recurse } return(count); @@ -1852,7 +1867,8 @@ int Fl_Tree::select_only(Fl_Tree_Item *selitem, int docallback) { // Deselect everything first. // Prevents callbacks from seeing more than one item selected. // - for ( Fl_Tree_Item *item = first(); item; item = item->next() ) { + Fl_Tree_Item *item; + for (item = first(); item; item = item->next() ) { if ( item == selitem ) continue; // don't do anything to selitem yet.. if ( item->is_selected() ) { deselect(item, docallback); @@ -1898,7 +1914,8 @@ int Fl_Tree::select_all(Fl_Tree_Item *item, int docallback) { if ( select(item, docallback) ) ++count; // Select its children - for ( int t=0; t<item->children(); t++ ) { + int t; + for (t =0; t<item->children(); t++ ) { count += select_all(item->child(t), docallback); // recurse } return(count); @@ -2490,7 +2507,8 @@ void Fl_Tree::hposition(int pos) { \par \code : - for ( int i=0; i<tree->children(); i++ ) { // walk children + int i; + for (i =0; i<tree->children(); i++ ) { // walk children Fl_Widget *w = tree->child(i); if ( tree->is_scrollbar(w) ) continue; // skip scrollbars ..do work here.. diff --git a/src/Fl_Tree_Item.cxx b/src/Fl_Tree_Item.cxx index 5157ea04a..3e07cab72 100644 --- a/src/Fl_Tree_Item.cxx +++ b/src/Fl_Tree_Item.cxx @@ -145,7 +145,8 @@ void Fl_Tree_Item::show_self(const char *indent) const { char *i2 = new char [strlen(indent)+3]; // 2 + nul byte strcpy(i2, indent); strcat(i2, " |"); - for ( int t=0; t<children(); t++ ) { + int t; + for (t =0; t<children(); t++ ) { child(t)->show_self(i2); } delete[] i2; @@ -186,7 +187,8 @@ void Fl_Tree_Item::clear_children() { /// int Fl_Tree_Item::find_child(const char *name) { if ( name ) { - for ( int t=0; t<children(); t++ ) + int t; + for (t =0; t<children(); t++ ) if ( child(t)->label() ) if ( strcmp(child(t)->label(), name) == 0 ) return(t); @@ -201,11 +203,13 @@ int Fl_Tree_Item::find_child(const char *name) { /// \version 1.3.3 /// const Fl_Tree_Item* Fl_Tree_Item::find_child_item(const char *name) const { - if ( name ) - for ( int t=0; t<children(); t++ ) + if ( name ) { + int t; + for (t =0; t<children(); t++ ) if ( child(t)->label() ) if ( strcmp(child(t)->label(), name) == 0 ) return(child(t)); + } return(0); } @@ -224,7 +228,8 @@ Fl_Tree_Item* Fl_Tree_Item::find_child_item(const char *name) { /// \version 1.3.0 release /// const Fl_Tree_Item *Fl_Tree_Item::find_child_item(char **arr) const { - for ( int t=0; t<children(); t++ ) { + int t; + for (t =0; t<children(); t++ ) { if ( child(t)->label() ) { if ( strcmp(child(t)->label(), *arr) == 0 ) { // match? if ( *(arr+1) ) { // more in arr? descend @@ -276,7 +281,8 @@ Fl_Tree_Item *Fl_Tree_Item::find_item(char **names) { /// \returns the index, or -1 if not found. /// int Fl_Tree_Item::find_child(Fl_Tree_Item *item) { - for ( int t=0; t<children(); t++ ) + int t; + for (t =0; t<children(); t++ ) if ( item == child(t) ) return(t); return(-1); @@ -309,13 +315,14 @@ Fl_Tree_Item *Fl_Tree_Item::add(const Fl_Tree_Prefs &prefs, { item = new Fl_Tree_Item(_tree); item->label(new_label); } recalc_tree(); // may change tree geometry item->_parent = this; + int t; switch ( prefs.sortorder() ) { case FL_TREE_SORT_NONE: { _children.add(item); return(item); } case FL_TREE_SORT_ASCENDING: { - for ( int t=0; t<_children.total(); t++ ) { + for (t =0; t<_children.total(); t++ ) { Fl_Tree_Item *c = _children[t]; if ( c->label() && strcmp(c->label(), new_label) > 0 ) { _children.insert(t, item); @@ -326,7 +333,7 @@ Fl_Tree_Item *Fl_Tree_Item::add(const Fl_Tree_Prefs &prefs, return(item); } case FL_TREE_SORT_DESCENDING: { - for ( int t=0; t<_children.total(); t++ ) { + for (t =0; t<_children.total(); t++ ) { Fl_Tree_Item *c = _children[t]; if ( c->label() && strcmp(c->label(), new_label) < 0 ) { _children.insert(t, item); @@ -417,7 +424,8 @@ Fl_Tree_Item *Fl_Tree_Item::insert_above(const Fl_Tree_Prefs &prefs, const char Fl_Tree_Item *p = _parent; if ( ! p ) return(0); // Walk our parent's children to find ourself - for ( int t=0; t<p->children(); t++ ) { + int t; + for (t =0; t<p->children(); t++ ) { Fl_Tree_Item *c = p->child(t); if ( this == c ) { return(p->insert(prefs, new_label, t)); @@ -642,7 +650,8 @@ Fl_Tree_Item *Fl_Tree_Item::replace_child(Fl_Tree_Item *olditem, /// \returns 0 if removed, -1 if item not an immediate child. /// int Fl_Tree_Item::remove_child(Fl_Tree_Item *item) { - for ( int t=0; t<children(); t++ ) { + int t; + for (t =0; t<children(); t++ ) { if ( child(t) == item ) { item->clear_children(); _children.remove(t); @@ -661,7 +670,8 @@ int Fl_Tree_Item::remove_child(Fl_Tree_Item *item) { /// \version 1.3.3 /// int Fl_Tree_Item::remove_child(const char *name) { - for ( int t=0; t<children(); t++ ) { + int t; + for (t =0; t<children(); t++ ) { if ( child(t)->label() ) { if ( strcmp(child(t)->label(), name) == 0 ) { _children.remove(t); @@ -697,7 +707,8 @@ void Fl_Tree_Item::swap_children(int ax, int bx) { /// int Fl_Tree_Item::swap_children(Fl_Tree_Item *a, Fl_Tree_Item *b) { int ax = -1, bx = -1; - for ( int t=0; t<children(); t++ ) { // find index for a and b + int t; + for (t =0; t<children(); t++ ) { // find index for a and b if ( _children[t] == a ) { ax = t; if ( bx != -1 ) break; else continue; } if ( _children[t] == b ) { bx = t; if ( ax != -1 ) break; else continue; } } @@ -722,7 +733,8 @@ void Fl_Tree_Item::draw_horizontal_connector(int x1, int x2, int y, const Fl_Tre case FL_TREE_CONNECTOR_DOTTED: { x1 |= 1; // force alignment w/dot pattern - for ( int xx=x1; xx<=x2; xx+=2 ) { + int xx; + for (xx =x1; xx<=x2; xx+=2 ) { fl_point(xx, y); } return; @@ -751,7 +763,8 @@ void Fl_Tree_Item::draw_vertical_connector(int x, int y1, int y2, const Fl_Tree_ { y1 |= 1; // force alignment w/dot pattern y2 |= 1; // force alignment w/dot pattern - for ( int yy=y1; yy<=y2; yy+=2 ) { + int yy; + for (yy =y1; yy<=y2; yy+=2 ) { fl_point(x, yy); } return; @@ -787,7 +800,8 @@ const Fl_Tree_Item *Fl_Tree_Item::find_clicked(const Fl_Tree_Prefs &prefs, int y } } if ( is_open() ) { // open? check children of this item - for ( int t=0; t<children(); t++ ) { + int t; + for (t =0; t<children(); t++ ) { const Fl_Tree_Item *item; if ( (item = _children[t]->find_clicked(prefs, yonly)) != NULL) // recurse into child for descendents return(item); // found? @@ -1140,7 +1154,8 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Tree_Item *itemfocus, : X; // unless didn't drawthis int child_w = W - (child_x-X); int child_y_start = Y; - for ( int t=0; t<children(); t++ ) { + int t; + for (t =0; t<children(); t++ ) { int is_lastchild = ((t+1)==children()) ? 1 : 0; _children[t]->draw(child_x, Y, child_w, itemfocus, tree_item_xmax, is_lastchild, render); } @@ -1238,7 +1253,8 @@ int Fl_Tree_Item::event_on_label(const Fl_Tree_Prefs &prefs) const { void Fl_Tree_Item::show_widgets() { if ( _widget ) _widget->show(); if ( is_open() ) { - for ( int t=0; t<_children.total(); t++ ) { + int t; + for (t =0; t<_children.total(); t++ ) { _children[t]->show_widgets(); } } @@ -1249,7 +1265,8 @@ void Fl_Tree_Item::show_widgets() { /// void Fl_Tree_Item::hide_widgets() { if ( _widget ) _widget->hide(); - for ( int t=0; t<_children.total(); t++ ) { + int t; + for (t =0; t<_children.total(); t++ ) { _children[t]->hide_widgets(); } } @@ -1258,7 +1275,8 @@ void Fl_Tree_Item::hide_widgets() { void Fl_Tree_Item::open() { set_flag(OPEN,1); // Tell children to show() their widgets - for ( int t=0; t<_children.total(); t++ ) { + int t; + for (t =0; t<_children.total(); t++ ) { _children[t]->show_widgets(); } recalc_tree(); // may change tree geometry @@ -1268,7 +1286,8 @@ void Fl_Tree_Item::open() { void Fl_Tree_Item::close() { set_flag(OPEN,0); // Tell children to hide() their widgets - for ( int t=0; t<_children.total(); t++ ) { + int t; + for (t =0; t<_children.total(); t++ ) { _children[t]->hide_widgets(); } recalc_tree(); // may change tree geometry @@ -1467,7 +1486,8 @@ Fl_Tree_Item *Fl_Tree_Item::prev_displayed(Fl_Tree_Prefs &prefs) { /// int Fl_Tree_Item::is_visible_r() const { if ( !visible() ) return(0); - for (const Fl_Tree_Item *p=parent(); p; p=p->parent())// move up through parents + const Fl_Tree_Item *p; + for (p =parent(); p; p=p->parent())// move up through parents if (!p->visible() || p->is_close()) return(0); // any parent not visible or closed? return(1); } diff --git a/src/Fl_Tree_Item_Array.cxx b/src/Fl_Tree_Item_Array.cxx index dca358288..9186baff9 100644 --- a/src/Fl_Tree_Item_Array.cxx +++ b/src/Fl_Tree_Item_Array.cxx @@ -50,7 +50,8 @@ Fl_Tree_Item_Array::Fl_Tree_Item_Array(const Fl_Tree_Item_Array* o) { _size = o->_size; _chunksize = o->_chunksize; _flags = o->_flags; - for ( int t=0; t<o->_total; t++ ) { + int t; + for (t =0; t<o->_total; t++ ) { if ( _flags & MANAGE_ITEM ) { _items[t] = new Fl_Tree_Item(o->_items[t]); // make new copy of item ++_total; @@ -69,7 +70,8 @@ Fl_Tree_Item_Array::Fl_Tree_Item_Array(const Fl_Tree_Item_Array* o) { /// void Fl_Tree_Item_Array::clear() { if ( _items ) { - for ( int t=0; t<_total; t++ ) { + int t; + for (t =0; t<_total; t++ ) { if ( _flags & MANAGE_ITEM ) { delete _items[t]; @@ -169,7 +171,8 @@ void Fl_Tree_Item_Array::remove(int index) { } _items[index] = 0; _total--; - for ( int i=index; i<_total; i++ ) { // reshuffle the array + int i; + for (i =index; i<_total; i++ ) { // reshuffle the array _items[i] = _items[i+1]; } if ( _flags & MANAGE_ITEM ) @@ -188,7 +191,8 @@ void Fl_Tree_Item_Array::remove(int index) { /// \returns 0 if removed, or -1 if the item was not in the array. /// int Fl_Tree_Item_Array::remove(Fl_Tree_Item *item) { - for ( int t=0; t<_total; t++ ) { + int t; + for (t =0; t<_total; t++ ) { if ( item == _items[t] ) { remove(t); return(0); @@ -223,16 +227,19 @@ int Fl_Tree_Item_Array::move(int to, int from) { if ( to<0 || to>=_total || from<0 || from>=_total ) return -1; Fl_Tree_Item *item = _items[from]; // Remove item.. - if ( from < to ) - for ( int t=from; t<to && t<(_total+1); t++ ) + int t; + if ( from < to ) { + for (t =from; t<to && t<(_total+1); t++ ) _items[t] = _items[t+1]; - else - for ( int t=from; t>to && t>0; t-- ) + } else { + for (t =from; t>to && t>0; t-- ) _items[t] = _items[t-1]; + } // Move to new position _items[to] = item; // Update all children - for ( int r=0; r<_total; r++ ) // XXX: excessive to do all children, + int r; + for (r =0; r<_total; r++ ) // XXX: excessive to do all children, _items[r]->update_prev_next(r); // XXX: but avoids weird boundary issues return 0; } @@ -252,7 +259,8 @@ int Fl_Tree_Item_Array::deparent(int pos) { Fl_Tree_Item *next = item->next_sibling(); // Remove from parent's list of children _total -= 1; - for ( int t=pos; t<_total; t++ ) + int t; + for (t =pos; t<_total; t++ ) _items[t] = _items[t+1]; // delete, no destroy // Now an orphan: remove association with old parent and siblings item->update_prev_next(-1); // become an orphan @@ -272,7 +280,8 @@ int Fl_Tree_Item_Array::reparent(Fl_Tree_Item *item, Fl_Tree_Item* newparent, in // Add item to new parent enlarge(1); _total += 1; - for ( int t=_total-1; t>pos; --t ) // shuffle array to make room for new entry + int t; + for (t =_total-1; t>pos; --t ) // shuffle array to make room for new entry _items[t] = _items[t-1]; _items[pos] = item; // insert new entry // Attach to new parent and siblings diff --git a/src/Fl_Widget.cxx b/src/Fl_Widget.cxx index 4eee6ef39..aba540802 100644 --- a/src/Fl_Widget.cxx +++ b/src/Fl_Widget.cxx @@ -334,7 +334,8 @@ void Fl_Widget::deactivate() { } int Fl_Widget::active_r() const { - for (const Fl_Widget* o = this; o; o = o->parent()) + const Fl_Widget *o; + for (o = this; o; o = o->parent()) if (!o->active()) return 0; return 1; } @@ -354,7 +355,8 @@ void Fl_Widget::show() { void Fl_Widget::hide() { if (visible_r()) { set_flag(INVISIBLE); - for (Fl_Widget *p = parent(); p; p = p->parent()) + Fl_Widget *p; + for (p = parent(); p; p = p->parent()) if (p->box() || !p->parent()) {p->redraw(); break;} handle(FL_HIDE); fl_throw_focus(this); @@ -364,7 +366,8 @@ void Fl_Widget::hide() { } int Fl_Widget::visible_r() const { - for (const Fl_Widget* o = this; o; o = o->parent()) + const Fl_Widget *o; + for (o = this; o; o = o->parent()) if (!o->visible()) return 0; return 1; } diff --git a/src/Fl_Widget_Surface.cxx b/src/Fl_Widget_Surface.cxx index 98cc736ad..4d9912a65 100644 --- a/src/Fl_Widget_Surface.cxx +++ b/src/Fl_Widget_Surface.cxx @@ -95,7 +95,8 @@ void Fl_Widget_Surface::traverse(Fl_Widget *widget) Fl_Group *g = widget->as_group(); if (!g) return; int n = g->children(); - for (int i = 0; i < n; i++) { + int i; + for (i = 0; i < n; i++) { Fl_Widget *c = g->child(i); if ( !c->visible() ) continue; if ( c->as_window() ) { diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx index e60a68eaa..b777463ac 100644 --- a/src/Fl_Window.cxx +++ b/src/Fl_Window.cxx @@ -105,7 +105,8 @@ Fl_Window::~Fl_Window() { \see top_window() */ Fl_Window *Fl_Widget::window() const { - for (Fl_Widget *o = parent(); o; o = o->parent()) + Fl_Widget *o; + for (o = parent(); o; o = o->parent()) if (o->type() >= FL_WINDOW) return (Fl_Window*)o; return 0; } diff --git a/src/Fl_Window_Driver.cxx b/src/Fl_Window_Driver.cxx index 5c4095104..a31c85d07 100644 --- a/src/Fl_Window_Driver.cxx +++ b/src/Fl_Window_Driver.cxx @@ -140,7 +140,8 @@ int Fl_Window_Driver::hide_common() { pWindow->flx_ = 0; // recursively remove any subwindows: - for (Fl_X *wi = Fl_X::first; wi;) { + Fl_X *wi; + for (wi = Fl_X::first; wi;) { Fl_Window* W = wi->w; if (W->window() == pWindow) { W->hide(); @@ -271,7 +272,8 @@ fl_uintptr_t Fl_Window_Driver::xid(const Fl_Window *win) { \version 1.4.0 */ Fl_Window *Fl_Window_Driver::find(fl_uintptr_t xid) { Fl_X *window; - for (Fl_X **pp = &Fl_X::first; (window = *pp); pp = &window->next) { + Fl_X **pp; + for (pp = &Fl_X::first; (window = *pp); pp = &window->next) { if (window->xid == xid) { if (window != Fl_X::first && !Fl::modal()) { // make this window be first to speed up searches diff --git a/src/Fl_XPM_Image.cxx b/src/Fl_XPM_Image.cxx index 438aa544f..d60f8fd1a 100644 --- a/src/Fl_XPM_Image.cxx +++ b/src/Fl_XPM_Image.cxx @@ -67,6 +67,7 @@ Fl_XPM_Image::Fl_XPM_Image(const char *name) : Fl_Pixmap((char *const*)0) { char *myp = buffer; char *q = buffer+1; while (*q != '\"' && myp < buffer+MAXSIZE) { + int x; if (*q == '\\') switch (*++q) { case '\r': case '\n': @@ -76,7 +77,7 @@ Fl_XPM_Image::Fl_XPM_Image(const char *name) : Fl_Pixmap((char *const*)0) { case 'x': { q++; int n = 0; - for (int x = 0; x < 2; x++) { + for (x = 0; x < 2; x++) { int xd = hexdigit(*q); if (xd > 15) break; n = (n<<4)+xd; @@ -88,7 +89,7 @@ Fl_XPM_Image::Fl_XPM_Image(const char *name) : Fl_Pixmap((char *const*)0) { int c = *q++; if (c>='0' && c<='7') { c -= '0'; - for (int x=0; x<2; x++) { + for (x =0; x<2; x++) { int xd = hexdigit(*q); if (xd>7) break; c = (c<<3)+xd; diff --git a/src/Fl_get_system_colors.cxx b/src/Fl_get_system_colors.cxx index 9264ab214..04abde77f 100644 --- a/src/Fl_get_system_colors.cxx +++ b/src/Fl_get_system_colors.cxx @@ -49,7 +49,8 @@ void Fl::background(uchar r, uchar g, uchar b) { double powg = log(g/255.0)/log((FL_GRAY-FL_GRAY_RAMP)/(FL_NUM_GRAY-1.0)); if (!b) b = 1; else if (b==255) b = 254; double powb = log(b/255.0)/log((FL_GRAY-FL_GRAY_RAMP)/(FL_NUM_GRAY-1.0)); - for (int i = 0; i < FL_NUM_GRAY; i++) { + int i; + for (i = 0; i < FL_NUM_GRAY; i++) { double gray = i/(FL_NUM_GRAY-1.0); Fl::set_color(fl_gray_ramp(i), uchar(pow(gray,powr)*255+.5), diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 373378e9b..b95c74a5b 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -1217,7 +1217,8 @@ static void react_to_screen_reconfiguration() { int old_count = Fl::screen_count(); int (*sizes)[4] = new int[old_count][4]; float *scales = new float[old_count]; - for (int screen = 0; screen < old_count; screen++) { + int screen; + for (screen = 0; screen < old_count; screen++) { Fl::screen_xywh(sizes[screen][0], sizes[screen][1], sizes[screen][2], sizes[screen][3], screen); scales[screen] = Fl::screen_scale(screen); } @@ -1227,7 +1228,7 @@ static void react_to_screen_reconfiguration() { // detect whether screen sizes were unchanged bool nochange = (old_count == Fl::screen_count()); if (nochange) { - for (int screen = 0; screen < old_count; screen++) { + for (screen = 0; screen < old_count; screen++) { int X,Y,W,H; Fl::screen_xywh(X,Y,W,H, screen); X /= scales[screen]; @@ -1243,12 +1244,12 @@ static void react_to_screen_reconfiguration() { delete[] sizes; if (nochange || (old_count == 1 && Fl::screen_count() == 1)) { // screen sizes did not change or single screen: re-use previous screen scale values - for (int screen = 0; screen < old_count; screen++) + for (screen = 0; screen < old_count; screen++) Fl::screen_driver()->scale(screen, scales[screen]); } else { Fl::screen_driver()->use_startup_scale_factor(); float new_scale = Fl::screen_driver()->scale(0); - for (int screen = 0; screen < Fl::screen_count(); screen++) { + for (screen = 0; screen < Fl::screen_count(); screen++) { Fl::screen_driver()->scale(screen, 1); Fl::screen_driver()->rescale_all_windows_from_screen(screen, new_scale, 1); } @@ -1269,7 +1270,8 @@ static void after_display_rescale(float *p_current_xft_dpi) { if (fabs(dpi - *p_current_xft_dpi) > 0.1) { *p_current_xft_dpi = dpi; float f = dpi / 96.; - for (int i = 0; i < Fl::screen_count(); i++) + int i; + for (i = 0; i < Fl::screen_count(); i++) Fl::screen_driver()->rescale_all_windows_from_screen(i, f, f); } } @@ -1291,7 +1293,8 @@ static void add_xid_vector(Window xid) { } static bool remove_xid_vector(Window xid) { - for (int pos = xid_vector_count - 1; pos >= 0; pos--) { + int pos; + for (pos = xid_vector_count - 1; pos >= 0; pos--) { if (xid_vector[pos] == xid) { if (pos != --xid_vector_count) xid_vector[pos] = xid_vector[xid_vector_count]; return true; @@ -1679,7 +1682,8 @@ int fl_handle(const XEvent& thisevent) } delete [] fl_dnd_source_types; fl_dnd_source_types = new Atom[count+1]; - for (unsigned i = 0; i < count; i++) { + unsigned i; + for (i = 0; i < count; i++) { fl_dnd_source_types[i] = ((Atom*)cm_buffer)[i]; } fl_dnd_source_types[count] = 0; @@ -2123,7 +2127,8 @@ int fl_handle(const XEvent& thisevent) unsigned long nitems; unsigned long *words = 0; if (0 == get_xwinprop(xid, fl_NET_WM_STATE, 64, &nitems, &words) ) { - for (unsigned long item = 0; item < nitems; item++) { + unsigned long item; + for (item = 0; item < nitems; item++) { if (words[item] == fl_NET_WM_STATE_FULLSCREEN) { fullscreen_state = 1; } @@ -2913,7 +2918,8 @@ static void icons_to_property(const Fl_RGB_Image *icons[], int count, unsigned long *data; sz = 0; - for (int i = 0;i < count;i++) + int i; + for (i = 0;i < count;i++) sz += 2 + icons[i]->data_w() * icons[i]->data_h(); // FIXME: Might want to sort the icons @@ -2921,7 +2927,7 @@ static void icons_to_property(const Fl_RGB_Image *icons[], int count, *property = data = new unsigned long[sz]; *len = sz; - for (int i = 0;i < count;i++) { + for (i = 0;i < count;i++) { const Fl_RGB_Image *image; image = icons[i]; @@ -2938,8 +2944,10 @@ static void icons_to_property(const Fl_RGB_Image *icons[], int count, const int extra_data = image->ld() ? (image->ld() - image->data_w() * image->d()) : 0; const uchar *in = (const uchar*)*image->data(); - for (int y = 0; y < image->data_h(); y++) { - for (int x = 0; x < image->data_w(); x++) { + int y; + for (y = 0; y < image->data_h(); y++) { + int x; + for (x = 0; x < image->data_w(); x++) { switch (image->d()) { case 1: *data = ( 0xff<<24) | (in[0]<<16) | (in[0]<<8) | in[0]; @@ -3151,8 +3159,10 @@ int Fl_X11_Window_Driver::set_cursor(const Fl_RGB_Image *image, int hotx, int ho const int extra_data = image->ld() ? (image->ld()-image->w()*image->d()) : 0; const uchar *i = (const uchar*)*image->data(); XcursorPixel *o = cursor->pixels; - for (int y = 0;y < image->h();y++) { - for (int x = 0;x < image->w();x++) { + int y; + for (y = 0;y < image->h();y++) { + int x; + for (x = 0;x < image->w();x++) { uchar r, g, b, a; switch (image->d()) { case 1: diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx index 6483dc30b..62f89c38c 100644 --- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx +++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx @@ -530,7 +530,8 @@ void Fl_Cairo_Graphics_Driver::pie(int x, int y, int w, int h, double a1, double } void Fl_Cairo_Graphics_Driver::end_points() { - for (int i = 0; i < n; i++) { + int i; + for (i = 0; i < n; i++) { point(xpoint[i].x, xpoint[i].y); } } @@ -649,7 +650,8 @@ void Fl_Cairo_Graphics_Driver::check_status(void) { void Fl_Cairo_Graphics_Driver::draw_image(Fl_Draw_Image_Cb call, void *data, int ix, int iy, int iw, int ih, int D) { uchar *array = new uchar[iw * D * ih]; - for (int l = 0; l < ih; l++) { + int l; + for (l = 0; l < ih; l++) { call(data, 0, l, iw, array + l*D*iw); if (D%2 == 0) for (int i = 0; i < iw; i++) { *(array + l*D*iw + i*D + D-1) = 0xff; @@ -850,11 +852,12 @@ void Fl_Cairo_Graphics_Driver::cache(Fl_RGB_Image *rgb) { uchar A = 0xff, R,G,B, *q; const uchar *r; float f = 1; + int i, j; if (rgb->d() >= 3) { // color images - for (int j = 0; j < rgb->data_h(); j++) { + for (j = 0; j < rgb->data_h(); j++) { r = rgb->array + j * lrgb; q = BGRA + j * stride; - for (int i = 0; i < rgb->data_w(); i++) { + for (i = 0; i < rgb->data_w(); i++) { R = *r; G = *(r+1); B = *(r+2); @@ -868,10 +871,10 @@ void Fl_Cairo_Graphics_Driver::cache(Fl_RGB_Image *rgb) { } } } else if (rgb->d() == 1 || rgb->d() == 2) { // B&W - for (int j = 0; j < rgb->data_h(); j++) { + for (j = 0; j < rgb->data_h(); j++) { r = rgb->array + j * lrgb; q = BGRA + j * stride; - for (int i = 0; i < rgb->data_w(); i++) { + for (i = 0; i < rgb->data_w(); i++) { G = *r; if (rgb->d() == 2) { A = *(r+1); @@ -939,13 +942,15 @@ cairo_pattern_t *Fl_Cairo_Graphics_Driver::bitmap_to_pattern(Fl_Bitmap *bm, int w_bitmap = ((bm->data_w() + 7) / 8); uchar *BGRA = new uchar[stride * bm->data_h()]; memset(BGRA, 0, stride * bm->data_h()); - for (int j = 0; j < bm->data_h(); j++) { + int j; + for (j = 0; j < bm->data_h(); j++) { uchar *r = (uchar *)bm->array + j * w_bitmap; uint32_t *q = (uint32_t *)(BGRA + j * stride); int k = 0; uint32_t mask32; uchar p; - for (int i = 0; i < bm->data_w(); i++) { + int i; + for (i = 0; i < bm->data_w(); i++) { if (k == 0) { #if WORDS_BIGENDIAN mask32 = (uint32_t)(1 << 31); @@ -1116,13 +1121,15 @@ Fl_Font Fl_Cairo_Graphics_Driver::set_fonts(const char* /*pattern_name*/) static PangoFontMap *pfmap_ = pango_cairo_font_map_get_default(); // 1.10 Fl_Cairo_Graphics_Driver::init_built_in_fonts(); pango_font_map_list_families(pfmap_, &families, &n_families); - for (int fam = 0; fam < n_families; fam++) { + int fam; + for (fam = 0; fam < n_families; fam++) { PangoFontFace **faces; int n_faces; const char *fam_name = pango_font_family_get_name (families[fam]); int lfam = strlen(fam_name); pango_font_family_list_faces(families[fam], &faces, &n_faces); - for (int j = 0; j < n_faces; j++) { + int j; + for (j = 0; j < n_faces; j++) { const char *p = pango_font_face_get_face_name(faces[j]); // Remove " Regular" suffix from font names if (!strcasecmp(p, "regular")) p = NULL; @@ -1156,7 +1163,8 @@ void Fl_Cairo_Graphics_Driver::font_name(int num, const char *name) { Fl_Fontdesc *s = fl_fonts + num; if (s->name) { if (!strcmp(s->name, name)) {s->name = name; return;} - for (Fl_Font_Descriptor* f = s->first; f;) { + Fl_Font_Descriptor *f; + for (f = s->first; f;) { Fl_Font_Descriptor* n = f->next; delete f; f = n; } s->first = 0; @@ -1242,7 +1250,8 @@ Fl_Cairo_Font_Descriptor::Fl_Cairo_Font_Descriptor(const char* name, Fl_Fontsize Fl_Cairo_Font_Descriptor::~Fl_Cairo_Font_Descriptor() { pango_font_description_free(fontref); if (width) { - for (int i = 0; i < 64; i++) delete[] width[i]; + int i; + for (i = 0; i < 64; i++) delete[] width[i]; } delete[] width; } @@ -1378,7 +1387,8 @@ double Fl_Cairo_Graphics_Driver::width(unsigned int utf32) { } if (!desc->width[r]) { desc->width[r] = (int*)new int[0x0400]; - for (int i = 0; i < 0x0400; i++) desc->width[r][i] = -1; + int i; + for (i = 0; i < 0x0400; i++) desc->width[r][i] = -1; } else { if ( desc->width[r][utf32&0x03FF] >= 0 ) { // already cached return desc->width[r][utf32 & 0x03FF] / double(PANGO_SCALE); @@ -1465,7 +1475,8 @@ void Fl_Cairo_Graphics_Driver::restore_clip() { } int count = cairo_region_num_rectangles(r); // 1.10 cairo_rectangle_int_t rect; - for (int i = 0; i < count; i++) { + int i; + for (i = 0; i < count; i++) { cairo_region_get_rectangle(r, i, &rect); // 1.10 cairo_rectangle(cairo_, rect.x - 0.5, rect.y - 0.5, rect.width, rect.height); } diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_arci.cxx b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_arci.cxx index 73b216f01..0204f633e 100644 --- a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_arci.cxx +++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_arci.cxx @@ -40,7 +40,8 @@ void Fl_OpenGL_Graphics_Driver::arc(int x,int y,int w,int h,double a1,double a2) double incr = (a2-a1)/(double)nSeg; glBegin(GL_LINE_STRIP); - for (int i=0; i<=nSeg; i++) { + int i; + for (i =0; i<=nSeg; i++) { glVertex2d(cx+cos(a1)*rx, cy-sin(a1)*ry); a1 += incr; } @@ -63,7 +64,8 @@ void Fl_OpenGL_Graphics_Driver::pie(int x,int y,int w,int h,double a1,double a2) glBegin(GL_TRIANGLE_FAN); glVertex2d(cx, cy); - for (int i=0; i<=nSeg; i++) { + int i; + for (i =0; i<=nSeg; i++) { glVertex2d(cx+cos(a1)*rx, cy-sin(a1)*ry); a1 += incr; } diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx index 461e045bb..92de4c561 100644 --- a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx +++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx @@ -261,7 +261,8 @@ void Fl_OpenGL_Graphics_Driver::circle(double cx, double cy, double r) { double y = 0; glBegin(GL_LINE_LOOP); - for(int ii = 0; ii < num_segments; ii++) { + int ii; + for (ii = 0; ii < num_segments; ii++) { vertex(x + cx, y + cy); // output vertex double tx = -y; double ty = x; diff --git a/src/drivers/PostScript/Fl_PostScript.cxx b/src/drivers/PostScript/Fl_PostScript.cxx index 9cece371d..35afe46f6 100644 --- a/src/drivers/PostScript/Fl_PostScript.cxx +++ b/src/drivers/PostScript/Fl_PostScript.cxx @@ -1107,7 +1107,8 @@ static uchar *calc_mask(uchar *img, int w, int h, Fl_Color bg) while (h-- > 0) { // for each row bit = 0x80; // byte with last bit set byte = 0; // next mask byte to compute - for (int j = 0; j < w; j++) { // for each column + int j; + for (j = 0; j < w; j++) { // for each column r = *img++; // the pixel color components g = *img++; b = *img++; @@ -1168,9 +1169,11 @@ void Fl_PostScript_Graphics_Driver::transformed_draw_extra(const char* str, int uchar *di; int wmask = (w2+7)/8; void *rle85 = prepare_rle85(); - for (int j = h - 1; j >= 0; j--){ + int j; + for (j = h - 1; j >= 0; j--){ di = img_mask + j * wmask; - for (int i = 0; i < wmask; i++){ + int i; + for (i = 0; i < wmask; i++){ write_rle85(*di, rle85); di++; } @@ -1628,7 +1631,8 @@ static int update_format_layout(int rank, Fl_Paged_Device::Page_Layout layout, modal->begin(); Fl_Choice *psize = new Fl_Choice(140, 10, 110, 30, Fl_PDF_File_Surface::format_dialog_page_size); psize->when(FL_WHEN_CHANGED); - for (int i = 0; i < size_count; i++) { + int i; + for (i = 0; i < size_count; i++) { psize->add(Fl_Paged_Device::page_formats[menu_to_size[i]].name); } psize->value(rank); @@ -1682,7 +1686,8 @@ int Fl_PDF_Pango_File_Surface::begin_job(const char *defaultname, char **perr_me char *pref_format; print_prefs.get("PDF/page_size", pref_format, "A4"); int rank = 1; // corresponds to A4 - for (int i = 0; i < size_count; i++) { + int i; + for (i = 0; i < size_count; i++) { if (strcmp(pref_format, Fl_Paged_Device::page_formats[menu_to_size[i]].name) == 0) { rank = i; break; diff --git a/src/drivers/PostScript/Fl_PostScript_image.cxx b/src/drivers/PostScript/Fl_PostScript_image.cxx index ebb91cf03..26eb31a89 100644 --- a/src/drivers/PostScript/Fl_PostScript_image.cxx +++ b/src/drivers/PostScript/Fl_PostScript_image.cxx @@ -100,6 +100,7 @@ void Fl_PostScript_Graphics_Driver::draw_rgb_bitmap_(Fl_Image *img,int XP, int Y int stride = cairo_format_stride_for_width(format, img->data_w()); uchar *BGRA = new uchar[stride * img->data_h()]; memset(BGRA, 0, stride * img->data_h()); + int i, j; if (img->d() >= 1) { // process Fl_RGB_Image of all depths Fl_RGB_Image *rgb = (Fl_RGB_Image*)img; int lrgb = rgb->ld() ? rgb->ld() : rgb->data_w() * rgb->d(); @@ -107,10 +108,10 @@ void Fl_PostScript_Graphics_Driver::draw_rgb_bitmap_(Fl_Image *img,int XP, int Y const uchar *r; float f = 1; if (rgb->d() >= 3) { // color images - for (int j = 0; j < rgb->data_h(); j++) { + for (j = 0; j < rgb->data_h(); j++) { r = rgb->array + j * lrgb; q = BGRA + j * stride; - for (int i = 0; i < rgb->data_w(); i++) { + for (i = 0; i < rgb->data_w(); i++) { R = *r; G = *(r+1); B = *(r+2); @@ -126,10 +127,10 @@ void Fl_PostScript_Graphics_Driver::draw_rgb_bitmap_(Fl_Image *img,int XP, int Y } } } else if (rgb->d() == 1 || rgb->d() == 2) { // B&W - for (int j = 0; j < rgb->data_h(); j++) { + for (j = 0; j < rgb->data_h(); j++) { r = rgb->array + j * lrgb; q = BGRA + j * stride; - for (int i = 0; i < rgb->data_w(); i++) { + for (i = 0; i < rgb->data_w(); i++) { G = *r; if (rgb->d() == 2) { A = *(r+1); @@ -147,12 +148,12 @@ void Fl_PostScript_Graphics_Driver::draw_rgb_bitmap_(Fl_Image *img,int XP, int Y Fl_Bitmap *bm = (Fl_Bitmap*)img; uchar *r, p; unsigned *q; - for (int j = 0; j < bm->data_h(); j++) { + for (j = 0; j < bm->data_h(); j++) { r = (uchar*)bm->array + j * ((bm->data_w() + 7)/8); q = (unsigned*)(BGRA + j * stride); unsigned k = 0, mask32 = 1; p = *r; - for (int i = 0; i < bm->data_w(); i++) { + for (i = 0; i < bm->data_w(); i++) { if (p&1) (*q) |= mask32; k++; if (k % 8 != 0) p >>= 1; else p = *(++r); diff --git a/src/drivers/SVG/Fl_SVG_File_Surface.cxx b/src/drivers/SVG/Fl_SVG_File_Surface.cxx index 2a1439f74..5109dc9b4 100644 --- a/src/drivers/SVG/Fl_SVG_File_Surface.cxx +++ b/src/drivers/SVG/Fl_SVG_File_Surface.cxx @@ -232,7 +232,8 @@ void Fl_SVG_Graphics_Driver::compute_dasharray(float s, char *dashes) { if (dasharray_) free(dasharray_); int array_len = int(10*strlen(dashes) + 1); dasharray_ = (char*)calloc(array_len, 1); - for (char *p = dashes; *p; p++) { + char *p; + for (p = dashes; *p; p++) { int c = snprintf(dasharray_+strlen(dasharray_), array_len, "%.3f,", (*p)/s); array_len -= c; } @@ -283,7 +284,8 @@ void Fl_SVG_Graphics_Driver::draw(const char *str, int n, int x, int y) { fprintf(out_, "<text x=\"%d\" y=\"%d\" font-family=\"%s\"%s%s font-size=\"%d\" " "xml:space=\"preserve\" " " fill=\"rgb(%u,%u,%u)\" textLength=\"%d\">", x, y, family_, bold_, style_, size(), red_, green_, blue_, (int)width(str, n)); - for (int i = 0; i < n; i++) { + int i; + for (i = 0; i < n; i++) { if (str[i] == '&') fputs("&", out_); else if (str[i] == '<') fputs("<", out_); else if (str[i] == '>') fputs(">", out_); @@ -526,7 +528,8 @@ void Fl_SVG_Graphics_Driver::define_rgb_png(Fl_RGB_Image *rgb, const char *name, png_set_IHDR(png_ptr, info_ptr, rgb->data_w(), rgb->data_h(), 8, color_type, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); const uchar **row_pointers = new const uchar*[rgb->data_h()]; int ld = rgb->ld() ? rgb->ld() : rgb->d() * rgb->data_w(); - for (int i=0; i < rgb->data_h(); i++) row_pointers[i] = (rgb->array + i*ld); + int i; + for (i =0; i < rgb->data_h(); i++) row_pointers[i] = (rgb->array + i*ld); png_set_rows(png_ptr, info_ptr, (png_bytepp)row_pointers); png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); png_write_end(png_ptr, NULL); @@ -683,12 +686,15 @@ void Fl_SVG_Graphics_Driver::draw_bitmap(Fl_Bitmap *bm, int XP, int YP, int WP, Fl_RGB_Image *rgb = new Fl_RGB_Image(data, bm->data_w(), bm->data_h(), 4); rgb->alloc_array = 1; int rowBytes = (bm->data_w()+7)>>3 ; - for (int j = 0; j < bm->data_h(); j++) { + int j; + for (j = 0; j < bm->data_h(); j++) { const uchar *p = bm->array + j*rowBytes; - for (int i = 0; i < rowBytes; i++) { + int i; + for (i = 0; i < rowBytes; i++) { uchar q = *p; int last = bm->data_w() - 8*i; if (last > 8) last = 8; - for (int k=0; k < last; k++) { + int k; + for (k =0; k < last; k++) { if (q&1) { uchar *r = (uchar*)rgb->array + j*bm->data_w()*4 + i*8*4 + k*4; *r++ = R; *r++ = G; *r++ = B; *r = ~0; @@ -729,7 +735,8 @@ void Fl_SVG_Graphics_Driver::draw_image(const uchar* buf, int x, int y, int w, i void Fl_SVG_Graphics_Driver::draw_image(Fl_Draw_Image_Cb cb, void* data, int x, int y, int w, int h, int d) { uchar *buf = new uchar[w*h*d]; - for (int j = 0; j < h; j++) { + int j; + for (j = 0; j < h; j++) { cb(data, 0, j, w, buf + j*w*d); } draw_image(buf, x, y, w, h, d, 0); @@ -743,7 +750,8 @@ struct mono_image_data { }; static void mono_image_cb(mono_image_data* data, int x, int y, int w, uchar* buf) { - for (int i = 0; i < w; i++) + int i; + for (i = 0; i < w; i++) *buf++ = *(data->buf + y*data->l + (x++)*data->d); } @@ -755,7 +763,8 @@ void Fl_SVG_Graphics_Driver::draw_image_mono(const uchar* buf, int x, int y, int void Fl_SVG_Graphics_Driver::draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int x, int y, int w, int h, int d) { uchar *buf = new uchar[w*h*d]; - for (int j = 0; j < h; j++) { + int j; + for (j = 0; j < h; j++) { cb(data, 0, j, w, buf + j*w*d); } draw_image_mono(buf, x, y, w, h, d, 0); @@ -879,7 +888,8 @@ void Fl_SVG_Graphics_Driver::loop(int x0, int y0, int x1, int y1, int x2, int y2 } void Fl_SVG_Graphics_Driver::end_points() { - for (int i=0; i<n; i++) { + int i; + for (i =0; i<n; i++) { clocale_printf("<path d=\"M %f %f L %f %f\" fill=\"none\" stroke=\"rgb(%u,%u,%u)\" stroke-width=\"%d\" />\n", xpoint[i].x, xpoint[i].y, xpoint[i].x, xpoint[i].y, red_, green_, blue_, width_); } @@ -892,7 +902,8 @@ void Fl_SVG_Graphics_Driver::end_line() { } if (n<=1) return; clocale_printf("<path d=\"M %f %f", xpoint[0].x, xpoint[0].y); - for (int i=1; i<n; i++) + int i; + for (i =1; i<n; i++) clocale_printf(" L %f %f", xpoint[i].x, xpoint[i].y); fprintf(out_, "\" fill=\"none\" stroke=\"rgb(%u,%u,%u)\" stroke-width=\"%d\" stroke-dasharray=\"%s\" stroke-linecap=\"%s\" stroke-linejoin=\"%s\" />\n", red_, green_, blue_, width_, dasharray_, linecap_, linejoin_); @@ -906,7 +917,8 @@ void Fl_SVG_Graphics_Driver::end_polygon() { } if (n<=1) return; clocale_printf("<path d=\"M %f %f", xpoint[0].x, xpoint[0].y); - for (int i=1; i<n; i++) + int i; + for (i =1; i<n; i++) clocale_printf(" L %f %f", xpoint[i].x, xpoint[i].y); fprintf(out_, " z\" fill=\"rgb(%u,%u,%u)\" />\n", red_, green_, blue_); } @@ -936,7 +948,8 @@ void Fl_SVG_Graphics_Driver::end_complex_polygon() { } if (n<=1) return; clocale_printf("<path d=\"M %f %f", xpoint[0].x, xpoint[0].y); - for (int i=1; i<n; i++) + int i; + for (i =1; i<n; i++) clocale_printf(" L %f %f", xpoint[i].x, xpoint[i].y); fprintf(out_, " z\" fill=\"rgb(%u,%u,%u)\" />\n", red_, green_, blue_); } diff --git a/src/drivers/Unix/Fl_Unix_Screen_Driver.cxx b/src/drivers/Unix/Fl_Unix_Screen_Driver.cxx index 97b11b840..7f10036ff 100644 --- a/src/drivers/Unix/Fl_Unix_Screen_Driver.cxx +++ b/src/drivers/Unix/Fl_Unix_Screen_Driver.cxx @@ -67,7 +67,8 @@ int Fl_Unix_Screen_Driver::poll_or_select_with_delay(double time_to_wait) { fl_lock_function(); if (n > 0) { - for (int i=0; i<nfds; i++) { + int i; + for (i =0; i<nfds; i++) { # if USE_POLL if (pollfds[i].revents) fd[i].cb(pollfds[i].fd, fd[i].arg); # else diff --git a/src/drivers/Unix/Fl_Unix_System_Driver.cxx b/src/drivers/Unix/Fl_Unix_System_Driver.cxx index ab6f678aa..c7dd44068 100644 --- a/src/drivers/Unix/Fl_Unix_System_Driver.cxx +++ b/src/drivers/Unix/Fl_Unix_System_Driver.cxx @@ -292,7 +292,8 @@ int Fl_Unix_System_Driver::file_browser_load_filesystem(Fl_File_Browser *browser res = -1; } else { struct vmount *vp = (struct vmount *) list; - for (int i = 0; i < res; ++i) { + int i; + for (i = 0; i < res; ++i) { name = (char *) vp + vp->vmt_data[VMT_STUB].vmt_off; strlcpy(filename, name, lname); // Skip the already added root filesystem @@ -326,7 +327,7 @@ int Fl_Unix_System_Driver::file_browser_load_filesystem(Fl_File_Browser *browser // Get list of statvfs structures res = getmntinfo(&list, ST_WAIT); if (0 < res) { - for (int i = 0; i < res; ++i) { + for (i = 0; i < res; ++i) { strlcpy(filename, list[i].f_mntonname, lname); // Skip the already added root filesystem if (strcmp("/", filename) != 0) { @@ -890,11 +891,13 @@ unsigned char *Fl_Unix_System_Driver::create_bmp(const unsigned char *data, int write_int(&c,0); // Pixel data data+=3*W*H; - for (int y=0;y<H;++y){ + int y; + for (y =0;y<H;++y){ data-=3*W; const unsigned char *s=data; unsigned char *p=c; - for (int x=0;x<W;++x){ + int x; + for (x =0;x<W;++x){ *p++=s[2]; *p++=s[1]; *p++=s[0]; @@ -924,9 +927,11 @@ Fl_RGB_Image *Fl_Unix_System_Driver::own_bmp_to_RGB(char *bmp) { bmp += 54; uchar *data = new uchar[w*h*3]; uchar *p = data; - for (int i = h-1; i >= 0; i--) { + int i; + for (i = h-1; i >= 0; i--) { char *s = bmp + i * R; - for (int j = 0; j < w; j++) { + int j; + for (j = 0; j < w; j++) { *p++=s[2]; *p++=s[1]; *p++=s[0]; diff --git a/src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx b/src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx index 822acc826..929bd0a1c 100644 --- a/src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx @@ -96,7 +96,8 @@ void Fl_X11_Gl_Window_Driver::get_list(Fl_Font_Descriptor *fd, int r) { if (gl_fd->glok[r]) return; gl_fd->glok[r] = 1; unsigned int ii = r * 0x400; - for (int i = 0; i < 0x400; i++) { + int i; + for (i = 0; i < 0x400; i++) { XFontStruct *font = NULL; unsigned short id; fl_XGetUtf8FontAndGlyph(gl_fd->font, ii, &font, &id); diff --git a/src/drivers/X11/Fl_X11_Screen_Driver.cxx b/src/drivers/X11/Fl_X11_Screen_Driver.cxx index 4fa3b8698..80bf4368e 100644 --- a/src/drivers/X11/Fl_X11_Screen_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Screen_Driver.cxx @@ -88,7 +88,8 @@ void Fl_X11_Screen_Driver::display(const char *d) { static char e[1024]; strcpy(e, "DISPLAY="); strlcat(e, d, sizeof(e)); - for (char *c = e + 8; *c != ':'; c++) { + char *c; + for (c = e + 8; *c != ':'; c++) { if (!*c) { strlcat(e,":0.0",sizeof(e)); break; @@ -188,7 +189,8 @@ int Fl_X11_Screen_Driver::visual(int flags) XVisualInfo *visualList = XGetVisualInfo(fl_display, 0, &vTemplate, &num); // find all matches, use the one with greatest depth: XVisualInfo *found = 0; - for (int i=0; i<num; i++) if (test_visual(visualList[i], flags)) { + int i; + for (i =0; i<num; i++) if (test_visual(visualList[i], flags)) { if (!found || found->depth < visualList[i].depth) found = &visualList[i]; } @@ -314,6 +316,8 @@ void Fl_X11_Screen_Driver::init() { #endif // USE_XRANDR + int i; + #if HAVE_XINERAMA if (XineramaIsActive(fl_display)) { @@ -321,7 +325,7 @@ void Fl_X11_Screen_Driver::init() { if (num_screens > MAX_SCREENS) num_screens = MAX_SCREENS; /* There's no way to use different DPI for different Xinerama screens. */ - for (int i=0; i<num_screens; i++) { + for (i =0; i<num_screens; i++) { screens[i].x_org = xsi[i].x_org; screens[i].y_org = xsi[i].y_org; screens[i].width = xsi[i].width; @@ -345,7 +349,7 @@ void Fl_X11_Screen_Driver::init() { num_screens = ScreenCount(fl_display); if (num_screens > MAX_SCREENS) num_screens = MAX_SCREENS; - for (int i=0; i<num_screens; i++) { + for (i =0; i<num_screens; i++) { screens[i].x_org = 0; screens[i].y_org = 0; screens[i].width = DisplayWidth(fl_display, i); @@ -450,7 +454,8 @@ void Fl_X11_Screen_Driver::grab(Fl_Window* win) static bool using_kde = ( p = getenv("XDG_CURRENT_DESKTOP") , (p && (strcmp(p, "KDE") == 0)) ); Fl_Window *fullscreen_win = NULL; - for (Fl_Window *W = Fl::first_window(); W; W = Fl::next_window(W)) { + Fl_Window *W; + for (W = Fl::first_window(); W; W = Fl::next_window(W)) { if (W->fullscreen_active()) { fullscreen_win = W; break; @@ -1177,7 +1182,8 @@ int Fl_X11_Screen_Driver::screen_num_unscaled(int x, int y) int screen = -1; if (num_screens < 0) init(); - for (int i = 0; i < num_screens; i ++) { + int i; + for (i = 0; i < num_screens; i ++) { int sx = screens[i].x_org, sy = screens[i].y_org, sw = screens[i].width, sh = screens[i].height; if ((x >= sx) && (x < (sx+sw)) && (y >= sy) && (y < (sy+sh))) { screen = i; @@ -1200,7 +1206,8 @@ void Fl_X11_Screen_Driver::desktop_scale_factor() if (factor < 1.1) factor = 1; else if (factor > 1.8 && factor < 2.2) factor = 2; else if (factor > 10.0) factor = 10.0; - for (int i = 0; i < screen_count(); i++) scale(i, factor); + int i; + for (i = 0; i < screen_count(); i++) scale(i, factor); } } } diff --git a/src/drivers/X11/Fl_X11_Window_Driver.cxx b/src/drivers/X11/Fl_X11_Window_Driver.cxx index 96f43ce26..e2e57b629 100644 --- a/src/drivers/X11/Fl_X11_Window_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Window_Driver.cxx @@ -316,7 +316,8 @@ void Fl_X11_Window_Driver::icons(const Fl_RGB_Image *icons[], int count) { icon_->icons = new Fl_RGB_Image*[count]; icon_->count = count; // FIXME: Fl_RGB_Image lacks const modifiers on methods - for (int i = 0;i < count;i++) { + int i; + for (i = 0;i < count;i++) { icon_->icons[i] = (Fl_RGB_Image*)((Fl_RGB_Image*)icons[i])->copy(); icon_->icons[i]->normalize(); } @@ -523,7 +524,8 @@ void Fl_X11_Window_Driver::show_with_args_end(int argc, char **argv) { int n=0; for (j=0; j<argc; j++) n += strlen(argv[j])+1; char *buffer = new char[n]; char *p = buffer; - for (j=0; j<argc; j++) for (const char *q = argv[j]; (*p++ = *q++);); + const char *q; + for (j=0; j<argc; j++) for (q = argv[j]; (*p++ = *q++);); XChangeProperty(fl_display, fl_xid(pWindow), XA_WM_COMMAND, XA_STRING, 8, 0, (unsigned char *)buffer, p-buffer-1); delete[] buffer; diff --git a/src/drivers/X11/fl_X11_platform_init.cxx b/src/drivers/X11/fl_X11_platform_init.cxx index 49947c1f3..eee2aa915 100644 --- a/src/drivers/X11/fl_X11_platform_init.cxx +++ b/src/drivers/X11/fl_X11_platform_init.cxx @@ -49,7 +49,8 @@ Fl_Screen_Driver *Fl_Screen_Driver::newScreenDriver() { Fl_X11_Screen_Driver *d = new Fl_X11_Screen_Driver(); #if USE_XFT || FLTK_USE_CAIRO - for (int i = 0; i < MAX_SCREENS; i++) d->screens[i].scale = 1; + int i; + for (i = 0; i < MAX_SCREENS; i++) d->screens[i].scale = 1; d->current_xft_dpi = 0.; // means the value of the Xft.dpi resource is still unknown #else secret_input_character = '*'; diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx index 336e4b429..1fa277520 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx @@ -128,7 +128,8 @@ void Fl_Xlib_Graphics_Driver::font_name(int num, const char *name) { #if !USE_XFT if (s->xlist && s->n >= 0) XFreeFontNames(s->xlist); #endif - for (Fl_Font_Descriptor* f = s->first; f;) { + Fl_Font_Descriptor *f; + for (f = s->first; f;) { Fl_Font_Descriptor* n = f->next; delete f; f = n; } s->first = 0; @@ -146,7 +147,8 @@ Fl_Region Fl_Xlib_Graphics_Driver::scale_clip(float f) { Region r = (Region)rstack[rstackptr]; if (r == 0 || (f == 1 && offset_x_ == 0 && offset_y_ == 0) ) return 0; Region r2 = XCreateRegion(); - for (int i = 0; i < r->numRects; i++) { + int i; + for (i = 0; i < r->numRects; i++) { int x = floor(r->rects[i].x1 + offset_x_, f); int y = floor(r->rects[i].y1 + offset_y_, f); int w = floor((r->rects[i].x2 + offset_x_) , f) - x; diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx index b6297da61..236734d90 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx @@ -232,14 +232,16 @@ ulong fl_xpixel(Fl_Color i) { // the colormap after this and make decisions here wrong. numcolors = fl_visual->colormap_size; if (!allcolors) allcolors = new XColor[numcolors]; - for (int p = numcolors; p--;) allcolors[p].pixel = p; + int p; + for (p = numcolors; p--;) allcolors[p].pixel = p; XQueryColors(fl_display, colormap, allcolors, numcolors); } // find least-squares match: int mindist = 0x7FFFFFFF; unsigned int bestmatch = 0; - for (unsigned int n = numcolors; n--;) { + unsigned int n; + for (n = numcolors; n--;) { XColor &a = allcolors[n]; int d, t; t = int(r)-int(a.red>>8); d = t*t; diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx index 8ba7fb908..176a388ae 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx @@ -159,7 +159,8 @@ const char* Fl_Xlib_Graphics_Driver::get_font_name(Fl_Font fnum, int* ap) { } // collect all the attribute words: - for (int n = 3; n <= 6; n++) { + int n; + for (n = 3; n <= 6; n++) { // get the next word: if (*e) e++; x = e; @@ -228,7 +229,8 @@ static int ultrasort(const void *aa, const void *bb) { // compare the family and all the attribute words: int atype = 0; int btype = 0; - for (int n = 2; n <= 6; n++) { + int n; + for (n = 2; n <= 6; n++) { int at = attribute(n,a); int bt = attribute(n,b); if (at < 0) { @@ -308,7 +310,8 @@ Fl_Font Fl_Xlib_Graphics_Driver::set_fonts(const char* xstarname) { if (!xlist) return (Fl_Font)fl_free_font; qsort(xlist, xlistsize, sizeof(*xlist), ultrasort); int used_xlist = 0; - for (int i=0; i<xlistsize;) { + int i; + for (i =0; i<xlistsize;) { int first_xlist = i; const char *p = xlist[i++]; char canon[1024]; @@ -359,7 +362,8 @@ int Fl_Xlib_Graphics_Driver::get_font_sizes(Fl_Font fnum, int*& sizep) { int listsize = s->n; if (listsize<0) listsize = -listsize; static int sizes[128]; int numsizes = 0; - for (int i = 0; i < listsize; i++) { + int i; + for (i = 0; i < listsize; i++) { char *q = s->xlist[i]; char *d = fl_find_fontsize(q); if (!d) continue; @@ -371,7 +375,8 @@ int Fl_Xlib_Graphics_Driver::get_font_sizes(Fl_Font fnum, int*& sizep) { int n; for (n = numsizes-1; n > 0; n--) if (sizes[n-1] < s) break; if (sizes[n] != s) { - for (int m = numsizes; m > n; m--) sizes[m] = sizes[m-1]; + int m; + for (m = numsizes; m > n; m--) sizes[m] = sizes[m-1]; sizes[n] = s; numsizes++; } @@ -392,7 +397,8 @@ Fl_Xlib_Font_Descriptor::Fl_Xlib_Font_Descriptor(const char* name) : Fl_Font_Des } # if HAVE_GL listbase = 0; - for (int u = 0; u < 64; u++) glok[u] = 0; + int u; + for (u = 0; u < 64; u++) glok[u] = 0; # endif } @@ -464,7 +470,8 @@ static const char *find_best_font(const char *fname, int size) { int matchedlength = 32767; int found_encoding = 0; int m = cnt; if (m<0) m = -m; - for (int n=0; n < m; n++) { + int n; + for (n =0; n < m; n++) { char* thisname = list[n]; if (fl_correct_encoding(thisname)) { if (!found_encoding) ptsize = 0; // force it to choose this diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx index a7537a184..92b0e0ef6 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx @@ -489,7 +489,8 @@ static XftFont* fontopen(const char* name, /*Fl_Fontsize*/double size, bool core int comma_count = 0; unsigned len = strlen(name); if (len > 512) len = 512; // ensure we are not passed an unbounded font name - for(unsigned idx = 0; idx < len; idx++) { + unsigned idx; + for (idx = 0; idx < len; idx++) { if(name[idx] == '-') hyphen_count++; // check for XLFD hyphens if(name[idx] == ',') comma_count++; // are there multiple names? } @@ -897,7 +898,8 @@ int Fl_Xlib_Graphics_Driver::get_font_sizes(Fl_Font fnum, int*& sizep) { array = new int[array_size = fs->nfont+1]; } array[0] = 0; int j = 1; // claim all fonts are scalable - for (int i = 0; i < fs->nfont; i++) { + int i; + for (i = 0; i < fs->nfont; i++) { double v; if (XftPatternGetDouble(fs->fonts[i], XFT_PIXEL_SIZE, 0, &v) == XftResultMatch) { array[j++] = int(v); @@ -1309,7 +1311,8 @@ double Fl_Xlib_Graphics_Driver::width_unscaled(unsigned int utf32) { } if (!desc->width[r]) { desc->width[r] = (int*)new int[0x0400]; - for (int i = 0; i < 0x0400; i++) desc->width[r][i] = -1; + int i; + for (i = 0; i < 0x0400; i++) desc->width[r][i] = -1; } else { if ( desc->width[r][utf32&0x03FF] >= 0 ) { // already cached return double(desc->width[r][utf32 & 0x03FF]); @@ -1412,13 +1415,15 @@ Fl_Font Fl_Xlib_Graphics_Driver::set_fonts(const char* pattern_name) Fl_Xlib_Graphics_Driver::context(); Fl_Xlib_Graphics_Driver::init_built_in_fonts(); pango_font_map_list_families(Fl_Xlib_Graphics_Driver::pfmap_, &families, &n_families); - for (int fam = 0; fam < n_families; fam++) { + int fam; + for (fam = 0; fam < n_families; fam++) { PangoFontFace **faces; int n_faces; const char *fam_name = pango_font_family_get_name (families[fam]); int lfam = strlen(fam_name); pango_font_family_list_faces(families[fam], &faces, &n_faces); - for (int j = 0; j < n_faces; j++) { + int j; + for (j = 0; j < n_faces; j++) { const char *p = pango_font_face_get_face_name(faces[j]); // Remove " Regular" suffix from font names if (!strcasecmp(p, "regular")) p = NULL; diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx index 5dafe503f..6c13f643f 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx @@ -544,7 +544,8 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, xi.bytes_per_line = linesize*sizeof(STORETYPE); if (buf) { buf += delta*dx+linedelta*dy; - for (int j=0; j<h; ) { + int j; + for (j =0; j<h; ) { STORETYPE *to = buffer; int k; for (k = 0; j<h && k<blocking; k++, j++) { @@ -556,7 +557,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, } } else { STORETYPE* linebuf = new STORETYPE[(W*delta+(sizeof(STORETYPE)-1))/sizeof(STORETYPE)]; - for (int j=0; j<h; ) { + for (j =0; j<h; ) { STORETYPE *to = buffer; int k; for (k = 0; j<h && k<blocking; k++, j++) { @@ -676,8 +677,10 @@ static void alpha_blend(Fl_RGB_Image *img, int X, int Y, int W, int H, int cx, i if (img->d() == 2) { // Composite grayscale + alpha over RGB... - for (int y = H; y > 0; y--, srcptr+=srcskip) - for (int x = W; x > 0; x--) { + int y; + for (y = H; y > 0; y--, srcptr+=srcskip) + int x; + for (x = W; x > 0; x--) { srcg = *srcptr++; srca = *srcptr++; if (srca == 255) { // special case "copy" @@ -700,8 +703,8 @@ static void alpha_blend(Fl_RGB_Image *img, int X, int Y, int W, int H, int cx, i } } else { // Composite RGBA over RGB... - for (int y = H; y > 0; y--, srcptr+=srcskip) - for (int x = W; x > 0; x--) { + for (y = H; y > 0; y--, srcptr+=srcskip) + for (x = W; x > 0; x--) { srcr = *srcptr++; srcg = *srcptr++; srcb = *srcptr++; @@ -901,7 +904,8 @@ void Fl_Xlib_Graphics_Driver::draw_fixed(Fl_Pixmap *pxm, int X, int Y, int W, in Region r = (Region)XRectangleRegion(X,Y,W,H); XIntersectRegion(r, (Region)clip_region(), r); int X1, Y1, W1, H1; - for (int i = 0; i < r->numRects; i++) { + int i; + for (i = 0; i < r->numRects; i++) { X1 = r->rects[i].x1; Y1 = r->rects[i].y1; W1 = r->rects[i].x2 - r->rects[i].x1; diff --git a/src/fl_curve.cxx b/src/fl_curve.cxx index c3324f96e..497a321be 100644 --- a/src/fl_curve.cxx +++ b/src/fl_curve.cxx @@ -84,7 +84,8 @@ void Fl_Graphics_Driver::curve(double X0, double Y0, double dy2 = dy3 + 2*yb*e*e; // draw points 1 .. nSeg-2: - for (int i=2; i<nSeg; i++) { + int i; + for (i =2; i<nSeg; i++) { x += dx1; dx1 += dx2; dx2 += dx3; diff --git a/src/fl_dnd_x.cxx b/src/fl_dnd_x.cxx index be5d18557..0d2a9b2c3 100644 --- a/src/fl_dnd_x.cxx +++ b/src/fl_dnd_x.cxx @@ -94,7 +94,8 @@ int Fl_X11_Screen_Driver::dnd(int unused) { // figure out what window we are pointing at: Window new_window = 0; int new_version = 0; Fl_Window* new_local_window = 0; - for (Window child = RootWindow(fl_display, fl_screen);;) { + Window child; + for (child = RootWindow(fl_display, fl_screen);;) { Window root; unsigned int junk3; XQueryPointer(fl_display, child, &root, &child, &Fl::e_x_root, &Fl::e_y_root, &dest_x, &dest_y, &junk3); diff --git a/src/fl_draw_pixmap.cxx b/src/fl_draw_pixmap.cxx index 923186889..d24dd8b47 100644 --- a/src/fl_draw_pixmap.cxx +++ b/src/fl_draw_pixmap.cxx @@ -101,7 +101,8 @@ int fl_convert_pixmap(const char*const* cdata, uchar* out, Fl_Color bg) { ncolors--; } // read all the rest of the colors: - for (int i=0; i < ncolors; i++) { + int i; + for (i =0; i < ncolors; i++) { uchar* c = colors[*p++]; if (Fl_Graphics_Driver::need_pixmap_bg_color) { used_colors[color_count].r = *(p+0); @@ -115,7 +116,8 @@ int fl_convert_pixmap(const char*const* cdata, uchar* out, Fl_Color bg) { *c = 255; } } else { // normal XPM colormap with names - for (int i=0; i<ncolors; i++) { + int i; + for (i =0; i<ncolors; i++) { const uchar *p = *data++; // the first 1 or 2 characters are the color index: int ind = *p++; @@ -164,13 +166,14 @@ int fl_convert_pixmap(const char*const* cdata, uchar* out, Fl_Color bg) { } U32 *q = (U32*)out; - for (int Y = 0; Y < h; Y++) { + int Y, X; + for (Y = 0; Y < h; Y++) { const uchar* p = data[Y]; if (chars_per_pixel <= 1) { - for (int X = 0; X < w; X++) + for (X = 0; X < w; X++) memcpy(q++, colors[*p++], 4); } else { - for (int X = 0; X < w; X++) { + for (X = 0; X < w; X++) { int ind = (*p++)<<8; ind |= *p++; memcpy(q++, colors[ind], 4); @@ -202,9 +205,10 @@ int fl_draw_pixmap(const char*const* cdata, int x, int y, Fl_Color bg) { *p = bitmap; const uchar *alphaPtr = &buffer[3]; uchar b = 0; - for (int Y = 0; Y < h; Y++) { + int Y, X, bit; + for (Y = 0; Y < h; Y++) { b = 0; - for (int X = 0, bit = 1; X < w; X++, alphaPtr += 4) { + for (X = 0, bit = 1; X < w; X++, alphaPtr += 4) { if (*alphaPtr > 127) b |= bit; bit <<= 1; diff --git a/src/fl_engraved_label.cxx b/src/fl_engraved_label.cxx index 3f98e3155..fad4bc9d1 100644 --- a/src/fl_engraved_label.cxx +++ b/src/fl_engraved_label.cxx @@ -25,7 +25,8 @@ static void innards(const char *str, int len, int X, int Y, const int data[][3], int n) { Fl_Color c = fl_color(); - for (int i = 0; i < n; i++) { + int i; + for (i = 0; i < n; i++) { fl_color((Fl_Color)(i < n-1 ? data[i][2] : c)); fl_draw(str, len, X+data[i][0], Y+data[i][1]); } diff --git a/src/fl_gleam.cxx b/src/fl_gleam.cxx index f3278f9d9..005de54e4 100644 --- a/src/fl_gleam.cxx +++ b/src/fl_gleam.cxx @@ -73,7 +73,8 @@ static void shade_rect_top_bottom(int x, int y, int w, int h, Fl_Color fg1, Fl_C float step_size_bottom = h_bottom > 1 ? (0.999f/float(h_bottom)) : 1; // draw the gradient at the top of the widget float k = 1; - for (int i = 0; i < h_top; i++, k -= step_size_top) { + int i; + for (i = 0; i < h_top; i++, k -= step_size_top) { gleam_color(fl_color_average(fl_color_average(fg1, fg2, th), fg1, k)); fl_xyline(x, y+i, x+w-1); } @@ -84,7 +85,7 @@ static void shade_rect_top_bottom(int x, int y, int w, int h, Fl_Color fg1, Fl_C // draw the gradient at the bottom of the widget k = 1; - for (int i = 0; i < h_bottom; i++, k -= step_size_bottom) { + for (i = 0; i < h_bottom; i++, k -= step_size_bottom) { gleam_color(fl_color_average(fg1, fl_color_average(fg1, fg2, th), k)); fl_xyline(x, y+h_top+h_flat+i, x+w-1); } diff --git a/src/fl_oxy.cxx b/src/fl_oxy.cxx index 6332508d6..4bac70f12 100644 --- a/src/fl_oxy.cxx +++ b/src/fl_oxy.cxx @@ -154,7 +154,8 @@ static void _oxy_up_box_(int x, int y, int w, int h, Fl_Color bg) { float stepoffset = (1.0f / (float)h); int xw = x + w - 1; // from bottom to top - for (int _y = y; _y < y + h; _y++) { + int _y; + for (_y = y; _y < y + h; _y++) { fl_color(fl_color_average(bg, FL_WHITE, (gradoffset < 1.0f) ? gradoffset : 1.0f)); fl_xyline(x, _y, xw); gradoffset += stepoffset; @@ -172,7 +173,8 @@ static void _oxy_down_box_(int x, int y, int w, int h, Fl_Color bg) { float stepoffset = (1.0f / (float)h); int xw = x + w - 1; // from top to bottom - for (int _y = y + h - 1; _y >= y; _y--) { + int _y; + for (_y = y + h - 1; _y >= y; _y--) { fl_color(fl_color_average(bg, FL_WHITE, (gradoffset < 1.0f) ? gradoffset : 1.0f)); fl_xyline(x, _y, xw); gradoffset += stepoffset; @@ -186,14 +188,15 @@ static void _oxy_button_up_box_(int x, int y, int w, int h, Fl_Color bg) { float stepoffset = (1.0f / (float)half_h); Fl_Color col = fl_color_average(bg, FL_WHITE, 0.5); int xw = x + w - 1; - for (int _y = y; _y <= y + half_h; _y++) { + int _y; + for (_y = y; _y <= y + half_h; _y++) { fl_color(fl_color_average(col, FL_WHITE, (gradoffset < 1.0f) ? gradoffset : 1.0f)); fl_xyline(x, _y, xw); gradoffset += stepoffset; } gradoffset = 0.0f; col = bg; - for (int _y = y + h - 1; _y >= y + half_h - 1; _y--) { + for (_y = y + h - 1; _y >= y + half_h - 1; _y--) { fl_color(fl_color_average(col, FL_WHITE, (gradoffset < 1.0f) ? gradoffset : 1.0f)); fl_xyline(x, _y, xw); gradoffset += stepoffset; @@ -207,14 +210,15 @@ static void _oxy_button_down_box_(int x, int y, int w, int h, Fl_Color bg) { int half_h = h / 2, xw = x + w - 1; float gradoffset = 0.15f, stepoffset = (1.0f / (float)half_h); Fl_Color col = fl_color_average(bg, FL_WHITE, 0.5); - for (int _y = y; _y <= y + half_h; _y++) { + int _y; + for (_y = y; _y <= y + half_h; _y++) { fl_color(fl_color_average(col, FL_WHITE, (gradoffset < 1.0f) ? gradoffset : 1.0f)); fl_xyline(x, _y, xw); gradoffset += stepoffset; } gradoffset = 0.0f; col = bg; - for (int _y = y + h - 1; _y >= y + half_h - 1; _y--) { + for (_y = y + h - 1; _y >= y + half_h - 1; _y--) { fl_color(fl_color_average(col, FL_WHITE, (gradoffset < 1.0f) ? gradoffset : 1.0f)); fl_xyline(x, _y, xw); gradoffset += stepoffset; diff --git a/src/fl_read_image.cxx b/src/fl_read_image.cxx index 181e2a094..2a36fb794 100644 --- a/src/fl_read_image.cxx +++ b/src/fl_read_image.cxx @@ -61,9 +61,11 @@ uchar *fl_read_image(uchar *p, int X, int Y, int w, int h, int alpha) { uchar *d = data; const uchar *q; int ld = img->ld() ? img->ld() : img->w() * img->d(); - for (int r = 0; r < img->h(); r++) { + int r; + for (r = 0; r < img->h(); r++) { q = img->array + r * ld; - for (int c = 0; c < img->w(); c++) { + int c; + for (c = 0; c < img->w(); c++) { d[0] = q[0]; d[1] = q[1]; d[2] = q[2]; diff --git a/src/fl_show_colormap.cxx b/src/fl_show_colormap.cxx index c9a96f79b..4442bbce9 100644 --- a/src/fl_show_colormap.cxx +++ b/src/fl_show_colormap.cxx @@ -62,7 +62,8 @@ void ColorMenu::drawbox(Fl_Color c) { void ColorMenu::draw() { if (damage() != FL_DAMAGE_CHILD) { fl_draw_box(FL_UP_BOX,0,0,w(),h(),color()); - for (int c = 0; c < 256; c++) drawbox((Fl_Color)c); + int c; + for (c = 0; c < 256; c++) drawbox((Fl_Color)c); } else { drawbox(previous); drawbox(which); diff --git a/src/fl_utf8.cxx b/src/fl_utf8.cxx index 2c52a04b6..1c8be67e3 100644 --- a/src/fl_utf8.cxx +++ b/src/fl_utf8.cxx @@ -72,7 +72,8 @@ static int Toupper(int ucs) { bool test(const char *str) { if (str == 0) return true; const char *src = str; - for (int p = 0; ; p++) { + int p; + for (p = 0; ; p++) { if (src == 0) return true; int len = fl_utf8len(*src); if (len == -1) { diff --git a/src/fl_write_png.cxx b/src/fl_write_png.cxx index c46072933..ad56bc12b 100644 --- a/src/fl_write_png.cxx +++ b/src/fl_write_png.cxx @@ -164,7 +164,8 @@ int fl_write_png(const char *filename, const char *pixels, int w, int h, int d, png_write_info(pptr, iptr); - for (int i = 0; i < h; i++, ptr += ld) { + int i; + for (i = 0; i < h; i++, ptr += ld) { png_write_row(pptr, ptr); } diff --git a/src/forms_compatibility.cxx b/src/forms_compatibility.cxx index c4901fedc..8c42efdc7 100644 --- a/src/forms_compatibility.cxx +++ b/src/forms_compatibility.cxx @@ -28,6 +28,7 @@ void fl_end_form() { void Fl_Group::forms_end() { // set the dimensions of a group to surround contents const int nc = children(); + int i; if (nc && !w()) { Fl_Widget*const* a = array(); Fl_Widget* o = *a++; @@ -35,7 +36,7 @@ void Fl_Group::forms_end() { int ry = o->y(); int rw = rx+o->w(); int rh = ry+o->h(); - for (int i = nc - 1; i--;) { + for (i = nc - 1; i--;) { o = *a++; if (o->x() < rx) rx = o->x(); if (o->y() < ry) ry = o->y(); @@ -52,7 +53,7 @@ void Fl_Group::forms_end() { Fl_Widget* o = as_window() ? this : window(); int Y = o->h(); Fl_Widget*const* a = array(); - for (int i = nc; i--;) { + for (i = nc; i--;) { Fl_Widget* ow = *a++; int newy = Y - ow->y() - ow->h(); ow->y(newy); diff --git a/src/gl_draw.cxx b/src/gl_draw.cxx index ae0dc94db..95436a610 100644 --- a/src/gl_draw.cxx +++ b/src/gl_draw.cxx @@ -106,11 +106,13 @@ void gl_remove_displaylist_fonts() // clear variables used mostly in fl_font fl_graphics_driver->font(0, 0); - for (int j = 0 ; j < FL_FREE_FONT ; ++j) + int j; + for (j = 0 ; j < FL_FREE_FONT ; ++j) { Fl_Font_Descriptor *prevDesc = 0L, *nextDesc = 0L; Fl_Font_Descriptor *&firstDesc = *Fl_Gl_Window_Driver::global()->fontnum_to_fontdescriptor(j); - for (Fl_Font_Descriptor *desc = firstDesc; desc; desc = nextDesc) + Fl_Font_Descriptor *desc; + for (desc = firstDesc; desc; desc = nextDesc) { nextDesc = desc->next; if(desc->listbase) { @@ -306,7 +308,8 @@ gl_texture_fifo::gl_texture_fifo(int max) gl_texture_fifo::~gl_texture_fifo() { - for (int i = 0; i < size_; i++) { + int i; + for (i = 0; i < size_; i++) { if (fifo[i].utf8) free(fifo[i].utf8); if (textures_generated) glDeleteTextures(1, &fifo[i].texName); } @@ -556,7 +559,8 @@ char *Fl_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, int w, delete image_surface; // This gives us an RGB rendering of the text. We build an alpha channel from that. char *alpha_buf = new char [w * h]; - for (int idx = 0; idx < w * h; ++idx) + int idx; + for (idx = 0; idx < w * h; ++idx) { // Fake up the alpha component using the green component's value alpha_buf[idx] = image->array[idx * 3 + 1]; } @@ -581,7 +585,8 @@ void Fl_Gl_Window_Driver::draw_string_legacy_get_list(const char* str, int n) { size = fl_graphics_driver->font_descriptor()->size; gl_font(fl_font(), Fl_Fontsize(size * gl_start_scale)); } - for (unsigned i = 0; i < wn; i++) { + unsigned i; + for (i = 0; i < wn; i++) { unsigned int r; r = (buf[i] & 0xFC00) >> 10; get_list(gl_fontsize, r); @@ -600,7 +605,8 @@ void Fl_Gl_Window_Driver::draw_string_legacy_glut(const char* str, int n) { uchar *str_nul = new uchar[n + 1]; int m = 0; - for (int i = 0; i < n; i++) { + int i; + for (i = 0; i < n; i++) { if ((uchar)str[i] < 128) str_nul[m++] = str[i]; } str_nul[m] = 0; diff --git a/src/glut_compatibility.cxx b/src/glut_compatibility.cxx index df25c456b..53db8a520 100644 --- a/src/glut_compatibility.cxx +++ b/src/glut_compatibility.cxx @@ -331,7 +331,8 @@ static Fl_Menu_Item* additem(menu *m) { if (m->size+1 >= m->alloc) { m->alloc = m->size*2+10; Fl_Menu_Item* nm = new Fl_Menu_Item[m->alloc]; - for (int i=0; i<m->size; i++) nm[i] = m->m[i]; + int i; + for (i =0; i<m->size; i++) nm[i] = m->m[i]; delete[] m->m; m->m = nm; } @@ -382,7 +383,8 @@ void glutChangeToSubMenu(int item, char *label, int submenu) { void glutRemoveMenuItem(int item) { menu *m = &menus[glut_menu]; if (item > m->size || item < 1) return; - for (int i = item-1; i <= m->size; i++) m->m[i] = m->m[i+1]; + int i; + for (i = item-1; i <= m->size; i++) m->m[i] = m->m[i+1]; m->size--; } |
