OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4EditCursorSelection Class Reference

#include <C4EditCursor.h>

Inheritance diagram for C4EditCursorSelection:
[legend]
Collaboration diagram for C4EditCursorSelection:
[legend]

Public Member Functions

StdStrBuf GetDataString () const
 
C4ObjectGetObject (int32_t index=0) const
 
C4ObjectGetLastObject () const
 
void ConsolidateEmpty ()
 
bool ClearPointers (C4Object *obj)
 
bool IsContained (C4PropList *obj) const
 
int32_t ObjectCount () const
 

Detailed Description

Definition at line 31 of file C4EditCursor.h.

Member Function Documentation

bool C4EditCursorSelection::ClearPointers ( C4Object obj)

Definition at line 100 of file C4EditCursor.cpp.

References ConsolidateEmpty().

Referenced by C4EditCursor::ClearPointers().

101 {
102  bool found = false;
103  for (C4Value &v : (*this))
104  if (obj == v.getObj())
105  {
106  found = true;
107  v.Set0();
108  }
109  if (found) ConsolidateEmpty();
110  return found;
111 }

Here is the call graph for this function:

Here is the caller graph for this function:

void C4EditCursorSelection::ConsolidateEmpty ( )

Definition at line 94 of file C4EditCursor.cpp.

References C4VNull.

Referenced by ClearPointers(), C4EditCursor::Execute(), and C4EditCursor::In().

95 {
96  // remove nullptred entries that may happen because objects got deleted
97  this->remove(C4VNull);
98 }
const C4Value C4VNull
Definition: C4Value.cpp:30

Here is the caller graph for this function:

StdStrBuf C4EditCursorSelection::GetDataString ( ) const

Definition at line 45 of file C4EditCursor.cpp.

References StdStrBuf::Format(), C4Object::GetDataString(), GetObject(), LoadResStr(), and StdStrBuf::Take().

46 {
47  StdStrBuf Output;
48  // Compose info text by selected object(s)
49  int32_t obj_count = size();
50  switch (obj_count)
51  {
52  // No selection
53  case 0:
54  Output = LoadResStr("IDS_CNS_NOOBJECT");
55  break;
56  // One selected object
57  case 1:
58  {
59  C4Object *obj = GetObject();
60  if (obj)
61  Output.Take(obj->GetDataString());
62  else
63  Output.Take(front().GetDataString());
64  break;
65  }
66  // Multiple selected objects
67  default:
68  Output.Format(LoadResStr("IDS_CNS_MULTIPLEOBJECTS"), obj_count);
69  break;
70  }
71  return Output;
72 }
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:174
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4Object * GetObject(int32_t index=0) const
StdStrBuf GetDataString()
Definition: C4Object.cpp:1625
void Take(char *pnData)
Definition: StdBuf.h:457
StdStrBuf GetDataString() const

Here is the call graph for this function:

C4Object * C4EditCursorSelection::GetLastObject ( ) const

Definition at line 85 of file C4EditCursor.cpp.

Referenced by C4EditCursor::Move().

86 {
87  C4Object *obj, *last = nullptr;
88  for (const C4Value &v : (*this))
89  if ((obj = v.getObj()))
90  last = obj;
91  return last;
92 }

Here is the caller graph for this function:

C4Object * C4EditCursorSelection::GetObject ( int32_t  index = 0) const

Definition at line 74 of file C4EditCursor.cpp.

Referenced by C4EditCursor::DoContextMenu(), C4EditCursor::GetCurrentSelectionPosition(), GetDataString(), C4EditCursor::GrabContents(), C4EditCursor::HasTransformMarker(), C4EditCursor::IsHoveringTransformMarker(), C4EditCursor::LeftButtonDown(), C4EditCursor::Move(), PropertyDlgProc(), and C4EditCursor::UpdateDropTarget().

75 {
76  // Get indexed C4Object * in list
77  C4Object *obj;
78  for (const C4Value &v : (*this))
79  if ((obj = v.getObj()))
80  if (!index--)
81  return obj;
82  return nullptr;
83 }

Here is the caller graph for this function:

bool C4EditCursorSelection::IsContained ( C4PropList obj) const

Definition at line 113 of file C4EditCursor.cpp.

Referenced by C4EditCursor::AddToSelection(), C4EditCursor::Move(), C4EditCursor::RemoveFromSelection(), and C4EditCursor::UpdateDropTarget().

114 {
115  for (const C4Value &v : (*this)) if (obj == v.getPropList()) return true;
116  return false;
117 }

Here is the caller graph for this function:

int32_t C4EditCursorSelection::ObjectCount ( ) const

Definition at line 119 of file C4EditCursor.cpp.

References C4Value::getObj().

Referenced by C4EditCursor::EMMoveObject().

120 {
121  // count only C4Object *
122  int32_t count = 0;
123  for (const C4Value &v : *this) if (v.getObj()) ++count;
124  return count;
125 }
C4Object * getObj() const
Definition: C4Value.cpp:68

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files: