view release on metacpan or search on metacpan
src/dlib/gui_core/gui_core_kernel_1.cpp view on Meta::CPAN
COMPOSITIONFORM cf;
cf.dwStyle = CFS_POINT;
cf.ptCurrentPos.x = x;
cf.ptCurrentPos.y = y;
ImmSetCompositionWindow(hImc, &cf);
ImmReleaseContext(hwnd, hImc);
}
// ----------------------------------------------------------------------------------------
void put_on_clipboard (
const std::string& str
)
{
put_on_clipboard(convert_mbstring_to_wstring(str));
}
void put_on_clipboard (
const dlib::ustring& str
)
{
put_on_clipboard(convert_utf32_to_wstring(str));
}
void put_on_clipboard (
const std::wstring& str
)
{
using namespace gui_core_kernel_1_globals;
using namespace std;
shared_ptr_thread_safe<event_handler_thread> globals(global_data());
if (OpenClipboard(globals->helper_window))
{
src/dlib/gui_core/gui_core_kernel_1.cpp view on Meta::CPAN
GlobalUnlock(mem);
SetClipboardData(CF_UNICODETEXT,mem);
}
}
CloseClipboard();
}
}
// ----------------------------------------------------------------------------------------
void get_from_clipboard (
std::string& str
)
{
std::wstring wstr;
get_from_clipboard(wstr);
str = convert_wstring_to_mbstring(wstr);
}
void get_from_clipboard (
dlib::ustring& str
)
{
std::wstring wstr;
get_from_clipboard(wstr);
str = convert_wstring_to_utf32(wstr);
}
void get_from_clipboard (
std::wstring& str
)
{
using namespace gui_core_kernel_1_globals;
using namespace std;
shared_ptr_thread_safe<event_handler_thread> globals(global_data());
auto_mutex M(globals->window_table.get_mutex());
if (OpenClipboard(globals->helper_window))
{
src/dlib/gui_core/gui_core_kernel_1.h view on Meta::CPAN
constexpr static long num = 3;
typedef unsigned char basic_pixel_type;
static basic_pixel_type min() { return 0;}
static basic_pixel_type max() { return 255;}
constexpr static bool is_unsigned = true;
constexpr static bool has_alpha = false;
};
// ----------------------------------------------------------------------------------------
void put_on_clipboard (
const std::string& str
);
void put_on_clipboard (
const std::wstring& str
);
void put_on_clipboard (
const dlib::ustring& str
);
// ----------------------------------------------------------------------------------------
void get_from_clipboard (
std::string& str
);
void get_from_clipboard (
std::wstring& str
);
void get_from_clipboard (
dlib::ustring& str
);
// ----------------------------------------------------------------------------------------
class base_window
{
friend LRESULT CALLBACK gui_core_kernel_1_globals::WndProc (HWND, UINT, WPARAM, LPARAM);
shared_ptr_thread_safe<gui_core_kernel_1_globals::event_handler_thread> globals;
src/dlib/gui_core/gui_core_kernel_2.cpp view on Meta::CPAN
int depth;
Display* disp;
XIM xim;
XIMStyle xim_style;
Screen* screen;
Atom delete_window;
Window exit_window;
std::wstring clipboard;
int alt_mask;
int meta_mask;
int num_lock_mask;
int scroll_lock_mask;
// the mutex in this object is the global mutex used to protect everything
// in the gui_core and gui_widgets components.
window_table_type window_table;
src/dlib/gui_core/gui_core_kernel_2.cpp view on Meta::CPAN
XEvent respond;
if (req->target == XA_STRING)
{
XChangeProperty (disp,
req->requestor,
req->property,
XA_STRING,
8,
PropModeReplace,
reinterpret_cast<const unsigned char*>(convert_wstring_to_mbstring(clipboard).c_str()),
clipboard.size()+1);
respond.xselection.property=req->property;
}
else if (req->target == a_ct)
{
XChangeProperty (disp,
req->requestor,
req->property,
a_ct,
sizeof(wchar_t)*8,
PropModeReplace,
reinterpret_cast<const unsigned char*>(clipboard.c_str()),
clipboard.size()+1);
respond.xselection.property=req->property;
}
else
{
respond.xselection.property= None;
}
respond.xselection.type= SelectionNotify;
respond.xselection.display= req->display;
respond.xselection.requestor= req->requestor;
respond.xselection.selection=req->selection;
src/dlib/gui_core/gui_core_kernel_2.cpp view on Meta::CPAN
while (start != end)
{
*start = pixel_value;
++start;
}
}
// ----------------------------------------------------------------------------------------
void put_on_clipboard (
const std::string& str
)
{
put_on_clipboard(convert_mbstring_to_wstring(str));
}
void put_on_clipboard (
const dlib::ustring& str
)
{
put_on_clipboard(convert_utf32_to_wstring(str));
}
void put_on_clipboard (
const std::wstring& str
)
{
using namespace gui_core_kernel_2_globals;
shared_ptr_thread_safe<event_handler_thread> globals(global_data());
auto_mutex M(globals->window_table.get_mutex());
globals->clipboard = str.c_str();
XSetSelectionOwner(globals->disp,XA_PRIMARY,globals->exit_window,CurrentTime);
}
// ----------------------------------------------------------------------------------------
Bool clip_peek_helper (
Display*,
XEvent* event,
XPointer
src/dlib/gui_core/gui_core_kernel_2.cpp view on Meta::CPAN
if ( event->type == SelectionNotify)
{
return True;
}
else
{
return False;
}
}
void get_from_clipboard (
std::string& str
)
{
std::wstring wstr;
get_from_clipboard(wstr);
str = convert_wstring_to_mbstring(wstr);
}
void get_from_clipboard (
dlib::ustring& str
)
{
std::wstring wstr;
get_from_clipboard(wstr);
str = convert_wstring_to_utf32(wstr);
}
void get_from_clipboard (
std::wstring& str
)
{
using namespace gui_core_kernel_2_globals;
shared_ptr_thread_safe<event_handler_thread> globals(global_data());
auto_mutex M(globals->window_table.get_mutex());
str.clear();
unsigned char *data = 0;
wchar_t **plist = 0;
src/dlib/gui_core/gui_core_kernel_2.cpp view on Meta::CPAN
unsigned long len, bytes_left, dummy;
XEvent e;
try
{
Atom atom_ct = XInternAtom(globals->disp, "COMPOUND_TEXT", False);
sown = XGetSelectionOwner (globals->disp, XA_PRIMARY);
if (sown == globals->exit_window)
{
// if we are copying from ourselfs then don't fool with the Xwindows junk.
str = globals->clipboard.c_str();
}
else if (sown != None)
{
// request that the selection be copied into the XA_PRIMARY property
// of the exit_window. It doesn't matter what window we put it in
// so long as it is one under the control of this process and exit_window
// is easy to use here so that is what I'm using.
XConvertSelection (globals->disp, XA_PRIMARY, atom_ct, XA_PRIMARY,
globals->exit_window, CurrentTime);
src/dlib/gui_core/gui_core_kernel_2.h view on Meta::CPAN
// This is a forward declaration for a struct that contains any
// X11 variables. This allows me to avoid having any dlib header files
// include the X11 headers. Which in turn speeds build times and simplifies
// build setups.
struct x11_base_windowstuff;
}
// ----------------------------------------------------------------------------------------
void put_on_clipboard (
const std::string& str
);
void put_on_clipboard (
const std::wstring& str
);
void put_on_clipboard (
const dlib::ustring& str
);
// ----------------------------------------------------------------------------------------
void get_from_clipboard (
std::string& str
);
void get_from_clipboard (
std::wstring& str
);
void get_from_clipboard (
dlib::ustring& str
);
// ----------------------------------------------------------------------------------------
class canvas : public rectangle
{
public:
struct pixel
{
src/dlib/gui_core/gui_core_kernel_abstract.h view on Meta::CPAN
handling thread. After the paint() event handler has returned do
not access that canvas object again.
base_window
All methods for this class are thread safe. You may call them
from any thread and do not need to serialize access.
!*/
// ----------------------------------------------------------------------------------------
void put_on_clipboard (
const std::string& str
);
/*!
ensures
- posts the contents of str to the system clipboard
throws
- std::bad_alloc
- dlib::gui_error
- dlib::thread_error
!*/
// overloads for wide character strings
void put_on_clipboard (const std::wstring& str);
void put_on_clipboard (const dlib::ustring& str);
// ----------------------------------------------------------------------------------------
void get_from_clipboard (
std::string& str
);
/*!
ensures
- if (there is string data on the system clipboard) then
- #str == the data from the clipboard
- else
- #str == ""
throws
- std::bad_alloc
- dlib::gui_error
- dlib::thread_error
!*/
// overloads for wide character strings
void get_from_clipboard (std::wtring& str);
void get_from_clipboard (dlib::utring& str);
// ----------------------------------------------------------------------------------------
class canvas : public rectangle
{
/*!
POINTERS AND REFERENCES TO INTERNAL DATA
All functions of this object may invalidate pointers and references
to internal data.
src/dlib/gui_widgets/widgets.cpp view on Meta::CPAN
}
// ----------------------------------------------------------------------------------------
void text_field::
on_copy (
)
{
if (highlight_start <= highlight_end)
{
put_on_clipboard(text_.substr(highlight_start, highlight_end-highlight_start+1));
}
}
// ----------------------------------------------------------------------------------------
void text_field::
on_paste (
)
{
ustring temp_str;
get_from_clipboard(temp_str);
// If this is a multi line string then just take the first line.
ustring::size_type pos = temp_str.find_first_of('\n');
if (pos != ustring::npos)
{
temp_str = temp_str.substr(0,pos);
}
if (highlight_start <= highlight_end)
{
src/dlib/gui_widgets/widgets.cpp view on Meta::CPAN
}
// ----------------------------------------------------------------------------------------
void text_box::
on_copy (
)
{
if (highlight_start <= highlight_end)
{
put_on_clipboard(text_.substr(highlight_start, highlight_end-highlight_start+1));
}
}
// ----------------------------------------------------------------------------------------
void text_box::
on_paste (
)
{
ustring temp_str;
get_from_clipboard(temp_str);
if (highlight_start <= highlight_end)
{
text_ = text_.substr(0,highlight_start) + temp_str +
text_.substr(highlight_end+1,text_.size()-highlight_end-1);
move_cursor(highlight_start+temp_str.size());
highlight_start = 0;
highlight_end = -1;
parent.invalidate_rectangle(rect);
src/dlib/test/gui/main.cpp view on Meta::CPAN
)
{
message_box("title","you clicked the ok button!\n HURRAY!");
}
static void try_this_junk (
void* param
)
{
win& p = *reinterpret_cast<win*>(param);
put_on_clipboard(p.tf.text() + "\nfoobar");
}
void on_set_clipboard (
)
{
create_new_thread(try_this_junk,this);
//try_this_junk(this);
}
static void try_this_junk2 (
void*
)
{
string temp;
get_from_clipboard(temp);
message_box("clipboard",temp);
}
void on_get_clipboard (
)
{
create_new_thread(try_this_junk2,this);
}
void on_show_msg_click (
)
{
message_box("title","This is a test message.",*this,&win::msg_box);
src/dlib/test/gui/main.cpp view on Meta::CPAN
lbl_last_keydown(*this),
lbl_mod_shift(*this),
lbl_mod_control(*this),
lbl_mod_alt(*this),
lbl_mod_meta(*this),
lbl_mod_caps_lock(*this),
lbl_mod_num_lock(*this),
lbl_mod_scroll_lock(*this),
b(*this),
btn_count(*this),
btn_get_clipboard(*this),
btn_set_clipboard(*this),
btn_show_message(*this),
cb1(*this,rectangle(100,100,200,200),255,0,0),
cb2(*this,rectangle(150,150,250,240),0,255,0),
cbl(*this),
cbox(*this),
group1(*this),
group2(*this),
group3(*this),
keyboard_count(1),
keydown(*this),
src/dlib/test/gui/main.cpp view on Meta::CPAN
lb.enable_multiple_select();
lb.set_double_click_handler(*this,&win::lb_double_click);
// lb.disable_multiple_select();
btn_show_message.set_pos(50,350);
btn_show_message.set_name("message_box()");
mbar.set_number_of_menus(2);
mbar.set_menu_name(0,"File",'F');
mbar.set_menu_name(1,"Help",'H');
mbar.menu(0).add_menu_item(menu_item_text("show msg click",*this,&win::on_show_msg_click,'s'));
mbar.menu(0).add_menu_item(menu_item_text("get clipboard",*this,&win::on_get_clipboard,'g'));
mbar.menu(0).add_menu_item(menu_item_text("set clipboard",*this,&win::on_set_clipboard,'c'));
mbar.menu(0).add_menu_item(menu_item_separator());
mbar.menu(0).add_submenu(menu_item_submenu("submenu",'m'), submenu);
submenu.add_menu_item(menu_item_separator());
submenu.add_menu_item(menu_item_separator());
submenu.add_menu_item(menu_item_text("show msg click",*this,&win::on_show_msg_click,'s'));
submenu.add_menu_item(menu_item_text("get clipboard",*this,&win::on_get_clipboard,'g'));
submenu.add_menu_item(menu_item_text("set clipboard",*this,&win::on_set_clipboard,'c'));
submenu.add_menu_item(menu_item_separator());
submenu.add_menu_item(menu_item_separator());
mbar.menu(1).add_menu_item(menu_item_text("About",*this,&win::on_menu_help,'A'));
btn_show_message.set_click_handler(*this,&win::on_show_msg_click);
btn_get_clipboard.set_pos(btn_show_message.right()+5,btn_show_message.top());
btn_get_clipboard.set_name("get_from_clipboard()");
btn_get_clipboard.set_click_handler(*this,&win::on_get_clipboard);
btn_get_clipboard.set_style(button_style_toolbar1());
btn_set_clipboard.set_pos(btn_get_clipboard.right()+5,btn_get_clipboard.top());
btn_set_clipboard.set_name("put_on_clipboard()");
btn_set_clipboard.set_click_handler(*this,&win::on_set_clipboard);
nrect.set_size(700,500);
nrect.set_name("test widgets");
nrect.set_pos(2,mbar.bottom()+2);
//throw dlib::error("holy crap batman");
tab_label.set_pos(10,440);
tabs.set_click_handler(*this,&win::tab_change);
tabs.set_pos(5,mbar.bottom()+10);
src/dlib/test/gui/main.cpp view on Meta::CPAN
else
{
flip = 0;
lb.set_size(200,300);
}
}
button b;
label btn_count;
button btn_get_clipboard;
button btn_set_clipboard;
button btn_show_message;
int button_count;
color_box cb1;
color_box cb2;
label cbl;
check_box cbox;
int count;
int flip;
widget_group group1;
widget_group group2;