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 32 of file C4EditCursor.h.

Member Function Documentation

bool C4EditCursorSelection::ClearPointers ( C4Object obj)

Definition at line 101 of file C4EditCursor.cpp.

References ConsolidateEmpty().

Referenced by C4EditCursor::ClearPointers().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4EditCursorSelection::ConsolidateEmpty ( )

Definition at line 95 of file C4EditCursor.cpp.

References C4VNull.

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

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

Here is the caller graph for this function:

StdStrBuf C4EditCursorSelection::GetDataString ( ) const

Definition at line 46 of file C4EditCursor.cpp.

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

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

Here is the call graph for this function:

C4Object * C4EditCursorSelection::GetLastObject ( ) const

Definition at line 86 of file C4EditCursor.cpp.

Referenced by C4EditCursor::Move().

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

Here is the caller graph for this function:

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

Definition at line 75 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().

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

Here is the caller graph for this function:

bool C4EditCursorSelection::IsContained ( C4PropList obj) const

Definition at line 114 of file C4EditCursor.cpp.

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

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

Here is the caller graph for this function:

int32_t C4EditCursorSelection::ObjectCount ( ) const

Definition at line 120 of file C4EditCursor.cpp.

References C4Value::getObj().

Referenced by C4EditCursor::EMMoveObject().

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

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: