windows/gui_functions: localization, nicer edit box, buttons have appropriate size
This commit is contained in:
parent
6d9b5f2d3a
commit
e2199bbb83
@ -1,4 +1,3 @@
|
|||||||
#define UNICODE
|
|
||||||
#include "gui_functions.hpp"
|
#include "gui_functions.hpp"
|
||||||
#include "databasewindow.hpp"
|
#include "databasewindow.hpp"
|
||||||
#include "mainwindow.hpp"
|
#include "mainwindow.hpp"
|
||||||
@ -6,6 +5,8 @@
|
|||||||
#include "progresswindow.hpp"
|
#include "progresswindow.hpp"
|
||||||
#include "searchwindow.hpp"
|
#include "searchwindow.hpp"
|
||||||
#include "seasonwindow.hpp"
|
#include "seasonwindow.hpp"
|
||||||
|
#include "../resources_windows.h"
|
||||||
|
#include "../functions.hpp"
|
||||||
|
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
|
|
||||||
@ -75,8 +76,7 @@ HWND createLabel( const wchar_t *text, int x, int y, int width, int height,
|
|||||||
HWND createEditBox( int x, int y, int width, int height, long long id,
|
HWND createEditBox( int x, int y, int width, int height, long long id,
|
||||||
HWND parent, HFONT hFont ) {
|
HWND parent, HFONT hFont ) {
|
||||||
return createWindow( L"Edit", NULL, x, y, width, height, id, parent, hFont,
|
return createWindow( L"Edit", NULL, x, y, width, height, id, parent, hFont,
|
||||||
WS_VISIBLE | WS_CHILD | WS_BORDER | WS_TABSTOP |
|
WS_VISIBLE | WS_CHILD | WS_TABSTOP | ES_AUTOHSCROLL,
|
||||||
ES_AUTOHSCROLL,
|
|
||||||
WS_EX_CLIENTEDGE );
|
WS_EX_CLIENTEDGE );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,11 +87,21 @@ HWND createCombo( int x, int y, int width, int height, long long id,
|
|||||||
WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP, 0 );
|
WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void idealButton( HWND hwnd, int x, int y, int width, int height ) {
|
||||||
|
SIZE size;
|
||||||
|
SendMessage( hwnd, BCM_GETIDEALSIZE, 0, ( LPARAM )&size );
|
||||||
|
auto ideal_width = size.cx + 10;
|
||||||
|
if ( ideal_width > width )
|
||||||
|
SetWindowPos( hwnd, HWND_TOP, x, y, ideal_width, height, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
HWND createButton( const wchar_t *text, int x, int y, int width, int height,
|
HWND createButton( const wchar_t *text, int x, int y, int width, int height,
|
||||||
long long id, HWND parent, HFONT hFont ) {
|
long long id, HWND parent, HFONT hFont ) {
|
||||||
return createWindow(
|
HWND hwnd = createWindow(
|
||||||
L"Button", text, x, y, width, height, id, parent, hFont,
|
L"Button", text, x, y, width, height, id, parent, hFont,
|
||||||
WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | WS_TABSTOP, 0 );
|
WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | WS_TABSTOP, 0 );
|
||||||
|
idealButton( hwnd, x, y, width, height );
|
||||||
|
return hwnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
HWND createCheckbox( const wchar_t *text, int x, int y, int width, int height,
|
HWND createCheckbox( const wchar_t *text, int x, int y, int width, int height,
|
||||||
@ -170,7 +180,7 @@ void setListViewItemText( HWND list_view, int row, int column,
|
|||||||
std::wstring getDir() {
|
std::wstring getDir() {
|
||||||
wchar_t path[MAX_PATH];
|
wchar_t path[MAX_PATH];
|
||||||
BROWSEINFO bi{};
|
BROWSEINFO bi{};
|
||||||
bi.lpszTitle = L"Choose a folder";
|
bi.lpszTitle = _( CHOOSE_DIR );
|
||||||
LPITEMIDLIST pidl = SHBrowseForFolder( &bi );
|
LPITEMIDLIST pidl = SHBrowseForFolder( &bi );
|
||||||
if ( pidl != 0 ) {
|
if ( pidl != 0 ) {
|
||||||
SHGetPathFromIDList( pidl, path );
|
SHGetPathFromIDList( pidl, path );
|
||||||
@ -194,3 +204,11 @@ std::wstring getItemText( HWND hwnd, int row, int column ) {
|
|||||||
int getComboCurSel( HWND hwnd ) {
|
int getComboCurSel( HWND hwnd ) {
|
||||||
return SendMessage( hwnd, CB_GETCURSEL, 0, 0 );
|
return SendMessage( hwnd, CB_GETCURSEL, 0, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setIcons( HINSTANCE hInstance, HWND window ) {
|
||||||
|
auto hIcon = LoadIcon( hInstance, MAKEINTRESOURCE( IDI_TV_RENAME_GUI ) );
|
||||||
|
auto hIconSmall = LoadIcon( hInstance, MAKEINTRESOURCE( IDI_SMALL ) );
|
||||||
|
SendMessage( window, WM_SETICON, ( WPARAM )ICON_BIG, ( LPARAM )hIcon );
|
||||||
|
SendMessage( window, WM_SETICON, ( WPARAM )ICON_SMALL,
|
||||||
|
( LPARAM )hIconSmall );
|
||||||
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <string>
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
void registerWindowClasses( HINSTANCE hInstance );
|
void registerWindowClasses( HINSTANCE hInstance );
|
||||||
void centerWindow( HWND hwnd );
|
void centerWindow( HWND hwnd );
|
||||||
@ -30,3 +30,4 @@ void setListViewItemText( HWND list_view, int row, int column,
|
|||||||
std::wstring getItemText( HWND hwnd, int row, int column );
|
std::wstring getItemText( HWND hwnd, int row, int column );
|
||||||
int getComboCurSel( HWND hwnd );
|
int getComboCurSel( HWND hwnd );
|
||||||
std::wstring getDir();
|
std::wstring getDir();
|
||||||
|
void setIcons( HINSTANCE hInstance, HWND window );
|
||||||
|
Loading…
Reference in New Issue
Block a user