Mercurial > ~dholland > hg > ag > index.cgi
view anagram/vaclgui/dpanel.cpp @ 14:a02e9434072e
Fix friend declaration for gcc10.
XXX: did not check it against the IBM compiler, might end up needing
XXX: to be conditional.
author | David A. Holland |
---|---|
date | Tue, 31 May 2022 00:59:42 -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. * * dpanel.cpp */ #include "agcstack.h" #include "dpanel.hpp" #include "myalloc.h" //#define INCLUDE_LOGGING #include "log.h" AgDataPanel::AgDataPanel(WindowData *data) : AgFrame( IFrameWindow::maximizeButton | IFrameWindow::systemMenu | IFrameWindow::sizingBorder) , dataView(new AgDataView(this, data)) , helpDemon(&windowTitle, data->headTitle()) { LOGSECTION("AgDataPanel::AgDataPanel(WindowData *)"); LOGV(windowId); ok_ptr(data); syntaxDependent = data->syntaxDependent(); init(); } AgDataPanel::AgDataPanel() : AgFrame( IFrameWindow::maximizeButton | IFrameWindow::systemMenu | IFrameWindow::sizingBorder) , helpDemon(&windowTitle) { LOGSECTION("AgDataPanel::AgDataPanel()"); LOGV(windowId); } void AgDataPanel::init() { LOGSECTION("AgDataPanel::init"); LOGV(windowId); AgString titleString; AgString title; AgString simpleTitle; ok_ptr(dataView->windowData); title = dataView->windowData->headTitle(); helpDemon.setTopic(title); LOGV(title.pointer()); AgString name = dataView->windowData->fileName(); char buf[500] = "AnaGram"; if (syntaxDependent && name.exists()) { sprintf(buf, "AnaGram : %s", name.pointer()); } AgString objectName = buf; AgString foot = dataView->windowData->footTitle(); if (foot.exists() && foot.size()) { simpleTitle = AgString::format("%s (%s)", title.pointer(), foot.pointer()); } else { simpleTitle = title; } LOGV(windowTitle.objectText()); LOGV(windowTitle.viewText()); LOGV(windowTitle.text()); windowTitle.setObjectText(objectName.pointer()); windowTitle.setViewText(simpleTitle.pointer()); AgCharStack cs; //cs.push(name).push(" - ").push(simpleTitle); cs << name; cs << " - " << simpleTitle; dataView->copyTitle = cs.popString(); LOGV(dataView->copyTitle); LOGV(windowTitle.objectText()); LOGV(windowTitle.viewText()); LOGV(windowTitle.text()); registerTitle(simpleTitle); ISize tableSize = dataView->suggestSize(); int width = 40*dataView->font().avgCharWidth(); int testWidth = tableSize.width(); int titleWidth = windowTitle.displaySize(windowTitle.text()).width() + windowTitle.minimumSize().width(); LOGV(windowTitle.text()); LOGV(titleWidth); LOGV(testWidth); if (testWidth < titleWidth) { testWidth = titleWidth; } LOGV(width); LOGV(testWidth); if (testWidth < width/2) { width = width/2; } else if (testWidth > 2*width) { width = 2*width; } else { width = testWidth; } LOGV(width); ISize clientSize(width, tableSize.height()); IRectangle frameRect(frameRectFor(clientSize)); LOGV(clientSize.asString()); LOGV(frameRect.size().asString()); sizeTo(frameRect.size()); //LOGV(cascadeOffset.asString()); setClient(dataView); positionFrame(); //show(); } AgDataPanel::~AgDataPanel() { LOGSECTION("AgDataPanel::~AgDataPanel"); LOGV(windowId); //dataView->disconnect(); ok_ptr(dataView->windowData); //dataView->disconnect(); //if (dataView->windowData) dataView->windowData->close(); delete dataView; } void AgDataPanel::disconnect() { LOGSECTION("AgDataPanel::disconnect"); dataView->disconnect(); } AgDataPanel &AgDataPanel::close() { LOGSECTION("AgDataPanel::close"); /* if (dataView->windowData) { dataView->windowData->close(); } delete dataView->windowData; */ //dataView->windowData = 0; //dataView->disconnect(); IFrameWindow::close(); return *this; } unsigned AgDataPanel::getLineNumber() { return dataView->getCursorLine(); } void AgDataPanel::setLineNumber(unsigned n) { dataView->setCursorLine(n); } Boolean AgDataPanel::findNext(AgString s) { return dataView->findNext(s); } Boolean AgDataPanel::findPrev(AgString s) { return dataView->findPrev(s); }