foobar2000 SDK  2015-08-03
Public Member Functions | Private Attributes
cfg_window_size

#include <window_placement_helper.h>

+ Inheritance diagram for cfg_window_size:

Public Member Functions

 cfg_window_size (const GUID &p_guid)
 
void get_data_raw (stream_writer *p_stream, abort_callback &p_abort)
 
bool on_window_creation (HWND window)
 
void on_window_destruction (HWND window)
 
bool read_from_window (HWND window)
 
void set_data_raw (stream_reader *p_stream, t_size p_sizehint, abort_callback &p_abort)
 
- Public Member Functions inherited from cfg_var
GUID get_guid () const
 
- Public Member Functions inherited from cfg_var_reader
 cfg_var_reader (const GUID &guid)
 
 ~cfg_var_reader ()
 
- Public Member Functions inherited from cfg_var_writer
 cfg_var_writer (const GUID &guid)
 
 ~cfg_var_writer ()
 

Private Attributes

t_uint32 m_height
 
t_uint32 m_width
 
pfc::list_hybrid_t< HWND, 2 > m_windows
 

Additional Inherited Members

- Static Public Member Functions inherited from cfg_var_reader
static void config_read_file (stream_reader *p_stream, abort_callback &p_abort)
 
- Static Public Member Functions inherited from cfg_var_writer
static void config_write_file (stream_writer *p_stream, abort_callback &p_abort)
 
- Data Fields inherited from cfg_var_reader
const GUID m_guid
 
- Data Fields inherited from cfg_var_writer
const GUID m_guid
 
- Protected Member Functions inherited from cfg_var
 cfg_var (const GUID &p_guid)
 

Detailed Description

Definition at line 21 of file window_placement_helper.h.

Constructor & Destructor Documentation

cfg_window_size::cfg_window_size ( const GUID p_guid)

Definition at line 131 of file window_placement_helper.cpp.

131 : cfg_var(p_guid), m_width(~0), m_height(~0) {}
cfg_var(const GUID &p_guid)
Definition: cfg_var.h:57

Member Function Documentation

void cfg_window_size::get_data_raw ( stream_writer p_stream,
abort_callback p_abort 
)
virtual

Retrieves state of the variable. Called only from main thread, when writing configuration file.

Parameters
p_streamStream receiving state of the variable.

Implements cfg_var_writer.

Definition at line 188 of file window_placement_helper.cpp.

188  {
189  if (g_is_enabled()) {
190  {
191  t_size n, m = m_windows.get_count();
192  for(n=0;n<m;n++) {
193  HWND window = m_windows[n];
194  PFC_ASSERT(IsWindow(window));
195  if (IsWindow(window) && read_from_window(window)) break;
196  }
197  }
198 
199  if (m_width != ~0 && m_height != ~0) {
200  p_stream->write_lendian_t(m_width,p_abort);
201  p_stream->write_lendian_t(m_height,p_abort);
202  }
203  }
204 }
t_size get_count() const
Definition: list.h:365
size_t t_size
Definition: int_types.h:48
static bool g_is_enabled()
pfc::list_hybrid_t< HWND, 2 > m_windows
bool read_from_window(HWND window)
bool cfg_window_size::on_window_creation ( HWND  window)

Definition at line 141 of file window_placement_helper.cpp.

142 {
143  bool ret = false;
144  PFC_ASSERT(!m_windows.have_item(p_wnd));
145  m_windows.add_item(p_wnd);
146 
147  if (g_is_enabled())
148  {
149  if (SetWindowSize(p_wnd,m_width,m_height)) ret = true;
150  }
151 
152  return ret;
153 }
t_size add_item(const T &item)
Definition: list.h:522
static bool g_is_enabled()
pfc::list_hybrid_t< HWND, 2 > m_windows
static BOOL SetWindowSize(HWND p_wnd, unsigned p_x, unsigned p_y)
bool have_item(const t_search &p_item) const
Definition: list.h:569
void cfg_window_size::on_window_destruction ( HWND  window)

Definition at line 155 of file window_placement_helper.cpp.

156 {
157  if (m_windows.have_item(p_wnd))
158  {
159  read_from_window(p_wnd);
160  m_windows.remove_item(p_wnd);
161  }
162 }
pfc::list_hybrid_t< HWND, 2 > m_windows
void remove_item(const T &item)
Definition: list.h:532
bool read_from_window(HWND window)
bool have_item(const t_search &p_item) const
Definition: list.h:569
bool cfg_window_size::read_from_window ( HWND  window)

Definition at line 164 of file window_placement_helper.cpp.

165 {
166  if (g_is_enabled())
167  {
168  RECT r;
169  if (GetWindowRect(p_wnd,&r))
170  {
171  m_width = r.right - r.left;
172  m_height = r.bottom - r.top;
173  return true;
174  }
175  else
176  {
177  m_width = m_height = ~0;
178  return false;
179  }
180  }
181  else
182  {
183  m_width = m_height = ~0;
184  return false;
185  }
186 }
static bool g_is_enabled()
void cfg_window_size::set_data_raw ( stream_reader p_stream,
t_size  p_sizehint,
abort_callback p_abort 
)
virtual

Sets state of the variable. Called only from main thread, when reading configuration file.

Parameters
p_streamStream containing new state of the variable.
p_sizehintNumber of bytes contained in the stream; reading past p_sizehint bytes will fail (EOF).

Implements cfg_var_reader.

Definition at line 206 of file window_placement_helper.cpp.

206  {
207  if (p_sizehint == 0) return;
208  t_uint32 width,height;
209  try {
210  p_stream->read_lendian_t(width,p_abort);
211  p_stream->read_lendian_t(height,p_abort);
212  } catch(exception_io_data) {return;}
213 
214  m_width = width; m_height = height;
215 }
uint32_t t_uint32
Definition: int_types.h:5

Field Documentation

t_uint32 cfg_window_size::m_height
private

Definition at line 32 of file window_placement_helper.h.

t_uint32 cfg_window_size::m_width
private

Definition at line 32 of file window_placement_helper.h.

pfc::list_hybrid_t<HWND,2> cfg_window_size::m_windows
private

Definition at line 31 of file window_placement_helper.h.


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