Mercurial > ~dholland > hg > ag > index.cgi
view anagram/guisupport/windowreg.cpp @ 8:ec2b657edf13
Add explicit lint-comment-style fallthrough annotations.
GCC now assumes that if you don't have these you're making a mistake,
which is annoying.
XXX: This changeset updates the AG output files only (by hand) and is
XXX: abusive - rebuilding them will erase the change. However, I need
XXX: to get things to build before I can try to get AG to issue the
XXX: annotations itself, so this seems like a reasonable expedient.
author | David A. Holland |
---|---|
date | Mon, 30 May 2022 23:51:43 -0400 |
parents | 13d2b8934445 |
children |
line wrap: on
line source
/* * AnaGram, A System for Syntax Directed Programming * Copyright 1997-2002 Parsifal Software. All Rights Reserved. * See the file COPYING for license and usage terms. * * windowreg.cpp */ #include "ctrlpanel.hpp" // sigh... XXX (for syntaxFileId/syntaxFileRect) #include "vaclgui.hpp" // XXX (for cascadeOrigin/cascadeOffset) #include "windowreg.h" //#define INCLUDE_LOGGING #include "log.h" void WindowRegistry::registerId(AgFrame *window, AgString title, AgAction action) { LOGSECTION("WindowRegistry::registerId"); int id = window->id(); int first = 0, last = registry.size(); LOGV(id) LCV(title.pointer()) LCV(last); int firstClone = -1; int firstViewNumber = 0; int maxView = 1; while (first < last) { registry[first++].isActive = 0; } first = 0; while (first < last) { WindowRecord &windowRecord = registry[first]; if (windowRecord.id == id) { windowRecord.action = action; windowRecord.title = title; windowRecord.window = window; windowRecord.isActive = 1; return; } if (windowRecord.title == title) { int viewNumber = windowRecord.window->windowTitle.viewNumber(); if (firstClone == -1) { firstClone = first; firstViewNumber = viewNumber; } if (maxView < viewNumber) { maxView = viewNumber; } } first++; } LOGV(maxView); registry.push(WindowRecord()); LOGV(first) LCV(registry.size()); WindowRecord &windowRecord = registry[first]; LOGV((int) ®istry[first]); LOGV((int) &windowRecord); windowRecord.id = id; windowRecord.action = action; windowRecord.title = title; windowRecord.window = window; windowRecord.isActive = 1; if (firstClone == -1) { return; } if (firstViewNumber == 0) { LOGV(firstClone); registry[firstClone].window->windowTitle.setViewNumber(1); } window->windowTitle.setViewNumber(maxView+1); LOGS("registration complete"); } void WindowRegistry::refresh(AgString title) { LOGSECTION("WindowRegistry::refresh"); int first = 0, last = registry.size(); LOGV(title.pointer()) LCV(last); while (first < last) { WindowRecord &windowRecord = registry[first]; if (windowRecord.title == title) { windowRecord.window->refresh(); } first++; } } void WindowRegistry::remove(int id) { LOGSECTION("WindowRegistry::remove"); LOGV(id); int first = 0, last = registry.size(); while (first < last) { if (registry[first].id == id) { LOGV(registry[first].title.pointer()); if (id == syntaxFileId) { LOGV(syntaxFileId); LOGV(syntaxFileRect.asString()); syntaxFileRect = registry[first].window->rect(); LOGV(syntaxFileRect.asString()); syntaxFileId = 0; } last--; while (first < last) { registry[first] = registry[first+1]; first++; } registry.pop(); break; } first++; } if (registry.size() == 0) { cascadeOffset = cascadeOrigin; } } AgFrame *WindowRegistry::find(AgString title) { LOGSECTION("WindowRegistry::find(AgString)"); LOGV(title.pointer()); int first = 0, last = registry.size(); LOGV(last); while (first < last) { LOGV(registry[first].title.pointer()); if (registry[first].title == title) { return registry[first].window; } first++; } return NULL; } AgFrame *WindowRegistry::find(int id) { LOGSECTION("WindowRegistry::find(int)"); int first = 0, last = registry.size(); while (first < last) { LOGV(registry[first].id); LOGV(registry[first].title.pointer()); if (registry[first].id == id) { return registry[first].window; } first++; } return NULL; } AgString WindowRegistry::getTitle(int id) { int first = 0, last = registry.size(); while (first < last) { if (registry[first].id == id) { return registry[first].title; } first++; } return AgString(); } /* void WindowRegistry::bubbleUp(int id) { LOGSECTION("WindowRegistry::bubbleUp"); if (cascadeFlag) return; int first = 0, last = registry.size() - 1; while (first < last) { LOGV(registry[first].id) LCV(registry[first].title.pointer()); if (registry[first].id == id) { LOGS("found it"); WindowRecord save = registry[first]; for (int i = first; i < last; i++) registry[i] = registry[i+1]; registry[last] = save; return; } first++; } } */ void WindowRegistry::markActive(int id) { LOGSECTION("WindowRegistry::markActive"); if (cascadeFlag) { return; } int first = 0, last = registry.size(); while (first < last) { registry[first++].isActive = 0; } first = 0; while (first < last) { LOGV(registry[first].id) LCV(registry[first].title.pointer()); if (registry[first].id == id) { LOGS("found it"); registry[first].isActive = 1; return; } first++; } } void WindowRegistry::clearActive() { LOGSECTION("WindowRegistry::clearActive"); int first = 0, last = registry.size(); while (first < last) { registry[first++].isActive = 0; } } int WindowRegistry::action(int id) { LOGSECTION("WindowRegistry::action"); int first = 0, last = registry.size(); while (first < last) { if (registry[first].id == id) { registry[first].action.perform(); return 1; } first++; } LOGS("command not recognized"); return 0; } int WindowRegistry::action(AgString title) { LOGSECTION("WindowRegistry::action(AgString)"); LOGV(title.pointer()); int first = 0, last = registry.size(); LOGV(last); while (first < last) { LOGV(registry[first].title.pointer()); if (registry[first].title == title) { registry[first].action.perform(); return 1; } first++; } return 0; }