/* * MathPlanner 3.1 - Mathematical design tool. * Copyright(C) 2002 Jarmo Nikkanen * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation. * * You should have received a copy of the GNU General Public License with this program. * */ #include "BaseStructures.h" #include "Datastore.h" #include "Error.h" #include "Header.h" #include "Object_string.h" #include "AppControl.h" #include "Function_object.h" #include "ConfigReader.h" // ************************************************************************************ // Base Object Message // ************************************************************************************ base_object_message::base_object_message(class ApplicationControl *a) { AppControl=a; } QWidget *base_object_message::MainWidget() { return(NULL); } base_object_message::~base_object_message() { } void base_object_message::ReadState(m_base_object *x) { } void base_object_message::PostMessage(DataStorage *msg,int dest) { AppControl->PostMessage(msg,dest); } // ************************************************************************************ // Base Object // ************************************************************************************ QColor m_base_object::GetColor(int id) { return(QColor(0,0,0)); } QFont m_base_object::GetFont(int id) { QFont font; return(font); } void m_base_object::SetFontSize(int id) { } void m_base_object::SetStringObject(class string_object *str) { string=str; } void m_base_object::FocusNextObject() { } void m_base_object::SendCall(int cal) { } void m_base_object::SeekObject(QPoint p) { SetFocus(); } void m_base_object::InsertString(str_range ran,string_object *st) { } bool m_base_object::AutoDeletion() { return(false); } void m_base_object::SetValue(math_node v) { value=v; } void m_base_object::SetRange(str_range ran) { range=ran; } void m_base_object::KeyOutput(key_code key) { if (string) string->KeyReceived(key); else ErrorReport("base_object::KeyOutput()","Unable to find destination"); } void m_base_object::SetFocus() { if (string) { string->SetInsertMode(MODE_AUTO); string->SelectObject(this); if (string->HasFocus()==false) string->SetFocus(); string->FocusObject(this); AppControl->CreateControlMenu(this); } // AppControl->Read(); } bool m_base_object::HasFocus() { if (string) if (string->GetFocus()==this) return(function->HasFocus()); return(false); } void m_base_object::UnFocus() { if (string) if (string->GetFocus()==this) string->UnFocusAll(); } m_base_object::m_base_object(ApplicationControl *Aplc,m_function_object *v,class string_object *str) { function=v; string=str; AppControl=Aplc; } m_base_object::m_base_object(DataStorage *msg) { // IMPORTANT First of All Take new pointer to function object IMPORTANT // Needed to intialize rest of functions if (msg->Contains("function")) msg->ReadPointer("function",(void **)&function); else ErrorReport("Base Constructor","No Function"); if (msg->Contains("string")) msg->ReadPointer("string",(void **)&string); else ErrorReport("Base Constructor","No String"); if (msg->Contains("appcontrol")) msg->ReadPointer("appcontrol",(void **)&AppControl); else ErrorReport("Base Constructor","No AppControl"); if (function==NULL) ErrorReport("base::Constructor","Function is NULL"); if (string==NULL) ErrorReport("base::Constructor","string is NULL"); if (AppControl==NULL) ErrorReport("base::Constructor","AppControl is NULL"); msg->ReadLayoutRect("bo:b",&bounds); msg->ReadLayoutRect("bo:o",&old_bounds); SubObject=msg->ReadInt("bo:S"); Type=msg->ReadInt("Object"); MainType=msg->ReadInt("bo:Main"); Priority=msg->ReadInt("bo:pri"); } m_base_object::~m_base_object() { } DataStorage *m_base_object::BuildStorage() { DataStorage *msg=new DataStorage(); msg->AddLayoutRect("bo:b",&bounds); msg->AddLayoutRect("bo:o",&old_bounds); msg->AddInt("bo:S",SubObject); msg->AddInt("Object",Type); msg->AddInt("bo:Main",MainType); msg->AddInt("bo:pri",Priority); return(msg); } void m_base_object::Reset() { value=0; // Do not reset archived values Error_flag=false; Neg=0; bounds_pen.setColor(AppControl->Prefs->Color("BoxColor")); bounds_pen.setWidth(0); bounds_pen.setStyle(Qt::DashLine); error_pen.setColor(AppControl->Prefs->Color("ErrorColor")); error_pen.setWidth(0); error_pen.setStyle(Qt::SolidLine); color_pen.setColor(AppControl->Prefs->Color("BaseFontColor")); color_pen.setWidth(0); color_pen.setStyle(Qt::SolidLine); focus_pen.setColor(AppControl->Prefs->Color("FocusColor")); focus_pen.setWidth(0); focus_pen.setStyle(Qt::DashLine); } math_node m_base_object::Calculate() { value.Clear(); return(value); } math_node m_base_object::Calculate(math_node mn) { value.Clear(); return(value); } void m_base_object::CalculateBounds() { bounds.x=0; bounds.y=0; bounds.width=0; bounds.ascent=0; bounds.descent=0; } void m_base_object::MoveTo(QPoint p) { bounds.SetPosition(p); } void m_base_object::Draw(QPainter *pd) { } void m_base_object::KeyReceived(key_code key) { KeyOutput(key); } void m_base_object::KeyFeedback(key_code key) { KeyOutput(key); } void m_base_object::Init() { SetFocus(); } void m_base_object::Build() { } void m_base_object::MessageReceived(DataStorage *msg,int rec) { if (rec!=TO_OPERATOR) PostMessage(msg,rec); } void m_base_object::PostMessage(DataStorage *msg,int dest) { if (dest==TO_FRAME) function->MessageReceived(msg,dest); else if (dest==TO_APPCONTROL) AppControl->MessageReceived(msg,dest); else AppControl->PostMessage(msg,dest); } base_object_message *m_base_object::CreateControlObject() { return(NULL); }