Contents page

Index

Source


//////////////////////////////////////////////////////////////////////////////
  // gadget.cpp
  //
  // Jeffry A Worth
  // Nov 9, 1995
  //////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////// // INCLUDES #include "aframe:include/gadget.hpp"

////////////////////////////////////////////////////////////////////////////// //

AFGadget::AFGadget() { m_pgadget = NULL; m_flags = NULL; }

AFGadget::~AFGadget() { // When the Window object is destroyed, all AFGadgets get their DestroyObject // method called. To remove the CGadget from the window without destroying // the window, the user must call the DestroyObject method. }

void AFGadget::DestroyObject() { if(m_pgadget && (!(m_flags & AFGADGET_OWNERSTRUCT)) ) { RemoveGadget(); delete m_pgadget; m_pgadget = NULL; m_flags = NULL; } }

void AFGadget::Create(AFWindow* pwindow, AFRect *rect, ULONG id) { m_pwindow = pwindow; m_pgadget = new struct Gadget; m_pgadget->NextGadget = NULL; m_pgadget->LeftEdge = rect->TopLeft()->m_x; m_pgadget->TopEdge = rect->TopLeft()->m_y; m_pgadget->Width = rect->Width(); m_pgadget->Height = rect->Height(); m_pgadget->GadgetID = id; FillGadgetStruct(m_pgadget); m_pgadget->UserData = this;

// Gadget Tracking - Not implemented yet! //m_pwindow->m_pgadgets = new AFNode(m_pgadget,m_pwindow->m_pgadgets);

AddGadget(); return; }

void AFGadget::Create(AFWindow* pwindow, LPGadget psgadget) { // Set up OWNERSTRUCT Gadget m_pgadget = psgadget; m_pwindow = pwindow; m_flags |= AFGADGET_OWNERSTRUCT; psgadget->UserData = this;

// Gadget Tracking - Not implemented yet! // m_pwindow->m_pgadgets = new CNode(m_pgadget,m_pwindow->m_pgadgets);

AddGadget(); }

void AFGadget::FillGadgetStruct(LPGadget psgadget) { psgadget->Flags = GFLG_GADGHCOMP; psgadget->Activation = GACT_RELVERIFY | GACT_IMMEDIATE; psgadget->GadgetType = GTYP_BOOLGADGET; psgadget->GadgetRender = NULL; psgadget->SelectRender = NULL; psgadget->GadgetText = NULL; psgadget->MutualExclude = NULL; psgadget->SpecialInfo = NULL; return; }

void AFGadget::AddGadget() { ::AddGadget(m_pwindow->m_pWindow,m_pgadget,-1); }

void AFGadget::RemoveGadget() { ::RemoveGadget(m_pwindow->m_pWindow,m_pgadget); }