Main Page Class Hierarchy Compound List File List Compound Members File Members

# MNAbstractEdit Class Reference

This class implements common edit control features. More...

`#include <MNAbstractEdit.h>`

Inheritance diagram for MNAbstractEdit:

List of all members.

## Public Methods
| MNAbstractEdit (MNComponent *parent, int type, int x, int y, int w, int h, int style=0, LPSTR def_text=NULL)
| Creates a new AbstractEdit Field.
virtual void | RegisterComponent (HWND *hwnd, MNComponent *com)
| Allows this component to recieve top level events.
virtual void | RegisterChild (HWND *hwnd, MNComponent *com)
| Allows this component to propagate an event to the given child.
virtual void | AddCallBack (BOOL(*callback)(MNComponent *, UINT, WPARAM, LPARAM))
| Adds a callback function.
virtual LRESULT | FireEvents (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
| Propagates events to all the callback functions.
virtual LRESULT | FireChildEvents (UINT message, WPARAM wParam, LPARAM lParam)
| Propagates the events to the appropriate child/children.
virtual LRESULT | SendEventToParent (UINT message, WPARAM wParam, LPARAM lParam)
| Transmits the given event to the parent.
virtual LRESULT | SendEventToChild (HWND child, UINT message, WPARAM wParam, LPARAM lParam)
| Transmits the given event to the child.
virtual LRESULT | SendEventToChild (MNComponent *child, UINT message, WPARAM wParam, LPARAM lParam)
| Transmits the given event to the child.
LRESULT | SendMessage (UINT msg, WPARAM wParam, LPARAM lParam)
| Sends a message to the underlying control.
virtual BOOL | Show ()
| Shows the component.
virtual BOOL | Hide ()
| Hides the component.
virtual HWND | GetHwnd ()
| Returns the window handle.
virtual HINSTANCE | GetInstance ()
| Returns the instance of the application.
virtual void | SetSize (int width, int height)
| Sets the size of the component.
virtual void | SetWidth (int width)
| Sets the width of the component.
virtual void | SetHeight (int height)
| Sets the height of the component.
virtual int | GetWidth ()
| Gets the width of the component.
virtual int | GetHeight ()
| Gets the height of the component.
virtual void | SetText (LPSTR label)
| Set the components text.
virtual void | GetText (LPSTR buf, int buf_len)
| Returns the component's text.
virtual int | GetX ()
| Returns the component's horizontal position.
virtual int | GetY ()
| Returns the component's vertical position.
virtual void | SetX (int x)
| Sets the component's horizontal position.
virtual void | SetY (int y)
| Sets the component's vertical position.
virtual void | SetPosition (int x, int y)
| Sets the component's position.
## Protected Methods
void | CreateControl (MNComponent *parent, LPSTR classname, LPSTR label, int width, int height, int x, int y, int style, int exstyle)
| Method that does the actual button creation.
void | GetCharSize ()
| Gets the average width of a character and the height of a character.
## Protected Attributes
MNComponent * | parent
| The parent of the component.
HWND | hwnd
| The handle to the component.
HINSTANCE | hInstance
| The instance of this application.
int | showstate
| The state of the window when hidden.
int | width
| The width of the component in pixels.
int | height
| The height of the component in pixels.
int | x
| The horizontal position of the panel.
int | y
| The vertical position of the panel.
vector< BOOL(*)(MNComponent *, UINT, WPARAM, LPARAM)> | listeners
| Stores the callbacks for this component. Stores the functions given to AddCallBack(). It is used by FireEvents() to notify the callbacks.
vector< CHILDCOMPONENT > | clisteners
| A list of the child components that events are to be passed to.
## Static Protected Attributes
TEXTMETRIC | finfo
| Information about the font used by the system.
## Friends
LRESULT CALLBACK | GlobalProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
| Is used to process all the callback functions.

## Detailed Description

This class implements common edit control features.

Author:
  Micheal Nooner

An edit control can generates the following events:

- EN_CHANGE The user has modified text in an edit control. The system updates the display before sending this message (unlike EN_UPDATE).
- EN_ERRSPACE The edit control cannot allocate enough memory to meet a specific request.
- EN_HSCROLL The user has clicked the edit control's horizontal scroll bar. The system sends this message before updating the screen.
- EN_KILLFOCUS The user has selected another control.
- EN_MAXTEXT While inserting text, the user has exceeded the specified number of characters for the edit control. Insertion has been truncated. This message is also sent either when an edit control does not have the ES_AUTOHSCROLL style and the number of characters to be inserted exceeds the width of the edit control or when an edit control does not have the ES_AUTOVSCROLL style and the total number of lines to be inserted exceeds the height of the edit control.
- EN_SETFOCUS The user has selected this edit control.
- EN_UPDATE The user has altered the text in the edit control and the system is about to display the new text. The system sends this message after formatting the text, but before displaying it, so that the application can resize the edit control window.
- EN_VSCROLL The user has clicked the edit control's vertical scroll bar or has scrolled the mouse wheel over the edit control. The system sends this message before updating the screen.

The following message can be sent to edit controls.

- EM_CANUNDO
- EM_CHARFROMPOS
- EM_EMPTYUNDOBUFFER
- EM_FMTLINES
- EM_GETFIRSTVISIBLELINE
- EM_GETHANDLE
- EM_GETIMESTATUS
- EM_GETLIMITTEXT
- EM_GETLINE
- EM_GETLINECOUNT
- EM_GETMARGINS
- EM_GETMODIFY
- EM_GETPASSWORDCHAR
- EM_GETRECT
- EM_GETSEL
- EM_GETTHUMB
- EM_GETWORDBREAKPROC
- EM_LIMITTEXT
- EM_LINEFROMCHAR
- EM_LINEINDEX
- EM_LINELENGTH
- EM_LINESCROLL
- EM_POSFROMCHAR
- EM_REPLACESEL
- EM_SCROLL
- EM_SCROLLCARET
- EM_SETHANDLE
- EM_SETIMESTATUS
- EM_SETLIMITTEXT
- EM_SETMARGINS
- EM_SETMODIFY
- EM_SETPASSWORDCHAR
- EM_SETREADONLY
- EM_SETRECT
- EM_SETRECTNP
- EM_SETSEL
- EM_SETTABSTOPS
- EM_SETWORDBREAKPROC
- EM_UNDO
- EN_ALIGN_LTR_EC
- EN_ALIGN_RTL_EC
- EN_CHANGE
- EN_ERRSPACE
- EN_HSCROLL
- EN_KILLFOCUS
- EN_MAXTEXT
- EN_SETFOCUS
- EN_UPDATE
- EN_VSCROLL
- WM_COMMAND
- WM_COPY
- WM_CTLCOLOREDIT
- WM_CUT
- WM_PASTE
- WM_UNDO

## Constructor & Destructor Documentation

MNAbstractEdit::MNAbstractEdit | ( | MNComponent * | parent,
|  | int | type,
|  | int | x,
|  | int | y,
|  | int | w,
|  | int | h,
|  | int | style = 0,
|  | LPSTR | def_text = NULL
| ) |

  | Creates a new AbstractEdit Field. Parameters:
  parent | the parent of this component.
  type | the type of edit control it is.
  x | how far left to place the control.
  y | how far down to place the control.
  w | the width of the component (in characters).
  h | the height of the component (in characters).
  style | the style of the control (see windows docs).
  def_text | the default text of the control.

## Member Function Documentation

void MNComponent::AddCallBack | ( | BOOL(* | callback)(MNComponent *, UINT, WPARAM, LPARAM) | ) | `[virtual, inherited]`

  | Adds a callback function. Parameters:
  callback | the function to call when an event occurs
See also: FireEvents(), listeners

void MNComponent::CreateControl | ( | MNComponent * | parent,
|  | LPSTR | classname,
|  | LPSTR | label,
|  | int | width,
|  | int | height,
|  | int | x,
|  | int | y,
|  | int | style,
|  | int | exstyle
| ) | `[protected, inherited]`

  | Method that does the actual button creation. Parameters:
  parent | the parent of this component.
  label | the text to associate with the button.
  classname | the name of the registered class to use (see windows docs).
  width | how wide to make the button.
  height | how tall to make the button.
  x | how far left to place the button at.
  y | how far down to place the button at.
  style | the style of the button (see windows docs).
  exstyle | the extended window style (see windows docs).

LRESULT MNComponent::FireChildEvents | ( | UINT | message,
|  | WPARAM | wParam,
|  | LPARAM | lParam
| ) | `[virtual, inherited]`

  | Propagates the events to the appropriate child/children. Parameters:
  message | the windows message to pass to the callback
  wParam | the submessage (see windows docs).
  lParam | the subparameter (see windows docs).
Returns: 0 if the event was handled otherwise what DefWindowProc returns. See also: RegisterChild(), clisteners

LRESULT MNComponent::FireEvents | ( | HWND | hwnd,
|  | UINT | message,
|  | WPARAM | wParam,
|  | LPARAM | lParam
| ) | `[virtual, inherited]`

  | Propagates events to all the callback functions. Parameters:
  hwnd | the window handle to the window the events go to.
  message | the windows message to pass to the callback.
  wParam | the submessage (see windows docs).
  lParam | the subparameter (see windows docs).
Returns: 0 if the event was handled otherwise what DefWindowProc returns. See also: AddCallBack(), listeners

int MNComponent::GetHeight | ( |  | ) | `[virtual, inherited]`

| Gets the height of the component. Returns: The height of the component. Reimplemented in MNPanel.

HWND MNComponent::GetHwnd | ( |  | ) | `[virtual, inherited]`

| Returns the window handle. Returns: the window handle.

HINSTANCE MNComponent::GetInstance | ( |  | ) | `[virtual, inherited]`

| Returns the instance of the application. Returns: the instance of the application.

void MNComponent::GetText | ( | LPSTR | buf,
|  | int | buf_len
| ) | `[virtual, inherited]`

  | Returns the component's text. Parameters:
  buf | Where to place the components text.
  buf_len | the length of the buffer.
Returns: The components text

int MNComponent::GetWidth | ( |  | ) | `[virtual, inherited]`

| Gets the width of the component. Returns: The width of the component. Reimplemented in MNPanel.

int MNComponent::GetX | ( |  | ) | `[virtual, inherited]`

| Returns the component's horizontal position. Returns: The component's horizontal position.

int MNComponent::GetY | ( |  | ) | `[virtual, inherited]`

| Returns the component's vertical position. Returns: The component's vertical position.

BOOL MNComponent::Hide | ( |  | ) | `[virtual, inherited]`

| Hides the component. It still may not be hidden if MNWindow::BeginMessageLoop() has not been called yet, or some callback negates this methods effect. Returns: whether the component was hidden.

void MNComponent::RegisterChild | ( | HWND * | hwnd,
|  | MNComponent * | com
| ) | `[virtual, inherited]`

  | Allows this component to propagate an event to the given child. Parameters:
  hwnd | the window handle of the component to register.
  com | the component to register.
See also: CHILDCOMPONENT, clisteners

void MNComponent::RegisterComponent | ( | HWND * | hwnd,
|  | MNComponent * | com
| ) | `[virtual, inherited]`

  | Allows this component to recieve top level events. Parameters:
  hwnd | the window handle of the component to register.
  com | the component to register.
See also: AddCallBack(), FireEvents(), GlobalProc()

LRESULT MNComponent::SendEventToChild | ( | MNComponent * | child,
|  | UINT | message,
|  | WPARAM | wParam,
|  | LPARAM | lParam
| ) | `[virtual, inherited]`

  | Transmits the given event to the child. Parameters:
  child | the child component to send the event to.
  message | the windows message to pass to the callback
  wParam | the submessage (see windows docs).
  lParam | the subparameter (see windows docs).
Returns: what is returned by the childs FireEvent(). See also: FireEvents()

LRESULT MNComponent::SendEventToChild | ( | HWND | child,
|  | UINT | message,
|  | WPARAM | wParam,
|  | LPARAM | lParam
| ) | `[virtual, inherited]`

  | Transmits the given event to the child. Parameters:
  child | the child component to send the event to.
  message | the windows message to pass to the callback
  wParam | the submessage (see windows docs).
  lParam | the subparameter (see windows docs).
Returns: what is returned by the childs FireEvent(). See also: FireEvents()

LRESULT MNComponent::SendEventToParent | ( | UINT | message,
|  | WPARAM | wParam,
|  | LPARAM | lParam
| ) | `[virtual, inherited]`

  | Transmits the given event to the parent. Parameters:
  message | the windows message to pass to the callback
  wParam | the submessage (see windows docs).
  lParam | the subparameter (see windows docs).
Returns: 0 if the event was handled otherwise what DefWindowProc returns.

LRESULT MNComponent::SendMessage | ( | UINT | msg,
|  | WPARAM | wParam,
|  | LPARAM | lParam
| ) | `[inherited]`

| Sends a message to the underlying control. See the components docs.

void MNComponent::SetHeight | ( | int | height | ) | `[virtual, inherited]`

  | Sets the height of the component. Parameters:
  height | the new height of the component.

void MNComponent::SetPosition | ( | int | x,
|  | int | y
| ) | `[virtual, inherited]`

  | Sets the component's position. This method is most often used by layout managers to set a control's position without affecting wether x or y's value is AUTOPOS. Parameters:
  x | the horizontal position to place the control.
  y | the vertical position to place the control.
Reimplemented in MNPanel.

void MNComponent::SetSize | ( | int | width,
|  | int | height
| ) | `[virtual, inherited]`

  | Sets the size of the component. Parameters:
  width | the new width of the component.
  height | the new height of the component.

void MNComponent::SetText | ( | LPSTR | label | ) | `[virtual, inherited]`

  | Set the components text. Parameters:
  label | the text to associate with the button.
Reimplemented in MNAbstractButton.

void MNComponent::SetWidth | ( | int | width | ) | `[virtual, inherited]`

  | Sets the width of the component. Parameters:
  width | the new width of the component.

void MNComponent::SetX | ( | int | x | ) | `[virtual, inherited]`

  | Sets the component's horizontal position. Parameters:
  x | what to set the component's horizontal position to.

void MNComponent::SetY | ( | int | y | ) | `[virtual, inherited]`

  | Sets the component's vertical position. Parameters:
  y | what to set the component's vertical position to.

BOOL MNComponent::Show | ( |  | ) | `[virtual, inherited]`

| Shows the component. It still may not be shown if MNWindow::BeginMessageLoop() has not been called yet, or some callback negates this methods effect. Returns: whether the component was shown.

## Friends And Related Function Documentation

LRESULT CALLBACK GlobalProc | ( | HWND | hwnd,
|  | UINT | message,
|  | WPARAM | wParam,
|  | LPARAM | lParam
| ) | `[friend, inherited]`

  | Is used to process all the callback functions. Parameters:
  hwnd | the window handle to the window the events go to
  message | the windows message to pass to the callback
  wParam | the submessage (see windows docs).
  lParam | the subparameter (see windows docs).
Returns: what the appropriate component's FireEvent() method returns otherwise if returns what DefWindowProc() returns. See also: MNComponent::FireEvents

## Member Data Documentation

vector< CHILDCOMPONENT > MNComponent::clisteners`[protected, inherited]`

| A list of the child components that events are to be passed to. Stores the children who wish to recieve events. See also: FireChildEvents(), CHILDCOMPONENT

vector<BOOL (*)(MNComponent* , UINT, WPARAM, LPARAM)> MNComponent::listeners`[protected, inherited]`

| Stores the callbacks for this component. Stores the functions given to AddCallBack(). It is used by FireEvents() to notify the callbacks. See also: AddCallBack(), FireEvents()

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

- MNAbstractEdit.h
- MNAbstractEdit.cpp